Skip to content

Commit

Permalink
OP-21802 : Springfox to Springdoc Update
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-agrawal committed May 12, 2024
1 parent d583bfb commit 7e8ddda
Show file tree
Hide file tree
Showing 33 changed files with 345 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.netflix.kayenta.metrics.SynchronousQueryProcessor;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import java.io.IOException;
import java.time.Instant;
import java.util.Collections;
Expand Down Expand Up @@ -55,14 +55,14 @@ public AtlasFetchController(
public Map queryMetrics(
@RequestParam(required = false) final String metricsAccountName,
@RequestParam(required = false) final String storageAccountName,
@ApiParam(defaultValue = "name,CpuRawUser,:eq,:sum") @RequestParam String q,
@ApiParam(defaultValue = "cpu") @RequestParam String metricSetName,
@ApiParam(defaultValue = "cluster") @RequestParam String type,
@Parameter @RequestParam String q,
@Parameter @RequestParam String metricSetName,
@Parameter @RequestParam String type,
@RequestParam String scope,
@ApiParam(defaultValue = "us-east-1") @RequestParam String location,
@ApiParam(defaultValue = "2000-01-01T00:00:00Z") @RequestParam Instant start,
@ApiParam(defaultValue = "2000-01-01T04:00:00Z") @RequestParam Instant end,
@ApiParam(defaultValue = "300") @RequestParam Long step)
@Parameter @RequestParam String location,
@Parameter @RequestParam Instant start,
@Parameter @RequestParam Instant end,
@Parameter @RequestParam Long step)
throws IOException {
String resolvedMetricsAccountName =
accountCredentialsRepository
Expand Down
5 changes: 1 addition & 4 deletions kayenta-core/kayenta-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ dependencies {
api "io.spinnaker.kork:kork-web"
api "com.netflix.spectator:spectator-api"

// TODO update korkSwagger?
// Force a newer version than what comes with korkSwagger, so that the api docs page isn't broken.
api "io.springfox:springfox-swagger-ui:2.9.2"
api "io.springfox:springfox-swagger2:2.9.2"
api "io.spinnaker.kork:kork-swagger"

api "io.spinnaker.orca:orca-core"
api "io.spinnaker.orca:orca-retrofit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
package com.netflix.kayenta.canary;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
import javax.validation.constraints.NotNull;
import lombok.*;
Expand All @@ -28,19 +27,19 @@
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(description = "The classification configuration, such as group weights.")
@Schema(description = "The classification configuration, such as group weights.")
public class CanaryClassifierConfig {

@ApiModelProperty(
value =
@Schema(
description =
"List of each metrics group along with its corresponding weight. Weights must total 100.",
example = "{\"pod-group\": 70, \"app-group\": 30}")
@NotNull
@Singular
@Getter
private Map<String, Double> groupWeights;

@ApiModelProperty(hidden = true)
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
@Getter
private CanaryClassifierThresholdsConfig scoreThresholds;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
package com.netflix.kayenta.canary;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotNull;
import lombok.*;

Expand All @@ -27,18 +26,19 @@
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(description = "Sets thresholds for canary score.")
@Schema(description = "Sets thresholds for canary score.")
public class CanaryClassifierThresholdsConfig {

@ApiModelProperty(
value = "If canary score is higher than this value -- canary is considered successful.",
@Schema(
description = "If canary score is higher than this value -- canary is considered successful.",
example = "75.0")
@NotNull
@Getter
private Double pass;

@ApiModelProperty(
value = "If canary score is lower than this value -- canary is considered marginal (failed).",
@Schema(
description =
"If canary score is lower than this value -- canary is considered marginal (failed).",
example = "50.0")
@NotNull
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
package com.netflix.kayenta.canary;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
import javax.validation.constraints.NotNull;
import lombok.*;
Expand All @@ -28,19 +27,19 @@
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(description = "Judge configuration.")
@Schema(description = "Judge configuration.")
public class CanaryJudgeConfig {

@ApiModelProperty(
value = "Judge to use, as of right now there is only `NetflixACAJudge-v1.0`.",
@Schema(
description = "Judge to use, as of right now there is only `NetflixACAJudge-v1.0`.",
example = "NetflixACAJudge-v1.0",
required = true)
@NotNull
@Getter
private String name;

@ApiModelProperty(
value =
@Schema(
description =
"Additional judgement configuration. As of right now, this should always be an empty object.",
example = "{}",
required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.netflix.kayenta.metrics.SynchronousQueryProcessor;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
Expand Down Expand Up @@ -61,18 +61,20 @@ public DatadogFetchController(
public Map queryMetrics(
@RequestParam(required = false) final String metricsAccountName,
@RequestParam(required = false) final String storageAccountName,
@ApiParam(defaultValue = "cpu") @RequestParam String metricSetName,
@ApiParam(defaultValue = "avg:system.cpu.user") @RequestParam String metricName,
@ApiParam(value = "The scope of the Datadog query. e.g. autoscaling_group:myapp-prod-v002")
@Parameter @RequestParam String metricSetName,
@Parameter @RequestParam String metricName,
@Parameter(
description =
"The scope of the Datadog query. e.g. autoscaling_group:myapp-prod-v002")
@RequestParam(required = false)
String scope,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@RequestParam(required = false)
String start,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@RequestParam(required = false)
String end,
@ApiParam(defaultValue = "false") @RequestParam(required = false) final boolean dryRun)
@Parameter @RequestParam(required = false) final boolean dryRun)
throws IOException {
// Apply defaults.
scope =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.netflix.kayenta.metrics.SynchronousQueryProcessor;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import java.io.IOException;
import java.time.Instant;
import java.util.Collections;
Expand Down Expand Up @@ -63,25 +63,25 @@ public GraphiteFetchController(
public Map queryMetrics(
@RequestParam(required = false) final String metricsAccountName,
@RequestParam(required = false) final String storageAccountName,
@ApiParam(defaultValue = "cpu") @RequestParam String metricSetName,
@ApiParam(defaultValue = "system.$location.$scope") @RequestParam String metricName,
@ApiParam(
value =
@Parameter @RequestParam String metricSetName,
@Parameter @RequestParam String metricName,
@Parameter(
description =
"The name of the resource to use when scoping the query. "
+ "This parameter will replace $scope in metricName")
@RequestParam(required = false)
String scope,
@ApiParam(
value =
@Parameter(
description =
"The name of the resource to use when locating the query. "
+ "This parameter will replace $location in metricName")
@RequestParam(required = false)
String location,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
String start,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
String end,
@ApiParam(defaultValue = "false") @RequestParam(required = false) final boolean dryRun)
@Parameter @RequestParam(required = false) final boolean dryRun)
throws IOException {

start =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.netflix.kayenta.metrics.SynchronousQueryProcessor;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import java.io.IOException;
import java.time.Instant;
import java.util.Collections;
Expand Down Expand Up @@ -64,21 +64,23 @@ public InfluxDbFetchController(
public Map<String, String> queryMetrics(
@RequestParam(required = false) final String metricsAccountName,
@RequestParam(required = false) final String storageAccountName,
@ApiParam(defaultValue = "cpu") @RequestParam String metricSetName,
@ApiParam(defaultValue = "temperature") @RequestParam String metricName,
@ApiParam(value = "Fields that are being queried. e.g. internal, external")
@Parameter @RequestParam String metricSetName,
@Parameter @RequestParam String metricName,
@Parameter(description = "Fields that are being queried. e.g. internal, external")
@RequestParam(required = false)
List<String> fields,
@ApiParam(value = "The scope of the Influxdb query. e.g. autoscaling_group:myapp-prod-v002")
@Parameter(
description =
"The scope of the Influxdb query. e.g. autoscaling_group:myapp-prod-v002")
@RequestParam(required = false)
String scope,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@RequestParam(required = false)
String start,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z")
@RequestParam(required = false)
String end,
@ApiParam(defaultValue = "60", value = "seconds") @RequestParam Long step)
@Parameter(description = "seconds") @RequestParam Long step)
throws IOException {
// Apply defaults.
scope =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.netflix.kayenta.newrelic.config.NewRelicConfigurationTestControllerDefaultProperties;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
Expand Down Expand Up @@ -62,22 +62,23 @@ public NewRelicFetchController(
public Map queryMetrics(
@RequestParam(required = false) final String metricsAccountName,
@RequestParam(required = false) final String storageAccountName,
@ApiParam(required = true) @Valid @RequestBody NewRelicFetchRequest newRelicFetchRequest,
@ApiParam(value = "The scope of the NewRelic query. e.g. autoscaling_group:myapp-prod-v002")
@Parameter(required = true) @Valid @RequestBody NewRelicFetchRequest newRelicFetchRequest,
@Parameter(
description =
"The scope of the NewRelic query. e.g. autoscaling_group:myapp-prod-v002")
@RequestParam(required = false)
String scope,
@ApiParam(value = "The location of the NewRelic query. e.g. us-west-2")
@Parameter(description = "The location of the NewRelic query. e.g. us-west-2")
@RequestParam(required = false)
String location,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
String start,
@ApiParam(value = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
@Parameter(description = "An ISO format timestamp, e.g.: 2018-03-15T01:23:45Z") @RequestParam
String end,
@ApiParam(defaultValue = "60", value = "seconds") @RequestParam Long step,
@ApiParam(defaultValue = "0", value = "canary config metrics index")
@RequestParam(required = false)
@Parameter(description = "seconds") @RequestParam Long step,
@Parameter(description = "canary config metrics index") @RequestParam(required = false)
Integer metricIndex,
@ApiParam(defaultValue = "false") @RequestParam(required = false) final boolean dryRun)
@Parameter @RequestParam(required = false) final boolean dryRun)
throws IOException {

// Apply defaults.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import com.netflix.kayenta.canary.CanaryConfig;
import com.netflix.kayenta.canary.CanaryMetricConfig;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
Expand All @@ -31,10 +30,10 @@
@ToString
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "Request body for using the New Relic Fetch controller")
@Schema(description = "Request body for using the New Relic Fetch controller")
class NewRelicFetchRequest {
@NotNull
@ApiModelProperty(value = "The metric config to query New Relic insights for")
@Schema(description = "The metric config to query New Relic insights for")
CanaryMetricConfig canaryMetricConfig;

@NotNull @Builder.Default Map<String, String> extendedScopeParams = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion kayenta-orca/kayenta-orca.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ dependencies {
api "io.spinnaker.orca:orca-queue"
api "io.spinnaker.orca:orca-queue-redis"
api "io.spinnaker.orca:orca-redis"
api "io.spinnaker.kork:kork-swagger"
api "org.springframework.boot:spring-boot-starter-actuator"
api "io.swagger:swagger-annotations:1.5.20"
api "com.jakewharton.retrofit:retrofit1-okhttp3-client:1.1.0"

// TODO(duftler): Move these to spinnaker-dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.netflix.spinnaker.orca.api.pipeline.models.PipelineExecution;
import com.netflix.spinnaker.orca.pipeline.ExecutionLauncher;
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -97,19 +97,19 @@ void startOrcaQueueProcessing() {
}
}

@ApiOperation(value = "Initiate a pipeline execution")
@Operation(summary = "Initiate a pipeline execution")
@RequestMapping(value = "/start", method = RequestMethod.POST)
String start(@RequestBody Map map) throws Exception {
return startPipeline(map);
}

@ApiOperation(value = "Retrieve a pipeline execution")
@Operation(summary = "Retrieve a pipeline execution")
@RequestMapping(value = "/{executionId}", method = RequestMethod.GET)
PipelineExecution getPipeline(@PathVariable String executionId) {
return executionRepository.retrieve(PIPELINE, executionId);
}

@ApiOperation(value = "Cancel a pipeline execution")
@Operation(summary = "Cancel a pipeline execution")
@RequestMapping(value = "/{executionId}/cancel", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.ACCEPTED)
void cancel(@PathVariable String executionId) {
Expand All @@ -126,7 +126,7 @@ void cancel(@PathVariable String executionId) {
executionRepository.updateStatus(PIPELINE, executionId, ExecutionStatus.CANCELED);
}

@ApiOperation(value = "Delete a pipeline execution")
@Operation(summary = "Delete a pipeline execution")
@RequestMapping(value = "/{executionId}", method = RequestMethod.DELETE)
ResponseEntity delete(@PathVariable String executionId) {
log.info("Deleting pipeline execution {}...", executionId);
Expand All @@ -139,7 +139,7 @@ ResponseEntity delete(@PathVariable String executionId) {
return new ResponseEntity(HttpStatus.OK);
}

@ApiOperation(value = "List all pipeline IDs")
@Operation(summary = "List all pipeline IDs")
@RequestMapping(method = RequestMethod.GET)
List<String> list() {
return executionRepository.retrieveAllExecutionIds(PIPELINE);
Expand Down
Loading

0 comments on commit 7e8ddda

Please sign in to comment.