Skip to content

Commit

Permalink
Merge pull request #150 from OpsMx/OP-11769
Browse files Browse the repository at this point in the history
OP-11769: added version based to call sapor api for cloud providers
  • Loading branch information
ramyaravi-opsmx authored Feb 28, 2022
2 parents 61a3a24 + 234b342 commit 16b4f4b
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,18 @@ class OpsmxOesController {
return addOrUpdateSpinnaker(files, postData.get("postData"))
}

@ApiOperation(value = "Add or Update spinnaker cloudprovider account configured in Spinnaker", response = String.class )
@ApiOperation(value = "Add or Update spinnaker cloudprovider account configured in Spinnaker")
@RequestMapping(value = "/accountsConfig/spinnaker/addOrUpdateCloudProviderAccount", method = RequestMethod.POST)
String addOrUpdateSpinnakerCloudProver(@RequestParam MultipartFile files, @RequestParam Map<String, String> postData) {
Object addOrUpdateSpinnakerCloudProver(@RequestParam MultipartFile files, @RequestParam Map<String, String> postData) {
String filename = files ? files.getOriginalFilename() : ''
return addOrUpdateSpinnakerCloudProverAccount(files, postData.get("postData"))
return addOrUpdateSpinnakerCloudProverAccount(files, postData.get("postData"), null)
}

@ApiOperation(value = "Add or Update spinnaker cloudprovider account configured in Spinnaker" )
@RequestMapping(value = "/accountsConfig/{version}/spinnaker/addOrUpdateCloudProviderAccount", method = RequestMethod.POST)
Object addOrUpdateVersionSpinnakerCloudProver(@PathVariable("version") String version, @RequestParam MultipartFile files, @RequestParam Map<String, String> postData) {
String filename = files ? files.getOriginalFilename() : ''
return addOrUpdateSpinnakerCloudProverAccount(files, postData.get("postData"), version)
}

@ApiOperation(value = "Add or Update Spinnaker x509")
Expand All @@ -290,8 +297,12 @@ class OpsmxOesController {
return createOrUpdateSpinnaker(files, postData.get("postData"), version)
}

private String addOrUpdateSpinnakerCloudProverAccount(MultipartFile files, String data) {
private Object addOrUpdateSpinnakerCloudProverAccount(MultipartFile files, String data, String version) {
Map<String, Optional<String>> authenticationHeaders = AuthenticatedRequest.getAuthenticationHeaders();
String oesUrl = "/oes/accountsConfig/spinnaker/addOrUpdateCloudProviderAccount";
if(version != null){
oesUrl = "/oes/accountsConfig/version/spinnaker/addOrUpdateCloudProviderAccount".replace("version", version);
}
Map headersMap = new HashMap()
authenticationHeaders.each { key, val ->
if(val.isPresent())
Expand All @@ -301,7 +312,7 @@ class OpsmxOesController {
}
def obj = AuthenticatedRequest.propagate {
def request = new Request.Builder()
.url(serviceConfiguration.getServiceEndpoint("opsmx").url +"/oes/accountsConfig/spinnaker/addOrUpdateCloudProviderAccount")
.url(serviceConfiguration.getServiceEndpoint("opsmx").url + oesUrl)
.headers(Headers.of(headersMap))
.post(uploadFileOkHttp(data,files))
.build()
Expand Down

0 comments on commit 16b4f4b

Please sign in to comment.