Skip to content

Commit f5ccc55

Browse files
authored
APPS-1858 TreeTurnaroundTime threshold (#123)
* APPS-1858_TAT_threshold (feat) DxObject - added new TreeTurnaroundTimeThreshold Field * APPS-1858_TAT_threshold (feat) DxObject - added new TreeTurnaroundTimeThreshold Field * APPS-1858_TAT_threshold (feat) DxAppDescribe, DxAppletDescribe, DxWorkflowDescribe - added a docstring for TreeTurnaroundTimeThreshold
1 parent d24e0f4 commit f5ccc55

File tree

4 files changed

+125
-80
lines changed

4 files changed

+125
-80
lines changed

api/src/main/scala/dx/api/DxApp.scala

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package dx.api
33
import dx.AppInternalException
44
import spray.json._
55

6+
/**
7+
* Class to store the output of app-xxx/describe API call.
8+
* @param treeTurnaroundTimeThreshold number of seconds the app runs before sending an email notification to the user
9+
*/
610
case class DxAppDescribe(id: String,
711
name: String,
812
version: String,
@@ -13,23 +17,27 @@ case class DxAppDescribe(id: String,
1317
details: Option[JsValue],
1418
inputSpec: Option[Vector[IOParameter]],
1519
outputSpec: Option[Vector[IOParameter]],
16-
access: Option[JsValue] = None)
20+
access: Option[JsValue] = None,
21+
treeTurnaroundTimeThreshold: Option[JsValue] = None)
1722
extends DxObjectDescribe {
1823
override def containsAll(fields: Set[Field.Value]): Boolean = {
1924
fields.diff(DxAppDescribe.RequiredFields).forall {
20-
case Field.Properties => properties.isDefined
21-
case Field.Details => details.isDefined
22-
case Field.InputSpec => inputSpec.isDefined
23-
case Field.OutputSpec => outputSpec.isDefined
24-
case Field.Access => access.isDefined
25-
case _ => false
25+
case Field.Properties => properties.isDefined
26+
case Field.Details => details.isDefined
27+
case Field.InputSpec => inputSpec.isDefined
28+
case Field.OutputSpec => outputSpec.isDefined
29+
case Field.Access => access.isDefined
30+
case Field.TreeTurnaroundTimeThreshold => treeTurnaroundTimeThreshold.isDefined
31+
case _ => false
2632
}
2733
}
2834
}
2935

3036
object DxAppDescribe {
3137
val RequiredFields = Set(Field.Id, Field.Name, Field.Version, Field.Created, Field.Modified)
32-
val DefaultFields: Set[Field.Value] = RequiredFields ++ Set(Field.InputSpec, Field.OutputSpec)
38+
val DefaultFields: Set[Field.Value] = RequiredFields ++ Set(Field.InputSpec,
39+
Field.OutputSpec,
40+
Field.TreeTurnaroundTimeThreshold)
3341
}
3442

3543
case class DxApp(id: String)(dxApi: DxApi = DxApi.get)
@@ -124,6 +132,12 @@ object DxApp {
124132
val tags = descJs.fields.get("tags").map(DxObject.parseJsonTags)
125133
val properties = descJs.fields.get("properties").map(DxObject.parseJsonProperties)
126134
val access = descJs.fields.get("access")
127-
desc.copy(details = details, tags = tags, properties = properties, access = access)
135+
val treeTurnaroundTimeThreshold =
136+
descJs.fields.get("treeTurnaroundTimeThreshold")
137+
desc.copy(details = details,
138+
tags = tags,
139+
properties = properties,
140+
access = access,
141+
treeTurnaroundTimeThreshold = treeTurnaroundTimeThreshold)
128142
}
129143
}

api/src/main/scala/dx/api/DxApplet.scala

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package dx.api
33
import dx.AppInternalException
44
import spray.json._
55

