-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#609 initial support of active reponse
- Loading branch information
Showing
8 changed files
with
443 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package connectors.cortex.models | ||
|
||
import java.util.Date | ||
|
||
import javax.inject.{ Inject, Singleton } | ||
|
||
import scala.concurrent.Future | ||
import play.api.libs.json.JsObject | ||
import org.elastic4play.JsonFormat.dateFormat | ||
import org.elastic4play.models.{ AttributeDef, BaseEntity, EntityDef, ModelDef, AttributeFormat ⇒ F, AttributeOption ⇒ O } | ||
import org.elastic4play.utils.RichJson | ||
import connectors.cortex.models.JsonFormat.jobStatusFormat | ||
import services.AuditedModel | ||
|
||
trait ActionAttributes { _: AttributeDef ⇒ | ||
val workerId = attribute("workerId", F.stringFmt, "Analyzer", O.readonly) | ||
val workerName = optionalAttribute("workerName", F.stringFmt, "Name of the worker", O.readonly) | ||
val workerDefinition = optionalAttribute("workerDefinition", F.stringFmt, "Name of the worker definition", O.readonly) | ||
val status = attribute("status", F.enumFmt(JobStatus), "Status of the action job", JobStatus.InProgress) | ||
val objectType = attribute("objectType", F.stringFmt, "Type of the object on which this job was executed") | ||
val objectId = attribute("objectId", F.stringFmt, "Object ID on which this job was executed", O.readonly) | ||
val startDate = attribute("startDate", F.dateFmt, "Timestamp of the job start") // , O.model) | ||
val endDate = optionalAttribute("endDate", F.dateFmt, "Timestamp of the job completion (or fail)") | ||
val report = optionalAttribute("report", F.textFmt, "Action output", O.unaudited) | ||
val cortexId = optionalAttribute("cortexId", F.stringFmt, "Id of cortex where the job is run", O.readonly) | ||
val cortexJobId = optionalAttribute("cortexJobId", F.stringFmt, "Id of job in cortex", O.readonly) | ||
val operations = multiAttribute("operations", F.textFmt, "Update operations applied at the end of the job", O.readonly) | ||
} | ||
@Singleton | ||
class ActionModel @Inject() extends ModelDef[ActionModel, Action]("action", "Action", "/connector/cortex/action") with ActionAttributes with AuditedModel { | ||
|
||
override def creationHook(parent: Option[BaseEntity], attrs: JsObject): Future[JsObject] = Future.successful { | ||
attrs | ||
.setIfAbsent("status", JobStatus.InProgress) | ||
.setIfAbsent("startDate", new Date) | ||
} | ||
} | ||
class Action(model: ActionModel, attributes: JsObject) extends EntityDef[ActionModel, Action](model, attributes) with ActionAttributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package connectors.cortex.models | ||
|
||
case class Worker( | ||
id: String, | ||
name: String, | ||
version: String, | ||
description: String, | ||
dataTypeList: Seq[String], | ||
maxTlp: Option[Long], | ||
maxPap: Option[Long], | ||
cortexIds: List[String] = Nil) { | ||
|
||
def addCortexId(cid: String): Worker = copy(cortexIds = cid :: cortexIds) | ||
|
||
def join(worker: Worker): Worker = copy(cortexIds = cortexIds ::: worker.cortexIds) | ||
} |
Oops, something went wrong.