/** * 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_15 */ package com.gilt.svc.sundial.v0.models { /** * The EC2 market of the EC2 instances */ sealed trait AwsMarket extends _root_.scala.Product with _root_.scala.Serializable /** * Whether or not to create a new EMR cluster or re-use a pre-existing one */ sealed trait EmrCluster extends _root_.scala.Product with _root_.scala.Serializable /** * The EMR role to use on the EC2 instances */ sealed trait EmrJobFlowRole extends _root_.scala.Product with _root_.scala.Serializable /** * The EMR service role to use */ sealed trait EmrServiceRole extends _root_.scala.Product with _root_.scala.Serializable sealed trait Notification extends _root_.scala.Product with _root_.scala.Serializable /** * A specification for when a process should be run */ sealed trait ProcessSchedule extends _root_.scala.Product with _root_.scala.Serializable sealed trait TaskExecutable extends _root_.scala.Product with _root_.scala.Serializable /** * @param image Name of docker image including registry URL if needed * @param tag Tag on docker image * @param command Command to pass to Docker container * @param jobRoleArn ARN of an IAM role, see * http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html * @param environmentVariables environment variables to be passed to container * @param jobQueue Override default job queue, eg: for priority queue or GPU instances queue */ final case class BatchImageCommand( image: String, tag: String = "latest", command: Seq[String], memory: Int, vCpus: Int, jobRoleArn: _root_.scala.Option[String] = None, environmentVariables: Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable] = Nil, jobQueue: _root_.scala.Option[String] = None ) extends TaskExecutable /** * @param bufferSeconds The minimum amount of time (in seconds) that must pass between executions of the * process */ final case class ContinuousSchedule( bufferSeconds: _root_.scala.Option[Int] = None ) extends ProcessSchedule /** * See http://quartz-scheduler.org/api/2.2.0/org/quartz/CronExpression.html */ final case class CronSchedule( dayOfWeek: String, month: String, dayOfMonth: String, hours: String, minutes: String ) extends ProcessSchedule /** * Custom, preconfigured, EMR EC2 instance role */ final case class CustomEmrJobFlowRole( roleName: String ) extends EmrJobFlowRole /** * Custom, preconfigured, EMR Service role */ final case class CustomEmrServiceRole( roleName: String ) extends EmrServiceRole final case class DockerImageCommand( image: String, tag: String = "latest", command: Seq[String], memory: _root_.scala.Option[Int] = None, cpu: _root_.scala.Option[Int] = None, taskRoleArn: _root_.scala.Option[String] = None, logPaths: Seq[String] = Nil, environmentVariables: Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable] = Nil ) extends TaskExecutable /** * An email to send notifications to */ final case class Email( name: String, email: String, notifyWhen: com.gilt.svc.sundial.v0.models.NotificationOptions = com.gilt.svc.sundial.v0.models.NotificationOptions.OnStateChangeAndFailures ) extends Notification /** * @param emrCluster The EMR cluster on which to launch the job (aka step) * @param jobName NAme to be assigned to the Job * @param region the AWS Region * @param `class` The spark job's `Main.class` to run * @param s3JarPath the s3 path to the jar of the job to be run * @param sparkConf options that will be sent to spark as --conf key=value, e.g. `--conf * spark.driver.extraJavaOptions=-Denvironment=integration` * @param args command line arguments to be passe to the job's main class * @param s3LogDetails AWS EMR periodically (currently every 5 minutes) zips up all the logs and upload * them into S3. This does not work well with sundial's _live logs_. Make use of S3 * Logs to visualise in real time job's log on sundial's live logs panel * @param loadData will trigger a s3 dist cp job for every entry in this array, can be used to load * data from s3 into HDFS. **requires Hadoop** as application on the cluster * @param saveResults will trigger a s3 dist cp job for every entry in this array, can be used to save * data from HDFS to s3. **requires Hadoop** as application on the cluster */ final case class EmrCommand( emrCluster: com.gilt.svc.sundial.v0.models.EmrCluster, jobName: String, region: String = "us-east-1", `class`: String, s3JarPath: String, sparkConf: Seq[String], args: Seq[String], s3LogDetails: _root_.scala.Option[com.gilt.svc.sundial.v0.models.S3LogDetails] = None, loadData: _root_.scala.Option[Seq[com.gilt.svc.sundial.v0.models.S3Cp]] = None, saveResults: _root_.scala.Option[Seq[com.gilt.svc.sundial.v0.models.S3Cp]] = None ) extends TaskExecutable /** * Additional configuration for Master/Core/Task EMR instance Groups. * * @param ebsVolumeSize optional EBS volume in GB to attach to the emr instance, for simplicity only one * volume for the given size and type gp2 will be created. */ final case class EmrInstanceGroupDetails( emrInstanceType: String, instanceCount: Int, awsMarket: com.gilt.svc.sundial.v0.models.AwsMarket, ebsVolumeSize: _root_.scala.Option[Int] = None ) final case class EnvironmentVariable( variableName: String, value: String ) /** * Existing EMR cluster configuration object * * @param clusterId The EMR cluster id */ final case class ExistingEmrCluster( clusterId: String ) extends EmrCluster final case class Healthcheck( status: String ) /** * @param logEntryId Uniquely identifies the log message to prevent duplication */ final case class LogEntry( logEntryId: _root_.java.util.UUID, when: _root_.java.time.Instant, source: String, message: String ) /** * @param metadataEntryId Uniquely identifies the metadata entry to prevent duplication */ final case class MetadataEntry( metadataEntryId: _root_.java.util.UUID, when: _root_.java.time.Instant, key: String, value: String ) /** * New EMR cluster configuration object * * @param ec2Subnet To be set in case the EMR cannot be launched in the `default VPC` * @param emrServiceRole role to be assigned to the service, the default one should cover most of the * cases * @param emrJobFlowRole role to be assigned to the ec2 instances composing the EMR cluster. The default * one should cover most of the cases * @param visibleToAllUsers whether or not to show the new cluster in the list of clusters. For more details * see [emr * docs](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-emr-cluster.html#cfn-emr-cluster-visibletoallusers) */ final case class NewEmrCluster( name: String, releaseLabel: com.gilt.svc.sundial.v0.models.EmrReleaseLabel = com.gilt.svc.sundial.v0.models.EmrReleaseLabel.Emr5100, applications: Seq[com.gilt.svc.sundial.v0.models.EmrApplication], s3LogUri: String, masterInstance: com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails, coreInstance: _root_.scala.Option[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] = None, taskInstance: _root_.scala.Option[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] = None, ec2Subnet: _root_.scala.Option[String] = None, emrServiceRole: com.gilt.svc.sundial.v0.models.EmrServiceRole, emrJobFlowRole: com.gilt.svc.sundial.v0.models.EmrJobFlowRole, visibleToAllUsers: Boolean = false ) extends EmrCluster /** * Pager Duty integration */ final case class Pagerduty( serviceKey: String, numConsecutiveFailures: Int = 1, apiUrl: String = "https://events.pagerduty.com" ) extends Notification final case class Process( processId: _root_.java.util.UUID, processDefinitionName: String, startTime: _root_.java.time.Instant, status: com.gilt.svc.sundial.v0.models.ProcessStatus, task: Seq[com.gilt.svc.sundial.v0.models.Task] ) /** * A grouping of related tasks that are run as a single unit on the same schedule * * @param paused If true, ignore schedule and only start process if triggered manually * @param schedule The schedule that the process runs on; if not specified, the process will only * run when triggered manually */ final case class ProcessDefinition( processDefinitionName: String, paused: _root_.scala.Option[Boolean] = None, processDescription: _root_.scala.Option[String] = None, schedule: _root_.scala.Option[com.gilt.svc.sundial.v0.models.ProcessSchedule] = None, taskDefinitions: Seq[com.gilt.svc.sundial.v0.models.TaskDefinition], overlapAction: com.gilt.svc.sundial.v0.models.ProcessOverlapAction = com.gilt.svc.sundial.v0.models.ProcessOverlapAction.Wait, notifications: _root_.scala.Option[Seq[com.gilt.svc.sundial.v0.models.Notification]] = None ) /** * Wrapper of the S3DistCp spark job for more info visit the aws * [s3-dist-cp](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/UsingEMR_s3distcp.html) * page * * @param source Source folder or file to copy. It can be either a s3 or HDFS location * @param destination Source folder or file to copy. It can be either a s3 or HDFS location */ final case class S3Cp( source: String, destination: String ) final case class S3LogDetails( logGroupName: String, logStreamName: String ) final case class ShellScriptCommand( script: String, environmentVariables: _root_.scala.Option[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]] = None ) extends TaskExecutable /** * the maximum spot bid price */ final case class Spot( bidPrice: BigDecimal ) extends AwsMarket /** * @param executionState Internal bookkeeping metadata used for task scheduling (e.g. ECS task ID and * cluster name) */ final case class Task( taskId: _root_.java.util.UUID, processId: _root_.java.util.UUID, processDefinitionName: String, taskDefinitionName: String, startTime: _root_.java.time.Instant, endTime: _root_.scala.Option[_root_.java.time.Instant] = None, previousAttemptCount: Int, logEntries: Seq[com.gilt.svc.sundial.v0.models.LogEntry], metadataEntries: Seq[com.gilt.svc.sundial.v0.models.MetadataEntry], executionState: _root_.scala.Option[Seq[com.gilt.svc.sundial.v0.models.MetadataEntry]] = None, status: com.gilt.svc.sundial.v0.models.TaskStatus ) /** * An individual task that runs as part of a process * * @param taskDefinitionName The canonical name for this task used by other tasks to identify this task * @param dependencies The tasks that must have completed prior to this one beginning * @param maxRuntimeSeconds The execution time (for a single attempt) after which the system will kill the * task * @param requireExplicitSuccess If true, the task must explicitly update its status with Sundial in order to * succeed. */ final case class TaskDefinition( taskDefinitionName: String, dependencies: Seq[com.gilt.svc.sundial.v0.models.TaskDependency], executable: com.gilt.svc.sundial.v0.models.TaskExecutable, maxAttempts: Int, maxRuntimeSeconds: _root_.scala.Option[Int] = None, backoffBaseSeconds: Int, backoffExponent: Double = 1.0, requireExplicitSuccess: Boolean = false ) final case class TaskDependency( taskDefinitionName: String, successRequired: Boolean = true ) /** * Provides future compatibility in clients - in the future, when a type is added * to the union AwsMarket, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class AwsMarketUndefinedType( description: String ) extends AwsMarket /** * Provides future compatibility in clients - in the future, when a type is added * to the union EmrCluster, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class EmrClusterUndefinedType( description: String ) extends EmrCluster /** * Provides future compatibility in clients - in the future, when a type is added * to the union EmrJobFlowRole, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class EmrJobFlowRoleUndefinedType( description: String ) extends EmrJobFlowRole /** * Provides future compatibility in clients - in the future, when a type is added * to the union EmrServiceRole, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class EmrServiceRoleUndefinedType( description: String ) extends EmrServiceRole /** * Provides future compatibility in clients - in the future, when a type is added * to the union Notification, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class NotificationUndefinedType( description: String ) extends Notification /** * Provides future compatibility in clients - in the future, when a type is added * to the union ProcessSchedule, it will need to be handled in the client code. * This implementation will deserialize these future types as an instance of this * class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class ProcessScheduleUndefinedType( description: String ) extends ProcessSchedule /** * Provides future compatibility in clients - in the future, when a type is added * to the union TaskExecutable, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class TaskExecutableUndefinedType( description: String ) extends TaskExecutable /** * The default EMR EC2 Instance role */ sealed trait DefaultEmrJobFlowRole extends EmrJobFlowRole object DefaultEmrJobFlowRole { case object DefaultEmrJobFlowRole extends DefaultEmrJobFlowRole { override def toString = "EMR_EC2_DefaultRole" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends DefaultEmrJobFlowRole /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[DefaultEmrJobFlowRole] = scala.List(DefaultEmrJobFlowRole) private val byName: Map[String, DefaultEmrJobFlowRole] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): DefaultEmrJobFlowRole = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[DefaultEmrJobFlowRole] = byName.get(value.toLowerCase) } /** * The default EMR Service role */ sealed trait DefaultEmrServiceRole extends EmrServiceRole object DefaultEmrServiceRole { case object DefaultEmrServiceRole extends DefaultEmrServiceRole { override def toString = "EMR_DefaultRole" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends DefaultEmrServiceRole /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[DefaultEmrServiceRole] = scala.List(DefaultEmrServiceRole) private val byName: Map[String, DefaultEmrServiceRole] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): DefaultEmrServiceRole = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[DefaultEmrServiceRole] = byName.get(value.toLowerCase) } /** * List of applications to install in the EMR cluster */ sealed trait EmrApplication extends _root_.scala.Product with _root_.scala.Serializable object EmrApplication { case object Hadoop extends EmrApplication { override def toString = "Hadoop" } case object Hive extends EmrApplication { override def toString = "Hive" } case object Mahout extends EmrApplication { override def toString = "Mahout" } case object Pig extends EmrApplication { override def toString = "Pig" } case object Spark extends EmrApplication { override def toString = "Spark" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends EmrApplication /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[EmrApplication] = scala.List(Hadoop, Hive, Mahout, Pig, Spark) private val byName: Map[String, EmrApplication] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): EmrApplication = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[EmrApplication] = byName.get(value.toLowerCase) } /** * Version (aka label in AWS-EMR) of the EMR stack to create. */ sealed trait EmrReleaseLabel extends _root_.scala.Product with _root_.scala.Serializable object EmrReleaseLabel { case object Emr5140 extends EmrReleaseLabel { override def toString = "emr-5.14.0" } case object Emr5130 extends EmrReleaseLabel { override def toString = "emr-5.13.0" } case object Emr5121 extends EmrReleaseLabel { override def toString = "emr-5.12.1" } case object Emr5120 extends EmrReleaseLabel { override def toString = "emr-5.12.0" } case object Emr5111 extends EmrReleaseLabel { override def toString = "emr-5.11.1" } case object Emr5110 extends EmrReleaseLabel { override def toString = "emr-5.11.0" } case object Emr5100 extends EmrReleaseLabel { override def toString = "emr-5.10.0" } case object Emr590 extends EmrReleaseLabel { override def toString = "emr-5.9.0" } case object Emr492 extends EmrReleaseLabel { override def toString = "emr-4.9.2" } case object Emr491 extends EmrReleaseLabel { override def toString = "emr-4.9.1" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends EmrReleaseLabel /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[EmrReleaseLabel] = scala.List(Emr5140, Emr5130, Emr5121, Emr5120, Emr5111, Emr5110, Emr5100, Emr590, Emr492, Emr491) private val byName: Map[String, EmrReleaseLabel] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): EmrReleaseLabel = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[EmrReleaseLabel] = byName.get(value.toLowerCase) } sealed trait NotificationOptions extends _root_.scala.Product with _root_.scala.Serializable object NotificationOptions { /** * Always notify when a process completes */ case object Always extends NotificationOptions { override def toString = "always" } /** * Notify when a process fails */ case object OnFailure extends NotificationOptions { override def toString = "on_failure" } /** * Notify when a process goes from succeeding to failing and vica versa */ case object OnStateChange extends NotificationOptions { override def toString = "on_state_change" } /** * Notify when going from failing to succeeded and on each failure */ case object OnStateChangeAndFailures extends NotificationOptions { override def toString = "on_state_change_and_failures" } /** * Never notify */ case object Never extends NotificationOptions { override def toString = "never" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends NotificationOptions /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[NotificationOptions] = scala.List(Always, OnFailure, OnStateChange, OnStateChangeAndFailures, Never) private val byName: Map[String, NotificationOptions] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): NotificationOptions = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[NotificationOptions] = byName.get(value.toLowerCase) } /** * The onDemand type of Market Type */ sealed trait OnDemand extends AwsMarket object OnDemand { case object OnDemand extends OnDemand { override def toString = "on_demand" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends OnDemand /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[OnDemand] = scala.List(OnDemand) private val byName: Map[String, OnDemand] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): OnDemand = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[OnDemand] = byName.get(value.toLowerCase) } sealed trait ProcessOverlapAction extends _root_.scala.Product with _root_.scala.Serializable object ProcessOverlapAction { /** * The process should wait until the currently running instance finishes */ case object Wait extends ProcessOverlapAction { override def toString = "wait" } /** * The currently running process should be killed */ case object Terminate extends ProcessOverlapAction { override def toString = "terminate" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends ProcessOverlapAction /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[ProcessOverlapAction] = scala.List(Wait, Terminate) private val byName: Map[String, ProcessOverlapAction] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): ProcessOverlapAction = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[ProcessOverlapAction] = byName.get(value.toLowerCase) } sealed trait ProcessStatus extends _root_.scala.Product with _root_.scala.Serializable object ProcessStatus { /** * The process has tasks currently executing */ case object Running extends ProcessStatus { override def toString = "running" } /** * All of the process's tasks succeeded on its last run */ case object Succeeded extends ProcessStatus { override def toString = "succeeded" } /** * At least one of the process's tasks failed on its last run */ case object Failed extends ProcessStatus { override def toString = "failed" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends ProcessStatus /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[ProcessStatus] = scala.List(Running, Succeeded, Failed) private val byName: Map[String, ProcessStatus] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): ProcessStatus = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[ProcessStatus] = byName.get(value.toLowerCase) } sealed trait TaskStatus extends _root_.scala.Product with _root_.scala.Serializable object TaskStatus { /** * The task has been submitted */ case object Submitted extends TaskStatus { override def toString = "submitted" } case object Runnable extends TaskStatus { override def toString = "runnable" } case object Starting extends TaskStatus { override def toString = "starting" } /** * The task is waiting on compute resources */ case object Pending extends TaskStatus { override def toString = "pending" } /** * The task is currently executing or awaiting backoff */ case object Running extends TaskStatus { override def toString = "running" } /** * The task has irrevocably failed */ case object Failed extends TaskStatus { override def toString = "failed" } /** * The task has succeeded without serious errors */ case object Succeeded extends TaskStatus { override def toString = "succeeded" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends TaskStatus /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[TaskStatus] = scala.List(Submitted, Runnable, Starting, Pending, Running, Failed, Succeeded) private val byName: Map[String, TaskStatus] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): TaskStatus = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[TaskStatus] = byName.get(value.toLowerCase) } } 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") } } }