6+
/**
7+
* Class to store the output of applet-xxx/describe API call.
8+
* @param treeTurnaroundTimeThreshold number of seconds the applet runs before sending an email notification to the user
9+
*/
610
case class DxAppletDescribe(project: String,
711
id: String,
812
name: String,
@@ -22,24 +26,26 @@ case class DxAppletDescribe(project: String,
2226
runSpec: Option[JsValue] = None,
2327
access: Option[JsValue] = None,
2428
ignoreReuse: Option[Boolean] = None,
25-
hidden: Option[Boolean] = None)
29+
hidden: Option[Boolean] = None,
30+
treeTurnaroundTimeThreshold: Option[Long] = None)
2631
extends DxObjectDescribe {
2732
override def containsAll(fields: Set[Field.Value]): Boolean = {
2833
fields.diff(DxAppletDescribe.RequiredFields).forall {
29-
case Field.Properties => properties.isDefined
30-
case Field.Details => details.isDefined
31-
case Field.InputSpec => inputSpec.isDefined
32-
case Field.OutputSpec => outputSpec.isDefined
33-
case Field.Description => description.isDefined
34-
case Field.DeveloperNotes => developerNotes.isDefined
35-
case Field.Summary => summary.isDefined
36-
case Field.Title => title.isDefined
37-
case Field.Types => types.isDefined
38-
case Field.Tags => tags.isDefined
39-
case Field.RunSpec => runSpec.isDefined
40-
case Field.Access => access.isDefined
41-
case Field.IgnoreReuse => ignoreReuse.isDefined
42-
case _ => false
34+
case Field.Properties => properties.isDefined
35+
case Field.Details => details.isDefined
36+
case Field.InputSpec => inputSpec.isDefined
37+
case Field.OutputSpec => outputSpec.isDefined
38+
case Field.Description => description.isDefined
39+
case Field.DeveloperNotes => developerNotes.isDefined
40+
case Field.Summary => summary.isDefined
41+
case Field.Title => title.isDefined
42+
case Field.Types => types.isDefined
43+
case Field.Tags => tags.isDefined
44+
case Field.RunSpec => runSpec.isDefined
45+
case Field.Access => access.isDefined
46+
case Field.IgnoreReuse => ignoreReuse.isDefined
47+
case Field.TreeTurnaroundTimeThreshold => treeTurnaroundTimeThreshold.isDefined
48+
case _ => false
4349
}
4450
}
4551
}
@@ -93,6 +99,8 @@ case class DxApplet(id: String, project: Option[DxProject])(dxApi: DxApi = DxApi
9399

94100
val descFields: Map[String, JsValue] = descJs.fields
95101
val details = descFields.get("details")
102+
val treeTurnaroundTimeThreshold =
103+
descFields.get("treeTurnaroundTimeThreshold").flatMap(unwrapNumber)
96104
val props = descFields.get("properties").map(DxObject.parseJsonProperties)
97105
val description = descFields.get("description").flatMap(unwrapString)
98106
val developerNotes = descFields.get("developerNotes").flatMap(unwrapString)
@@ -116,7 +124,8 @@ case class DxApplet(id: String, project: Option[DxProject])(dxApi: DxApi = DxApi
116124
runSpec = runSpec,
117125
access = access,
118126
ignoreReuse = ignoreReuse,
119-
hidden = hidden
127+
hidden = hidden,
128+
treeTurnaroundTimeThreshold = treeTurnaroundTimeThreshold
120129
)
121130
}
122131

@@ -127,6 +136,13 @@ case class DxApplet(id: String, project: Option[DxProject])(dxApi: DxApi = DxApi
127136
}
128137
}
129138

