Skip to content

Commit e3460db

Browse files
committed
unecessary 'required' property in Solution openapi removed
1 parent cd3b010 commit e3460db

File tree

10 files changed

+60
-49
lines changed

10 files changed

+60
-49
lines changed

doc/Models/RunTemplate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**id** | **String** | the Solution Run Template id | [default to null]
7-
**name** | **String** | the Run Template name | [default to null]
7+
**name** | **String** | the Run Template name | [optional] [default to null]
88
**description** | **String** | the Run Template description | [optional] [default to null]
99
**csmSimulation** | **String** | the Cosmo Tech simulation name. This information is send to the Engine. Mandatory information if no Engine is defined | [optional] [default to null]
1010
**tags** | **List** | the list of Run Template tags | [optional] [default to null]

doc/Models/RunTemplateParameter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**id** | **String** | the Parameter id | [default to null]
7-
**labels** | **Map** | a translated label with key as ISO 639-1 code | [default to null]
8-
**varType** | **String** | the variable type for the parameter. Basic types or special type %DATASETID% | [default to null]
7+
**labels** | **Map** | a translated label with key as ISO 639-1 code | [optional] [default to null]
8+
**varType** | **String** | the variable type for the parameter. Basic types or special type %DATASETID% | [optional] [default to null]
99
**defaultValue** | **String** | the default value for this parameter | [optional] [default to null]
1010
**minValue** | **String** | the minimum value for this parameter | [optional] [default to null]
1111
**maxValue** | **String** | the maximum value for this parameter | [optional] [default to null]

doc/Models/RunTemplateParameterGroup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**id** | **String** | the Parameter Group id | [default to null]
7-
**labels** | **Map** | a translated label with key as ISO 639-1 code | [default to null]
7+
**labels** | **Map** | a translated label with key as ISO 639-1 code | [optional] [default to null]
88
**isTable** | **Boolean** | does the group define a table | [optional] [default to null]
99
**options** | **Map** | freeform options | [optional] [default to null]
1010
**parentId** | **String** | the Run Template Group parent Id | [optional] [default to null]
11-
**parameters** | **List** | an ordered list of Run Template Parameters | [default to null]
11+
**parameters** | **List** | an ordered list of Run Template Parameters | [optional] [default to null]
1212

1313
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1414

doc/Models/Solution.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**id** | **String** | the Solution version unique identifier | [optional] [default to null]
7-
**key** | **String** | the Solution key which group Solution versions | [default to null]
8-
**name** | **String** | the Solution name | [default to null]
7+
**key** | **String** | the Solution key which group Solution versions | [optional] [default to null]
8+
**name** | **String** | the Solution name | [optional] [default to null]
99
**description** | **String** | the Solution description | [optional] [default to null]
10-
**repository** | **String** | the registry repository containing the image | [default to null]
10+
**repository** | **String** | the registry repository containing the image | [optional] [default to null]
1111
**csmSimulator** | **String** | the main Cosmo Tech simulator name used in standard Run Template | [optional] [default to null]
12-
**version** | **String** | the Solution version MAJOR.MINOR.PATCH. Must be aligned with an existing repository tag | [default to null]
12+
**version** | **String** | the Solution version MAJOR.MINOR.PATCH. Must be aligned with an existing repository tag | [optional] [default to null]
1313
**ownerId** | **String** | the User id which own this Solution | [optional] [default to null]
1414
**sdkVersion** | **String** | the MAJOR.MINOR version used to build this solution | [optional] [default to null]
1515
**url** | **String** | an optional URL link to solution page | [optional] [default to null]
1616
**tags** | **List** | the list of tags | [optional] [default to null]
1717
**parameters** | [**List**](RunTemplateParameter.md) | the list of Run Template Parameters | [optional] [default to null]
1818
**parameterGroups** | [**List**](RunTemplateParameterGroup.md) | the list of parameters groups for the Run Templates | [optional] [default to null]
19-
**runTemplates** | [**List**](RunTemplate.md) | list of Run Template | [default to null]
19+
**runTemplates** | [**List**](RunTemplate.md) | list of Run Template | [optional] [default to null]
2020

2121
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
2222

