/** * 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/play_2_x_scala_3_json */ 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_.org.joda.time.DateTime, 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_.org.joda.time.DateTime, 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_.org.joda.time.DateTime, 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_.org.joda.time.DateTime, endTime: _root_.scala.Option[_root_.org.joda.time.DateTime] = 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 play.api.libs.json.__ import play.api.libs.json.JsString import play.api.libs.json.Writes import play.api.libs.functional.syntax._ import com.gilt.svc.sundial.v0.models.json._ private[v0] implicit val jsonReadsUUID: play.api.libs.json.Reads[_root_.java.util.UUID] = __.read[String].map { str => _root_.java.util.UUID.fromString(str) } private[v0] implicit val jsonWritesUUID: play.api.libs.json.Writes[_root_.java.util.UUID] = (x: _root_.java.util.UUID) => play.api.libs.json.JsString(x.toString) private[v0] implicit val jsonReadsJodaDateTime: play.api.libs.json.Reads[_root_.org.joda.time.DateTime] = __.read[String].map { str => _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(str) } private[v0] implicit val jsonWritesJodaDateTime: play.api.libs.json.Writes[_root_.org.joda.time.DateTime] = (x: _root_.org.joda.time.DateTime) => { play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(x)) } private[v0] implicit val jsonReadsJodaLocalDate: play.api.libs.json.Reads[_root_.org.joda.time.LocalDate] = __.read[String].map { str => _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(str) } private[v0] implicit val jsonWritesJodaLocalDate: play.api.libs.json.Writes[_root_.org.joda.time.LocalDate] = (x: _root_.org.joda.time.LocalDate) => { play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x)) } implicit val jsonReadsSvcSundialDefaultEmrJobFlowRole: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole(v)) case _: play.api.libs.json.JsError => (js \ "default_emr_job_flow_role").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialDefaultEmrJobFlowRole(obj: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole) = { play.api.libs.json.JsString(obj.toString) } def jsObjectDefaultEmrJobFlowRole(obj: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialDefaultEmrJobFlowRole: play.api.libs.json.Writes[DefaultEmrJobFlowRole] = { (obj: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialDefaultEmrJobFlowRole(obj) } } implicit val jsonReadsSvcSundialDefaultEmrServiceRole: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole(v)) case _: play.api.libs.json.JsError => (js \ "default_emr_service_role").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialDefaultEmrServiceRole(obj: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole) = { play.api.libs.json.JsString(obj.toString) } def jsObjectDefaultEmrServiceRole(obj: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialDefaultEmrServiceRole: play.api.libs.json.Writes[DefaultEmrServiceRole] = { (obj: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialDefaultEmrServiceRole(obj) } } implicit val jsonReadsSvcSundialEmrApplication: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EmrApplication] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EmrApplication] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.EmrApplication] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.EmrApplication(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.EmrApplication(v)) case _: play.api.libs.json.JsError => (js \ "emr_application").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.EmrApplication(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialEmrApplication(obj: com.gilt.svc.sundial.v0.models.EmrApplication) = { play.api.libs.json.JsString(obj.toString) } def jsObjectEmrApplication(obj: com.gilt.svc.sundial.v0.models.EmrApplication) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialEmrApplication: play.api.libs.json.Writes[EmrApplication] = { (obj: com.gilt.svc.sundial.v0.models.EmrApplication) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialEmrApplication(obj) } } implicit val jsonReadsSvcSundialEmrReleaseLabel: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.EmrReleaseLabel(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.EmrReleaseLabel(v)) case _: play.api.libs.json.JsError => (js \ "emr_release_label").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.EmrReleaseLabel(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialEmrReleaseLabel(obj: com.gilt.svc.sundial.v0.models.EmrReleaseLabel) = { play.api.libs.json.JsString(obj.toString) } def jsObjectEmrReleaseLabel(obj: com.gilt.svc.sundial.v0.models.EmrReleaseLabel) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialEmrReleaseLabel: play.api.libs.json.Writes[EmrReleaseLabel] = { (obj: com.gilt.svc.sundial.v0.models.EmrReleaseLabel) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialEmrReleaseLabel(obj) } } implicit val jsonReadsSvcSundialNotificationOptions: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.NotificationOptions] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.NotificationOptions] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.NotificationOptions] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.NotificationOptions(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.NotificationOptions(v)) case _: play.api.libs.json.JsError => (js \ "notification_options").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.NotificationOptions(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialNotificationOptions(obj: com.gilt.svc.sundial.v0.models.NotificationOptions) = { play.api.libs.json.JsString(obj.toString) } def jsObjectNotificationOptions(obj: com.gilt.svc.sundial.v0.models.NotificationOptions) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialNotificationOptions: play.api.libs.json.Writes[NotificationOptions] = { (obj: com.gilt.svc.sundial.v0.models.NotificationOptions) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialNotificationOptions(obj) } } implicit val jsonReadsSvcSundialOnDemand: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.OnDemand] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.OnDemand] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.OnDemand] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.OnDemand(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.OnDemand(v)) case _: play.api.libs.json.JsError => (js \ "on_demand").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.OnDemand(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialOnDemand(obj: com.gilt.svc.sundial.v0.models.OnDemand) = { play.api.libs.json.JsString(obj.toString) } def jsObjectOnDemand(obj: com.gilt.svc.sundial.v0.models.OnDemand) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialOnDemand: play.api.libs.json.Writes[OnDemand] = { (obj: com.gilt.svc.sundial.v0.models.OnDemand) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialOnDemand(obj) } } implicit val jsonReadsSvcSundialProcessOverlapAction: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.ProcessOverlapAction(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.ProcessOverlapAction(v)) case _: play.api.libs.json.JsError => (js \ "process_overlap_action").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.ProcessOverlapAction(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialProcessOverlapAction(obj: com.gilt.svc.sundial.v0.models.ProcessOverlapAction) = { play.api.libs.json.JsString(obj.toString) } def jsObjectProcessOverlapAction(obj: com.gilt.svc.sundial.v0.models.ProcessOverlapAction) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialProcessOverlapAction: play.api.libs.json.Writes[ProcessOverlapAction] = { (obj: com.gilt.svc.sundial.v0.models.ProcessOverlapAction) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialProcessOverlapAction(obj) } } implicit val jsonReadsSvcSundialProcessStatus: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ProcessStatus] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ProcessStatus] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.ProcessStatus] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.ProcessStatus(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.ProcessStatus(v)) case _: play.api.libs.json.JsError => (js \ "process_status").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.ProcessStatus(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialProcessStatus(obj: com.gilt.svc.sundial.v0.models.ProcessStatus) = { play.api.libs.json.JsString(obj.toString) } def jsObjectProcessStatus(obj: com.gilt.svc.sundial.v0.models.ProcessStatus) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialProcessStatus: play.api.libs.json.Writes[ProcessStatus] = { (obj: com.gilt.svc.sundial.v0.models.ProcessStatus) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialProcessStatus(obj) } } implicit val jsonReadsSvcSundialTaskStatus: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.TaskStatus] = new play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.TaskStatus] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.TaskStatus] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.TaskStatus(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.TaskStatus(v)) case _: play.api.libs.json.JsError => (js \ "task_status").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(com.gilt.svc.sundial.v0.models.TaskStatus(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesSvcSundialTaskStatus(obj: com.gilt.svc.sundial.v0.models.TaskStatus) = { play.api.libs.json.JsString(obj.toString) } def jsObjectTaskStatus(obj: com.gilt.svc.sundial.v0.models.TaskStatus) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesSvcSundialTaskStatus: play.api.libs.json.Writes[TaskStatus] = { (obj: com.gilt.svc.sundial.v0.models.TaskStatus) => { com.gilt.svc.sundial.v0.models.json.jsonWritesSvcSundialTaskStatus(obj) } } def jsonReadsSvcSundialBatchImageCommand: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.BatchImageCommand] = { for { image <- (__ \ "image").read[String] tag <- (__ \ "tag").read[String] command <- (__ \ "command").read[Seq[String]] memory <- (__ \ "memory").read[Int] vCpus <- (__ \ "vCpus").read[Int] jobRoleArn <- (__ \ "job_role_arn").readNullable[String] environmentVariables <- (__ \ "environment_variables").read[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]] jobQueue <- (__ \ "job_queue").readNullable[String] } yield BatchImageCommand(image, tag, command, memory, vCpus, jobRoleArn, environmentVariables, jobQueue) } def jsObjectBatchImageCommand(obj: com.gilt.svc.sundial.v0.models.BatchImageCommand): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "image" -> play.api.libs.json.JsString(obj.image), "tag" -> play.api.libs.json.JsString(obj.tag), "command" -> play.api.libs.json.Json.toJson(obj.command), "memory" -> play.api.libs.json.JsNumber(obj.memory), "vCpus" -> play.api.libs.json.JsNumber(obj.vCpus), "environment_variables" -> play.api.libs.json.Json.toJson(obj.environmentVariables) ) ++ (obj.jobRoleArn match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("job_role_arn" -> play.api.libs.json.JsString(x)) }) ++ (obj.jobQueue match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("job_queue" -> play.api.libs.json.JsString(x)) }) } def jsonWritesSvcSundialBatchImageCommand: play.api.libs.json.Writes[BatchImageCommand] = { (obj: com.gilt.svc.sundial.v0.models.BatchImageCommand) => { com.gilt.svc.sundial.v0.models.json.jsObjectBatchImageCommand(obj) } } def jsonReadsSvcSundialContinuousSchedule: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ContinuousSchedule] = { (__ \ "buffer_seconds").readNullable[Int].map { x => ContinuousSchedule(bufferSeconds = x) } } def jsObjectContinuousSchedule(obj: com.gilt.svc.sundial.v0.models.ContinuousSchedule): play.api.libs.json.JsObject = { (obj.bufferSeconds match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("buffer_seconds" -> play.api.libs.json.JsNumber(x)) }) } def jsonWritesSvcSundialContinuousSchedule: play.api.libs.json.Writes[ContinuousSchedule] = { (obj: com.gilt.svc.sundial.v0.models.ContinuousSchedule) => { com.gilt.svc.sundial.v0.models.json.jsObjectContinuousSchedule(obj) } } def jsonReadsSvcSundialCronSchedule: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.CronSchedule] = { for { dayOfWeek <- (__ \ "day_of_week").read[String] month <- (__ \ "month").read[String] dayOfMonth <- (__ \ "day_of_month").read[String] hours <- (__ \ "hours").read[String] minutes <- (__ \ "minutes").read[String] } yield CronSchedule(dayOfWeek, month, dayOfMonth, hours, minutes) } def jsObjectCronSchedule(obj: com.gilt.svc.sundial.v0.models.CronSchedule): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "day_of_week" -> play.api.libs.json.JsString(obj.dayOfWeek), "month" -> play.api.libs.json.JsString(obj.month), "day_of_month" -> play.api.libs.json.JsString(obj.dayOfMonth), "hours" -> play.api.libs.json.JsString(obj.hours), "minutes" -> play.api.libs.json.JsString(obj.minutes) ) } def jsonWritesSvcSundialCronSchedule: play.api.libs.json.Writes[CronSchedule] = { (obj: com.gilt.svc.sundial.v0.models.CronSchedule) => { com.gilt.svc.sundial.v0.models.json.jsObjectCronSchedule(obj) } } def jsonReadsSvcSundialCustomEmrJobFlowRole: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.CustomEmrJobFlowRole] = { (__ \ "role_name").read[String].map { x => CustomEmrJobFlowRole(roleName = x) } } def jsObjectCustomEmrJobFlowRole(obj: com.gilt.svc.sundial.v0.models.CustomEmrJobFlowRole): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "role_name" -> play.api.libs.json.JsString(obj.roleName) ) } def jsonWritesSvcSundialCustomEmrJobFlowRole: play.api.libs.json.Writes[CustomEmrJobFlowRole] = { (obj: com.gilt.svc.sundial.v0.models.CustomEmrJobFlowRole) => { com.gilt.svc.sundial.v0.models.json.jsObjectCustomEmrJobFlowRole(obj) } } def jsonReadsSvcSundialCustomEmrServiceRole: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.CustomEmrServiceRole] = { (__ \ "role_name").read[String].map { x => CustomEmrServiceRole(roleName = x) } } def jsObjectCustomEmrServiceRole(obj: com.gilt.svc.sundial.v0.models.CustomEmrServiceRole): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "role_name" -> play.api.libs.json.JsString(obj.roleName) ) } def jsonWritesSvcSundialCustomEmrServiceRole: play.api.libs.json.Writes[CustomEmrServiceRole] = { (obj: com.gilt.svc.sundial.v0.models.CustomEmrServiceRole) => { com.gilt.svc.sundial.v0.models.json.jsObjectCustomEmrServiceRole(obj) } } def jsonReadsSvcSundialDockerImageCommand: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.DockerImageCommand] = { for { image <- (__ \ "image").read[String] tag <- (__ \ "tag").read[String] command <- (__ \ "command").read[Seq[String]] memory <- (__ \ "memory").readNullable[Int] cpu <- (__ \ "cpu").readNullable[Int] taskRoleArn <- (__ \ "taskRoleArn").readNullable[String] logPaths <- (__ \ "log_paths").read[Seq[String]] environmentVariables <- (__ \ "environment_variables").read[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]] } yield DockerImageCommand(image, tag, command, memory, cpu, taskRoleArn, logPaths, environmentVariables) } def jsObjectDockerImageCommand(obj: com.gilt.svc.sundial.v0.models.DockerImageCommand): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "image" -> play.api.libs.json.JsString(obj.image), "tag" -> play.api.libs.json.JsString(obj.tag), "command" -> play.api.libs.json.Json.toJson(obj.command), "log_paths" -> play.api.libs.json.Json.toJson(obj.logPaths), "environment_variables" -> play.api.libs.json.Json.toJson(obj.environmentVariables) ) ++ (obj.memory match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("memory" -> play.api.libs.json.JsNumber(x)) }) ++ (obj.cpu match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("cpu" -> play.api.libs.json.JsNumber(x)) }) ++ (obj.taskRoleArn match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("taskRoleArn" -> play.api.libs.json.JsString(x)) }) } def jsonWritesSvcSundialDockerImageCommand: play.api.libs.json.Writes[DockerImageCommand] = { (obj: com.gilt.svc.sundial.v0.models.DockerImageCommand) => { com.gilt.svc.sundial.v0.models.json.jsObjectDockerImageCommand(obj) } } def jsonReadsSvcSundialEmail: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.Email] = { for { name <- (__ \ "name").read[String] email <- (__ \ "email").read[String] notifyWhen <- (__ \ "notify_when").read[com.gilt.svc.sundial.v0.models.NotificationOptions] } yield Email(name, email, notifyWhen) } def jsObjectEmail(obj: com.gilt.svc.sundial.v0.models.Email): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "name" -> play.api.libs.json.JsString(obj.name), "email" -> play.api.libs.json.JsString(obj.email), "notify_when" -> play.api.libs.json.JsString(obj.notifyWhen.toString) ) } def jsonWritesSvcSundialEmail: play.api.libs.json.Writes[Email] = { (obj: com.gilt.svc.sundial.v0.models.Email) => { com.gilt.svc.sundial.v0.models.json.jsObjectEmail(obj) } } def jsonReadsSvcSundialEmrCommand: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EmrCommand] = { for { emrCluster <- (__ \ "emr_cluster").read[com.gilt.svc.sundial.v0.models.EmrCluster] jobName <- (__ \ "job_name").read[String] region <- (__ \ "region").read[String] `class` <- (__ \ "class").read[String] s3JarPath <- (__ \ "s3_jar_path").read[String] sparkConf <- (__ \ "spark_conf").read[Seq[String]] args <- (__ \ "args").read[Seq[String]] s3LogDetails <- (__ \ "s3_log_details").readNullable[com.gilt.svc.sundial.v0.models.S3LogDetails] loadData <- (__ \ "load_data").readNullable[Seq[com.gilt.svc.sundial.v0.models.S3Cp]] saveResults <- (__ \ "save_results").readNullable[Seq[com.gilt.svc.sundial.v0.models.S3Cp]] } yield EmrCommand(emrCluster, jobName, region, `class`, s3JarPath, sparkConf, args, s3LogDetails, loadData, saveResults) } def jsObjectEmrCommand(obj: com.gilt.svc.sundial.v0.models.EmrCommand): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "emr_cluster" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrCluster(obj.emrCluster), "job_name" -> play.api.libs.json.JsString(obj.jobName), "region" -> play.api.libs.json.JsString(obj.region), "class" -> play.api.libs.json.JsString(obj.`class`), "s3_jar_path" -> play.api.libs.json.JsString(obj.s3JarPath), "spark_conf" -> play.api.libs.json.Json.toJson(obj.sparkConf), "args" -> play.api.libs.json.Json.toJson(obj.args) ) ++ (obj.s3LogDetails match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("s3_log_details" -> com.gilt.svc.sundial.v0.models.json.jsObjectS3LogDetails(x)) }) ++ (obj.loadData match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("load_data" -> play.api.libs.json.Json.toJson(x)) }) ++ (obj.saveResults match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("save_results" -> play.api.libs.json.Json.toJson(x)) }) } def jsonWritesSvcSundialEmrCommand: play.api.libs.json.Writes[EmrCommand] = { (obj: com.gilt.svc.sundial.v0.models.EmrCommand) => { com.gilt.svc.sundial.v0.models.json.jsObjectEmrCommand(obj) } } implicit def jsonReadsSvcSundialEmrInstanceGroupDetails: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] = { for { emrInstanceType <- (__ \ "emr_instance_type").read[String] instanceCount <- (__ \ "instance_count").read[Int] awsMarket <- (__ \ "aws_market").read[com.gilt.svc.sundial.v0.models.AwsMarket] ebsVolumeSize <- (__ \ "ebs_volume_size").readNullable[Int] } yield EmrInstanceGroupDetails(emrInstanceType, instanceCount, awsMarket, ebsVolumeSize) } def jsObjectEmrInstanceGroupDetails(obj: com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "emr_instance_type" -> play.api.libs.json.JsString(obj.emrInstanceType), "instance_count" -> play.api.libs.json.JsNumber(obj.instanceCount), "aws_market" -> com.gilt.svc.sundial.v0.models.json.jsObjectAwsMarket(obj.awsMarket) ) ++ (obj.ebsVolumeSize match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("ebs_volume_size" -> play.api.libs.json.JsNumber(x)) }) } implicit def jsonWritesSvcSundialEmrInstanceGroupDetails: play.api.libs.json.Writes[EmrInstanceGroupDetails] = { (obj: com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails) => { com.gilt.svc.sundial.v0.models.json.jsObjectEmrInstanceGroupDetails(obj) } } implicit def jsonReadsSvcSundialEnvironmentVariable: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.EnvironmentVariable] = { for { variableName <- (__ \ "variable_name").read[String] value <- (__ \ "value").read[String] } yield EnvironmentVariable(variableName, value) } def jsObjectEnvironmentVariable(obj: com.gilt.svc.sundial.v0.models.EnvironmentVariable): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "variable_name" -> play.api.libs.json.JsString(obj.variableName), "value" -> play.api.libs.json.JsString(obj.value) ) } implicit def jsonWritesSvcSundialEnvironmentVariable: play.api.libs.json.Writes[EnvironmentVariable] = { (obj: com.gilt.svc.sundial.v0.models.EnvironmentVariable) => { com.gilt.svc.sundial.v0.models.json.jsObjectEnvironmentVariable(obj) } } def jsonReadsSvcSundialExistingEmrCluster: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ExistingEmrCluster] = { (__ \ "cluster_id").read[String].map { x => ExistingEmrCluster(clusterId = x) } } def jsObjectExistingEmrCluster(obj: com.gilt.svc.sundial.v0.models.ExistingEmrCluster): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "cluster_id" -> play.api.libs.json.JsString(obj.clusterId) ) } def jsonWritesSvcSundialExistingEmrCluster: play.api.libs.json.Writes[ExistingEmrCluster] = { (obj: com.gilt.svc.sundial.v0.models.ExistingEmrCluster) => { com.gilt.svc.sundial.v0.models.json.jsObjectExistingEmrCluster(obj) } } implicit def jsonReadsSvcSundialHealthcheck: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.Healthcheck] = { (__ \ "status").read[String].map { x => Healthcheck(status = x) } } def jsObjectHealthcheck(obj: com.gilt.svc.sundial.v0.models.Healthcheck): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "status" -> play.api.libs.json.JsString(obj.status) ) } implicit def jsonWritesSvcSundialHealthcheck: play.api.libs.json.Writes[Healthcheck] = { (obj: com.gilt.svc.sundial.v0.models.Healthcheck) => { com.gilt.svc.sundial.v0.models.json.jsObjectHealthcheck(obj) } } implicit def jsonReadsSvcSundialLogEntry: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.LogEntry] = { for { logEntryId <- (__ \ "log_entry_id").read[_root_.java.util.UUID] when <- (__ \ "when").read[_root_.org.joda.time.DateTime] source <- (__ \ "source").read[String] message <- (__ \ "message").read[String] } yield LogEntry(logEntryId, when, source, message) } def jsObjectLogEntry(obj: com.gilt.svc.sundial.v0.models.LogEntry): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "log_entry_id" -> play.api.libs.json.JsString(obj.logEntryId.toString), "when" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(obj.when)), "source" -> play.api.libs.json.JsString(obj.source), "message" -> play.api.libs.json.JsString(obj.message) ) } implicit def jsonWritesSvcSundialLogEntry: play.api.libs.json.Writes[LogEntry] = { (obj: com.gilt.svc.sundial.v0.models.LogEntry) => { com.gilt.svc.sundial.v0.models.json.jsObjectLogEntry(obj) } } implicit def jsonReadsSvcSundialMetadataEntry: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.MetadataEntry] = { for { metadataEntryId <- (__ \ "metadata_entry_id").read[_root_.java.util.UUID] when <- (__ \ "when").read[_root_.org.joda.time.DateTime] key <- (__ \ "key").read[String] value <- (__ \ "value").read[String] } yield MetadataEntry(metadataEntryId, when, key, value) } def jsObjectMetadataEntry(obj: com.gilt.svc.sundial.v0.models.MetadataEntry): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "metadata_entry_id" -> play.api.libs.json.JsString(obj.metadataEntryId.toString), "when" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(obj.when)), "key" -> play.api.libs.json.JsString(obj.key), "value" -> play.api.libs.json.JsString(obj.value) ) } implicit def jsonWritesSvcSundialMetadataEntry: play.api.libs.json.Writes[MetadataEntry] = { (obj: com.gilt.svc.sundial.v0.models.MetadataEntry) => { com.gilt.svc.sundial.v0.models.json.jsObjectMetadataEntry(obj) } } def jsonReadsSvcSundialNewEmrCluster: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.NewEmrCluster] = { for { name <- (__ \ "name").read[String] releaseLabel <- (__ \ "release_label").read[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] applications <- (__ \ "applications").read[Seq[com.gilt.svc.sundial.v0.models.EmrApplication]] s3LogUri <- (__ \ "s3_log_uri").read[String] masterInstance <- (__ \ "master_instance").read[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] coreInstance <- (__ \ "core_instance").readNullable[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] taskInstance <- (__ \ "task_instance").readNullable[com.gilt.svc.sundial.v0.models.EmrInstanceGroupDetails] ec2Subnet <- (__ \ "ec2_subnet").readNullable[String] emrServiceRole <- (__ \ "emr_service_role").read[com.gilt.svc.sundial.v0.models.EmrServiceRole] emrJobFlowRole <- (__ \ "emr_job_flow_role").read[com.gilt.svc.sundial.v0.models.EmrJobFlowRole] visibleToAllUsers <- (__ \ "visible_to_all_users").read[Boolean] } yield NewEmrCluster(name, releaseLabel, applications, s3LogUri, masterInstance, coreInstance, taskInstance, ec2Subnet, emrServiceRole, emrJobFlowRole, visibleToAllUsers) } def jsObjectNewEmrCluster(obj: com.gilt.svc.sundial.v0.models.NewEmrCluster): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "name" -> play.api.libs.json.JsString(obj.name), "release_label" -> play.api.libs.json.JsString(obj.releaseLabel.toString), "applications" -> play.api.libs.json.Json.toJson(obj.applications), "s3_log_uri" -> play.api.libs.json.JsString(obj.s3LogUri), "master_instance" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrInstanceGroupDetails(obj.masterInstance), "emr_service_role" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrServiceRole(obj.emrServiceRole), "emr_job_flow_role" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrJobFlowRole(obj.emrJobFlowRole), "visible_to_all_users" -> play.api.libs.json.JsBoolean(obj.visibleToAllUsers) ) ++ (obj.coreInstance match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("core_instance" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrInstanceGroupDetails(x)) }) ++ (obj.taskInstance match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("task_instance" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrInstanceGroupDetails(x)) }) ++ (obj.ec2Subnet match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("ec2_subnet" -> play.api.libs.json.JsString(x)) }) } def jsonWritesSvcSundialNewEmrCluster: play.api.libs.json.Writes[NewEmrCluster] = { (obj: com.gilt.svc.sundial.v0.models.NewEmrCluster) => { com.gilt.svc.sundial.v0.models.json.jsObjectNewEmrCluster(obj) } } def jsonReadsSvcSundialPagerduty: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.Pagerduty] = { for { serviceKey <- (__ \ "service_key").read[String] numConsecutiveFailures <- (__ \ "num_consecutive_failures").read[Int] apiUrl <- (__ \ "api_url").read[String] } yield Pagerduty(serviceKey, numConsecutiveFailures, apiUrl) } def jsObjectPagerduty(obj: com.gilt.svc.sundial.v0.models.Pagerduty): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "service_key" -> play.api.libs.json.JsString(obj.serviceKey), "num_consecutive_failures" -> play.api.libs.json.JsNumber(obj.numConsecutiveFailures), "api_url" -> play.api.libs.json.JsString(obj.apiUrl) ) } def jsonWritesSvcSundialPagerduty: play.api.libs.json.Writes[Pagerduty] = { (obj: com.gilt.svc.sundial.v0.models.Pagerduty) => { com.gilt.svc.sundial.v0.models.json.jsObjectPagerduty(obj) } } implicit def jsonReadsSvcSundialProcess: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.Process] = { for { processId <- (__ \ "process_id").read[_root_.java.util.UUID] processDefinitionName <- (__ \ "process_definition_name").read[String] startTime <- (__ \ "start_time").read[_root_.org.joda.time.DateTime] status <- (__ \ "status").read[com.gilt.svc.sundial.v0.models.ProcessStatus] task <- (__ \ "task").read[Seq[com.gilt.svc.sundial.v0.models.Task]] } yield Process(processId, processDefinitionName, startTime, status, task) } def jsObjectProcess(obj: com.gilt.svc.sundial.v0.models.Process): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "process_id" -> play.api.libs.json.JsString(obj.processId.toString), "process_definition_name" -> play.api.libs.json.JsString(obj.processDefinitionName), "start_time" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(obj.startTime)), "status" -> play.api.libs.json.JsString(obj.status.toString), "task" -> play.api.libs.json.Json.toJson(obj.task) ) } implicit def jsonWritesSvcSundialProcess: play.api.libs.json.Writes[Process] = { (obj: com.gilt.svc.sundial.v0.models.Process) => { com.gilt.svc.sundial.v0.models.json.jsObjectProcess(obj) } } implicit def jsonReadsSvcSundialProcessDefinition: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ProcessDefinition] = { for { processDefinitionName <- (__ \ "process_definition_name").read[String] paused <- (__ \ "paused").readNullable[Boolean] processDescription <- (__ \ "process_description").readNullable[String] schedule <- (__ \ "schedule").readNullable[com.gilt.svc.sundial.v0.models.ProcessSchedule] taskDefinitions <- (__ \ "task_definitions").read[Seq[com.gilt.svc.sundial.v0.models.TaskDefinition]] overlapAction <- (__ \ "overlap_action").read[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] notifications <- (__ \ "notifications").readNullable[Seq[com.gilt.svc.sundial.v0.models.Notification]] } yield ProcessDefinition(processDefinitionName, paused, processDescription, schedule, taskDefinitions, overlapAction, notifications) } def jsObjectProcessDefinition(obj: com.gilt.svc.sundial.v0.models.ProcessDefinition): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "process_definition_name" -> play.api.libs.json.JsString(obj.processDefinitionName), "task_definitions" -> play.api.libs.json.Json.toJson(obj.taskDefinitions), "overlap_action" -> play.api.libs.json.JsString(obj.overlapAction.toString) ) ++ (obj.paused match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("paused" -> play.api.libs.json.JsBoolean(x)) }) ++ (obj.processDescription match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("process_description" -> play.api.libs.json.JsString(x)) }) ++ (obj.schedule match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("schedule" -> com.gilt.svc.sundial.v0.models.json.jsObjectProcessSchedule(x)) }) ++ (obj.notifications match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("notifications" -> play.api.libs.json.Json.toJson(x)) }) } implicit def jsonWritesSvcSundialProcessDefinition: play.api.libs.json.Writes[ProcessDefinition] = { (obj: com.gilt.svc.sundial.v0.models.ProcessDefinition) => { com.gilt.svc.sundial.v0.models.json.jsObjectProcessDefinition(obj) } } implicit def jsonReadsSvcSundialS3Cp: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.S3Cp] = { for { source <- (__ \ "source").read[String] destination <- (__ \ "destination").read[String] } yield S3Cp(source, destination) } def jsObjectS3Cp(obj: com.gilt.svc.sundial.v0.models.S3Cp): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "source" -> play.api.libs.json.JsString(obj.source), "destination" -> play.api.libs.json.JsString(obj.destination) ) } implicit def jsonWritesSvcSundialS3Cp: play.api.libs.json.Writes[S3Cp] = { (obj: com.gilt.svc.sundial.v0.models.S3Cp) => { com.gilt.svc.sundial.v0.models.json.jsObjectS3Cp(obj) } } implicit def jsonReadsSvcSundialS3LogDetails: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.S3LogDetails] = { for { logGroupName <- (__ \ "log_group_name").read[String] logStreamName <- (__ \ "log_stream_name").read[String] } yield S3LogDetails(logGroupName, logStreamName) } def jsObjectS3LogDetails(obj: com.gilt.svc.sundial.v0.models.S3LogDetails): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "log_group_name" -> play.api.libs.json.JsString(obj.logGroupName), "log_stream_name" -> play.api.libs.json.JsString(obj.logStreamName) ) } implicit def jsonWritesSvcSundialS3LogDetails: play.api.libs.json.Writes[S3LogDetails] = { (obj: com.gilt.svc.sundial.v0.models.S3LogDetails) => { com.gilt.svc.sundial.v0.models.json.jsObjectS3LogDetails(obj) } } def jsonReadsSvcSundialShellScriptCommand: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.ShellScriptCommand] = { for { script <- (__ \ "script").read[String] environmentVariables <- (__ \ "environment_variables").readNullable[Seq[com.gilt.svc.sundial.v0.models.EnvironmentVariable]] } yield ShellScriptCommand(script, environmentVariables) } def jsObjectShellScriptCommand(obj: com.gilt.svc.sundial.v0.models.ShellScriptCommand): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "script" -> play.api.libs.json.JsString(obj.script) ) ++ (obj.environmentVariables match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("environment_variables" -> play.api.libs.json.Json.toJson(x)) }) } def jsonWritesSvcSundialShellScriptCommand: play.api.libs.json.Writes[ShellScriptCommand] = { (obj: com.gilt.svc.sundial.v0.models.ShellScriptCommand) => { com.gilt.svc.sundial.v0.models.json.jsObjectShellScriptCommand(obj) } } def jsonReadsSvcSundialSpot: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.Spot] = { (__ \ "bid_price").read[BigDecimal].map { x => Spot(bidPrice = x) } } def jsObjectSpot(obj: com.gilt.svc.sundial.v0.models.Spot): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "bid_price" -> play.api.libs.json.JsNumber(obj.bidPrice) ) } def jsonWritesSvcSundialSpot: play.api.libs.json.Writes[Spot] = { (obj: com.gilt.svc.sundial.v0.models.Spot) => { com.gilt.svc.sundial.v0.models.json.jsObjectSpot(obj) } } implicit def jsonReadsSvcSundialTask: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.Task] = { for { taskId <- (__ \ "task_id").read[_root_.java.util.UUID] processId <- (__ \ "process_id").read[_root_.java.util.UUID] processDefinitionName <- (__ \ "process_definition_name").read[String] taskDefinitionName <- (__ \ "task_definition_name").read[String] startTime <- (__ \ "start_time").read[_root_.org.joda.time.DateTime] endTime <- (__ \ "end_time").readNullable[_root_.org.joda.time.DateTime] previousAttemptCount <- (__ \ "previous_attempt_count").read[Int] logEntries <- (__ \ "log_entries").read[Seq[com.gilt.svc.sundial.v0.models.LogEntry]] metadataEntries <- (__ \ "metadata_entries").read[Seq[com.gilt.svc.sundial.v0.models.MetadataEntry]] executionState <- (__ \ "execution_state").readNullable[Seq[com.gilt.svc.sundial.v0.models.MetadataEntry]] status <- (__ \ "status").read[com.gilt.svc.sundial.v0.models.TaskStatus] } yield Task(taskId, processId, processDefinitionName, taskDefinitionName, startTime, endTime, previousAttemptCount, logEntries, metadataEntries, executionState, status) } def jsObjectTask(obj: com.gilt.svc.sundial.v0.models.Task): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "task_id" -> play.api.libs.json.JsString(obj.taskId.toString), "process_id" -> play.api.libs.json.JsString(obj.processId.toString), "process_definition_name" -> play.api.libs.json.JsString(obj.processDefinitionName), "task_definition_name" -> play.api.libs.json.JsString(obj.taskDefinitionName), "start_time" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(obj.startTime)), "previous_attempt_count" -> play.api.libs.json.JsNumber(obj.previousAttemptCount), "log_entries" -> play.api.libs.json.Json.toJson(obj.logEntries), "metadata_entries" -> play.api.libs.json.Json.toJson(obj.metadataEntries), "status" -> play.api.libs.json.JsString(obj.status.toString) ) ++ (obj.endTime match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("end_time" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(x))) }) ++ (obj.executionState match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("execution_state" -> play.api.libs.json.Json.toJson(x)) }) } implicit def jsonWritesSvcSundialTask: play.api.libs.json.Writes[Task] = { (obj: com.gilt.svc.sundial.v0.models.Task) => { com.gilt.svc.sundial.v0.models.json.jsObjectTask(obj) } } implicit def jsonReadsSvcSundialTaskDefinition: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.TaskDefinition] = { for { taskDefinitionName <- (__ \ "task_definition_name").read[String] dependencies <- (__ \ "dependencies").read[Seq[com.gilt.svc.sundial.v0.models.TaskDependency]] executable <- (__ \ "executable").read[com.gilt.svc.sundial.v0.models.TaskExecutable] maxAttempts <- (__ \ "max_attempts").read[Int] maxRuntimeSeconds <- (__ \ "max_runtime_seconds").readNullable[Int] backoffBaseSeconds <- (__ \ "backoff_base_seconds").read[Int] backoffExponent <- (__ \ "backoff_exponent").read[Double] requireExplicitSuccess <- (__ \ "require_explicit_success").read[Boolean] } yield TaskDefinition(taskDefinitionName, dependencies, executable, maxAttempts, maxRuntimeSeconds, backoffBaseSeconds, backoffExponent, requireExplicitSuccess) } def jsObjectTaskDefinition(obj: com.gilt.svc.sundial.v0.models.TaskDefinition): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "task_definition_name" -> play.api.libs.json.JsString(obj.taskDefinitionName), "dependencies" -> play.api.libs.json.Json.toJson(obj.dependencies), "executable" -> com.gilt.svc.sundial.v0.models.json.jsObjectTaskExecutable(obj.executable), "max_attempts" -> play.api.libs.json.JsNumber(obj.maxAttempts), "backoff_base_seconds" -> play.api.libs.json.JsNumber(obj.backoffBaseSeconds), "backoff_exponent" -> play.api.libs.json.JsNumber(obj.backoffExponent), "require_explicit_success" -> play.api.libs.json.JsBoolean(obj.requireExplicitSuccess) ) ++ (obj.maxRuntimeSeconds match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("max_runtime_seconds" -> play.api.libs.json.JsNumber(x)) }) } implicit def jsonWritesSvcSundialTaskDefinition: play.api.libs.json.Writes[TaskDefinition] = { (obj: com.gilt.svc.sundial.v0.models.TaskDefinition) => { com.gilt.svc.sundial.v0.models.json.jsObjectTaskDefinition(obj) } } implicit def jsonReadsSvcSundialTaskDependency: play.api.libs.json.Reads[com.gilt.svc.sundial.v0.models.TaskDependency] = { for { taskDefinitionName <- (__ \ "task_definition_name").read[String] successRequired <- (__ \ "success_required").read[Boolean] } yield TaskDependency(taskDefinitionName, successRequired) } def jsObjectTaskDependency(obj: com.gilt.svc.sundial.v0.models.TaskDependency): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "task_definition_name" -> play.api.libs.json.JsString(obj.taskDefinitionName), "success_required" -> play.api.libs.json.JsBoolean(obj.successRequired) ) } implicit def jsonWritesSvcSundialTaskDependency: play.api.libs.json.Writes[TaskDependency] = { (obj: com.gilt.svc.sundial.v0.models.TaskDependency) => { com.gilt.svc.sundial.v0.models.json.jsObjectTaskDependency(obj) } } implicit def jsonReadsSvcSundialAwsMarket[T <: com.gilt.svc.sundial.v0.models.AwsMarket]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialOnDemand.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialSpot.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(AwsMarketUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialAwsMarketSeq[T <: com.gilt.svc.sundial.v0.models.AwsMarket]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.AwsMarket]] = a.value.map(jsonReadsSvcSundialAwsMarket.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectAwsMarket(obj: com.gilt.svc.sundial.v0.models.AwsMarket): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.OnDemand => play.api.libs.json.Json.obj("on_demand" -> play.api.libs.json.JsString(x.toString)) case x: com.gilt.svc.sundial.v0.models.Spot => play.api.libs.json.Json.obj("spot" -> com.gilt.svc.sundial.v0.models.json.jsObjectSpot(x)) case x: com.gilt.svc.sundial.v0.models.AwsMarketUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.AwsMarketUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialAwsMarket[T <: com.gilt.svc.sundial.v0.models.AwsMarket]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.AwsMarket) => { com.gilt.svc.sundial.v0.models.json.jsObjectAwsMarket(obj) } } implicit def jsonReadsSvcSundialEmrCluster[T <: com.gilt.svc.sundial.v0.models.EmrCluster]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialNewEmrCluster.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialExistingEmrCluster.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(EmrClusterUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialEmrClusterSeq[T <: com.gilt.svc.sundial.v0.models.EmrCluster]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.EmrCluster]] = a.value.map(jsonReadsSvcSundialEmrCluster.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectEmrCluster(obj: com.gilt.svc.sundial.v0.models.EmrCluster): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.NewEmrCluster => play.api.libs.json.Json.obj("new_emr_cluster" -> com.gilt.svc.sundial.v0.models.json.jsObjectNewEmrCluster(x)) case x: com.gilt.svc.sundial.v0.models.ExistingEmrCluster => play.api.libs.json.Json.obj("existing_emr_cluster" -> com.gilt.svc.sundial.v0.models.json.jsObjectExistingEmrCluster(x)) case x: com.gilt.svc.sundial.v0.models.EmrClusterUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.EmrClusterUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialEmrCluster[T <: com.gilt.svc.sundial.v0.models.EmrCluster]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.EmrCluster) => { com.gilt.svc.sundial.v0.models.json.jsObjectEmrCluster(obj) } } implicit def jsonReadsSvcSundialEmrJobFlowRole[T <: com.gilt.svc.sundial.v0.models.EmrJobFlowRole]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialDefaultEmrJobFlowRole.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialCustomEmrJobFlowRole.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(EmrJobFlowRoleUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialEmrJobFlowRoleSeq[T <: com.gilt.svc.sundial.v0.models.EmrJobFlowRole]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.EmrJobFlowRole]] = a.value.map(jsonReadsSvcSundialEmrJobFlowRole.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectEmrJobFlowRole(obj: com.gilt.svc.sundial.v0.models.EmrJobFlowRole): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole => play.api.libs.json.Json.obj("default_emr_job_flow_role" -> play.api.libs.json.JsString(x.toString)) case x: com.gilt.svc.sundial.v0.models.CustomEmrJobFlowRole => play.api.libs.json.Json.obj("custom_emr_job_flow_role" -> com.gilt.svc.sundial.v0.models.json.jsObjectCustomEmrJobFlowRole(x)) case x: com.gilt.svc.sundial.v0.models.EmrJobFlowRoleUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.EmrJobFlowRoleUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialEmrJobFlowRole[T <: com.gilt.svc.sundial.v0.models.EmrJobFlowRole]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.EmrJobFlowRole) => { com.gilt.svc.sundial.v0.models.json.jsObjectEmrJobFlowRole(obj) } } implicit def jsonReadsSvcSundialEmrServiceRole[T <: com.gilt.svc.sundial.v0.models.EmrServiceRole]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialDefaultEmrServiceRole.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialCustomEmrServiceRole.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(EmrServiceRoleUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialEmrServiceRoleSeq[T <: com.gilt.svc.sundial.v0.models.EmrServiceRole]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.EmrServiceRole]] = a.value.map(jsonReadsSvcSundialEmrServiceRole.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectEmrServiceRole(obj: com.gilt.svc.sundial.v0.models.EmrServiceRole): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole => play.api.libs.json.Json.obj("default_emr_service_role" -> play.api.libs.json.JsString(x.toString)) case x: com.gilt.svc.sundial.v0.models.CustomEmrServiceRole => play.api.libs.json.Json.obj("custom_emr_service_role" -> com.gilt.svc.sundial.v0.models.json.jsObjectCustomEmrServiceRole(x)) case x: com.gilt.svc.sundial.v0.models.EmrServiceRoleUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.EmrServiceRoleUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialEmrServiceRole[T <: com.gilt.svc.sundial.v0.models.EmrServiceRole]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.EmrServiceRole) => { com.gilt.svc.sundial.v0.models.json.jsObjectEmrServiceRole(obj) } } implicit def jsonReadsSvcSundialNotification[T <: com.gilt.svc.sundial.v0.models.Notification]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialEmail.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialPagerduty.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(NotificationUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialNotificationSeq[T <: com.gilt.svc.sundial.v0.models.Notification]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.Notification]] = a.value.map(jsonReadsSvcSundialNotification.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectNotification(obj: com.gilt.svc.sundial.v0.models.Notification): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.Email => play.api.libs.json.Json.obj("email" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmail(x)) case x: com.gilt.svc.sundial.v0.models.Pagerduty => play.api.libs.json.Json.obj("pagerduty" -> com.gilt.svc.sundial.v0.models.json.jsObjectPagerduty(x)) case x: com.gilt.svc.sundial.v0.models.NotificationUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.NotificationUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialNotification[T <: com.gilt.svc.sundial.v0.models.Notification]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.Notification) => { com.gilt.svc.sundial.v0.models.json.jsObjectNotification(obj) } } implicit def jsonReadsSvcSundialProcessSchedule[T <: com.gilt.svc.sundial.v0.models.ProcessSchedule]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialCronSchedule.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialContinuousSchedule.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(ProcessScheduleUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialProcessScheduleSeq[T <: com.gilt.svc.sundial.v0.models.ProcessSchedule]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.ProcessSchedule]] = a.value.map(jsonReadsSvcSundialProcessSchedule.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectProcessSchedule(obj: com.gilt.svc.sundial.v0.models.ProcessSchedule): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.CronSchedule => play.api.libs.json.Json.obj("cron_schedule" -> com.gilt.svc.sundial.v0.models.json.jsObjectCronSchedule(x)) case x: com.gilt.svc.sundial.v0.models.ContinuousSchedule => play.api.libs.json.Json.obj("continuous_schedule" -> com.gilt.svc.sundial.v0.models.json.jsObjectContinuousSchedule(x)) case x: com.gilt.svc.sundial.v0.models.ProcessScheduleUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.ProcessScheduleUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialProcessSchedule[T <: com.gilt.svc.sundial.v0.models.ProcessSchedule]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.ProcessSchedule) => { com.gilt.svc.sundial.v0.models.json.jsObjectProcessSchedule(obj) } } implicit def jsonReadsSvcSundialTaskExecutable[T <: com.gilt.svc.sundial.v0.models.TaskExecutable]: play.api.libs.json.Reads[T] = (json: play.api.libs.json.JsValue) => { Seq( jsonReadsSvcSundialDockerImageCommand.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialShellScriptCommand.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialBatchImageCommand.reads(json).map(_.asInstanceOf[T]), jsonReadsSvcSundialEmrCommand.reads(json).map(_.asInstanceOf[T]) ).view.find(_.isSuccess).getOrElse { play.api.libs.json.JsSuccess(TaskExecutableUndefinedType(json.toString).asInstanceOf[T]) } } implicit def jsonReadsSvcSundialTaskExecutableSeq[T <: com.gilt.svc.sundial.v0.models.TaskExecutable]: play.api.libs.json.Reads[Seq[T]] = { case a: play.api.libs.json.JsArray => { val all: Seq[play.api.libs.json.JsResult[com.gilt.svc.sundial.v0.models.TaskExecutable]] = a.value.map(jsonReadsSvcSundialTaskExecutable.reads).toSeq all.collect { case e: play.api.libs.json.JsError => e }.toList match { case Nil => play.api.libs.json.JsSuccess(all.collect { case play.api.libs.json.JsSuccess(v, _) => v.asInstanceOf[T] }) case errors => play.api.libs.json.JsError(play.api.libs.json.JsError.merge(errors.flatMap(_.errors), Nil)) } } case other => play.api.libs.json.JsError(s"Expected array but found [" + other.getClass.getName + "]") } def jsObjectTaskExecutable(obj: com.gilt.svc.sundial.v0.models.TaskExecutable): play.api.libs.json.JsObject = { obj match { case x: com.gilt.svc.sundial.v0.models.DockerImageCommand => play.api.libs.json.Json.obj("docker_image_command" -> com.gilt.svc.sundial.v0.models.json.jsObjectDockerImageCommand(x)) case x: com.gilt.svc.sundial.v0.models.ShellScriptCommand => play.api.libs.json.Json.obj("shell_script_command" -> com.gilt.svc.sundial.v0.models.json.jsObjectShellScriptCommand(x)) case x: com.gilt.svc.sundial.v0.models.BatchImageCommand => play.api.libs.json.Json.obj("batch_image_command" -> com.gilt.svc.sundial.v0.models.json.jsObjectBatchImageCommand(x)) case x: com.gilt.svc.sundial.v0.models.EmrCommand => play.api.libs.json.Json.obj("emr_command" -> com.gilt.svc.sundial.v0.models.json.jsObjectEmrCommand(x)) case x: com.gilt.svc.sundial.v0.models.TaskExecutableUndefinedType => { scala.util.Try { // If we received a JSON object - echo it back. This is a workaround for a bug in // serialization for unions w/out discriminators where they sometimes have the // type wrapper and sometimes do not play.api.libs.json.Json.parse(x.description).asInstanceOf[play.api.libs.json.JsObject] } match { case scala.util.Success(o) => o case scala.util.Failure(_) => sys.error("The type[com.gilt.svc.sundial.v0.models.TaskExecutableUndefinedType] should never be serialized") } } } } implicit def jsonWritesSvcSundialTaskExecutable[T <: com.gilt.svc.sundial.v0.models.TaskExecutable]: play.api.libs.json.Writes[T] = { (obj: com.gilt.svc.sundial.v0.models.TaskExecutable) => { com.gilt.svc.sundial.v0.models.json.jsObjectTaskExecutable(obj) } } } } package com.gilt.svc.sundial.v0 { object Bindables { import play.api.mvc.{PathBindable, QueryStringBindable} // import models directly for backwards compatibility with prior versions of the generator import Core._ import Models._ object Core { implicit def pathBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.DateTime] = ApibuilderPathBindable(ApibuilderTypes.dateTimeIso8601) implicit def queryStringBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.DateTime] = ApibuilderQueryStringBindable(ApibuilderTypes.dateTimeIso8601) implicit def pathBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.LocalDate] = ApibuilderPathBindable(ApibuilderTypes.dateIso8601) implicit def queryStringBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.LocalDate] = ApibuilderQueryStringBindable(ApibuilderTypes.dateIso8601) } object Models { import com.gilt.svc.sundial.v0.models._ val defaultEmrJobFlowRoleConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] { override def convert(value: String): com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole = com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole(value) override def convert(value: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole): String = value.toString override def example: com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole = com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole.DefaultEmrJobFlowRole override def validValues: Seq[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole.all } implicit def pathBindableDefaultEmrJobFlowRole(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = ApibuilderPathBindable(defaultEmrJobFlowRoleConverter) implicit def queryStringBindableDefaultEmrJobFlowRole(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.DefaultEmrJobFlowRole] = ApibuilderQueryStringBindable(defaultEmrJobFlowRoleConverter) val defaultEmrServiceRoleConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] { override def convert(value: String): com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole = com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole(value) override def convert(value: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole): String = value.toString override def example: com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole = com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole.DefaultEmrServiceRole override def validValues: Seq[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole.all } implicit def pathBindableDefaultEmrServiceRole(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = ApibuilderPathBindable(defaultEmrServiceRoleConverter) implicit def queryStringBindableDefaultEmrServiceRole(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.DefaultEmrServiceRole] = ApibuilderQueryStringBindable(defaultEmrServiceRoleConverter) val emrApplicationConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.EmrApplication] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.EmrApplication] { override def convert(value: String): com.gilt.svc.sundial.v0.models.EmrApplication = com.gilt.svc.sundial.v0.models.EmrApplication(value) override def convert(value: com.gilt.svc.sundial.v0.models.EmrApplication): String = value.toString override def example: com.gilt.svc.sundial.v0.models.EmrApplication = com.gilt.svc.sundial.v0.models.EmrApplication.Hadoop override def validValues: Seq[com.gilt.svc.sundial.v0.models.EmrApplication] = com.gilt.svc.sundial.v0.models.EmrApplication.all } implicit def pathBindableEmrApplication(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.EmrApplication] = ApibuilderPathBindable(emrApplicationConverter) implicit def queryStringBindableEmrApplication(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.EmrApplication] = ApibuilderQueryStringBindable(emrApplicationConverter) val emrReleaseLabelConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] { override def convert(value: String): com.gilt.svc.sundial.v0.models.EmrReleaseLabel = com.gilt.svc.sundial.v0.models.EmrReleaseLabel(value) override def convert(value: com.gilt.svc.sundial.v0.models.EmrReleaseLabel): String = value.toString override def example: com.gilt.svc.sundial.v0.models.EmrReleaseLabel = com.gilt.svc.sundial.v0.models.EmrReleaseLabel.Emr5140 override def validValues: Seq[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = com.gilt.svc.sundial.v0.models.EmrReleaseLabel.all } implicit def pathBindableEmrReleaseLabel(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = ApibuilderPathBindable(emrReleaseLabelConverter) implicit def queryStringBindableEmrReleaseLabel(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.EmrReleaseLabel] = ApibuilderQueryStringBindable(emrReleaseLabelConverter) val notificationOptionsConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.NotificationOptions] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.NotificationOptions] { override def convert(value: String): com.gilt.svc.sundial.v0.models.NotificationOptions = com.gilt.svc.sundial.v0.models.NotificationOptions(value) override def convert(value: com.gilt.svc.sundial.v0.models.NotificationOptions): String = value.toString override def example: com.gilt.svc.sundial.v0.models.NotificationOptions = com.gilt.svc.sundial.v0.models.NotificationOptions.Always override def validValues: Seq[com.gilt.svc.sundial.v0.models.NotificationOptions] = com.gilt.svc.sundial.v0.models.NotificationOptions.all } implicit def pathBindableNotificationOptions(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.NotificationOptions] = ApibuilderPathBindable(notificationOptionsConverter) implicit def queryStringBindableNotificationOptions(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.NotificationOptions] = ApibuilderQueryStringBindable(notificationOptionsConverter) val onDemandConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.OnDemand] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.OnDemand] { override def convert(value: String): com.gilt.svc.sundial.v0.models.OnDemand = com.gilt.svc.sundial.v0.models.OnDemand(value) override def convert(value: com.gilt.svc.sundial.v0.models.OnDemand): String = value.toString override def example: com.gilt.svc.sundial.v0.models.OnDemand = com.gilt.svc.sundial.v0.models.OnDemand.OnDemand override def validValues: Seq[com.gilt.svc.sundial.v0.models.OnDemand] = com.gilt.svc.sundial.v0.models.OnDemand.all } implicit def pathBindableOnDemand(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.OnDemand] = ApibuilderPathBindable(onDemandConverter) implicit def queryStringBindableOnDemand(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.OnDemand] = ApibuilderQueryStringBindable(onDemandConverter) val processOverlapActionConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] { override def convert(value: String): com.gilt.svc.sundial.v0.models.ProcessOverlapAction = com.gilt.svc.sundial.v0.models.ProcessOverlapAction(value) override def convert(value: com.gilt.svc.sundial.v0.models.ProcessOverlapAction): String = value.toString override def example: com.gilt.svc.sundial.v0.models.ProcessOverlapAction = com.gilt.svc.sundial.v0.models.ProcessOverlapAction.Wait override def validValues: Seq[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = com.gilt.svc.sundial.v0.models.ProcessOverlapAction.all } implicit def pathBindableProcessOverlapAction(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = ApibuilderPathBindable(processOverlapActionConverter) implicit def queryStringBindableProcessOverlapAction(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.ProcessOverlapAction] = ApibuilderQueryStringBindable(processOverlapActionConverter) val processStatusConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.ProcessStatus] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.ProcessStatus] { override def convert(value: String): com.gilt.svc.sundial.v0.models.ProcessStatus = com.gilt.svc.sundial.v0.models.ProcessStatus(value) override def convert(value: com.gilt.svc.sundial.v0.models.ProcessStatus): String = value.toString override def example: com.gilt.svc.sundial.v0.models.ProcessStatus = com.gilt.svc.sundial.v0.models.ProcessStatus.Running override def validValues: Seq[com.gilt.svc.sundial.v0.models.ProcessStatus] = com.gilt.svc.sundial.v0.models.ProcessStatus.all } implicit def pathBindableProcessStatus(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.ProcessStatus] = ApibuilderPathBindable(processStatusConverter) implicit def queryStringBindableProcessStatus(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.ProcessStatus] = ApibuilderQueryStringBindable(processStatusConverter) val taskStatusConverter: ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.TaskStatus] = new ApibuilderTypeConverter[com.gilt.svc.sundial.v0.models.TaskStatus] { override def convert(value: String): com.gilt.svc.sundial.v0.models.TaskStatus = com.gilt.svc.sundial.v0.models.TaskStatus(value) override def convert(value: com.gilt.svc.sundial.v0.models.TaskStatus): String = value.toString override def example: com.gilt.svc.sundial.v0.models.TaskStatus = com.gilt.svc.sundial.v0.models.TaskStatus.Submitted override def validValues: Seq[com.gilt.svc.sundial.v0.models.TaskStatus] = com.gilt.svc.sundial.v0.models.TaskStatus.all } implicit def pathBindableTaskStatus(implicit stringBinder: QueryStringBindable[String]): PathBindable[com.gilt.svc.sundial.v0.models.TaskStatus] = ApibuilderPathBindable(taskStatusConverter) implicit def queryStringBindableTaskStatus(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[com.gilt.svc.sundial.v0.models.TaskStatus] = ApibuilderQueryStringBindable(taskStatusConverter) } trait ApibuilderTypeConverter[T] { def convert(value: String): T def convert(value: T): String def example: T def validValues: Seq[T] = Nil def errorMessage(key: String, value: String, ex: java.lang.Exception): String = { val base = s"Invalid value '$value' for parameter '$key'. " validValues.toList match { case Nil => base + "Ex: " + convert(example) case values => base + ". Valid values are: " + values.mkString("'", "', '", "'") } } } object ApibuilderTypes { val dateTimeIso8601: ApibuilderTypeConverter[_root_.org.joda.time.DateTime] = new ApibuilderTypeConverter[_root_.org.joda.time.DateTime] { override def convert(value: String): _root_.org.joda.time.DateTime = _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(value) override def convert(value: _root_.org.joda.time.DateTime): String = _root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(value) override def example: _root_.org.joda.time.DateTime = _root_.org.joda.time.DateTime.now } val dateIso8601: ApibuilderTypeConverter[_root_.org.joda.time.LocalDate] = new ApibuilderTypeConverter[_root_.org.joda.time.LocalDate] { override def convert(value: String): _root_.org.joda.time.LocalDate = _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(value) override def convert(value: _root_.org.joda.time.LocalDate): String = _root_.org.joda.time.format.ISODateTimeFormat.date.print(value) override def example: _root_.org.joda.time.LocalDate = _root_.org.joda.time.LocalDate.now } } final case class ApibuilderQueryStringBindable[T]( converters: ApibuilderTypeConverter[T] ) extends QueryStringBindable[T] { override def bind(key: String, params: Map[String, Seq[String]]): _root_.scala.Option[_root_.scala.Either[String, T]] = { params.getOrElse(key, Nil).headOption.map { v => try { Right( converters.convert(v) ) } catch { case ex: java.lang.Exception => Left( converters.errorMessage(key, v, ex) ) } } } override def unbind(key: String, value: T): String = { s"$key=${converters.convert(value)}" } } final case class ApibuilderPathBindable[T]( converters: ApibuilderTypeConverter[T] ) extends PathBindable[T] { override def bind(key: String, value: String): _root_.scala.Either[String, T] = { try { Right( converters.convert(value) ) } catch { case ex: java.lang.Exception => Left( converters.errorMessage(key, value, ex) ) } } override def unbind(key: String, value: T): String = { converters.convert(value) } } } }