diff --git a/.gitignore b/.gitignore index 401f7bd5d..110d9a23b 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ out/ # generated openapi/plantuml/.openapi-generator/ openapi/openapi.yaml +doc/generated-snippets ### Personal directory ### perso diff --git a/api/build.gradle.kts b/api/build.gradle.kts index bb0655af8..ebaafb8e7 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -57,7 +57,7 @@ tasks.register("copySubProjectsOpenAPIFiles") { logger.debug("Found project dependency: $it") it.name.matches("^cosmotech-[a-zA-Z]+-api$".toRegex()) } - .map { it.dependencyProject.projectDir } + .map { project.project(it.path).projectDir } .map { file("${it}/src/main/openapi/${it.relativeTo(rootDir)}.yaml") } .filter { it.exists() } .map { it.absolutePath } diff --git a/api/src/integrationTest/kotlin/com/cosmotech/api/home/solution/SolutionControllerTests.kt b/api/src/integrationTest/kotlin/com/cosmotech/api/home/solution/SolutionControllerTests.kt index 04c719000..37926d0e4 100644 --- a/api/src/integrationTest/kotlin/com/cosmotech/api/home/solution/SolutionControllerTests.kt +++ b/api/src/integrationTest/kotlin/com/cosmotech/api/home/solution/SolutionControllerTests.kt @@ -124,7 +124,6 @@ class SolutionControllerTests : ControllerTestBase() { val parameterGroupDescription = "this_is_a_description" val parameterMinValue = "this_is_a_minimal_value" val parameterMaxValue = "this_is_a_maximal_value" - val parameterRegexValidation = "this_is_a_regex_to_validate_value" val additionalData = mutableMapOf( "you_can_put" to "whatever_you_want_here", @@ -139,19 +138,15 @@ class SolutionControllerTests : ControllerTestBase() { parameterDefaultValue, parameterMinValue, parameterMaxValue, - parameterRegexValidation, additionalData)) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroups = mutableListOf( RunTemplateParameterGroupCreateRequest( parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId))) val runTemplateId = "runtemplate1" val runTemplateName = "this_is_a_name" @@ -216,11 +211,8 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.parameters[0].defaultValue").value(parameterDefaultValue)) .andExpect(jsonPath("$.parameters[0].minValue").value(parameterMinValue)) .andExpect(jsonPath("$.parameters[0].maxValue").value(parameterMaxValue)) - .andExpect(jsonPath("$.parameters[0].regexValidation").value(parameterRegexValidation)) .andExpect(jsonPath("$.parameterGroups[0].id").value(parameterGroupId)) .andExpect(jsonPath("$.parameterGroups[0].labels").value(parameterLabels)) - .andExpect(jsonPath("$.parameterGroups[0].isTable").value(false)) - .andExpect(jsonPath("$.parameterGroups[0].parentId").value(parameterGroupParentId)) .andExpect(jsonPath("$.parameterGroups[0].parameters").value(mutableListOf(parameterId))) .andExpect(jsonPath("$.runTemplates[0].id").value(runTemplateId)) .andExpect(jsonPath("$.runTemplates[0].name").value(runTemplateName)) @@ -261,7 +253,6 @@ class SolutionControllerTests : ControllerTestBase() { val parameterDefaultValue = "this_is_a_default_value" val parameterMinValue = "this_is_a_minimal_value" val parameterMaxValue = "this_is_a_maximal_value" - val parameterRegexValidation = "this_is_a_regex_to_validate_value" val additionalData = mutableMapOf( "you_can_put" to "whatever_you_want_here", @@ -276,10 +267,8 @@ class SolutionControllerTests : ControllerTestBase() { parameterDefaultValue, parameterMinValue, parameterMaxValue, - parameterRegexValidation, additionalData)) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroupDescription = "this_is_a_description" val parameterGroups = mutableListOf( @@ -287,9 +276,7 @@ class SolutionControllerTests : ControllerTestBase() { parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId))) val runTemplateId = "runtemplate1" val runTemplateName = "this_is_a_name" @@ -355,7 +342,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.parameters[0].defaultValue").value(parameterDefaultValue)) .andExpect(jsonPath("$.parameters[0].minValue").value(parameterMinValue)) .andExpect(jsonPath("$.parameters[0].maxValue").value(parameterMaxValue)) - .andExpect(jsonPath("$.parameters[0].regexValidation").value(parameterRegexValidation)) .andExpect( jsonPath("$.parameters[0].additionalData[\"you_can_put\"]") .value("whatever_you_want_here")) @@ -363,8 +349,6 @@ class SolutionControllerTests : ControllerTestBase() { jsonPath("$.parameters[0].additionalData[\"even\"][\"object\"]").value("if_you_want")) .andExpect(jsonPath("$.parameterGroups[0].id").value(parameterGroupId)) .andExpect(jsonPath("$.parameterGroups[0].labels").value(parameterLabels)) - .andExpect(jsonPath("$.parameterGroups[0].isTable").value(false)) - .andExpect(jsonPath("$.parameterGroups[0].parentId").value(parameterGroupParentId)) .andExpect(jsonPath("$.parameterGroups[0].parameters").value(mutableListOf(parameterId))) .andExpect( jsonPath("$.parameterGroups[0].additionalData[\"you_can_put\"]") @@ -471,7 +455,6 @@ class SolutionControllerTests : ControllerTestBase() { val parameterDefaultValue = "this_is_a_default_value" val parameterMinValue = "this_is_a_minimal_value" val parameterMaxValue = "this_is_a_maximal_value" - val parameterRegexValidation = "this_is_a_regex_to_validate_value" val additionalData = mutableMapOf( "you_can_put" to "whatever_you_want_here", @@ -485,7 +468,6 @@ class SolutionControllerTests : ControllerTestBase() { parameterDefaultValue, parameterMinValue, parameterMaxValue, - parameterRegexValidation, additionalData) val solutionId = @@ -504,7 +486,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.defaultValue").value(parameterDefaultValue)) .andExpect(jsonPath("$.minValue").value(parameterMinValue)) .andExpect(jsonPath("$.maxValue").value(parameterMaxValue)) - .andExpect(jsonPath("$.regexValidation").value(parameterRegexValidation)) .andExpect(jsonPath("$.additionalData[\"you_can_put\"]").value("whatever_you_want_here")) .andExpect(jsonPath("$.additionalData[\"even\"][\"object\"]").value("if_you_want")) .andDo(MockMvcResultHandlers.print()) @@ -522,7 +503,6 @@ class SolutionControllerTests : ControllerTestBase() { val parameterDefaultValue = "this_is_a_default_value" val parameterMinValue = "this_is_a_minimal_value" val parameterMaxValue = "this_is_a_maximal_value" - val parameterRegexValidation = "this_is_a_regex_to_validate_value" val additionalData = mutableMapOf( "you_can_put" to "whatever_you_want_here", @@ -536,7 +516,6 @@ class SolutionControllerTests : ControllerTestBase() { parameterDefaultValue, parameterMinValue, parameterMaxValue, - parameterRegexValidation, additionalData) val solutionId = @@ -560,7 +539,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.defaultValue").value(parameterDefaultValue)) .andExpect(jsonPath("$.minValue").value(parameterMinValue)) .andExpect(jsonPath("$.maxValue").value(parameterMaxValue)) - .andExpect(jsonPath("$.regexValidation").value(parameterRegexValidation)) .andExpect(jsonPath("$.additionalData[\"you_can_put\"]").value("whatever_you_want_here")) .andExpect(jsonPath("$.additionalData[\"even\"][\"object\"]").value("if_you_want")) .andDo(MockMvcResultHandlers.print()) @@ -580,7 +558,6 @@ class SolutionControllerTests : ControllerTestBase() { val newParameterDefaultValue = "this_is_a_new_default_value" val newParameterMinValue = "this_is_a_new_minimal_value" val newParameterMaxValue = "this_is_a_new_maximal_value" - val newParameterRegexValidation = "this_is_a_new_regex_to_validate_value" val newParameterAdditionalData = mutableMapOf( "new_you_can_put" to "new_whatever_you_want_here", @@ -594,7 +571,6 @@ class SolutionControllerTests : ControllerTestBase() { newParameterDefaultValue, newParameterMinValue, newParameterMaxValue, - newParameterRegexValidation, newParameterAdditionalData) val solutionId = @@ -612,7 +588,6 @@ class SolutionControllerTests : ControllerTestBase() { "this_is_a_default_value", "this_is_a_minimal_value", "this_is_a_maximal_value", - "this_is_a_regex_to_validate_value", mutableMapOf( "you_can_put" to "whatever_you_want_here", "even" to JSONObject(mapOf("object" to "if_you_want"))))))) @@ -630,7 +605,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.defaultValue").value(newParameterDefaultValue)) .andExpect(jsonPath("$.minValue").value(newParameterMinValue)) .andExpect(jsonPath("$.maxValue").value(newParameterMaxValue)) - .andExpect(jsonPath("$.regexValidation").value(newParameterRegexValidation)) .andExpect( jsonPath("$.additionalData[\"new_you_can_put\"]").value("new_whatever_you_want_here")) .andExpect( @@ -652,7 +626,6 @@ class SolutionControllerTests : ControllerTestBase() { val parameterDefaultValue = "this_is_a_default_value" val parameterMinValue = "this_is_a_minimal_value" val parameterMaxValue = "this_is_a_maximal_value" - val parameterRegexValidation = "this_is_a_regex_to_validate_value" val additionalData = mutableMapOf( "you_can_put" to "whatever_you_want_here", @@ -667,7 +640,6 @@ class SolutionControllerTests : ControllerTestBase() { parameterDefaultValue, parameterMinValue, parameterMaxValue, - parameterRegexValidation, additionalData)) val solutionId = createSolutionAndReturnId( @@ -684,7 +656,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$[0].defaultValue").value(parameterDefaultValue)) .andExpect(jsonPath("$[0].minValue").value(parameterMinValue)) .andExpect(jsonPath("$[0].maxValue").value(parameterMaxValue)) - .andExpect(jsonPath("$[0].regexValidation").value(parameterRegexValidation)) .andExpect(jsonPath("$[0].additionalData[\"you_can_put\"]").value("whatever_you_want_here")) .andExpect(jsonPath("$[0].additionalData[\"even\"][\"object\"]").value("if_you_want")) .andDo(document("organizations/{organization_id}/solutions/{solution_id}/parameters/GET")) @@ -701,7 +672,6 @@ class SolutionControllerTests : ControllerTestBase() { val parameterDefaultValue = "this_is_a_default_value" val parameterMinValue = "this_is_a_minimal_value" val parameterMaxValue = "this_is_a_maximal_value" - val parameterRegexValidation = "this_is_a_regex_to_validate_value" val additionalData = mutableMapOf( "you_can_put" to "whatever_you_want_here", @@ -716,7 +686,6 @@ class SolutionControllerTests : ControllerTestBase() { parameterDefaultValue, parameterMinValue, parameterMaxValue, - parameterRegexValidation, additionalData)) val solutionId = createSolutionAndReturnId( @@ -746,16 +715,13 @@ class SolutionControllerTests : ControllerTestBase() { "you_can_put" to "whatever_you_want_here", "even" to JSONObject(mapOf("object" to "if_you_want"))) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroupDescription = "this_is_a_description" val parameterGroup = RunTemplateParameterGroupCreateRequest( parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId)) mvc.perform( @@ -767,8 +733,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.id").value(parameterGroupId)) .andExpect(jsonPath("$.description").value(parameterGroupDescription)) .andExpect(jsonPath("$.labels").value(parameterLabels)) - .andExpect(jsonPath("$.isTable").value(false)) - .andExpect(jsonPath("$.parentId").value(parameterGroupParentId)) .andExpect(jsonPath("$.additionalData[\"you_can_put\"]").value("whatever_you_want_here")) .andExpect(jsonPath("$.additionalData[\"even\"][\"object\"]").value("if_you_want")) .andExpect(jsonPath("$.parameters").value(mutableListOf(parameterId))) @@ -788,16 +752,13 @@ class SolutionControllerTests : ControllerTestBase() { "you_can_put" to "whatever_you_want_here", "even" to JSONObject(mapOf("object" to "if_you_want"))) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroupDescription = "this_is_a_description" val parameterGroup = RunTemplateParameterGroupCreateRequest( parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId)) val solutionId = @@ -814,8 +775,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.id").value(parameterGroupId)) .andExpect(jsonPath("$.description").value(parameterGroupDescription)) .andExpect(jsonPath("$.labels").value(parameterLabels)) - .andExpect(jsonPath("$.isTable").value(false)) - .andExpect(jsonPath("$.parentId").value(parameterGroupParentId)) .andExpect(jsonPath("$.additionalData[\"you_can_put\"]").value("whatever_you_want_here")) .andExpect(jsonPath("$.additionalData[\"even\"][\"object\"]").value("if_you_want")) .andExpect(jsonPath("$.parameters").value(mutableListOf(parameterId))) @@ -835,16 +794,13 @@ class SolutionControllerTests : ControllerTestBase() { "you_can_put" to "whatever_you_want_here", "even" to JSONObject(mapOf("object" to "if_you_want"))) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroupDescription = "this_is_a_description" val parameterGroup = RunTemplateParameterGroupCreateRequest( parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId)) val solutionId = @@ -858,16 +814,13 @@ class SolutionControllerTests : ControllerTestBase() { mutableMapOf( "you_can_put" to "whatever_you_want_new_here", "even" to JSONObject(mapOf("new_object" to "if_you_want"))) - val newParameterGroupParentId = "this_is_a_new_parent_id" val newParameterGroupDescription = "this_is_a_new_description" val newParameterId = "parameter2" val newParameterGroup = RunTemplateParameterGroupUpdateRequest( newParameterGroupDescription, newParameterLabels, - true, newadditionalData, - newParameterGroupParentId, mutableListOf(newParameterId)) mvc.perform( @@ -880,8 +833,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$.id").value(parameterGroupId)) .andExpect(jsonPath("$.description").value(newParameterGroupDescription)) .andExpect(jsonPath("$.labels").value(newParameterLabels)) - .andExpect(jsonPath("$.isTable").value(true)) - .andExpect(jsonPath("$.parentId").value(newParameterGroupParentId)) .andExpect( jsonPath("$.additionalData[\"you_can_put\"]").value("whatever_you_want_new_here")) .andExpect(jsonPath("$.additionalData[\"even\"][\"new_object\"]").value("if_you_want")) @@ -903,16 +854,13 @@ class SolutionControllerTests : ControllerTestBase() { "you_can_put" to "whatever_you_want_here", "even" to JSONObject(mapOf("object" to "if_you_want"))) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroupDescription = "this_is_a_description" val parameterGroup = RunTemplateParameterGroupCreateRequest( parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId)) val solutionId = @@ -929,8 +877,6 @@ class SolutionControllerTests : ControllerTestBase() { .andExpect(jsonPath("$[0].id").value(parameterGroupId)) .andExpect(jsonPath("$[0].description").value(parameterGroupDescription)) .andExpect(jsonPath("$[0].labels").value(parameterLabels)) - .andExpect(jsonPath("$[0].isTable").value(false)) - .andExpect(jsonPath("$[0].parentId").value(parameterGroupParentId)) .andExpect(jsonPath("$[0].additionalData[\"you_can_put\"]").value("whatever_you_want_here")) .andExpect(jsonPath("$[0].additionalData[\"even\"][\"object\"]").value("if_you_want")) .andExpect(jsonPath("$[0].parameters").value(mutableListOf(parameterId))) @@ -948,16 +894,13 @@ class SolutionControllerTests : ControllerTestBase() { "you_can_put" to "whatever_you_want_here", "even" to JSONObject(mapOf("object" to "if_you_want"))) val parameterGroupId = "parameterGroup1" - val parameterGroupParentId = "this_is_a_parent_id" val parameterGroupDescription = "this_is_a_description" val parameterGroup = RunTemplateParameterGroupCreateRequest( parameterGroupId, parameterGroupDescription, parameterLabels, - false, additionalData, - parameterGroupParentId, mutableListOf(parameterId)) val solutionId = diff --git a/api/src/integrationTest/resources/application-test.yml b/api/src/integrationTest/resources/application-test.yml index e0a752fe9..30bf678ae 100644 --- a/api/src/integrationTest/resources/application-test.yml +++ b/api/src/integrationTest/resources/application-test.yml @@ -52,8 +52,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process upload: diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index 1152663a9..1c3039af5 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -69,8 +69,6 @@ csm: base-path: / base-url: "http://cosmotech-api-${csm.platform.api.version}:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process metrics: diff --git a/common/src/main/kotlin/com/cosmotech/common/CsmPhoenixService.kt b/common/src/main/kotlin/com/cosmotech/common/CsmPhoenixService.kt index cc4c546f2..56d449f1b 100644 --- a/common/src/main/kotlin/com/cosmotech/common/CsmPhoenixService.kt +++ b/common/src/main/kotlin/com/cosmotech/common/CsmPhoenixService.kt @@ -4,7 +4,6 @@ package com.cosmotech.common import com.cosmotech.common.config.CsmPlatformProperties import com.cosmotech.common.events.CsmEventPublisher -import com.cosmotech.common.id.CsmIdGenerator import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -16,7 +15,5 @@ abstract class CsmPhoenixService { @Autowired protected lateinit var csmPlatformProperties: CsmPlatformProperties - @Autowired protected lateinit var idGenerator: CsmIdGenerator - @Autowired protected lateinit var eventPublisher: CsmEventPublisher } diff --git a/common/src/main/kotlin/com/cosmotech/common/config/CsmPlatformProperties.kt b/common/src/main/kotlin/com/cosmotech/common/config/CsmPlatformProperties.kt index 9f9f52cf5..01b71cf87 100644 --- a/common/src/main/kotlin/com/cosmotech/common/config/CsmPlatformProperties.kt +++ b/common/src/main/kotlin/com/cosmotech/common/config/CsmPlatformProperties.kt @@ -11,9 +11,6 @@ data class CsmPlatformProperties( /** API Configuration */ val api: Api, - /** Id Generator */ - val idGenerator: IdGenerator, - /** Event Publisher */ val eventPublisher: EventPublisher, @@ -184,16 +181,6 @@ data class CsmPlatformProperties( val basePath: String, ) - data class IdGenerator(val type: Type) { - enum class Type { - /** short unique UIDs */ - HASHID, - - /** UUIDs */ - UUID - } - } - data class EventPublisher(val type: Type) { enum class Type { /** In-process, via Spring Application Events */ diff --git a/common/src/main/kotlin/com/cosmotech/common/id/CsmIdGenerator.kt b/common/src/main/kotlin/com/cosmotech/common/id/CsmIdGenerator.kt index 560fe051f..c8e86dcd5 100644 --- a/common/src/main/kotlin/com/cosmotech/common/id/CsmIdGenerator.kt +++ b/common/src/main/kotlin/com/cosmotech/common/id/CsmIdGenerator.kt @@ -2,21 +2,26 @@ // Licensed under the MIT license. package com.cosmotech.common.id -interface CsmIdGenerator { +import java.util.UUID +import kotlin.math.min +import org.hashids.Hashids +import org.hashids.Hashids.MAX_NUMBER - fun generate(scope: String, prependPrefix: String? = null): String -} - -internal abstract class AbstractCsmIdGenerator : CsmIdGenerator { +private const val MIN_HASH_LENGTH = 0 +private const val ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789" - final override fun generate(scope: String, prependPrefix: String?): String { - if (scope.isBlank()) { - throw IllegalArgumentException("scope must not be blank") - } - - val id = this.buildId(scope) - return "${prependPrefix ?: "${scope[0].lowercaseChar()}-"}$id" +fun generateId(scope: String, prependPrefix: String? = null): String { + if (scope.isBlank()) { + throw IllegalArgumentException("scope must not be blank") } - protected abstract fun buildId(scope: String): String + // We do not intend to decode generated IDs afterwards => we can safely generate a unique salt. + // This will give us different ids even with equal numbers to encode + val id = + Hashids("$scope-${UUID.randomUUID()}", MIN_HASH_LENGTH, ALPHABET) + .encode( + // PROD-8703: encodedElement might be higher than the maximum number supported + min(System.nanoTime(), MAX_NUMBER)) + + return "${prependPrefix ?: "${scope[0].lowercaseChar()}-"}$id" } diff --git a/common/src/main/kotlin/com/cosmotech/common/id/hashids/HashidsCsmIdGenerator.kt b/common/src/main/kotlin/com/cosmotech/common/id/hashids/HashidsCsmIdGenerator.kt deleted file mode 100644 index d48eb83e0..000000000 --- a/common/src/main/kotlin/com/cosmotech/common/id/hashids/HashidsCsmIdGenerator.kt +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Cosmo Tech. -// Licensed under the MIT license. -package com.cosmotech.common.id.hashids - -import com.cosmotech.common.id.AbstractCsmIdGenerator -import java.util.UUID -import kotlin.math.min -import org.hashids.Hashids -import org.hashids.Hashids.MAX_NUMBER -import org.slf4j.LoggerFactory -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty -import org.springframework.stereotype.Component - -private const val MIN_HASH_LENGTH = 0 -private const val ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789" - -@Component -@ConditionalOnProperty( - name = ["csm.platform.id-generator.type"], havingValue = "hashid", matchIfMissing = true) -internal class HashidsCsmIdGenerator() : AbstractCsmIdGenerator() { - - private val logger = LoggerFactory.getLogger(HashidsCsmIdGenerator::class.java) - - private var encodedElementSupplier: (() -> ULong)? = null - - constructor(encodedElementSupplier: () -> ULong) : this() { - this.encodedElementSupplier = encodedElementSupplier - } - - override fun buildId(scope: String): String { - if (scope.isBlank()) { - throw IllegalArgumentException("scope must not be blank") - } - val encodedElement = - this.encodedElementSupplier?.invoke()?.toLong() - ?: run { - logger.trace( - "encoded element supplier is not defined " + - "=> defaulting to current time in nanos for ID Generation") - System.nanoTime() - } - // We do not intend to decode generated IDs afterwards => we can safely generate a unique salt. - // This will give us different ids even with equal numbers to encode - return Hashids("$scope-${UUID.randomUUID()}", MIN_HASH_LENGTH, ALPHABET) - .encode( - // PROD-8703: encodedElement might be higher than the maximum number supported - min(encodedElement, MAX_NUMBER)) - } -} diff --git a/common/src/main/kotlin/com/cosmotech/common/id/uuid/UUIDCsmIdGenerator.kt b/common/src/main/kotlin/com/cosmotech/common/id/uuid/UUIDCsmIdGenerator.kt deleted file mode 100644 index 6b96ade3d..000000000 --- a/common/src/main/kotlin/com/cosmotech/common/id/uuid/UUIDCsmIdGenerator.kt +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Cosmo Tech. -// Licensed under the MIT license. -package com.cosmotech.common.id.uuid - -import com.cosmotech.common.id.AbstractCsmIdGenerator -import java.util.UUID -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty -import org.springframework.stereotype.Component - -@Component -@ConditionalOnProperty(name = ["csm.platform.id-generator.type"], havingValue = "uuid") -internal class UUIDCsmIdGenerator : AbstractCsmIdGenerator() { - - override fun buildId(scope: String) = UUID.randomUUID().toString() -} diff --git a/common/src/test/kotlin/com/cosmotech/common/id/CsmIdGeneratorTests.kt b/common/src/test/kotlin/com/cosmotech/common/id/CsmIdGeneratorTests.kt new file mode 100644 index 000000000..8f8f0d5e3 --- /dev/null +++ b/common/src/test/kotlin/com/cosmotech/common/id/CsmIdGeneratorTests.kt @@ -0,0 +1,56 @@ +// Copyright (c) Cosmo Tech. +// Licensed under the MIT license. +package com.cosmotech.common.id + +import java.lang.IllegalArgumentException +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +class CsmIdGeneratorTests { + @Test + fun `generate with blank scope`() { + assertThrows { generateId("") } + assertThrows { generateId(" ") } + } + + @Test + fun `generate with no prepend prefix`() { + val hashid = generateId("fake_scope") + assertFalse { hashid.isBlank() } + assertTrue { hashid.startsWith("f-", ignoreCase = false) } + assertFalse { hashid.substringAfter("f-", missingDelimiterValue = "").isBlank() } + } + + @Test + fun `generate with custom prepend prefix`() { + val hashid = generateId("test_scope", prependPrefix = "my-custom-prefix-") + assertFalse { hashid.isBlank() } + assertTrue { hashid.startsWith("my-custom-prefix-", ignoreCase = false) } + assertFalse { hashid.substringAfter("my-custom-prefix-").isBlank() } + } + + @Test + fun `2 generations within a same scope do not return the same ID`() { + val hashid1 = generateId("test_scope") + val hashid2 = generateId("test_scope") + assertFalse { hashid1.isBlank() } + assertTrue { hashid1.startsWith("t-", ignoreCase = false) } + assertFalse { hashid2.isBlank() } + assertTrue { hashid2.startsWith("t-", ignoreCase = false) } + assertNotEquals(hashid1, hashid2) + } + + @Test + fun `2 generations within different scopes do not return the same ID`() { + val hashid1 = generateId("test scope") + val hashid2 = generateId("another scope") + assertFalse { hashid1.isBlank() } + assertTrue { hashid1.startsWith("t-", ignoreCase = false) } + assertFalse { hashid2.isBlank() } + assertTrue { hashid2.startsWith("a-", ignoreCase = false) } + assertNotEquals(hashid1, hashid2) + } +} diff --git a/common/src/test/kotlin/com/cosmotech/common/id/hashids/HashidsCsmIdGeneratorTests.kt b/common/src/test/kotlin/com/cosmotech/common/id/hashids/HashidsCsmIdGeneratorTests.kt deleted file mode 100644 index 944ec3323..000000000 --- a/common/src/test/kotlin/com/cosmotech/common/id/hashids/HashidsCsmIdGeneratorTests.kt +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Cosmo Tech. -// Licensed under the MIT license. -package com.cosmotech.common.id.hashids - -import java.lang.IllegalArgumentException -import kotlin.test.assertFalse -import kotlin.test.assertNotEquals -import kotlin.test.assertTrue -import org.hashids.Hashids -import org.junit.jupiter.api.DynamicTest.dynamicTest -import org.junit.jupiter.api.TestFactory -import org.junit.jupiter.api.assertThrows - -private typealias Tester = (hashidGenerator: HashidsCsmIdGenerator) -> Unit - -class HashidsCsmIdGeneratorTests { - - private fun performTestWithDifferentHashidGenerators(tester: Tester) = - mapOf( - "default with current time in nanos" to HashidsCsmIdGenerator(), - "PROD-8703: number higher than the max allowed" to - HashidsCsmIdGenerator { (Hashids.MAX_NUMBER + 100).toULong() }) - .map { (purpose, idGenerator) -> dynamicTest(purpose) { tester(idGenerator) } } - - @TestFactory - fun `generate with blank scope`() = performTestWithDifferentHashidGenerators { - assertThrows { it.generate("") } - assertThrows { it.generate(" ") } - } - - @TestFactory - fun `generate with no prepend prefix`() = performTestWithDifferentHashidGenerators { - val hashid = it.generate("fake_scope") - assertFalse { hashid.isBlank() } - assertTrue { hashid.startsWith("f-", ignoreCase = false) } - assertFalse { hashid.substringAfter("f-", missingDelimiterValue = "").isBlank() } - } - - @TestFactory - fun `generate with custom prepend prefix`() = performTestWithDifferentHashidGenerators { - val hashid = it.generate("test_scope", prependPrefix = "my-custom-prefix-") - assertFalse { hashid.isBlank() } - assertTrue { hashid.startsWith("my-custom-prefix-", ignoreCase = false) } - assertFalse { hashid.substringAfter("my-custom-prefix-").isBlank() } - } - - @TestFactory - fun `2 generations within a same scope do not return the same ID`() = - performTestWithDifferentHashidGenerators { - val hashid1 = it.generate("test_scope") - val hashid2 = it.generate("test_scope") - assertFalse { hashid1.isBlank() } - assertTrue { hashid1.startsWith("t-", ignoreCase = false) } - assertFalse { hashid2.isBlank() } - assertTrue { hashid2.startsWith("t-", ignoreCase = false) } - assertNotEquals(hashid1, hashid2) - } - - @TestFactory - fun `2 generations within different scopes do not return the same ID`() = - performTestWithDifferentHashidGenerators { - val hashid1 = it.generate("test scope") - val hashid2 = it.generate("another scope") - assertFalse { hashid1.isBlank() } - assertTrue { hashid1.startsWith("t-", ignoreCase = false) } - assertFalse { hashid2.isBlank() } - assertTrue { hashid2.startsWith("a-", ignoreCase = false) } - assertNotEquals(hashid1, hashid2) - } -} diff --git a/common/src/test/kotlin/com/cosmotech/common/id/uuid/UUIDCsmIdGeneratorTests.kt b/common/src/test/kotlin/com/cosmotech/common/id/uuid/UUIDCsmIdGeneratorTests.kt deleted file mode 100644 index 84e594446..000000000 --- a/common/src/test/kotlin/com/cosmotech/common/id/uuid/UUIDCsmIdGeneratorTests.kt +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Cosmo Tech. -// Licensed under the MIT license. -package com.cosmotech.common.id.uuid - -import java.lang.IllegalArgumentException -import java.util.UUID -import kotlin.test.BeforeTest -import kotlin.test.Test -import kotlin.test.assertFalse -import kotlin.test.assertNotEquals -import kotlin.test.assertTrue -import org.junit.jupiter.api.assertDoesNotThrow -import org.junit.jupiter.api.assertThrows - -class UUIDCsmIdGeneratorTests { - - private lateinit var uuidCsmIdGenerator: UUIDCsmIdGenerator - - @BeforeTest - fun beforeEachTest() { - this.uuidCsmIdGenerator = UUIDCsmIdGenerator() - } - - @Test - fun `generate with blank scope`() { - assertThrows { this.uuidCsmIdGenerator.generate("") } - assertThrows { this.uuidCsmIdGenerator.generate(" ") } - } - - @Test - fun `generate with no prepend prefix`() { - val uuidId = this.uuidCsmIdGenerator.generate("test_scope") - assertFalse { uuidId.isBlank() } - assertTrue { uuidId.startsWith("t-", ignoreCase = false) } - assertDoesNotThrow { UUID.fromString(uuidId.substringAfter("t-")) } - } - - @Test - fun `generate with custom prepend prefix`() { - val uuidId = this.uuidCsmIdGenerator.generate("test_scope", prependPrefix = "my-custom-prefix-") - assertFalse { uuidId.isBlank() } - assertTrue { uuidId.startsWith("my-custom-prefix-", ignoreCase = false) } - assertDoesNotThrow { UUID.fromString(uuidId.substringAfter("my-custom-prefix-")) } - } - - @Test - fun `2 generations within a same scope do not return the same ID`() { - val uuidId1 = this.uuidCsmIdGenerator.generate("test_scope") - val uuidId2 = this.uuidCsmIdGenerator.generate("test_scope") - assertFalse { uuidId1.isBlank() } - assertTrue { uuidId1.startsWith("t-", ignoreCase = false) } - assertFalse { uuidId2.isBlank() } - assertTrue { uuidId2.startsWith("t-", ignoreCase = false) } - assertNotEquals(uuidId2, uuidId1) - } - - @Test - fun `2 generations within different scopes do not return the same ID`() { - val uuidId1 = this.uuidCsmIdGenerator.generate("test scope") - val uuidId2 = this.uuidCsmIdGenerator.generate("another scope") - assertFalse { uuidId1.isBlank() } - assertTrue { uuidId1.startsWith("t-", ignoreCase = false) } - assertFalse { uuidId2.isBlank() } - assertTrue { uuidId2.startsWith("a-", ignoreCase = false) } - assertNotEquals(uuidId2, uuidId1) - } -} diff --git a/config/application-dev.sample.yml b/config/application-dev.sample.yml index 0e68a66e3..eee90f731 100644 --- a/config/application-dev.sample.yml +++ b/config/application-dev.sample.yml @@ -49,8 +49,6 @@ csm: base-path: / base-url: "[fill-this-value]" # e.g for running it locally http://localhost:8080 version: latest - id-generator: - type: hashid event-publisher: type: in_process allowedTenants: diff --git a/dataset/src/integrationTest/resources/application-dataset-test.yml b/dataset/src/integrationTest/resources/application-dataset-test.yml index 8b4324870..37e6725e4 100644 --- a/dataset/src/integrationTest/resources/application-dataset-test.yml +++ b/dataset/src/integrationTest/resources/application-dataset-test.yml @@ -62,8 +62,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process upload: diff --git a/dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt b/dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt index dca6702d2..0719624b3 100644 --- a/dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt +++ b/dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt @@ -5,6 +5,7 @@ package com.cosmotech.dataset.service import com.cosmotech.common.CsmPhoenixService import com.cosmotech.common.config.DATASET_INPUTS_SCHEMA import com.cosmotech.common.exceptions.CsmResourceNotFoundException +import com.cosmotech.common.id.generateId import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_CREATE_CHILDREN import com.cosmotech.common.rbac.PERMISSION_DELETE @@ -22,10 +23,11 @@ import com.cosmotech.common.utils.findAllPaginated import com.cosmotech.common.utils.getCurrentAccountIdentifier import com.cosmotech.common.utils.sanitizeDatasetPartId import com.cosmotech.dataset.DatasetApiServiceInterface -import com.cosmotech.dataset.domain.CreateInfo import com.cosmotech.dataset.domain.Dataset import com.cosmotech.dataset.domain.DatasetAccessControl +import com.cosmotech.dataset.domain.DatasetCreateInfo import com.cosmotech.dataset.domain.DatasetCreateRequest +import com.cosmotech.dataset.domain.DatasetEditInfo import com.cosmotech.dataset.domain.DatasetPart import com.cosmotech.dataset.domain.DatasetPartCreateRequest import com.cosmotech.dataset.domain.DatasetPartTypeEnum @@ -33,7 +35,6 @@ import com.cosmotech.dataset.domain.DatasetPartUpdateRequest import com.cosmotech.dataset.domain.DatasetRole import com.cosmotech.dataset.domain.DatasetSecurity import com.cosmotech.dataset.domain.DatasetUpdateRequest -import com.cosmotech.dataset.domain.EditInfo import com.cosmotech.dataset.part.factories.DatasetPartManagementFactory import com.cosmotech.dataset.repositories.DatasetPartRepository import com.cosmotech.dataset.repositories.DatasetRepository @@ -144,12 +145,13 @@ class DatasetServiceImpl( logger.debug("Registering Dataset: {}", datasetCreateRequest) validDatasetCreateRequest(datasetCreateRequest, filesUploaded) - val datasetId = idGenerator.generate("dataset") + val datasetId = generateId("dataset") val now = Instant.now().toEpochMilli() val userId = getCurrentAccountIdentifier(csmPlatformProperties) - val editInfo = EditInfo(timestamp = now, userId = userId) + val editInfo = DatasetEditInfo(timestamp = now, userId = userId) val createInfo = - CreateInfo(timestamp = now, userId = userId, runnerId = datasetCreateRequest.runnerId) + DatasetCreateInfo( + timestamp = now, userId = userId, runnerId = datasetCreateRequest.runnerId) val security = csmRbac .initSecurity(datasetCreateRequest.security.toGenericSecurity(datasetId)) @@ -341,7 +343,7 @@ class DatasetServiceImpl( parts = newDatasetParts ?: previousDataset.parts, createInfo = previousDataset.createInfo, updateInfo = - EditInfo( + DatasetEditInfo( timestamp = Instant.now().toEpochMilli(), userId = getCurrentAccountIdentifier(csmPlatformProperties)), security = datasetUpdateRequest.security ?: previousDataset.security) @@ -408,7 +410,7 @@ class DatasetServiceImpl( fun save(dataset: Dataset): Dataset { dataset.updateInfo = - EditInfo( + DatasetEditInfo( timestamp = Instant.now().toEpochMilli(), userId = getCurrentAccountIdentifier(csmPlatformProperties)) return datasetRepository.save(dataset) @@ -455,11 +457,11 @@ class DatasetServiceImpl( logger.debug("Registering DatasetPart: {}", datasetPartCreateRequest) val now = Instant.now().toEpochMilli() val userId = getCurrentAccountIdentifier(csmPlatformProperties) - val editInfo = EditInfo(timestamp = now, userId = userId) + val editInfo = DatasetEditInfo(timestamp = now, userId = userId) val createdDatasetPart = DatasetPart( - id = idGenerator.generate("datasetpart", prependPrefix = "dp-"), + id = generateId("datasetpart", prependPrefix = "dp-"), datasetId = datasetId, name = datasetPartCreateRequest.name, description = datasetPartCreateRequest.description, @@ -802,7 +804,7 @@ class DatasetServiceImpl( } val now = Instant.now().toEpochMilli() val userId = getCurrentAccountIdentifier(csmPlatformProperties) - val editInfo = EditInfo(timestamp = now, userId = userId) + val editInfo = DatasetEditInfo(timestamp = now, userId = userId) dataset.parts .find { it.id == datasetPartId } @@ -847,7 +849,7 @@ class DatasetServiceImpl( val now = Instant.now().toEpochMilli() val userId = getCurrentAccountIdentifier(csmPlatformProperties) - val editInfo = EditInfo(timestamp = now, userId = userId) + val editInfo = DatasetEditInfo(timestamp = now, userId = userId) val datasetPartUpdater = datasetPart.copy() dataset.parts .find { it.id == datasetPartId } diff --git a/dataset/src/main/openapi/dataset.yaml b/dataset/src/main/openapi/dataset.yaml index 400be64e7..c530deeda 100644 --- a/dataset/src/main/openapi/dataset.yaml +++ b/dataset/src/main/openapi/dataset.yaml @@ -807,11 +807,11 @@ components: createInfo: description: The details of the Dataset creation allOf: - - $ref: '#/components/schemas/CreateInfo' + - $ref: '#/components/schemas/DatasetCreateInfo' updateInfo: description: The details of the Dataset last update allOf: - - $ref: '#/components/schemas/EditInfo' + - $ref: '#/components/schemas/DatasetEditInfo' security: x-field-extra-annotation: "@com.redis.om.spring.annotations.Indexed" allOf: @@ -934,11 +934,11 @@ components: createInfo: description: The details of the Dataset creation allOf: - - $ref: '#/components/schemas/EditInfo' + - $ref: '#/components/schemas/DatasetEditInfo' updateInfo: description: The details of the Dataset last update allOf: - - $ref: '#/components/schemas/EditInfo' + - $ref: '#/components/schemas/DatasetEditInfo' required: - id - name @@ -1065,7 +1065,7 @@ components: required: - role - EditInfo: + DatasetEditInfo: type: object properties: timestamp: @@ -1079,7 +1079,7 @@ components: - timestamp - userId - CreateInfo: + DatasetCreateInfo: type: object properties: timestamp: diff --git a/doc/.openapi-generator/FILES b/doc/.openapi-generator/FILES index 73a442bbc..7ed491a91 100644 --- a/doc/.openapi-generator/FILES +++ b/doc/.openapi-generator/FILES @@ -10,11 +10,12 @@ Models/AboutInfoVersion.md Models/ComponentRolePermissions.md Models/ContainerResourceSizeInfo.md Models/ContainerResourceSizing.md -Models/CreateInfo.md Models/CreatedRun.md Models/Dataset.md Models/DatasetAccessControl.md +Models/DatasetCreateInfo.md Models/DatasetCreateRequest.md +Models/DatasetEditInfo.md Models/DatasetPart.md Models/DatasetPartCreateRequest.md Models/DatasetPartTypeEnum.md @@ -22,7 +23,6 @@ Models/DatasetPartUpdateRequest.md Models/DatasetRole.md Models/DatasetSecurity.md Models/DatasetUpdateRequest.md -Models/EditInfo.md Models/LastRunInfo.md Models/Organization.md Models/OrganizationAccessControl.md diff --git a/doc/Models/Dataset.md b/doc/Models/Dataset.md index 50156aad9..b09fd2532 100644 --- a/doc/Models/Dataset.md +++ b/doc/Models/Dataset.md @@ -11,8 +11,8 @@ | **tags** | **List** | the list of tags | [default to null] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | | **parts** | [**List**](DatasetPart.md) | | [default to null] | -| **createInfo** | [**CreateInfo**](CreateInfo.md) | The details of the Dataset creation | [default to null] | -| **updateInfo** | [**EditInfo**](EditInfo.md) | The details of the Dataset last update | [default to null] | +| **createInfo** | [**DatasetCreateInfo**](DatasetCreateInfo.md) | The details of the Dataset creation | [default to null] | +| **updateInfo** | [**DatasetEditInfo**](DatasetEditInfo.md) | The details of the Dataset last update | [default to null] | | **security** | [**DatasetSecurity**](DatasetSecurity.md) | | [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/CreateInfo.md b/doc/Models/DatasetCreateInfo.md similarity index 96% rename from doc/Models/CreateInfo.md rename to doc/Models/DatasetCreateInfo.md index 94d8bac21..6d9fd3805 100644 --- a/doc/Models/CreateInfo.md +++ b/doc/Models/DatasetCreateInfo.md @@ -1,4 +1,4 @@ -# CreateInfo +# DatasetCreateInfo ## Properties | Name | Type | Description | Notes | diff --git a/doc/Models/EditInfo.md b/doc/Models/DatasetEditInfo.md similarity index 96% rename from doc/Models/EditInfo.md rename to doc/Models/DatasetEditInfo.md index 24281841b..7a62a3930 100644 --- a/doc/Models/EditInfo.md +++ b/doc/Models/DatasetEditInfo.md @@ -1,4 +1,4 @@ -# EditInfo +# DatasetEditInfo ## Properties | Name | Type | Description | Notes | diff --git a/doc/Models/DatasetPart.md b/doc/Models/DatasetPart.md index 7ecf3f480..f47966e71 100644 --- a/doc/Models/DatasetPart.md +++ b/doc/Models/DatasetPart.md @@ -13,8 +13,8 @@ | **organizationId** | **String** | the associated Organization Id | [default to null] | | **workspaceId** | **String** | the associated Workspace Id | [default to null] | | **datasetId** | **String** | the associated Dataset Id | [default to null] | -| **createInfo** | [**EditInfo**](EditInfo.md) | The details of the Dataset creation | [default to null] | -| **updateInfo** | [**EditInfo**](EditInfo.md) | The details of the Dataset last update | [default to null] | +| **createInfo** | [**DatasetEditInfo**](DatasetEditInfo.md) | The details of the Dataset creation | [default to null] | +| **updateInfo** | [**DatasetEditInfo**](DatasetEditInfo.md) | The details of the Dataset last update | [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/RunTemplateParameter.md b/doc/Models/RunTemplateParameter.md index 9e68d1c7a..5ee2d4ad5 100644 --- a/doc/Models/RunTemplateParameter.md +++ b/doc/Models/RunTemplateParameter.md @@ -10,7 +10,6 @@ | **defaultValue** | **String** | The default value for this parameter | [optional] [default to null] | | **minValue** | **String** | The minimum value for this parameter | [optional] [default to null] | | **maxValue** | **String** | The maximum value for this parameter | [optional] [default to null] | -| **regexValidation** | **String** | A regex to validate the value | [optional] [default to null] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/RunTemplateParameterCreateRequest.md b/doc/Models/RunTemplateParameterCreateRequest.md index 2ed866ff4..f6122d4bb 100644 --- a/doc/Models/RunTemplateParameterCreateRequest.md +++ b/doc/Models/RunTemplateParameterCreateRequest.md @@ -10,7 +10,6 @@ | **defaultValue** | **String** | The default value for this parameter | [optional] [default to null] | | **minValue** | **String** | The minimum value for this parameter | [optional] [default to null] | | **maxValue** | **String** | The maximum value for this parameter | [optional] [default to null] | -| **regexValidation** | **String** | A regex to validate the value | [optional] [default to null] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/RunTemplateParameterGroup.md b/doc/Models/RunTemplateParameterGroup.md index 725a9ef44..9ec47b8af 100644 --- a/doc/Models/RunTemplateParameterGroup.md +++ b/doc/Models/RunTemplateParameterGroup.md @@ -6,9 +6,7 @@ | **id** | **String** | The Parameter Group id | [default to null] | | **description** | **String** | A description of the parameter group | [optional] [default to null] | | **labels** | **Map** | A translated label with key as ISO 639-1 code | [optional] [default to null] | -| **isTable** | **Boolean** | Does the group define a table | [default to null] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | -| **parentId** | **String** | The Run Template Group parent Id | [optional] [default to null] | | **parameters** | **List** | An ordered list of Run Template Parameters | [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/RunTemplateParameterGroupCreateRequest.md b/doc/Models/RunTemplateParameterGroupCreateRequest.md index 50ae71ac2..e995b41f4 100644 --- a/doc/Models/RunTemplateParameterGroupCreateRequest.md +++ b/doc/Models/RunTemplateParameterGroupCreateRequest.md @@ -6,9 +6,7 @@ | **id** | **String** | The Parameter Group id | [default to null] | | **description** | **String** | A description of the parameter group | [optional] [default to null] | | **labels** | **Map** | A translated label with key as ISO 639-1 code | [optional] [default to null] | -| **isTable** | **Boolean** | Does the group define a table | [optional] [default to false] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | -| **parentId** | **String** | The Run Template Group parent Id | [optional] [default to null] | | **parameters** | **List** | An ordered list of Run Template Parameters | [optional] [default to []] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/RunTemplateParameterGroupUpdateRequest.md b/doc/Models/RunTemplateParameterGroupUpdateRequest.md index 92a238225..d28cc826c 100644 --- a/doc/Models/RunTemplateParameterGroupUpdateRequest.md +++ b/doc/Models/RunTemplateParameterGroupUpdateRequest.md @@ -5,9 +5,7 @@ |------------ | ------------- | ------------- | -------------| | **description** | **String** | A description of the parameter group | [optional] [default to null] | | **labels** | **Map** | A translated label with key as ISO 639-1 code | [optional] [default to null] | -| **isTable** | **Boolean** | Does the group define a table | [optional] [default to null] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | -| **parentId** | **String** | The Run Template Group parent Id | [optional] [default to null] | | **parameters** | **List** | An ordered list of Run Template Parameters | [optional] [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/Models/RunTemplateParameterUpdateRequest.md b/doc/Models/RunTemplateParameterUpdateRequest.md index 44ed0e7ba..7ca52c6a1 100644 --- a/doc/Models/RunTemplateParameterUpdateRequest.md +++ b/doc/Models/RunTemplateParameterUpdateRequest.md @@ -9,7 +9,6 @@ | **defaultValue** | **String** | The default value for this parameter | [optional] [default to null] | | **minValue** | **String** | The minimum value for this parameter | [optional] [default to null] | | **maxValue** | **String** | The maximum value for this parameter | [optional] [default to null] | -| **regexValidation** | **String** | A regex to validate the value | [optional] [default to null] | | **additionalData** | [**Map**](AnyType.md) | Free form additional data | [optional] [default to null] | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/doc/README.md b/doc/README.md index 888448c40..d728008a9 100644 --- a/doc/README.md +++ b/doc/README.md @@ -118,11 +118,12 @@ All URIs are relative to *http://localhost:8080* - [ComponentRolePermissions](./Models/ComponentRolePermissions.md) - [ContainerResourceSizeInfo](./Models/ContainerResourceSizeInfo.md) - [ContainerResourceSizing](./Models/ContainerResourceSizing.md) - - [CreateInfo](./Models/CreateInfo.md) - [CreatedRun](./Models/CreatedRun.md) - [Dataset](./Models/Dataset.md) - [DatasetAccessControl](./Models/DatasetAccessControl.md) + - [DatasetCreateInfo](./Models/DatasetCreateInfo.md) - [DatasetCreateRequest](./Models/DatasetCreateRequest.md) + - [DatasetEditInfo](./Models/DatasetEditInfo.md) - [DatasetPart](./Models/DatasetPart.md) - [DatasetPartCreateRequest](./Models/DatasetPartCreateRequest.md) - [DatasetPartTypeEnum](./Models/DatasetPartTypeEnum.md) @@ -130,7 +131,6 @@ All URIs are relative to *http://localhost:8080* - [DatasetRole](./Models/DatasetRole.md) - [DatasetSecurity](./Models/DatasetSecurity.md) - [DatasetUpdateRequest](./Models/DatasetUpdateRequest.md) - - [EditInfo](./Models/EditInfo.md) - [LastRunInfo](./Models/LastRunInfo.md) - [Organization](./Models/Organization.md) - [OrganizationAccessControl](./Models/OrganizationAccessControl.md) diff --git a/openapi/plantuml/schemas.plantuml b/openapi/plantuml/schemas.plantuml index 3f2d2bb95..2cba114d9 100644 --- a/openapi/plantuml/schemas.plantuml +++ b/openapi/plantuml/schemas.plantuml @@ -31,12 +31,6 @@ entity ContainerResourceSizing { * limits: ContainerResourceSizeInfo } -entity CreateInfo { - * timestamp: Long - * userId: String - runnerId: String -} - entity CreatedRun { * id: String } @@ -50,8 +44,8 @@ entity Dataset { * tags: List additionalData: Map * parts: List - * createInfo: CreateInfo - * updateInfo: EditInfo + * createInfo: DatasetCreateInfo + * updateInfo: DatasetEditInfo * security: DatasetSecurity } @@ -60,6 +54,12 @@ entity DatasetAccessControl { * role: String } +entity DatasetCreateInfo { + * timestamp: Long + * userId: String + runnerId: String +} + entity DatasetCreateRequest { * name: String description: String @@ -70,6 +70,11 @@ entity DatasetCreateRequest { runnerId: String } +entity DatasetEditInfo { + * timestamp: Long + * userId: String +} + entity DatasetPart { * id: String * name: String @@ -81,8 +86,8 @@ entity DatasetPart { * organizationId: String * workspaceId: String * datasetId: String - * createInfo: EditInfo - * updateInfo: EditInfo + * createInfo: DatasetEditInfo + * updateInfo: DatasetEditInfo } entity DatasetPartCreateRequest { @@ -122,11 +127,6 @@ entity DatasetUpdateRequest { security: DatasetSecurity } -entity EditInfo { - * timestamp: Long - * userId: String -} - entity LastRunInfo { lastRunId: String lastRunStatus: String @@ -286,7 +286,6 @@ entity RunTemplateParameter { defaultValue: String minValue: String maxValue: String - regexValidation: String additionalData: Map } @@ -298,7 +297,6 @@ entity RunTemplateParameterCreateRequest { defaultValue: String minValue: String maxValue: String - regexValidation: String additionalData: Map } @@ -306,9 +304,7 @@ entity RunTemplateParameterGroup { * id: String description: String labels: Map - * isTable: Boolean additionalData: Map - parentId: String * parameters: List } @@ -316,18 +312,14 @@ entity RunTemplateParameterGroupCreateRequest { * id: String description: String labels: Map - isTable: Boolean additionalData: Map - parentId: String parameters: List } entity RunTemplateParameterGroupUpdateRequest { description: String labels: Map - isTable: Boolean additionalData: Map - parentId: String parameters: List } @@ -338,7 +330,6 @@ entity RunTemplateParameterUpdateRequest { defaultValue: String minValue: String maxValue: String - regexValidation: String additionalData: Map } @@ -639,8 +630,8 @@ RunTemplateCreateRequest -- RunTemplateResourceSizing : runSizing RunnerSecurity -- "0..*" RunnerAccessControl : accessControlList RunStatusNode -- RunResourceRequested : resourcesDuration WorkspaceUpdateRequest -- WorkspaceSolution : solution -DatasetPart -- EditInfo : createInfo -DatasetPart -- EditInfo : updateInfo +DatasetPart -- DatasetEditInfo : createInfo +DatasetPart -- DatasetEditInfo : updateInfo Solution -- SolutionEditInfo : createInfo Solution -- SolutionEditInfo : updateInfo Solution -- "0..*" RunTemplateParameter : parameters @@ -648,8 +639,8 @@ Solution -- "0..*" RunTemplateParameterGroup : parameterGroups Solution -- "0..*" RunTemplate : runTemplates Solution -- SolutionSecurity : security Dataset -- "0..*" DatasetPart : parts -Dataset -- CreateInfo : createInfo -Dataset -- EditInfo : updateInfo +Dataset -- DatasetCreateInfo : createInfo +Dataset -- DatasetEditInfo : updateInfo Dataset -- DatasetSecurity : security Run -- RunEditInfo : createInfo Run -- "0..*" RunTemplateParameterValue : parametersValues diff --git a/organization/src/integrationTest/resources/application-organization-test.yml b/organization/src/integrationTest/resources/application-organization-test.yml index af83d50be..3b6adf9db 100644 --- a/organization/src/integrationTest/resources/application-organization-test.yml +++ b/organization/src/integrationTest/resources/application-organization-test.yml @@ -58,8 +58,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process images: diff --git a/organization/src/main/kotlin/com/cosmotech/organization/service/OrganizationServiceImpl.kt b/organization/src/main/kotlin/com/cosmotech/organization/service/OrganizationServiceImpl.kt index 0c8438456..b131912f7 100644 --- a/organization/src/main/kotlin/com/cosmotech/organization/service/OrganizationServiceImpl.kt +++ b/organization/src/main/kotlin/com/cosmotech/organization/service/OrganizationServiceImpl.kt @@ -5,6 +5,7 @@ package com.cosmotech.organization.service import com.cosmotech.common.CsmPhoenixService import com.cosmotech.common.events.OrganizationUnregistered import com.cosmotech.common.exceptions.CsmResourceNotFoundException +import com.cosmotech.common.id.generateId import com.cosmotech.common.rbac.CsmAdmin import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_DELETE @@ -86,7 +87,7 @@ class OrganizationServiceImpl( "Organization name must not be null or blank" } - val organizationId = idGenerator.generate("organization") + val organizationId = generateId("organization") val now = Instant.now().toEpochMilli() val security = csmRbac diff --git a/organization/src/test/kotlin/com/cosmotech/organization/service/OrganizationServiceImplTests.kt b/organization/src/test/kotlin/com/cosmotech/organization/service/OrganizationServiceImplTests.kt index af5babb80..1127e900a 100644 --- a/organization/src/test/kotlin/com/cosmotech/organization/service/OrganizationServiceImplTests.kt +++ b/organization/src/test/kotlin/com/cosmotech/organization/service/OrganizationServiceImplTests.kt @@ -6,7 +6,6 @@ import com.cosmotech.common.config.CsmPlatformProperties import com.cosmotech.common.events.CsmEventPublisher import com.cosmotech.common.exceptions.CsmAccessForbiddenException import com.cosmotech.common.exceptions.CsmResourceNotFoundException -import com.cosmotech.common.id.CsmIdGenerator import com.cosmotech.common.rbac.CsmAdmin import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.ROLE_ADMIN @@ -52,7 +51,6 @@ const val USER_ID = "bob@mycompany.com" class OrganizationServiceImplTests { @Suppress("unused") @MockK private var eventPublisher: CsmEventPublisher = mockk(relaxed = true) - @Suppress("unused") @MockK private var idGenerator: CsmIdGenerator = mockk(relaxed = true) @Suppress("unused") @MockK diff --git a/run/src/integrationTest/resources/application-run-test.yml b/run/src/integrationTest/resources/application-run-test.yml index 0855ea3e7..753f0f57b 100644 --- a/run/src/integrationTest/resources/application-run-test.yml +++ b/run/src/integrationTest/resources/application-run-test.yml @@ -64,8 +64,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process images: diff --git a/run/src/main/kotlin/com/cosmotech/run/service/RunServiceImpl.kt b/run/src/main/kotlin/com/cosmotech/run/service/RunServiceImpl.kt index e1ae431aa..009711592 100644 --- a/run/src/main/kotlin/com/cosmotech/run/service/RunServiceImpl.kt +++ b/run/src/main/kotlin/com/cosmotech/run/service/RunServiceImpl.kt @@ -8,6 +8,7 @@ import com.cosmotech.common.events.RunStart import com.cosmotech.common.events.RunStop import com.cosmotech.common.events.RunnerDeleted import com.cosmotech.common.events.UpdateRunnerStatus +import com.cosmotech.common.id.generateId import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_DELETE import com.cosmotech.common.rbac.PERMISSION_READ @@ -221,7 +222,7 @@ class RunServiceImpl( @EventListener(RunStart::class) fun onRunStart(runStartRequest: RunStart) { val runner = runStartRequest.runnerData as Runner - val runId = idGenerator.generate("run", prependPrefix = "run-") + val runId = generateId("run", prependPrefix = "run-") val startInfo = containerFactory.getStartInfo( diff --git a/run/src/test/kotlin/com/cosmotech/run/ContainerFactoryTests.kt b/run/src/test/kotlin/com/cosmotech/run/ContainerFactoryTests.kt index 0c5303b76..0510367d8 100644 --- a/run/src/test/kotlin/com/cosmotech/run/ContainerFactoryTests.kt +++ b/run/src/test/kotlin/com/cosmotech/run/ContainerFactoryTests.kt @@ -235,8 +235,7 @@ class ContainerFactoryTests { parameters = mutableListOf(RunTemplateParameter("parameter", "string")), parameterGroups = mutableListOf( - RunTemplateParameterGroup( - id = "parameter", isTable = false, parameters = mutableListOf())), + RunTemplateParameterGroup(id = "parameter", parameters = mutableListOf())), organizationId = "Organizationid", security = SolutionSecurity(ROLE_ADMIN, mutableListOf()), ) diff --git a/runner/src/integrationTest/resources/application-runner-test.yml b/runner/src/integrationTest/resources/application-runner-test.yml index 77504c795..05cafa246 100644 --- a/runner/src/integrationTest/resources/application-runner-test.yml +++ b/runner/src/integrationTest/resources/application-runner-test.yml @@ -58,8 +58,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process upload: diff --git a/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt b/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt index 6985b0367..0fefe0511 100644 --- a/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt +++ b/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt @@ -10,6 +10,7 @@ import com.cosmotech.common.events.RunnerDeleted import com.cosmotech.common.events.UpdateRunnerStatus import com.cosmotech.common.exceptions.CsmClientException import com.cosmotech.common.exceptions.CsmResourceNotFoundException +import com.cosmotech.common.id.generateId import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_READ import com.cosmotech.common.rbac.PERMISSION_READ_SECURITY @@ -256,7 +257,7 @@ class RunnerService( val now = Instant.now().toEpochMilli() this.runner = Runner( - id = idGenerator.generate("runner"), + id = generateId("runner"), name = "init", createInfo = RunnerEditInfo( diff --git a/solution/src/integrationTest/kotlin/com/cosmotech/solution/service/SolutionServiceIntegrationTest.kt b/solution/src/integrationTest/kotlin/com/cosmotech/solution/service/SolutionServiceIntegrationTest.kt index 9ab9f7547..0072e6a54 100644 --- a/solution/src/integrationTest/kotlin/com/cosmotech/solution/service/SolutionServiceIntegrationTest.kt +++ b/solution/src/integrationTest/kotlin/com/cosmotech/solution/service/SolutionServiceIntegrationTest.kt @@ -337,7 +337,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "0", minValue = "0", maxValue = "100", - regexValidation = "\\d", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0)), @@ -347,7 +346,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)))) @@ -364,7 +362,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("0", firstParam.defaultValue) assertEquals("0", firstParam.minValue) assertEquals("100", firstParam.maxValue) - assertEquals("\\d", firstParam.regexValidation) assertEquals("this_is_a_description", firstParam.description) assertEquals(mutableMapOf("fr" to "this_is_a_label"), firstParam.labels) assertEquals(2, firstParam.additionalData?.size) @@ -376,7 +373,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("5", secondParam.defaultValue) assertEquals("0", secondParam.minValue) assertEquals("1000", secondParam.maxValue) - assertEquals("\\d", secondParam.regexValidation) assertEquals("this_is_a_description2", secondParam.description) assertEquals(mutableMapOf("fr" to "this_is_a_label2"), secondParam.labels) assertEquals(2, secondParam.additionalData?.size) @@ -397,7 +393,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "0", minValue = "0", maxValue = "100", - regexValidation = "\\d", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0)), @@ -407,7 +402,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)))) @@ -425,7 +419,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("0", solutionParameter.defaultValue) assertEquals("0", solutionParameter.minValue) assertEquals("100", solutionParameter.maxValue) - assertEquals("\\d", solutionParameter.regexValidation) assertEquals("this_is_a_description", solutionParameter.description) assertEquals(mutableMapOf("fr" to "this_is_a_label"), solutionParameter.labels) assertEquals(2, solutionParameter.additionalData?.size) @@ -458,7 +451,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "0", minValue = "0", maxValue = "100", - regexValidation = "\\d", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0)), @@ -468,7 +460,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)))) @@ -487,7 +478,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "", minValue = "", maxValue = "", - regexValidation = "\\w", description = "new_this_is_a_description2", labels = mutableMapOf("en" to "new_this_is_a_label2"), additionalData = mutableMapOf("option1" to "newValue1"))) @@ -497,7 +487,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("", solutionParameter.defaultValue) assertEquals("", solutionParameter.minValue) assertEquals("", solutionParameter.maxValue) - assertEquals("\\w", solutionParameter.regexValidation) assertEquals("new_this_is_a_description2", solutionParameter.description) assertEquals(mutableMapOf("en" to "new_this_is_a_label2"), solutionParameter.labels) assertEquals(1, solutionParameter.additionalData?.size) @@ -533,7 +522,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "0", minValue = "0", maxValue = "100", - regexValidation = "\\d", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0)), @@ -543,7 +531,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)))) @@ -610,7 +597,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)) @@ -629,7 +615,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("5", newParam.defaultValue) assertEquals("0", newParam.minValue) assertEquals("1000", newParam.maxValue) - assertEquals("\\d", newParam.regexValidation) assertEquals("this_is_a_description2", newParam.description) assertEquals(mutableMapOf("fr" to "this_is_a_label2"), newParam.labels) assertEquals("value1", newParam.additionalData?.get("option1")) @@ -645,7 +630,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)) @@ -679,7 +663,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8)), @@ -689,7 +672,6 @@ class SolutionServiceIntegrationTest : CsmTestBase() { defaultValue = "5", minValue = "0", maxValue = "1000", - regexValidation = "\\d", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), additionalData = mutableMapOf("option1" to "value1", "option2" to 100.8))) @@ -1339,17 +1321,13 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "parameterGroupId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")), RunTemplateParameterGroupCreateRequest( id = "parameterGroupId2", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), - isTable = true, additionalData = mutableMapOf("option2" to "value2", "option3" to 20.0), - parentId = "this_is_a_parent_id2", parameters = mutableListOf("parameterId3", "parameterId4")))) val newSolution = @@ -1362,19 +1340,15 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("parameterGroupId", firstParamGroup.id) assertEquals("this_is_a_description", firstParamGroup.description) assertEquals(mutableMapOf("fr" to "this_is_a_label"), firstParamGroup.labels) - assertFalse(firstParamGroup.isTable) assertEquals("value1", firstParamGroup.additionalData?.get("option1")) assertEquals(10.0, firstParamGroup.additionalData?.get("option2")) - assertEquals("this_is_a_parent_id", firstParamGroup.parentId) assertEquals(mutableListOf("parameterId1", "parameterId2"), firstParamGroup.parameters) val secondParamGroup = parameterGroupList[1] assertEquals("parameterGroupId2", secondParamGroup.id) assertEquals("this_is_a_description2", secondParamGroup.description) assertEquals(mutableMapOf("fr" to "this_is_a_label2"), secondParamGroup.labels) - assertTrue(secondParamGroup.isTable) assertEquals("value2", secondParamGroup.additionalData?.get("option2")) assertEquals(20.0, secondParamGroup.additionalData?.get("option3")) - assertEquals("this_is_a_parent_id2", secondParamGroup.parentId) assertEquals(mutableListOf("parameterId3", "parameterId4"), secondParamGroup.parameters) } @@ -1389,17 +1363,13 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "parameterGroupId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")), RunTemplateParameterGroupCreateRequest( id = "parameterGroupId2", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), - isTable = true, additionalData = mutableMapOf("option2" to "value2", "option3" to 20.0), - parentId = "this_is_a_parent_id2", parameters = mutableListOf("parameterId3", "parameterId4")))) val newSolution = @@ -1413,11 +1383,9 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("parameterGroupId", solutionParameterGroup.id) assertEquals("this_is_a_description", solutionParameterGroup.description) assertEquals(mutableMapOf("fr" to "this_is_a_label"), solutionParameterGroup.labels) - assertFalse(solutionParameterGroup.isTable) assertEquals(2, solutionParameterGroup.additionalData?.size) assertEquals("value1", solutionParameterGroup.additionalData?.get("option1")) assertEquals(10.0, solutionParameterGroup.additionalData?.get("option2")) - assertEquals("this_is_a_parent_id", solutionParameterGroup.parentId) assertEquals(mutableListOf("parameterId1", "parameterId2"), solutionParameterGroup.parameters) } @@ -1444,17 +1412,13 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "parameterGroupId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")), RunTemplateParameterGroupCreateRequest( id = "parameterGroupId2", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), - isTable = true, additionalData = mutableMapOf("option2" to "value2", "option3" to 20.0), - parentId = "this_is_a_parent_id2", parameters = mutableListOf("parameterId3", "parameterId4")))) val newSolution = @@ -1469,18 +1433,14 @@ class SolutionServiceIntegrationTest : CsmTestBase() { RunTemplateParameterGroupUpdateRequest( description = "this_is_a_description3", labels = mutableMapOf("fr" to "this_is_a_label3"), - isTable = true, additionalData = mutableMapOf("option3" to "value1"), - parentId = "this_is_a_parent_id3", parameters = mutableListOf("parameterId13", "parameterId23"))) assertNotNull(solutionParameterGroup) assertEquals(parameterGroupId, solutionParameterGroup.id) assertEquals("this_is_a_description3", solutionParameterGroup.description) assertEquals(mutableMapOf("fr" to "this_is_a_label3"), solutionParameterGroup.labels) - assertTrue(solutionParameterGroup.isTable) assertEquals(1, solutionParameterGroup.additionalData?.size) assertEquals("value1", solutionParameterGroup.additionalData?.get("option3")) - assertEquals("this_is_a_parent_id3", solutionParameterGroup.parentId) assertEquals(mutableListOf("parameterId13", "parameterId23"), solutionParameterGroup.parameters) } @@ -1511,17 +1471,13 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "parameterGroupId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")), RunTemplateParameterGroupCreateRequest( id = "parameterGroupId2", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), - isTable = true, additionalData = mutableMapOf("option2" to "value2", "option3" to 20.0), - parentId = "this_is_a_parent_id2", parameters = mutableListOf("parameterId3", "parameterId4")))) val newSolution = @@ -1583,9 +1539,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "parameterGroupId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")) solutionApiService.createSolutionParameterGroup( @@ -1600,11 +1554,9 @@ class SolutionServiceIntegrationTest : CsmTestBase() { assertEquals("parameterGroupId", newParamGroup.id) assertEquals("this_is_a_description", newParamGroup.description) assertEquals(mutableMapOf("fr" to "this_is_a_label"), newParamGroup.labels) - assertFalse(newParamGroup.isTable) assertEquals(2, newParamGroup.additionalData?.size) assertEquals("value1", newParamGroup.additionalData?.get("option1")) assertEquals(10.0, newParamGroup.additionalData?.get("option2")) - assertEquals("this_is_a_parent_id", newParamGroup.parentId) assertEquals(mutableListOf("parameterId1", "parameterId2"), newParamGroup.parameters) } @@ -1615,9 +1567,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "parameterGroupId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")) val newSolutionWithParameterGroup = @@ -1648,17 +1598,13 @@ class SolutionServiceIntegrationTest : CsmTestBase() { id = "PaRamEtErGrOuPId", description = "this_is_a_description", labels = mutableMapOf("fr" to "this_is_a_label"), - isTable = false, additionalData = mutableMapOf("option1" to "value1", "option2" to 10.0), - parentId = "this_is_a_parent_id", parameters = mutableListOf("parameterId1", "parameterId2")), RunTemplateParameterGroupCreateRequest( id = "pArAmEtErGrOuPId", description = "this_is_a_description2", labels = mutableMapOf("fr" to "this_is_a_label2"), - isTable = true, additionalData = mutableMapOf("option2" to "value2", "option3" to 20.0), - parentId = "this_is_a_parent_id2", parameters = mutableListOf("parameterId3", "parameterId4")))) val exception = diff --git a/solution/src/integrationTest/resources/application-solution-test.yml b/solution/src/integrationTest/resources/application-solution-test.yml index e772ee3c5..37ce6565d 100644 --- a/solution/src/integrationTest/resources/application-solution-test.yml +++ b/solution/src/integrationTest/resources/application-solution-test.yml @@ -58,8 +58,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process upload: diff --git a/solution/src/main/kotlin/com/cosmotech/solution/service/SolutionServiceImpl.kt b/solution/src/main/kotlin/com/cosmotech/solution/service/SolutionServiceImpl.kt index 9a4788169..579304f29 100644 --- a/solution/src/main/kotlin/com/cosmotech/solution/service/SolutionServiceImpl.kt +++ b/solution/src/main/kotlin/com/cosmotech/solution/service/SolutionServiceImpl.kt @@ -6,6 +6,7 @@ import com.cosmotech.common.CsmPhoenixService import com.cosmotech.common.containerregistry.ContainerRegistryService import com.cosmotech.common.events.OrganizationUnregistered import com.cosmotech.common.exceptions.CsmResourceNotFoundException +import com.cosmotech.common.id.generateId import com.cosmotech.common.rbac.CsmAdmin import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_CREATE_CHILDREN @@ -114,7 +115,7 @@ class SolutionServiceImpl( ): Solution { organizationApiService.getVerifiedOrganization(organizationId, PERMISSION_CREATE_CHILDREN) - val solutionId = idGenerator.generate("solution", prependPrefix = "sol-") + val solutionId = generateId("solution", prependPrefix = "sol-") val now = Instant.now().toEpochMilli() val security = csmRbac @@ -426,10 +427,8 @@ class SolutionServiceImpl( ?.apply { description = runTemplateParameterGroupUpdateRequest.description ?: this.description labels = runTemplateParameterGroupUpdateRequest.labels ?: this.labels - isTable = runTemplateParameterGroupUpdateRequest.isTable ?: this.isTable additionalData = runTemplateParameterGroupUpdateRequest.additionalData ?: this.additionalData - parentId = runTemplateParameterGroupUpdateRequest.parentId ?: this.parentId parameters = runTemplateParameterGroupUpdateRequest.parameters ?: this.parameters } ?: throw CsmResourceNotFoundException( @@ -507,8 +506,6 @@ class SolutionServiceImpl( defaultValue = runTemplateParameterUpdateRequest.defaultValue ?: this.defaultValue minValue = runTemplateParameterUpdateRequest.minValue ?: this.minValue maxValue = runTemplateParameterUpdateRequest.maxValue ?: this.maxValue - regexValidation = - runTemplateParameterUpdateRequest.regexValidation ?: this.regexValidation additionalData = runTemplateParameterUpdateRequest.additionalData ?: this.additionalData } ?: throw CsmResourceNotFoundException( @@ -639,7 +636,6 @@ class SolutionServiceImpl( defaultValue = runTemplateParameterCreateRequest.defaultValue, minValue = runTemplateParameterCreateRequest.minValue, maxValue = runTemplateParameterCreateRequest.maxValue, - regexValidation = runTemplateParameterCreateRequest.regexValidation, additionalData = runTemplateParameterCreateRequest.additionalData) } @@ -650,9 +646,7 @@ class SolutionServiceImpl( id = runTemplateParameterGroupCreateRequest.id, description = runTemplateParameterGroupCreateRequest.description, labels = runTemplateParameterGroupCreateRequest.labels, - isTable = runTemplateParameterGroupCreateRequest.isTable!!, additionalData = runTemplateParameterGroupCreateRequest.additionalData, - parentId = runTemplateParameterGroupCreateRequest.parentId, parameters = runTemplateParameterGroupCreateRequest.parameters!!) } diff --git a/solution/src/main/openapi/solution.yaml b/solution/src/main/openapi/solution.yaml index 534dc34eb..3278cfc75 100644 --- a/solution/src/main/openapi/solution.yaml +++ b/solution/src/main/openapi/solution.yaml @@ -1253,16 +1253,10 @@ components: description: A description of the parameter group labels: $ref: '#/components/schemas/TranslatedLabels' - isTable: - type: boolean - description: Does the group define a table additionalData: type: object description: Free form additional data additionalProperties: true - parentId: - type: string - description: The Run Template Group parent Id parameters: type: array description: An ordered list of Run Template Parameters @@ -1271,7 +1265,6 @@ components: description: A Run Template Parameter id required: - id - - isTable - parameters RunTemplateParameterGroupCreateRequest: @@ -1288,17 +1281,10 @@ components: description: A description of the parameter group labels: $ref: '#/components/schemas/TranslatedLabels' - isTable: - type: boolean - default: false - description: Does the group define a table additionalData: type: object description: Free form additional data additionalProperties: true - parentId: - type: string - description: The Run Template Group parent Id parameters: type: array description: An ordered list of Run Template Parameters @@ -1318,16 +1304,10 @@ components: description: A description of the parameter group labels: $ref: '#/components/schemas/TranslatedLabels' - isTable: - type: boolean - description: Does the group define a table additionalData: type: object description: Free form additional data additionalProperties: true - parentId: - type: string - description: The Run Template Group parent Id parameters: type: array description: An ordered list of Run Template Parameters @@ -1363,9 +1343,6 @@ components: maxValue: type: string description: The maximum value for this parameter - regexValidation: - type: string - description: A regex to validate the value additionalData: type: object description: Free form additional data @@ -1401,9 +1378,6 @@ components: maxValue: type: string description: The maximum value for this parameter - regexValidation: - type: string - description: A regex to validate the value additionalData: type: object description: Free form additional data @@ -1434,9 +1408,6 @@ components: maxValue: type: string description: The maximum value for this parameter - regexValidation: - type: string - description: A regex to validate the value additionalData: type: object description: Free form additional data diff --git a/workspace/src/integrationTest/resources/application-workspace-test.yml b/workspace/src/integrationTest/resources/application-workspace-test.yml index 4f7f8ccbf..b64c8d913 100644 --- a/workspace/src/integrationTest/resources/application-workspace-test.yml +++ b/workspace/src/integrationTest/resources/application-workspace-test.yml @@ -62,8 +62,6 @@ csm: base-path: / base-url: "http://fake_url:8080" version: latest - id-generator: - type: hashid event-publisher: type: in_process images: diff --git a/workspace/src/main/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImpl.kt b/workspace/src/main/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImpl.kt index ccc1fd3c0..aa0aa72b6 100644 --- a/workspace/src/main/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImpl.kt +++ b/workspace/src/main/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImpl.kt @@ -7,6 +7,7 @@ import com.cosmotech.common.CsmPhoenixService import com.cosmotech.common.events.OrganizationUnregistered import com.cosmotech.common.events.WorkspaceDeleted import com.cosmotech.common.exceptions.CsmResourceNotFoundException +import com.cosmotech.common.id.generateId import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_CREATE_CHILDREN import com.cosmotech.common.rbac.PERMISSION_DELETE @@ -123,7 +124,7 @@ internal class WorkspaceServiceImpl( solutionService.getSolution(organizationId, it) } - val workspaceId = idGenerator.generate("workspace") + val workspaceId = generateId("workspace") val now = Instant.now().toEpochMilli() val security = csmRbac diff --git a/workspace/src/test/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImplTests.kt b/workspace/src/test/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImplTests.kt index cce43e05f..932a125f1 100644 --- a/workspace/src/test/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImplTests.kt +++ b/workspace/src/test/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImplTests.kt @@ -6,7 +6,6 @@ import com.cosmotech.common.config.CsmPlatformProperties import com.cosmotech.common.events.CsmEventPublisher import com.cosmotech.common.exceptions.CsmAccessForbiddenException import com.cosmotech.common.exceptions.CsmResourceNotFoundException -import com.cosmotech.common.id.CsmIdGenerator import com.cosmotech.common.rbac.CsmAdmin import com.cosmotech.common.rbac.CsmRbac import com.cosmotech.common.rbac.PERMISSION_CREATE_CHILDREN @@ -90,7 +89,6 @@ class WorkspaceServiceImplTests { @RelaxedMockK private lateinit var workspaceFile: MultipartFile @Suppress("unused") @MockK private var eventPublisher: CsmEventPublisher = mockk(relaxed = true) - @Suppress("unused") @MockK private var idGenerator: CsmIdGenerator = mockk(relaxed = true) @Suppress("unused") @MockK @@ -637,9 +635,7 @@ class WorkspaceServiceImplTests { repository = "repository", parameters = mutableListOf(RunTemplateParameter("parameter", "string")), parameterGroups = - mutableListOf( - RunTemplateParameterGroup( - id = "group", isTable = false, parameters = mutableListOf())), + mutableListOf(RunTemplateParameterGroup(id = "group", parameters = mutableListOf())), runTemplates = mutableListOf(RunTemplate(id = "template", parameterGroups = mutableListOf())), security =