Skip to content

Commit

Permalink
feat(core/serverGroups): Get a list of servergroups by name
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Nov 14, 2017
1 parent 1076898 commit a580ae3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ interface ClouddriverService {
@Headers("Accept: application/json")
@GET("/serverGroups")
List getServerGroups(@Query("applications") List applications,
@Query("serverGroupNames") List serverGroupNames,
@Query("ids") List ids,
@Query("cloudProvider") String cloudProvider)

@Headers("Accept: application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ class ServerGroupController {
@ApiOperation(value = "Retrieve a list of server groups for a list of applications or a list of servergroups by 'account:region:name'")
@RequestMapping(value = "/serverGroups", method = RequestMethod.GET)
List getServerGroups(@RequestParam(required = false, value = 'applications') List<String> applications,
@RequestParam(required = false, value = 'serverGroupNames') List<String> serverGroupNames,
@RequestParam(required = false, value = 'ids') List<String> ids,
@RequestParam(required = false, value = 'cloudProvider') String cloudProvider,
@RequestHeader(value = "X-RateLimit-App", required = false) String sourceApp) {
if ((applications && serverGroupNames) || (!applications && !serverGroupNames)) {
if ((applications && ids) || (!applications && !ids)) {
throw new IllegalArgumentException("Provide either 'applications' or 'serverGroupNames' parameter, but not both");
}

if (applications) {
return serverGroupService.getForApplications(applications, cloudProvider, sourceApp)
} else {
return serverGroupService.getForNames(serverGroupNames, cloudProvider, sourceApp)
return serverGroupService.getForIds(ids, cloudProvider, sourceApp)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class ServerGroupService {
} execute()
}

List getForNames(List<String> serverGroupNames, String cloudProvider, String selectorKey) {
List getForIds(List<String> ids, String cloudProvider, String selectorKey) {
HystrixFactory.newListCommand(GROUP, "getServerGroupsForNames") {
clouddriverServiceSelector.select(selectorKey).getServerGroups(null, serverGroupNames, cloudProvider)
clouddriverServiceSelector.select(selectorKey).getServerGroups(null, ids, cloudProvider)
} execute()
}

Expand Down

0 comments on commit a580ae3

Please sign in to comment.