139+
private def unwrapNumber(jsValue: JsValue): Option[Long] = {
140+
jsValue match {
141+
case JsNumber(value) => Some(value.toLong)
142+
case _ => None
143+
}
144+
}
145+
130146
def unwrapStringArray(jsValue: JsValue): Option[Vector[String]] = {
131147
jsValue match {
132148
case JsArray(array) => Some(array.flatMap(unwrapString))

api/src/main/scala/dx/api/DxObject.scala

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Field extends Enum {
1818
Hidden, Id, IgnoreReuse, Input, Inputs, InputSpec, InstanceType, Modified, Name, Output,
1919
Outputs, OutputSpec, ParentJob, Parts, PricingModelsByRegion, Port, Project, Properties, Region,
2020
RunSpec, Size, Stages, State, Status, StatusAsOf, Summary, Tags, Title, Types, UniqueDatabaseName,
21-
Version = Value
21+
Version, TreeTurnaroundTimeThreshold = Value
2222
}
2323
// format: on
2424

@@ -74,58 +74,59 @@ object DxObject {
7474

7575
def requestFields(fields: Set[Field.Value]): JsValue = {
7676
val fieldStrings = fields.map {
77-
case Field.Access => "access"
78-
case Field.Analysis => "analysis"
79-
case Field.App => "app"
80-
case Field.Applet => "applet"
81-
case Field.ArchivalState => "archivalState"
82-
case Field.AvailableInstanceTypes => "availableInstanceTypes"
83-
case Field.BillTo => "billTo"
84-
case Field.Categories => "categories"
85-
case Field.Created => "created"
86-
case Field.DatabaseName => "databaseName"
87-
case Field.DependsOn => "dependsOn"
88-
case Field.Description => "description"
89-
case Field.DeveloperNotes => "developerNotes"
90-
case Field.Details => "details"
91-
case Field.DxInstanceClass => "dxInstanceClass"
92-
case Field.Endpoint => "endpoint"
93-
case Field.Engine => "engine"
94-
case Field.EngineVersion => "engineVersion"
95-
case Field.Executable => "executable"
96-
case Field.ExecutableName => "executableName"
97-
case Field.Folder => "folder"
98-
case Field.Id => "id"
99-
case Field.Hidden => "hidden"
100-
case Field.IgnoreReuse => "ignoreReuse"
101-
case Field.Input => "input"
102-
case Field.Inputs => "inputs"
103-
case Field.InputSpec => "inputSpec"
104-
case Field.InstanceType => "instanceType"
105-
case Field.Modified => "modified"
106-
case Field.Name => "name"
107-
case Field.Output => "output"
108-
case Field.Outputs => "outputs"
109-
case Field.OutputSpec => "outputSpec"
110-
case Field.ParentJob => "parentJob"
111-
case Field.Parts => "parts"
112-
case Field.Port => "port"
113-
case Field.PricingModelsByRegion => "pricingModelsByRegion"
114-
case Field.Project => "project"
115-
case Field.Properties => "properties"
116-
case Field.Region => "region"
117-
case Field.RunSpec => "runSpec"
118-
case Field.Size => "size"
119-
case Field.Stages => "stages"
120-
case Field.State => "state"
121-
case Field.Status => "status"
122-
case Field.StatusAsOf => "statusAsOf"
123-
case Field.Summary => "summary"
124-
case Field.Tags => "tags"
125-
case Field.Title => "title"
126-
case Field.Types => "types"
127-
case Field.UniqueDatabaseName => "uniqueDatabaseName"
128-
case Field.Version => "version"
77+
case Field.Access => "access"
78+
case Field.Analysis => "analysis"
79+
case Field.App => "app"
80+
case Field.Applet => "applet"
81+
case Field.ArchivalState => "archivalState"
82+
case Field.AvailableInstanceTypes => "availableInstanceTypes"
83+
case Field.BillTo => "billTo"
84+
case Field.Categories => "categories"
85+
case Field.Created => "created"
86+
case Field.DatabaseName => "databaseName"
87+
case Field.DependsOn => "dependsOn"
88+
case Field.Description => "description"
89+
case Field.DeveloperNotes => "developerNotes"
90+
case Field.Details => "details"
91+
case Field.DxInstanceClass => "dxInstanceClass"
92+
case Field.Endpoint => "endpoint"
93+
case Field.Engine => "engine"
94+
case Field.EngineVersion => "engineVersion"
95+
case Field.Executable => "executable"
96+
case Field.ExecutableName => "executableName"
97+
case Field.Folder => "folder"
98+
case Field.Id => "id"
99+
case Field.Hidden => "hidden"
100+
case Field.IgnoreReuse => "ignoreReuse"
101+
case Field.Input => "input"
102+
case Field.Inputs => "inputs"
103+
case Field.InputSpec => "inputSpec"
104+
case Field.InstanceType => "instanceType"
105+
case Field.Modified => "modified"
106+
case Field.Name => "name"
107+
case Field.Output => "output"
108+
case Field.Outputs => "outputs"
109+
case Field.OutputSpec => "outputSpec"
110+
case Field.ParentJob => "parentJob"
111+
case Field.Parts => "parts"
112+
case Field.Port => "port"
113+
case Field.PricingModelsByRegion => "pricingModelsByRegion"
114+
case Field.Project => "project"
115+
case Field.Properties => "properties"
116+
case Field.Region => "region"
117+
case Field.RunSpec => "runSpec"
118+
case Field.Size => "size"
119+
case Field.Stages => "stages"
120+
case Field.State => "state"
121+
case Field.Status => "status"
122+
case Field.StatusAsOf => "statusAsOf"
123+
case Field.Summary => "summary"
124+
case Field.Tags => "tags"
125+
case Field.Title => "title"
126+
case Field.Types => "types"
127+
case Field.UniqueDatabaseName => "uniqueDatabaseName"
128+
case Field.Version => "version"
129+
case Field.TreeTurnaroundTimeThreshold => "treeTurnaroundTimeThreshold"
129130
}.toVector
130131
val m: Map[String, JsValue] = fieldStrings.map { x =>
131132
x -> JsTrue

api/src/main/scala/dx/api/DxWorkflow.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ case class DxWorkflowStage(id: String) {
2424
}
2525
}
2626

27+
/**
28+
* Class to store the output of workflow-xxx/describe API call.
29+
* @param treeTurnaroundTimeThreshold number of seconds the workflow runs before sending an email notification to the user
30+
*/
2731
case class DxWorkflowDescribe(project: String,
2832
id: String,
2933
name: String,
@@ -42,7 +46,8 @@ case class DxWorkflowDescribe(project: String,
4246
types: Option[Vector[String]] = None,
4347
inputs: Option[Vector[IOParameter]] = None,
4448
outputs: Option[Vector[IOParameter]] = None,
45-
hidden: Option[Boolean] = None)
49+
hidden: Option[Boolean] = None,
50+
treeTurnaroundTimeThreshold: Option[Long] = None)
4651
extends DxObjectDescribe
4752

4853
object DxWorkflowDescribe {
@@ -113,6 +118,8 @@ case class DxWorkflow(id: String, project: Option[DxProject])(dxApi: DxApi = DxA
113118

114119
val descFields: Map[String, JsValue] = descJs.fields
115120
val details = descFields.get("details")
121+
val treeTurnaroundTimeThreshold =
122+
descFields.get("treeTurnaroundTimeThreshold").flatMap(unwrapNumber)
116123
val props = descFields.get("properties").map(DxObject.parseJsonProperties)
117124
val stages = descFields.get("stages").map(DxWorkflowDescribe.parseStages)
118125
val description = descFields.get("description").flatMap(unwrapString)
@@ -150,7 +157,8 @@ case class DxWorkflow(id: String, project: Option[DxProject])(dxApi: DxApi = DxA
150157
tags = tags,
151158
inputs = inputs,
152159
outputs = outputs,
153-
hidden = hidden
160+
hidden = hidden,
161+
treeTurnaroundTimeThreshold = treeTurnaroundTimeThreshold
154162
)
155163
}
156164

@@ -160,6 +168,12 @@ case class DxWorkflow(id: String, project: Option[DxProject])(dxApi: DxApi = DxA
160168
case _ => None
161169
}
162170
}
171+
private def unwrapNumber(jsValue: JsValue): Option[Long] = {
172+
jsValue match {
173+
case JsNumber(value) => Some(value.toLong)
174+
case _ => None
175+
}
176+
}
163177

164178
def unwrapStringArray(jsValue: JsValue): Option[Vector[String]] = {
165179
jsValue match {

0 commit comments

Comments
 (0)