/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.1-dev * User agent: apibuilder app.apibuilder.io/grhodes/code-deploy-dashboard/0.0.1-dev/http4s_0_23 */ package io.grhodes.code.deploy.dashboard.v0.models { /** * @param name Name of this application. * @param deploymentGroups List of deployment groups for this application. */ final case class Application( name: String, deploymentGroups: Seq[io.grhodes.code.deploy.dashboard.v0.models.DeploymentGroup] ) /** * @param id The deployment id * @param created Date deployment created * @param started Date deployment started * @param completed Date deployment created * @param deploymentGroupName The deployment group name * @param failed The number of instances failed deployment * @param skipped The number of instances skipped deployment * @param inProgress The number of instances currently deploying * @param pending The number of instances pending deployment * @param succeeded The number of instances succeeded at deployment * @param status The status of the deployment * @param errorMessage A error message if the deployment failed * @param revisionLocation The location of the revision * @param instances The instances involved in this deployment */ final case class Deployment( id: String, created: _root_.java.time.Instant, started: _root_.java.time.Instant, completed: _root_.java.time.Instant, creator: String, deploymentGroupName: String, failed: Int, skipped: Int, inProgress: Int, pending: Int, succeeded: Int, status: String, errorMessage: _root_.scala.Option[String] = None, revisionLocation: String, instances: Seq[io.grhodes.code.deploy.dashboard.v0.models.DeploymentInstance] ) /** * @param name Name of this deployment group. * @param autoScalingGroupNames List of auto scaling groups for this deployment group. */ final case class DeploymentGroup( name: String, autoScalingGroupNames: Seq[String] ) /** * @param id The instance id * @param status The status of this instances deployment * @param lastUpdatedAt Last updated at time * @param lifecycleEvents Deployment lifecycle events */ final case class DeploymentInstance( id: String, status: String, lastUpdatedAt: _root_.java.time.Instant, lifecycleEvents: Seq[io.grhodes.code.deploy.dashboard.v0.models.DeploymentLifecycleEvent] ) /** * @param name The deployment lifecycle event name * @param startTime Time the deployment lifecycle event started * @param endTime Time the deployment lifecycle event ended * @param status The status of the deployment lifecycle event * @param errorLogTail The deployment lifecycle event log tail if it failed * @param errorMessage The deployment lifecycle event error message if it failed * @param scriptName The deployment lifecycle event script filename if it failed */ final case class DeploymentLifecycleEvent( name: String, startTime: _root_.java.time.Instant, endTime: _root_.java.time.Instant, status: String, errorLogTail: _root_.scala.Option[String] = None, errorMessage: _root_.scala.Option[String] = None, scriptName: _root_.scala.Option[String] = None ) /** * @param name Name of this service. * @param version Version of this service. * @param scalaVersion Version of Scala this service is using. * @param sbtVersion Version of SBT used to build this service. * @param buildTime Time the service was built at. */ final case class Info( name: String, version: String, scalaVersion: String, sbtVersion: String, buildTime: _root_.java.time.Instant ) } package io.grhodes.code.deploy.dashboard.v0.models { package object json { import io.circe.Decoder._ import io.circe.Encoder._ import scala.language.implicitConversions // See below - Make Scala 2.11 Either monadic import scala.util.Try import io.circe.{Json, JsonObject, Encoder, Decoder, DecodingFailure} import io.circe.syntax._ import io.grhodes.code.deploy.dashboard.v0.models.json._ // Make Scala 2.11 Either monadic private[v0] implicit def eitherOps[A,B](e: Either[A,B]) = cats.implicits.catsSyntaxEither(e) private[v0] implicit val decodeUUID: Decoder[_root_.java.util.UUID] = Decoder.decodeString.emapTry(str => Try(_root_.java.util.UUID.fromString(str))) private[v0] implicit val encodeUUID: Encoder[_root_.java.util.UUID] = Encoder.encodeString.contramap[_root_.java.util.UUID](uuid => uuid.toString) private[v0] implicit val decodeInstant: Decoder[_root_.java.time.Instant] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.OffsetDateTime.parse(str).toInstant)) private[v0] implicit val encodeInstant: Encoder[_root_.java.time.Instant] = Encoder.encodeString.contramap[_root_.java.time.Instant](_.toString) private[v0] implicit val decodeLocalDate: Decoder[_root_.java.time.LocalDate] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.LocalDate.parse(str))) private[v0] implicit val encodeLocalDate: Encoder[_root_.java.time.LocalDate] = Encoder.encodeString.contramap[_root_.java.time.LocalDate](_.toString) implicit def decodeCodeDeployDashboardApplication: Decoder[Application] = Decoder.instance { c => for { name <- c.downField("name").as[String] deploymentGroups <- c.downField("deploymentGroups").as[Seq[io.grhodes.code.deploy.dashboard.v0.models.DeploymentGroup]] } yield { Application( name = name, deploymentGroups = deploymentGroups ) } } implicit def encodeCodeDeployDashboardApplication: Encoder[Application] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("deploymentGroups" -> t.deploymentGroups.asJson) ).flatten) } implicit def decodeCodeDeployDashboardDeployment: Decoder[Deployment] = Decoder.instance { c => for { id <- c.downField("id").as[String] created <- c.downField("created").as[_root_.java.time.Instant] started <- c.downField("started").as[_root_.java.time.Instant] completed <- c.downField("completed").as[_root_.java.time.Instant] creator <- c.downField("creator").as[String] deploymentGroupName <- c.downField("deployment_group_name").as[String] failed <- c.downField("failed").as[Int] skipped <- c.downField("skipped").as[Int] inProgress <- c.downField("in_progress").as[Int] pending <- c.downField("pending").as[Int] succeeded <- c.downField("succeeded").as[Int] status <- c.downField("status").as[String] errorMessage <- c.downField("error_message").as[Option[String]] revisionLocation <- c.downField("revision_location").as[String] instances <- c.downField("instances").as[Seq[io.grhodes.code.deploy.dashboard.v0.models.DeploymentInstance]] } yield { Deployment( id = id, created = created, started = started, completed = completed, creator = creator, deploymentGroupName = deploymentGroupName, failed = failed, skipped = skipped, inProgress = inProgress, pending = pending, succeeded = succeeded, status = status, errorMessage = errorMessage, revisionLocation = revisionLocation, instances = instances ) } } implicit def encodeCodeDeployDashboardDeployment: Encoder[Deployment] = Encoder.instance { t => Json.fromFields(Seq( Some("id" -> t.id.asJson), Some("created" -> t.created.asJson), Some("started" -> t.started.asJson), Some("completed" -> t.completed.asJson), Some("creator" -> t.creator.asJson), Some("deployment_group_name" -> t.deploymentGroupName.asJson), Some("failed" -> t.failed.asJson), Some("skipped" -> t.skipped.asJson), Some("in_progress" -> t.inProgress.asJson), Some("pending" -> t.pending.asJson), Some("succeeded" -> t.succeeded.asJson), Some("status" -> t.status.asJson), t.errorMessage.map(t => "error_message" -> t.asJson), Some("revision_location" -> t.revisionLocation.asJson), Some("instances" -> t.instances.asJson) ).flatten) } implicit def decodeCodeDeployDashboardDeploymentGroup: Decoder[DeploymentGroup] = Decoder.instance { c => for { name <- c.downField("name").as[String] autoScalingGroupNames <- c.downField("autoScalingGroupNames").as[Seq[String]] } yield { DeploymentGroup( name = name, autoScalingGroupNames = autoScalingGroupNames ) } } implicit def encodeCodeDeployDashboardDeploymentGroup: Encoder[DeploymentGroup] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("autoScalingGroupNames" -> t.autoScalingGroupNames.asJson) ).flatten) } implicit def decodeCodeDeployDashboardDeploymentInstance: Decoder[DeploymentInstance] = Decoder.instance { c => for { id <- c.downField("id").as[String] status <- c.downField("status").as[String] lastUpdatedAt <- c.downField("last_updated_at").as[_root_.java.time.Instant] lifecycleEvents <- c.downField("lifecycle_events").as[Seq[io.grhodes.code.deploy.dashboard.v0.models.DeploymentLifecycleEvent]] } yield { DeploymentInstance( id = id, status = status, lastUpdatedAt = lastUpdatedAt, lifecycleEvents = lifecycleEvents ) } } implicit def encodeCodeDeployDashboardDeploymentInstance: Encoder[DeploymentInstance] = Encoder.instance { t => Json.fromFields(Seq( Some("id" -> t.id.asJson), Some("status" -> t.status.asJson), Some("last_updated_at" -> t.lastUpdatedAt.asJson), Some("lifecycle_events" -> t.lifecycleEvents.asJson) ).flatten) } implicit def decodeCodeDeployDashboardDeploymentLifecycleEvent: Decoder[DeploymentLifecycleEvent] = Decoder.instance { c => for { name <- c.downField("name").as[String] startTime <- c.downField("start_time").as[_root_.java.time.Instant] endTime <- c.downField("end_time").as[_root_.java.time.Instant] status <- c.downField("status").as[String] errorLogTail <- c.downField("error_log_tail").as[Option[String]] errorMessage <- c.downField("error_message").as[Option[String]] scriptName <- c.downField("script_name").as[Option[String]] } yield { DeploymentLifecycleEvent( name = name, startTime = startTime, endTime = endTime, status = status, errorLogTail = errorLogTail, errorMessage = errorMessage, scriptName = scriptName ) } } implicit def encodeCodeDeployDashboardDeploymentLifecycleEvent: Encoder[DeploymentLifecycleEvent] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("start_time" -> t.startTime.asJson), Some("end_time" -> t.endTime.asJson), Some("status" -> t.status.asJson), t.errorLogTail.map(t => "error_log_tail" -> t.asJson), t.errorMessage.map(t => "error_message" -> t.asJson), t.scriptName.map(t => "script_name" -> t.asJson) ).flatten) } implicit def decodeCodeDeployDashboardInfo: Decoder[Info] = Decoder.instance { c => for { name <- c.downField("name").as[String] version <- c.downField("version").as[String] scalaVersion <- c.downField("scala_version").as[String] sbtVersion <- c.downField("sbt_version").as[String] buildTime <- c.downField("build_time").as[_root_.java.time.Instant] } yield { Info( name = name, version = version, scalaVersion = scalaVersion, sbtVersion = sbtVersion, buildTime = buildTime ) } } implicit def encodeCodeDeployDashboardInfo: Encoder[Info] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("version" -> t.version.asJson), Some("scala_version" -> t.scalaVersion.asJson), Some("sbt_version" -> t.sbtVersion.asJson), Some("build_time" -> t.buildTime.asJson) ).flatten) } } }