All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.spinnaker.orca.kayenta.KayentaService.kt Maven / Gradle / Ivy

There is a newer version: 8.54.0
Show newest version
/*
 * Copyright 2018 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.netflix.spinnaker.orca.kayenta

import com.fasterxml.jackson.annotation.JsonIgnore
import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus
import java.time.Duration
import java.time.Instant
import retrofit.http.Body
import retrofit.http.GET
import retrofit.http.POST
import retrofit.http.PUT
import retrofit.http.Path
import retrofit.http.Query

interface KayentaService {

  @POST("/canary/{canaryConfigId}")
  fun create(
    @Path("canaryConfigId") canaryConfigId: String,
    @Query("application") application: String,
    @Query("parentPipelineExecutionId") parentPipelineExecutionId: String,
    @Query("metricsAccountName") metricsAccountName: String?,
    @Query("configurationAccountName") configurationAccountName: String?,
    @Query("storageAccountName") storageAccountName: String?,
    @Body canaryExecutionRequest: CanaryExecutionRequest
  ): Map<*, *>

  @GET("/canary/{canaryExecutionId}")
  fun getCanaryResults(
    @Query("storageAccountName") storageAccountName: String?,
    @Path("canaryExecutionId") canaryExecutionId: String
  ): CanaryResults

  @PUT("/pipelines/{executionId}/cancel")
  fun cancelPipelineExecution(
    @Path("executionId") executionId: String,
    @Body ignored: String
  ): Map<*, *>

  @GET("/credentials")
  fun getCredentials(): List

  @GET("/canaryConfig")
  fun getAllCanaryConfigs(): List
}

data class CanaryExecutionRequest(
  val scopes: Map = emptyMap(),
  val thresholds: Thresholds,
  // TODO: Remove all remnants of siteLocal when addressing https://github.com/spinnaker/kayenta/issues/600
  val siteLocal: Map = emptyMap()
)

data class CanaryScopes(
  val controlScope: CanaryScope,
  val experimentScope: CanaryScope
)

data class CanaryScope(
  val scope: String?,
  val location: String?,
  val start: Instant,
  val end: Instant,
  val step: Long = 60, // TODO: would be nice to use a Duration
  val extendedScopeParams: Map = emptyMap()
)

data class Thresholds(
  val pass: Int,
  val marginal: Int
)

data class CanaryResults(
  val complete: Boolean,
  val status: String,
  val result: CanaryResult?,
  val buildTimeIso: Instant?,
  val startTimeIso: Instant?,
  val endTimeIso: Instant?,
  val storageAccountName: String?,
  val application: String,
  val canaryExecutionRequest: CanaryExecutionRequest?,
  val exception: Map?
) {
  @JsonIgnore
  val executionStatus = ExecutionStatus.valueOf(status.toUpperCase())
}

data class CanaryResult(
  val judgeResult: JudgeResult,
  val canaryDuration: Duration?
)

data class JudgeResult(
  val score: JudgeScore,
  val results: Array
)

data class JudgeScore(
  val score: Int,
  val classification: String,
  val classificationReason: String
)

data class JudgeResultEntry(
  val controlMetadata: ControlMetadata
)

data class ControlMetadata(
  val stats: ControlMetadataStats
)

data class ControlMetadataStats(
  val count: Int
)

data class KayentaCredential(
  val name: String,
  val type: String
)

data class KayentaCanaryConfig(
  val id: String,
  val name: String,
  val updatedTimestamp: Long?,
  val updateTimestampIso: String?,
  val applications: List
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy