Skip to content

Commit

Permalink
Added the manifest file download request message
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhakaropsmx committed Jan 21, 2021
1 parent 925cbb4 commit 9d7a8df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import org.apache.commons.io.IOUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.http.HttpHeaders
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import java.util.stream.Collectors

import com.netflix.spinnaker.gate.config.ServiceConfiguration
import com.netflix.spinnaker.gate.services.internal.OpsmxOesService
Expand Down Expand Up @@ -322,5 +324,23 @@ class OpsmxOesController {
builder.addFormDataPart("postData", null, okhttp3.RequestBody.create(MediaType.parse("text/plain"), data));
return builder.build();
}

@ApiOperation(value = "download the manifest file")
@GetMapping(value = "/accountsConfig/cloudProviders/manifestfile/{agentName}", produces = "application/octet-stream")
@ResponseBody Object getDownloadManifestFile(@PathVariable("agentName") String agentName){

Response response = opsmxOesService.manifestDownloadFile(agentName)
InputStream inputStream = response.getBody().in()
try {
byte [] manifestFile = IOUtils.toByteArray(inputStream)
HttpHeaders headers = new HttpHeaders()
headers.add("Content-Disposition", response.getHeaders().stream().filter({ header -> header.getName().trim().equalsIgnoreCase("Content-Disposition") }).collect(Collectors.toList()).get(0).value)
return ResponseEntity.ok().headers(headers).body(manifestFile)
} finally{
if (inputStream!=null){
inputStream.close()
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

package com.netflix.spinnaker.gate.services.internal

import retrofit.client.Response
import retrofit.http.*

interface OpsmxOesService {

@GET("/oes/accountsConfig/cloudProviders/manifestfile/{agentName}")
Response manifestDownloadFile(@Path('agentName') String agentName)

@GET("/oes/{type}/{source}")
Object getOesResponse(@Path('type') String type,
Expand Down

0 comments on commit 9d7a8df

Please sign in to comment.