Skip to content

Commit

Permalink
chore(upgrade): Migrate to openapi swagger spec (#1046)
Browse files Browse the repository at this point in the history
Co-authored-by: christosarvanitis <christos.arvanitis@armory.io>
  • Loading branch information
jasonmcintosh and christosarvanitis authored Dec 3, 2024
1 parent 6f4cc55 commit 3deb7ad
Show file tree
Hide file tree
Showing 34 changed files with 350 additions and 343 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
orcaVersion=8.57.0
orcaVersion=8.58.0
org.gradle.parallel=true
spinnakerGradleVersion=8.32.1
targetJava17=true
Expand Down
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(example = "name,CpuRawUser,:eq,:sum") @RequestParam String q,
@Parameter(example = "cpu") @RequestParam String metricSetName,
@Parameter(example = "cluster") @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(example = "us-east-1") @RequestParam String location,
@Parameter(example = "2000-01-01T00:00:00Z") @RequestParam Instant start,
@Parameter(example = "2000-01-01T04:00:00Z") @RequestParam Instant end,
@Parameter(example = "300") @RequestParam Long step)
throws IOException {
String resolvedMetricsAccountName =
accountCredentialsRepository
Expand Down
3 changes: 1 addition & 2 deletions kayenta-core/kayenta-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ dependencies {
api "io.spinnaker.kork:kork-retrofit"
api "com.netflix.spectator:spectator-api"

api "io.swagger:swagger-annotations"

api "io.spinnaker.orca:orca-core"
api "io.spinnaker.orca:orca-retrofit"

Expand All @@ -16,6 +14,7 @@ dependencies {
api "net.logstash.logback:logstash-logback-encoder"

api "javax.validation:validation-api"
api "io.swagger.core.v3:swagger-annotations"

testImplementation "io.spinnaker.kork:kork-jedis-test"
}
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(hidden = true)
@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,8 @@
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 io.swagger.v3.oas.annotations.media.Schema;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
Expand Down Expand Up @@ -61,18 +62,21 @@ 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(example = "cpu") @RequestParam String metricSetName,
@Parameter(example = "avg:system.cpu.user") @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(schema = @Schema(defaultValue = "false")) @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(example = "cpu") @RequestParam String metricSetName,
@Parameter(example = "system.$location.$scope") @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(example = "false") @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(example = "cpu") @RequestParam String metricSetName,
@Parameter(example = "temperature") @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(example = "60", 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,8 @@
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 io.swagger.v3.oas.annotations.media.Schema;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
Expand Down Expand Up @@ -62,22 +63,25 @@ 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")
@Parameter(example = "60", description = "seconds") @RequestParam Long step,
@Parameter(schema = @Schema(defaultValue = "0"), description = "canary config metrics index")
@RequestParam(required = false)
Integer metricIndex,
@ApiParam(defaultValue = "false") @RequestParam(required = false) final boolean dryRun)
@Parameter(schema = @Schema(defaultValue = "false")) @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
1 change: 1 addition & 0 deletions kayenta-orca/kayenta-orca.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
api "io.spinnaker.orca:orca-redis"
api "org.springframework.boot:spring-boot-starter-actuator"
api "org.springframework.cloud:spring-cloud-commons"
api "io.swagger.core.v3:swagger-annotations"

// TODO(duftler): Move these to spinnaker-dependencies.
testImplementation "io.spinnaker.orca:orca-test"
Expand Down
Loading

0 comments on commit 3deb7ad

Please sign in to comment.