/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.2.7 * User agent: apibuilder app.apibuilder.io/gilt/svc-sundial/0.2.7/http4s_0_22 */ package com.gilt.svc.sundial.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 com.gilt.svc.sundial.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 val jsonDecoderSvcSundialDefaultEmrJobFlowRole: Decoder[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole(_)) implicit val jsonEncoderSvcSundialDefaultEmrJobFlowRole: Encoder[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole](_.toString) implicit val jsonDecoderSvcSundialDefaultEmrServiceRole: Decoder[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole(_)) implicit val jsonEncoderSvcSundialDefaultEmrServiceRole: Encoder[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole](_.toString) implicit val jsonDecoderSvcSundialEmrApplication: Decoder[com.gilt.svc.sundial.v0.models.EmrApplication] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.EmrApplication(_)) implicit val jsonEncoderSvcSundialEmrApplication: Encoder[com.gilt.svc.sundial.v0.models.EmrApplication] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.EmrApplication](_.toString) implicit val jsonDecoderSvcSundialEmrReleaseLabel: Decoder[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.EmrReleaseLabel(_)) implicit val jsonEncoderSvcSundialEmrReleaseLabel: Encoder[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.EmrReleaseLabel](_.toString) implicit val jsonDecoderSvcSundialNotificationOptions: Decoder[com.gilt.svc.sundial.v0.models.NotificationOptions] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.NotificationOptions(_)) implicit val jsonEncoderSvcSundialNotificationOptions: Encoder[com.gilt.svc.sundial.v0.models.NotificationOptions] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.NotificationOptions](_.toString) implicit val jsonDecoderSvcSundialOnDemand: Decoder[com.gilt.svc.sundial.v0.models.OnDemand] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.OnDemand(_)) implicit val jsonEncoderSvcSundialOnDemand: Encoder[com.gilt.svc.sundial.v0.models.OnDemand] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.OnDemand](_.toString) implicit val jsonDecoderSvcSundialProcessOverlapAction: Decoder[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.ProcessOverlapAction(_)) implicit val jsonEncoderSvcSundialProcessOverlapAction: Encoder[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.ProcessOverlapAction](_.toString) implicit val jsonDecoderSvcSundialProcessStatus: Decoder[com.gilt.svc.sundial.v0.models.ProcessStatus] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.ProcessStatus(_)) implicit val jsonEncoderSvcSundialProcessStatus: Encoder[com.gilt.svc.sundial.v0.models.ProcessStatus] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.ProcessStatus](_.toString) implicit val jsonDecoderSvcSundialTaskStatus: Decoder[com.gilt.svc.sundial.v0.models.TaskStatus] = Decoder.decodeString.map(com.gilt.svc.sundial.v0.models.TaskStatus(_)) implicit val jsonEncoderSvcSundialTaskStatus: Encoder[com.gilt.svc.sundial.v0.models.TaskStatus] = Encoder.encodeString.contramap[com.gilt.svc.sundial.v0.models.TaskStatus](_.toString) implicit def decodeSvcSundialBatchImageCommand: Decoder[BatchImageCommand] = Decoder.instance { c => for { image <- c.downField("image").as[String] tag <- c.downField("tag").as[String] command <- c.downField("command").as[Seq[String]] memory <- c.downField("memory").as[Int] vCpus <- c.downField("vCpus").as[Int] jobRoleArn <- c.downField("job_role_arn").as[Option[String]] environmentVariables <- c.downField("environment_variables").as[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]] jobQueue <- c.downField("job_queue").as[Option[String]] } yield { BatchImageCommand( image = image, tag = tag, command = command, memory = memory, vCpus = vCpus, jobRoleArn = jobRoleArn, environmentVariables = environmentVariables, jobQueue = jobQueue ) } } implicit def encodeSvcSundialBatchImageCommand: Encoder[BatchImageCommand] = Encoder.instance { t => Json.fromFields(Seq( Some("image" -> t.image.asJson), Some("tag" -> t.tag.asJson), Some("command" -> t.command.asJson), Some("memory" -> t.memory.asJson), Some("vCpus" -> t.vCpus.asJson), t.jobRoleArn.map(t => "job_role_arn" -> t.asJson), Some("environment_variables" -> t.environmentVariables.asJson), t.jobQueue.map(t => "job_queue" -> t.asJson) ).flatten) } implicit def decodeSvcSundialContinuousSchedule: Decoder[ContinuousSchedule] = Decoder.instance { c => for { bufferSeconds <- c.downField("buffer_seconds").as[Option[Int]] } yield { ContinuousSchedule( bufferSeconds = bufferSeconds ) } } implicit def encodeSvcSundialContinuousSchedule: Encoder[ContinuousSchedule] = Encoder.instance { t => Json.fromFields(Seq( t.bufferSeconds.map(t => "buffer_seconds" -> t.asJson) ).flatten) } implicit def decodeSvcSundialCronSchedule: Decoder[CronSchedule] = Decoder.instance { c => for { dayOfWeek <- c.downField("day_of_week").as[String] month <- c.downField("month").as[String] dayOfMonth <- c.downField("day_of_month").as[String] hours <- c.downField("hours").as[String] minutes <- c.downField("minutes").as[String] } yield { CronSchedule( dayOfWeek = dayOfWeek, month = month, dayOfMonth = dayOfMonth, hours = hours, minutes = minutes ) } } implicit def encodeSvcSundialCronSchedule: Encoder[CronSchedule] = Encoder.instance { t => Json.fromFields(Seq( Some("day_of_week" -> t.dayOfWeek.asJson), Some("month" -> t.month.asJson), Some("day_of_month" -> t.dayOfMonth.asJson), Some("hours" -> t.hours.asJson), Some("minutes" -> t.minutes.asJson) ).flatten) } implicit def decodeSvcSundialCustomEmrJobFlowRole: Decoder[CustomEmrJobFlowRole] = Decoder.instance { c => for { roleName <- c.downField("role_name").as[String] } yield { CustomEmrJobFlowRole( roleName = roleName ) } } implicit def encodeSvcSundialCustomEmrJobFlowRole: Encoder[CustomEmrJobFlowRole] = Encoder.instance { t => Json.fromFields(Seq( Some("role_name" -> t.roleName.asJson) ).flatten) } implicit def decodeSvcSundialCustomEmrServiceRole: Decoder[CustomEmrServiceRole] = Decoder.instance { c => for { roleName <- c.downField("role_name").as[String] } yield { CustomEmrServiceRole( roleName = roleName ) } } implicit def encodeSvcSundialCustomEmrServiceRole: Encoder[CustomEmrServiceRole] = Encoder.instance { t => Json.fromFields(Seq( Some("role_name" -> t.roleName.asJson) ).flatten) } implicit def decodeSvcSundialDockerImageCommand: Decoder[DockerImageCommand] = Decoder.instance { c => for { image <- c.downField("image").as[String] tag <- c.downField("tag").as[String] command <- c.downField("command").as[Seq[String]] memory <- c.downField("memory").as[Option[Int]] cpu <- c.downField("cpu").as[Option[Int]] taskRoleArn <- c.downField("taskRoleArn").as[Option[String]] logPaths <- c.downField("log_paths").as[Seq[String]] environmentVariables <- c.downField("environment_variables").as[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]] } yield { DockerImageCommand( image = image, tag = tag, command = command, memory = memory, cpu = cpu, taskRoleArn = taskRoleArn, logPaths = logPaths, environmentVariables = environmentVariables ) } } implicit def encodeSvcSundialDockerImageCommand: Encoder[DockerImageCommand] = Encoder.instance { t => Json.fromFields(Seq( Some("image" -> t.image.asJson), Some("tag" -> t.tag.asJson), Some("command" -> t.command.asJson), t.memory.map(t => "memory" -> t.asJson), t.cpu.map(t => "cpu" -> t.asJson), t.taskRoleArn.map(t => "taskRoleArn" -> t.asJson), Some("log_paths" -> t.logPaths.asJson), Some("environment_variables" -> t.environmentVariables.asJson) ).flatten) } implicit def decodeSvcSundialEmail: Decoder[Email] = Decoder.instance { c => for { name <- c.downField("name").as[String] email <- c.downField("email").as[String] notifyWhen <- c.downField("notify_when").as[com.gilt.svc.sundial.v0.models.NotificationOptions] } yield { Email( name = name, email = email, notifyWhen = notifyWhen ) } } implicit def encodeSvcSundialEmail: Encoder[Email] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("email" -> t.email.asJson), Some("notify_when" -> t.notifyWhen.asJson) ).flatten) } implicit def decodeSvcSundialEmrCommand: Decoder[EmrCommand] = Decoder.instance { c => for { emrCluster <- c.downField("emr_cluster").as[com.gilt.svc.sundial.v0.models.EmrCluster] jobName <- c.downField("job_name").as[String] region <- c.downField("region").as[String] __class__ <- c.downField("class").as[String] s3JarPath <- c.downField("s3_jar_path").as[String] sparkConf <- c.downField("spark_conf").as[Seq[String]] args <- c.downField("args").as[Seq[String]] s3LogDetails <- c.downField("s3_log_details").as[Option[com.gilt.svc.sundial.v0.models.S3LogDetails]] loadData <- c.downField("load_data").as[Option[Seq[com.gilt.svc.sundial.v0.models.S3Cp]]] saveResults <- c.downField("save_results").as[Option[Seq[com.gilt.svc.sundial.v0.models.S3Cp]]] } yield { EmrCommand( emrCluster = emrCluster, jobName = jobName, region = region, `class` = __class__, s3JarPath = s3JarPath, sparkConf = sparkConf, args = args, s3LogDetails = s3LogDetails, loadData = loadData, saveResults = saveResults ) } } implicit def encodeSvcSundialEmrCommand: Encoder[EmrCommand] = Encoder.instance { t => Json.fromFields(Seq( Some("emr_cluster" -> t.emrCluster.asJson), Some("job_name" -> t.jobName.asJson), Some("region" -> t.region.asJson), Some("class" -> t.`class`.asJson), Some("s3_jar_path" -> t.s3JarPath.asJson), Some("spark_conf" -> t.sparkConf.asJson), Some("args" -> t.args.asJson), t.s3LogDetails.map(t => "s3_log_details" -> t.asJson), t.loadData.map(t => "load_data" -> t.asJson), t.saveResults.map(t => "save_results" -> t.asJson) ).flatten) } implicit def decodeSvcSundialEmrInstanceGroupDetails: Decoder[EmrInstanceGroupDetails] = Decoder.instance { c => for { emrInstanceType <- c.downField("emr_instance_type").as[String] instanceCount <- c.downField("instance_count").as[Int] awsMarket <- c.downField("aws_market").as[com.gilt.svc.sundial.v0.models.AwsMarket] ebsVolumeSize <- c.downField("ebs_volume_size").as[Option[Int]] } yield { EmrInstanceGroupDetails( emrInstanceType = emrInstanceType, instanceCount = instanceCount, awsMarket = awsMarket, ebsVolumeSize = ebsVolumeSize ) } } implicit def encodeSvcSundialEmrInstanceGroupDetails: Encoder[EmrInstanceGroupDetails] = Encoder.instance { t => Json.fromFields(Seq( Some("emr_instance_type" -> t.emrInstanceType.asJson), Some("instance_count" -> t.instanceCount.asJson), Some("aws_market" -> t.awsMarket.asJson), t.ebsVolumeSize.map(t => "ebs_volume_size" -> t.asJson) ).flatten) } implicit def decodeSvcSundialEnvironmentVariable: Decoder[EnvironmentVariable] = Decoder.instance { c => for { variableName <- c.downField("variable_name").as[String] value <- c.downField("value").as[String] } yield { EnvironmentVariable( variableName = variableName, value = value ) } } implicit def encodeSvcSundialEnvironmentVariable: Encoder[EnvironmentVariable] = Encoder.instance { t => Json.fromFields(Seq( Some("variable_name" -> t.variableName.asJson), Some("value" -> t.value.asJson) ).flatten) } implicit def decodeSvcSundialExistingEmrCluster: Decoder[ExistingEmrCluster] = Decoder.instance { c => for { clusterId <- c.downField("cluster_id").as[String] } yield { ExistingEmrCluster( clusterId = clusterId ) } } implicit def encodeSvcSundialExistingEmrCluster: Encoder[ExistingEmrCluster] = Encoder.instance { t => Json.fromFields(Seq( Some("cluster_id" -> t.clusterId.asJson) ).flatten) } implicit def decodeSvcSundialHealthcheck: Decoder[Healthcheck] = Decoder.instance { c => for { status <- c.downField("status").as[String] } yield { Healthcheck( status = status ) } } implicit def encodeSvcSundialHealthcheck: Encoder[Healthcheck] = Encoder.instance { t => Json.fromFields(Seq( Some("status" -> t.status.asJson) ).flatten) } implicit def decodeSvcSundialLogEntry: Decoder[LogEntry] = Decoder.instance { c => for { logEntryId <- c.downField("log_entry_id").as[_root_.java.util.UUID] when <- c.downField("when").as[_root_.java.time.Instant] source <- c.downField("source").as[String] message <- c.downField("message").as[String] } yield { LogEntry( logEntryId = logEntryId, when = when, source = source, message = message ) } } implicit def encodeSvcSundialLogEntry: Encoder[LogEntry] = Encoder.instance { t => Json.fromFields(Seq( Some("log_entry_id" -> t.logEntryId.asJson), Some("when" -> t.when.asJson), Some("source" -> t.source.asJson), Some("message" -> t.message.asJson) ).flatten) } implicit def decodeSvcSundialMetadataEntry: Decoder[MetadataEntry] = Decoder.instance { c => for { metadataEntryId <- c.downField("metadata_entry_id").as[_root_.java.util.UUID] when <- c.downField("when").as[_root_.java.time.Instant] key <- c.downField("key").as[String] value <- c.downField("value").as[String] } yield { MetadataEntry( metadataEntryId = metadataEntryId, when = when, key = key, value = value ) } } implicit def encodeSvcSundialMetadataEntry: Encoder[MetadataEntry] = Encoder.instance { t => Json.fromFields(Seq( Some("metadata_entry_id" -> t.metadataEntryId.asJson), Some("when" -> t.when.asJson), Some("key" -> t.key.asJson), Some("value" -> t.value.asJson) ).flatten) } implicit def decodeSvcSundialNewEmrCluster: Decoder[NewEmrCluster] = Decoder.instance { c => for { name <- c.downField("name").as[String] releaseLabel <- c.downField("release_label").as[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] applications <- c.downField("applications").as[Seq[com.gilt.svc.sundial.v0.models.EmrApplication]] s3LogUri <- c.downField("s3_log_uri").as[String] masterInstance <- c.downField("master_instance").as[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] coreInstance <- c.downField("core_instance").as[Option[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails]] taskInstance <- c.downField("task_instance").as[Option[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails]] ec2Subnet <- c.downField("ec2_subnet").as[Option[String]] emrServiceRole <- c.downField("emr_service_role").as[com.gilt.svc.sundial.v0.models.EmrServiceRole] emrJobFlowRole <- c.downField("emr_job_flow_role").as[com.gilt.svc.sundial.v0.models.EmrJobFlowRole] visibleToAllUsers <- c.downField("visible_to_all_users").as[Boolean] } yield { NewEmrCluster( name = name, releaseLabel = releaseLabel, applications = applications, s3LogUri = s3LogUri, masterInstance = masterInstance, coreInstance = coreInstance, taskInstance = taskInstance, ec2Subnet = ec2Subnet, emrServiceRole = emrServiceRole, emrJobFlowRole = emrJobFlowRole, visibleToAllUsers = visibleToAllUsers ) } } implicit def encodeSvcSundialNewEmrCluster: Encoder[NewEmrCluster] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("release_label" -> t.releaseLabel.asJson), Some("applications" -> t.applications.asJson), Some("s3_log_uri" -> t.s3LogUri.asJson), Some("master_instance" -> t.masterInstance.asJson), t.coreInstance.map(t => "core_instance" -> t.asJson), t.taskInstance.map(t => "task_instance" -> t.asJson), t.ec2Subnet.map(t => "ec2_subnet" -> t.asJson), Some("emr_service_role" -> t.emrServiceRole.asJson), Some("emr_job_flow_role" -> t.emrJobFlowRole.asJson), Some("visible_to_all_users" -> t.visibleToAllUsers.asJson) ).flatten) } implicit def decodeSvcSundialPagerduty: Decoder[Pagerduty] = Decoder.instance { c => for { serviceKey <- c.downField("service_key").as[String] numConsecutiveFailures <- c.downField("num_consecutive_failures").as[Int] apiUrl <- c.downField("api_url").as[String] } yield { Pagerduty( serviceKey = serviceKey, numConsecutiveFailures = numConsecutiveFailures, apiUrl = apiUrl ) } } implicit def encodeSvcSundialPagerduty: Encoder[Pagerduty] = Encoder.instance { t => Json.fromFields(Seq( Some("service_key" -> t.serviceKey.asJson), Some("num_consecutive_failures" -> t.numConsecutiveFailures.asJson), Some("api_url" -> t.apiUrl.asJson) ).flatten) } implicit def decodeSvcSundialProcess: Decoder[Process] = Decoder.instance { c => for { processId <- c.downField("process_id").as[_root_.java.util.UUID] processDefinitionName <- c.downField("process_definition_name").as[String] startTime <- c.downField("start_time").as[_root_.java.time.Instant] status <- c.downField("status").as[com.gilt.svc.sundial.v0.models.ProcessStatus] task <- c.downField("task").as[Seq[com.gilt.svc.sundial.v0.models.Task]] } yield { Process( processId = processId, processDefinitionName = processDefinitionName, startTime = startTime, status = status, task = task ) } } implicit def encodeSvcSundialProcess: Encoder[Process] = Encoder.instance { t => Json.fromFields(Seq( Some("process_id" -> t.processId.asJson), Some("process_definition_name" -> t.processDefinitionName.asJson), Some("start_time" -> t.startTime.asJson), Some("status" -> t.status.asJson), Some("task" -> t.task.asJson) ).flatten) } implicit def decodeSvcSundialProcessDefinition: Decoder[ProcessDefinition] = Decoder.instance { c => for { processDefinitionName <- c.downField("process_definition_name").as[String] paused <- c.downField("paused").as[Option[Boolean]] processDescription <- c.downField("process_description").as[Option[String]] schedule <- c.downField("schedule").as[Option[com.gilt.svc.sundial.v0.models.ProcessSchedule]] taskDefinitions <- c.downField("task_definitions").as[Seq[com.gilt.svc.sundial.v0.models.TaskDefinition]] overlapAction <- c.downField("overlap_action").as[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] notifications <- c.downField("notifications").as[Option[Seq[com.gilt.svc.sundial.v0.models.Notification]]] } yield { ProcessDefinition( processDefinitionName = processDefinitionName, paused = paused, processDescription = processDescription, schedule = schedule, taskDefinitions = taskDefinitions, overlapAction = overlapAction, notifications = notifications ) } } implicit def encodeSvcSundialProcessDefinition: Encoder[ProcessDefinition] = Encoder.instance { t => Json.fromFields(Seq( Some("process_definition_name" -> t.processDefinitionName.asJson), t.paused.map(t => "paused" -> t.asJson), t.processDescription.map(t => "process_description" -> t.asJson), t.schedule.map(t => "schedule" -> t.asJson), Some("task_definitions" -> t.taskDefinitions.asJson), Some("overlap_action" -> t.overlapAction.asJson), t.notifications.map(t => "notifications" -> t.asJson) ).flatten) } implicit def decodeSvcSundialS3Cp: Decoder[S3Cp] = Decoder.instance { c => for { source <- c.downField("source").as[String] destination <- c.downField("destination").as[String] } yield { S3Cp( source = source, destination = destination ) } } implicit def encodeSvcSundialS3Cp: Encoder[S3Cp] = Encoder.instance { t => Json.fromFields(Seq( Some("source" -> t.source.asJson), Some("destination" -> t.destination.asJson) ).flatten) } implicit def decodeSvcSundialS3LogDetails: Decoder[S3LogDetails] = Decoder.instance { c => for { logGroupName <- c.downField("log_group_name").as[String] logStreamName <- c.downField("log_stream_name").as[String] } yield { S3LogDetails( logGroupName = logGroupName, logStreamName = logStreamName ) } } implicit def encodeSvcSundialS3LogDetails: Encoder[S3LogDetails] = Encoder.instance { t => Json.fromFields(Seq( Some("log_group_name" -> t.logGroupName.asJson), Some("log_stream_name" -> t.logStreamName.asJson) ).flatten) } implicit def decodeSvcSundialShellScriptCommand: Decoder[ShellScriptCommand] = Decoder.instance { c => for { script <- c.downField("script").as[String] environmentVariables <- c.downField("environment_variables").as[Option[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]]] } yield { ShellScriptCommand( script = script, environmentVariables = environmentVariables ) } } implicit def encodeSvcSundialShellScriptCommand: Encoder[ShellScriptCommand] = Encoder.instance { t => Json.fromFields(Seq( Some("script" -> t.script.asJson), t.environmentVariables.map(t => "environment_variables" -> t.asJson) ).flatten) } implicit def decodeSvcSundialSpot: Decoder[Spot] = Decoder.instance { c => for { bidPrice <- c.downField("bid_price").as[BigDecimal] } yield { Spot( bidPrice = bidPrice ) } } implicit def encodeSvcSundialSpot: Encoder[Spot] = Encoder.instance { t => Json.fromFields(Seq( Some("bid_price" -> t.bidPrice.asJson) ).flatten) } implicit def decodeSvcSundialTask: Decoder[Task] = Decoder.instance { c => for { taskId <- c.downField("task_id").as[_root_.java.util.UUID] processId <- c.downField("process_id").as[_root_.java.util.UUID] processDefinitionName <- c.downField("process_definition_name").as[String] taskDefinitionName <- c.downField("task_definition_name").as[String] startTime <- c.downField("start_time").as[_root_.java.time.Instant] endTime <- c.downField("end_time").as[Option[_root_.java.time.Instant]] previousAttemptCount <- c.downField("previous_attempt_count").as[Int] logEntries <- c.downField("log_entries").as[Seq[com.gilt.svc.sundial.v0.models.LogEntry]] metadataEntries <- c.downField("metadata_entries").as[Seq[com.gilt.svc.sundial.v0.models.MetadataEntry]] executionState <- c.downField("execution_state").as[Option[Seq[com.gilt.svc.sundial.v0.models.MetadataEntry]]] status <- c.downField("status").as[com.gilt.svc.sundial.v0.models.TaskStatus] } yield { Task( taskId = taskId, processId = processId, processDefinitionName = processDefinitionName, taskDefinitionName = taskDefinitionName, startTime = startTime, endTime = endTime, previousAttemptCount = previousAttemptCount, logEntries = logEntries, metadataEntries = metadataEntries, executionState = executionState, status = status ) } } implicit def encodeSvcSundialTask: Encoder[Task] = Encoder.instance { t => Json.fromFields(Seq( Some("task_id" -> t.taskId.asJson), Some("process_id" -> t.processId.asJson), Some("process_definition_name" -> t.processDefinitionName.asJson), Some("task_definition_name" -> t.taskDefinitionName.asJson), Some("start_time" -> t.startTime.asJson), t.endTime.map(t => "end_time" -> t.asJson), Some("previous_attempt_count" -> t.previousAttemptCount.asJson), Some("log_entries" -> t.logEntries.asJson), Some("metadata_entries" -> t.metadataEntries.asJson), t.executionState.map(t => "execution_state" -> t.asJson), Some("status" -> t.status.asJson) ).flatten) } implicit def decodeSvcSundialTaskDefinition: Decoder[TaskDefinition] = Decoder.instance { c => for { taskDefinitionName <- c.downField("task_definition_name").as[String] dependencies <- c.downField("dependencies").as[Seq[com.gilt.svc.sundial.v0.models.TaskDependency]] executable <- c.downField("executable").as[com.gilt.svc.sundial.v0.models.TaskExecutable] maxAttempts <- c.downField("max_attempts").as[Int] maxRuntimeSeconds <- c.downField("max_runtime_seconds").as[Option[Int]] backoffBaseSeconds <- c.downField("backoff_base_seconds").as[Int] backoffExponent <- c.downField("backoff_exponent").as[Double] requireExplicitSuccess <- c.downField("require_explicit_success").as[Boolean] } yield { TaskDefinition( taskDefinitionName = taskDefinitionName, dependencies = dependencies, executable = executable, maxAttempts = maxAttempts, maxRuntimeSeconds = maxRuntimeSeconds, backoffBaseSeconds = backoffBaseSeconds, backoffExponent = backoffExponent, requireExplicitSuccess = requireExplicitSuccess ) } } implicit def encodeSvcSundialTaskDefinition: Encoder[TaskDefinition] = Encoder.instance { t => Json.fromFields(Seq( Some("task_definition_name" -> t.taskDefinitionName.asJson), Some("dependencies" -> t.dependencies.asJson), Some("executable" -> t.executable.asJson), Some("max_attempts" -> t.maxAttempts.asJson), t.maxRuntimeSeconds.map(t => "max_runtime_seconds" -> t.asJson), Some("backoff_base_seconds" -> t.backoffBaseSeconds.asJson), Some("backoff_exponent" -> t.backoffExponent.asJson), Some("require_explicit_success" -> t.requireExplicitSuccess.asJson) ).flatten) } implicit def decodeSvcSundialTaskDependency: Decoder[TaskDependency] = Decoder.instance { c => for { taskDefinitionName <- c.downField("task_definition_name").as[String] successRequired <- c.downField("success_required").as[Boolean] } yield { TaskDependency( taskDefinitionName = taskDefinitionName, successRequired = successRequired ) } } implicit def encodeSvcSundialTaskDependency: Encoder[TaskDependency] = Encoder.instance { t => Json.fromFields(Seq( Some("task_definition_name" -> t.taskDefinitionName.asJson), Some("success_required" -> t.successRequired.asJson) ).flatten) } implicit def decodeSvcSundialAwsMarket: Decoder[AwsMarket] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.OnDemand]("on_demand") orElse c.get[com.gilt.svc.sundial.v0.models.Spot]("spot") orElse Right(com.gilt.svc.sundial.v0.models.AwsMarketUndefinedType(c.value.toString)) } implicit def encodeSvcSundialAwsMarket: Encoder[AwsMarket] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.OnDemand => Json.fromJsonObject(JsonObject.singleton("on_demand", t.asJson)) case t: com.gilt.svc.sundial.v0.models.Spot => Json.fromJsonObject(JsonObject.singleton("spot", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } implicit def decodeSvcSundialEmrCluster: Decoder[EmrCluster] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.NewEmrCluster]("new_emr_cluster") orElse c.get[com.gilt.svc.sundial.v0.models.ExistingEmrCluster]("existing_emr_cluster") orElse Right(com.gilt.svc.sundial.v0.models.EmrClusterUndefinedType(c.value.toString)) } implicit def encodeSvcSundialEmrCluster: Encoder[EmrCluster] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.NewEmrCluster => Json.fromJsonObject(JsonObject.singleton("new_emr_cluster", t.asJson)) case t: com.gilt.svc.sundial.v0.models.ExistingEmrCluster => Json.fromJsonObject(JsonObject.singleton("existing_emr_cluster", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } implicit def decodeSvcSundialEmrJobFlowRole: Decoder[EmrJobFlowRole] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole]("default_emr_job_flow_role") orElse c.get[com.gilt.svc.sundial.v0.models.CustomEmrJobFlowRole]("custom_emr_job_flow_role") orElse Right(com.gilt.svc.sundial.v0.models.EmrJobFlowRoleUndefinedType(c.value.toString)) } implicit def encodeSvcSundialEmrJobFlowRole: Encoder[EmrJobFlowRole] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole => Json.fromJsonObject(JsonObject.singleton("default_emr_job_flow_role", t.asJson)) case t: com.gilt.svc.sundial.v0.models.CustomEmrJobFlowRole => Json.fromJsonObject(JsonObject.singleton("custom_emr_job_flow_role", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } implicit def decodeSvcSundialEmrServiceRole: Decoder[EmrServiceRole] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole]("default_emr_service_role") orElse c.get[com.gilt.svc.sundial.v0.models.CustomEmrServiceRole]("custom_emr_service_role") orElse Right(com.gilt.svc.sundial.v0.models.EmrServiceRoleUndefinedType(c.value.toString)) } implicit def encodeSvcSundialEmrServiceRole: Encoder[EmrServiceRole] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole => Json.fromJsonObject(JsonObject.singleton("default_emr_service_role", t.asJson)) case t: com.gilt.svc.sundial.v0.models.CustomEmrServiceRole => Json.fromJsonObject(JsonObject.singleton("custom_emr_service_role", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } implicit def decodeSvcSundialNotification: Decoder[Notification] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.Email]("email") orElse c.get[com.gilt.svc.sundial.v0.models.Pagerduty]("pagerduty") orElse Right(com.gilt.svc.sundial.v0.models.NotificationUndefinedType(c.value.toString)) } implicit def encodeSvcSundialNotification: Encoder[Notification] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.Email => Json.fromJsonObject(JsonObject.singleton("email", t.asJson)) case t: com.gilt.svc.sundial.v0.models.Pagerduty => Json.fromJsonObject(JsonObject.singleton("pagerduty", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } implicit def decodeSvcSundialProcessSchedule: Decoder[ProcessSchedule] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.CronSchedule]("cron_schedule") orElse c.get[com.gilt.svc.sundial.v0.models.ContinuousSchedule]("continuous_schedule") orElse Right(com.gilt.svc.sundial.v0.models.ProcessScheduleUndefinedType(c.value.toString)) } implicit def encodeSvcSundialProcessSchedule: Encoder[ProcessSchedule] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.CronSchedule => Json.fromJsonObject(JsonObject.singleton("cron_schedule", t.asJson)) case t: com.gilt.svc.sundial.v0.models.ContinuousSchedule => Json.fromJsonObject(JsonObject.singleton("continuous_schedule", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } implicit def decodeSvcSundialTaskExecutable: Decoder[TaskExecutable] = Decoder.instance { c => c.get[com.gilt.svc.sundial.v0.models.DockerImageCommand]("docker_image_command") orElse c.get[com.gilt.svc.sundial.v0.models.ShellScriptCommand]("shell_script_command") orElse c.get[com.gilt.svc.sundial.v0.models.BatchImageCommand]("batch_image_command") orElse c.get[com.gilt.svc.sundial.v0.models.EmrCommand]("emr_command") orElse Right(com.gilt.svc.sundial.v0.models.TaskExecutableUndefinedType(c.value.toString)) } implicit def encodeSvcSundialTaskExecutable: Encoder[TaskExecutable] = Encoder.instance { case t: com.gilt.svc.sundial.v0.models.DockerImageCommand => Json.fromJsonObject(JsonObject.singleton("docker_image_command", t.asJson)) case t: com.gilt.svc.sundial.v0.models.ShellScriptCommand => Json.fromJsonObject(JsonObject.singleton("shell_script_command", t.asJson)) case t: com.gilt.svc.sundial.v0.models.BatchImageCommand => Json.fromJsonObject(JsonObject.singleton("batch_image_command", t.asJson)) case t: com.gilt.svc.sundial.v0.models.EmrCommand => Json.fromJsonObject(JsonObject.singleton("emr_command", t.asJson)) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } } }