Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP21637: Added Endpoint for POST /history and /history/download #480

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.http.HttpHeaders
import retrofit.client.Response
import org.apache.commons.io.IOUtils
Expand Down Expand Up @@ -187,6 +188,41 @@ class OpsmxAuditClientServiceController {
return ResponseEntity.status(response.getStatus()).build()
}

@Operation(summary = "Endpoint for platform rest services")
@RequestMapping(value = "/{version}/{type}/{source}", method = RequestMethod.POST)
Object postAuditClientResponse1(@PathVariable("version") String version,
@PathVariable("type") String type,
@PathVariable("source") String source,
@RequestBody(required = false) Object data) {

return opsmxAuditClientService.postAuditClientResponse1(version, type, source, data)
}

@Operation(summary = "Endpoint for platform rest services")
@RequestMapping(value = "/{version}/{type}/{source}/download", method = RequestMethod.POST)
Object downloadCSVFileSystemAudit(@PathVariable("version") String version,
@PathVariable("type") String type,
@PathVariable("source") String source,
@RequestBody(required = false) Object data) {
Response response = opsmxAuditClientService.downloadCSVFile2(version, type, source, data)
log.info("response for the system audit endpoint:" + response.getHeaders())
if (response.getBody()!= null) {
InputStream inputStream = response.getBody().in()
try {
byte[] csvFile = IOUtils.toByteArray(inputStream)
HttpHeaders headers = new HttpHeaders()
headers.setContentType(MediaType.parseMediaType("text/csv"));
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(csvFile)
} finally {
if (inputStream != null) {
inputStream.close()
}
}
}
return ResponseEntity.status(response.getStatus()).build()
}

@Operation(summary = "Endpoint for Delivery Insights controller to download csv file")
@RequestMapping(value = "/{version}/{type}/{source}/download", produces = "text/csv", method = RequestMethod.GET)
Object downloadCSVFileAuditService(@PathVariable("version") String version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package com.opsmx.spinnaker.gate.services
import org.springframework.web.bind.annotation.RequestParam
import retrofit.client.Response
import retrofit.http.GET
import retrofit.http.POST
import retrofit.http.Path
import retrofit.http.Body
import retrofit.http.Query

interface OpsmxAuditClientService {
Expand Down Expand Up @@ -137,4 +139,16 @@ interface OpsmxAuditClientService {
@Query('search') String search,
@Query("noOfDays") String noOfDays,
@Query('limit') Integer limit)

@POST("/auditclientservice/{version}/{type}/{source}")
Object postAuditClientResponse1(@Path('version') String version,
@Path('type') String type,
@Path('source') String source,
@Body Object data)

@POST("/auditclientservice/{version}/{type}/{source}/download")
Response downloadCSVFile2(@Path('version') String version,
@Path('type') String type,
@Path('source') String source,
@Body Object data)
}
Loading