Skip to content

Commit

Permalink
Autopilot API modified to return byte data
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav-b-7 committed Jan 5, 2021
1 parent 45530fc commit 341a3f2
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import okhttp3.OkHttpClient
import okhttp3.Request
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

Expand Down Expand Up @@ -63,7 +65,7 @@ class OpsmxAutopilotController {

@ApiOperation(value = "Endpoint for autopilot rest services")
@RequestMapping(value = "/{type}/{source}", method = RequestMethod.GET)
Object getAutoResponse(@PathVariable("type") String type, @PathVariable("source") String source,
@ResponseBody Object getAutoResponse(@PathVariable("type") String type, @PathVariable("source") String source,
@RequestParam(value = "application", required = false) Integer id,
@RequestParam(value = "applicationId", required = false) Integer applicationId,
@RequestParam(value = "serviceId", required = false) Integer serviceId,
Expand Down Expand Up @@ -113,10 +115,20 @@ class OpsmxAutopilotController {
@RequestParam(value = "serviceList", required = false) List<String> serviceList,
@RequestParam(value = "pipelineId", required = false) String pipelineId,
@RequestParam(value = "referer", required = false) String referer){
return opsmxAutopilotService.getAutoResponse(type, source, id, applicationId, serviceId, startTime, endTime, intervalMins, limit, sourceType, datasourceType,


okhttp3.ResponseBody response = opsmxAutopilotService.getAutoResponse(type, source, id, applicationId, serviceId, startTime, endTime, intervalMins, limit, sourceType, datasourceType,
accountName, templateType, name, appId, pipelineid, applicationName, username, userName, templateName, credentialType, canaryId, service, canary, canaryid, clusterId, version, canaryAnalysisId,
metric,account,metricType,isBoxplotData,metricname,numofver,serviceName,platform,ruleId,zone,appType,metricTemplate,logTemplate,riskanalysis_id,service_id,
userId,logTemplateName,forceDelete,deleteAssociateRuns, event, serviceList, pipelineId, referer)

if (response.contentType().type().equalsIgnoreCase("application/zip")){
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", response.contentType().type())
return ResponseEntity.ok().headers(headers).body(response.bytes())
} else {
return response.string()
}
}

@ApiOperation(value = "Endpoint for autopilot rest services")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import okhttp3.ResponseBody
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -26,57 +27,57 @@ import retrofit.http.*
interface OpsmxAutopilotService {

@GET("/autopilot/{type}/{source}")
Object getAutoResponse(@Path('type') String type,
@Path('source') String source,
@Query("application") Integer id,
@Query("applicationId") Integer applicationId,
@Query("serviceId") Integer serviceId,
@Query("startTime") Long startTime,
@Query("endTime") Long endTime,
@Query("intervalMins") Float intervalMins,
@Query("limit") Integer limit,
@Query("sourceType") String sourceType,
@Query("datasourceType") String datasourceType,
@Query("accountName") String accountName,
@Query("templateType") String templateType,
@Query("name") String name,
@Query("appId") Integer appId,
@Query("pipelineid") String pipelineid,
@Query("applicationName") String applicationName,
@Query("username") String username,
@Query("userName") String userName,
@Query("templateName") String templateName,
@Query("credentialType") String credentialType,
@Query("id") Integer Id,
@Query("service") Integer service,
@Query("canaryId") Integer canary,
@Query("canaryid") Integer canaryid,
@Query("clusterId") Long clusterId,
@Query("version") String version,
@Query("canaryAnalysisId") Integer canaryAnalysisId,
@Query("metric") String metric,
@Query("account") String account,
@Query("metricType") String metricType,
@Query("isBoxplotData") Boolean isBoxplotData,
@Query("metricname") String metricname,
@Query("numofver") Integer numofver,
@Query("serviceName") String serviceName,
@Query("platform") String platform,
@Query("ruleId") Integer ruleId,
@Query("zone") String zone,
@Query("type") String appType,
@Query("metricTemplate") String metricTemplate,
@Query("logTemplate") String logTemplate,
@Query("riskanalysis_id") Integer riskanalysis_id,
@Query("service_id") Integer service_id,
@Query("userId") Integer userId,
@Query("logTemplateName") String logTemplateName,
@Query("forceDelete") Boolean forceDelete,
@Query("deleteAssociateRuns") Boolean deleteAssociateRuns,
@Query("event") String event,
@Query("serviceList") List<String> serviceList,
@Query("pipelineId") String pipelineId,
@Query("referer") String referer)
ResponseBody getAutoResponse(@Path('type') String type,
@Path('source') String source,
@Query("application") Integer id,
@Query("applicationId") Integer applicationId,
@Query("serviceId") Integer serviceId,
@Query("startTime") Long startTime,
@Query("endTime") Long endTime,
@Query("intervalMins") Float intervalMins,
@Query("limit") Integer limit,
@Query("sourceType") String sourceType,
@Query("datasourceType") String datasourceType,
@Query("accountName") String accountName,
@Query("templateType") String templateType,
@Query("name") String name,
@Query("appId") Integer appId,
@Query("pipelineid") String pipelineid,
@Query("applicationName") String applicationName,
@Query("username") String username,
@Query("userName") String userName,
@Query("templateName") String templateName,
@Query("credentialType") String credentialType,
@Query("id") Integer Id,
@Query("service") Integer service,
@Query("canaryId") Integer canary,
@Query("canaryid") Integer canaryid,
@Query("clusterId") Long clusterId,
@Query("version") String version,
@Query("canaryAnalysisId") Integer canaryAnalysisId,
@Query("metric") String metric,
@Query("account") String account,
@Query("metricType") String metricType,
@Query("isBoxplotData") Boolean isBoxplotData,
@Query("metricname") String metricname,
@Query("numofver") Integer numofver,
@Query("serviceName") String serviceName,
@Query("platform") String platform,
@Query("ruleId") Integer ruleId,
@Query("zone") String zone,
@Query("type") String appType,
@Query("metricTemplate") String metricTemplate,
@Query("logTemplate") String logTemplate,
@Query("riskanalysis_id") Integer riskanalysis_id,
@Query("service_id") Integer service_id,
@Query("userId") Integer userId,
@Query("logTemplateName") String logTemplateName,
@Query("forceDelete") Boolean forceDelete,
@Query("deleteAssociateRuns") Boolean deleteAssociateRuns,
@Query("event") String event,
@Query("serviceList") List<String> serviceList,
@Query("pipelineId") String pipelineId,
@Query("referer") String referer)

@GET("/autopilot/{type}")
Object getAutoResponse1(@Path('type') String type)
Expand Down

0 comments on commit 341a3f2

Please sign in to comment.