Skip to content

Commit

Permalink
Merge pull request #161 from sudhakaropsmx/master
Browse files Browse the repository at this point in the history
Added the new method for Spinnaker Cloud Providers
  • Loading branch information
sriharshakancharla authored Feb 25, 2021
2 parents 9fd9ce6 + a7c7e08 commit 95bcb9f
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,34 @@ class OpsmxOesController {
return addOrUpdateSpinnaker(files, postData.get("postData"))
}

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

private String addOrUpdateSpinnakerCloudProverAccount(MultipartFile files, String data) {
Map<String, Optional<String>> authenticationHeaders = AuthenticatedRequest.getAuthenticationHeaders();
Map headersMap = new HashMap()
authenticationHeaders.each { key, val ->
if(val.isPresent())
headersMap.putAt(key,val.get())
else
headersMap.putAt(key,"")
}
AuthenticatedRequest.propagate {
def request = new Request.Builder()
.url(serviceConfiguration.getServiceEndpoint("opsmx").url +"/oes/accountsConfig/spinnaker/addOrUpdateCloudProviderAccount")
.headers(Headers.of(headersMap))
.post(uploadFileOkHttp(data,files))
.build()

def response = okHttpClient.newCall(request).execute()
return response.body()?.string() ?: "Unknown reason: " + response.code()
}.call() as String
}

Object addOrUpdateSpinnaker(MultipartFile files, String data) {
Map<String, Optional<String>> authenticationHeaders = AuthenticatedRequest.getAuthenticationHeaders();
Map headersMap = new HashMap()
Expand Down

0 comments on commit 95bcb9f

Please sign in to comment.