openapi/plantuml/schemas.plantuml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ entity OrganizationUser {
9898

9999
entity RunTemplate {
100100
* id: String
101-
* name: String
101+
name: String
102102
description: String
103103
csmSimulation: String
104104
tags: List<String>
@@ -134,8 +134,8 @@ entity RunTemplateHandlerId {
134134

135135
entity RunTemplateParameter {
136136
* id: String
137-
* labels: Map
138-
* varType: String
137+
labels: Map
138+
varType: String
139139
defaultValue: String
140140
minValue: String
141141
maxValue: String
@@ -145,11 +145,11 @@ entity RunTemplateParameter {
145145

146146
entity RunTemplateParameterGroup {
147147
* id: String
148-
* labels: Map
148+
labels: Map
149149
isTable: Boolean
150150
options: Map
151151
parentId: String
152-
* parameters: List<String>
152+
parameters: List<String>
153153
}
154154

155155
entity RunTemplateParameterValue {
@@ -342,19 +342,19 @@ entity ScenarioValidationStatus {
342342

343343
entity Solution {
344344
id: String
345-
* key: String
346-
* name: String
345+
key: String
346+
name: String
347347
description: String
348-
* repository: String
348+
repository: String
349349
csmSimulator: String
350-
* version: String
350+
version: String
351351
ownerId: String
352352
sdkVersion: String
353353
url: String
354354
tags: List<String>
355355
parameters: List<RunTemplateParameter>
356356
parameterGroups: List<RunTemplateParameterGroup>
357-
* runTemplates: List<RunTemplate>
357+
runTemplates: List<RunTemplate>
358358
}
359359

360360
entity User {

scenario/src/main/kotlin/com/cosmotech/scenario/azure/ScenarioServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ internal class ScenarioServiceImpl(
233233
?.filter { parameterGroup ->
234234
runTemplate?.parameterGroups?.contains(parameterGroup.id) == true
235235
}
236-
?.flatMap { parameterGroup -> parameterGroup.parameters }
236+
?.flatMap { parameterGroup -> parameterGroup?.parameters ?: mutableListOf() }
237237
if (!runTemplateParametersIds.isNullOrEmpty()) {
238238
val parentParameters = parent.parametersValues?.associate { it.parameterId to it }
239239
val scenarioParameters = scenario.parametersValues?.associate { it.parameterId to it }

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/ContainerFactory.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,9 @@ internal class ContainerFactory(
10081008
}
10091009

10101010
private fun getRunTemplate(solution: Solution, runTemplateId: String): RunTemplate {
1011-
return solution.runTemplates.find { runTemplate -> runTemplate.id == runTemplateId }
1011+
return (solution.runTemplates ?: mutableListOf()).find { runTemplate ->
1012+
runTemplate.id == runTemplateId
1013+
}
10121014
?: throw IllegalStateException(
10131015
"runTemplateId $runTemplateId not found in Solution ${solution.id}")
10141016
}
@@ -1026,7 +1028,6 @@ internal class ContainerFactory(
10261028
): ScenarioRunContainer {
10271029

10281030
if (step == null) throw IllegalStateException("Solution Container Step Spec is not defined")
1029-
val template = getRunTemplate(solution, runTemplateId)
10301031
val imageName =
10311032
getImageName(
10321033
csmPlatformProperties.azure?.containerRegistries?.solutions ?: "",
@@ -1045,6 +1046,7 @@ internal class ContainerFactory(
10451046

10461047
envVars.putAll(getEventHubEnvVars(organization, workspace))
10471048

1049+
val template = getRunTemplate(solution, runTemplateId)
10481050
val csmSimulation = template.csmSimulation
10491051
if (csmSimulation != null) {
10501052
envVars[CSM_SIMULATION_VAR] = csmSimulation
@@ -1248,8 +1250,10 @@ internal class ContainerFactory(
12481250
}
12491251
}
12501252

1251-
private fun getImageName(registry: String, repository: String, version: String? = null): String {
1252-
val repoVersion = if (version == null) repository else "${repository}:${version}"
1253+
private fun getImageName(registry: String, repository: String?, version: String? = null): String {
1254+
if (repository == null) throw IllegalStateException("Solution repository is not defined")
1255+
val repo = repository ?: "ERROR"
1256+
val repoVersion = if (version == null) repo else "${repo}:${version}"
12531257
return if (registry != "") "${registry}/${repoVersion}" else repoVersion
12541258
}
12551259
}

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/dataset/DatasetUtils.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ internal fun findDatasetsAndConnectors(
3232
addDatasetAndConnector(
3333
datasetService, connectorService, organizationId, datasetId, datasets, connectors)
3434
}
35-
val parameterGroupIds = runTemplate.parameterGroups
35+
val parameterGroupIds = runTemplate.parameterGroups ?: listOf()
3636
if (parameterGroupIds != null) {
3737
val parametersIds =
38-
(solution.parameterGroups?.filter { it.id in parameterGroupIds }?.map { it.parameters })
38+
(solution.parameterGroups?.filter { it.id in parameterGroupIds }?.map {
39+
it.parameters ?: listOf()
40+
})
3941
?.flatten()
4042
if (parametersIds != null) {
4143
solution

solution/src/main/kotlin/com/cosmotech/solution/azure/SolutionServiceImpl.kt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ internal class SolutionServiceImpl(
122122
}
123123

124124
val existingSolution = findSolutionById(organizationId, solutionId)
125-
val runTemplateMap = existingSolution.runTemplates.associateBy { it.id }.toMutableMap()
125+
val runTemplateMap =
126+
existingSolution.runTemplates?.associateBy { it.id }?.toMutableMap() ?: mutableMapOf()
126127
runTemplateMap.putAll(runTemplate.filter { it.id.isNotBlank() }.associateBy { it.id })
127128
existingSolution.runTemplates = runTemplateMap.values.toMutableList()
128129
cosmosTemplate.upsert("${organizationId}_solutions", existingSolution)
@@ -153,7 +154,7 @@ internal class SolutionServiceImpl(
153154
runTemplateId: String
154155
) {
155156
val existingSolution = findSolutionById(organizationId, solutionId)
156-
if (!existingSolution.runTemplates.removeIf { it.id == runTemplateId }) {
157+
if (!(existingSolution.runTemplates?.removeIf { it.id == runTemplateId } ?: true)) {
157158
throw CsmResourceNotFoundException("Run Template '$runTemplateId' *not* found")
158159
}
159160
cosmosTemplate.upsert("${organizationId}_solutions", existingSolution)
@@ -198,7 +199,8 @@ internal class SolutionServiceImpl(
198199
): List<RunTemplate> {
199200
val existingSolution = findSolutionById(organizationId, solutionId)
200201
val runTemplates =
201-
existingSolution.runTemplates.filter { it.id == runTemplateId }.toMutableList()
202+
existingSolution.runTemplates?.filter { it.id == runTemplateId }?.toMutableList()
203+
?: mutableListOf()
202204
if (runTemplates.isEmpty()) {
203205
throw CsmResourceNotFoundException("Run Template '$runTemplateId' *not* found")
204206
}
@@ -261,17 +263,20 @@ internal class SolutionServiceImpl(
261263
"${solutionId.sanitizeForAzureStorage()}/$runTemplateId/${handlerId.value}.zip")
262264
.upload(body.inputStream, body.contentLength(), overwrite)
263265

264-
val runTemplate = solution.runTemplates.findLast { it.id == runTemplateId }!!
266+
val runTemplate = solution.runTemplates?.findLast { it.id == runTemplateId }
267+
if (runTemplate == null) {
268+
throw CsmResourceNotFoundException("Run Template '$runTemplateId' *not* found")
269+
}
265270
when (handlerId) {
266271
RunTemplateHandlerId.parameters_handler ->
267-
runTemplate.parametersHandlerSource = RunTemplateStepSource.cloud
272+
runTemplate!!.parametersHandlerSource = RunTemplateStepSource.cloud
268273
RunTemplateHandlerId.validator ->
269-
runTemplate.datasetValidatorSource = RunTemplateStepSource.cloud
270-
RunTemplateHandlerId.prerun -> runTemplate.preRunSource = RunTemplateStepSource.cloud
271-
RunTemplateHandlerId.engine -> runTemplate.runSource = RunTemplateStepSource.cloud
272-
RunTemplateHandlerId.postrun -> runTemplate.postRunSource = RunTemplateStepSource.cloud
274+
runTemplate!!.datasetValidatorSource = RunTemplateStepSource.cloud
275+
RunTemplateHandlerId.prerun -> runTemplate!!.preRunSource = RunTemplateStepSource.cloud
276+
RunTemplateHandlerId.engine -> runTemplate!!.runSource = RunTemplateStepSource.cloud
277+
RunTemplateHandlerId.postrun -> runTemplate!!.postRunSource = RunTemplateStepSource.cloud
273278
RunTemplateHandlerId.scenariodata_transform ->
274-
runTemplate.scenariodataTransformSource = RunTemplateStepSource.cloud
279+
runTemplate!!.scenariodataTransformSource = RunTemplateStepSource.cloud
275280
}.run {
276281
// This trick forces Kotlin to raise an error at compile time if the "when" statement is not
277282
// exhaustive
@@ -308,7 +313,7 @@ internal class SolutionServiceImpl(
308313
runTemplateId: String,
309314
): Solution {
310315
val solution = findSolutionById(organizationId, solutionId)
311-
val validRunTemplateIds = solution.runTemplates.map { it.id }.toSet()
316+
val validRunTemplateIds = solution.runTemplates?.map { it.id }?.toSet() ?: setOf()
312317
if (validRunTemplateIds.isEmpty()) {
313318
throw IllegalArgumentException(
314319
"Solution $solutionId does not declare any run templates. " +

solution/src/main/openapi/solution.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,12 @@ components:
533533
description: list of Run Template
534534
items:
535535
$ref: '#/components/schemas/RunTemplate'
536-
required:
537-
- key
538-
- name
539-
- repository
540-
- version
541-
- runTemplates
536+
# required:
537+
# - key
538+
# - name
539+
# - repository
540+
# - version
541+
# - runTemplates
542542
RunTemplate:
543543
type: object
544544
description: a Solution Run Template
@@ -634,7 +634,7 @@ components:
634634
description: an optional duration in seconds in which a workflow is allowed to run
635635
required:
636636
- id
637-
- name
637+
# - name
638638
RunTemplateHandlerId:
639639
type: string
640640
description: the Run Template step handler identifier
@@ -670,8 +670,8 @@ components:
670670
description: a Run Template Parameter id
671671
required:
672672
- id
673-
- labels
674-
- parameters
673+
#  - labels
674+
#  - parameters
675675
RunTemplateParameter:
676676
type: object
677677
description: a Run Template Parameter
@@ -702,8 +702,8 @@ components:
702702
additionalProperties: true
703703
required:
704704
- id
705-
- labels
706-
- varType
705+
# - labels
706+
# - varType
707707
TranslatedLabels:
708708
type: object
709709
description: a translated label with key as ISO 639-1 code

0 commit comments

Comments
 (0)