diff --git a/.changelog/195.txt b/.changelog/195.txt new file mode 100644 index 00000000..d7129e0d --- /dev/null +++ b/.changelog/195.txt @@ -0,0 +1,3 @@ +```release-note:note +Added `terraform import` documentation to all applicable resources. +``` \ No newline at end of file diff --git a/.changelog/196.txt b/.changelog/196.txt new file mode 100644 index 00000000..360211e0 --- /dev/null +++ b/.changelog/196.txt @@ -0,0 +1,15 @@ +```release-note:bug +`resource/davinci_variable`: Fixed error when attempting to import resource state. +``` + +```release-note:bug +`resource/davinci_application`: Fixed error when attempting to import resource state. +``` + +```release-note:bug +`resource/davinci_flow`: Fixed error when attempting to import resource state. +``` + +```release-note:bug +`resource/davinci_connection`: Fixed error when attempting to import resource state. +``` diff --git a/docs/resources/application.md b/docs/resources/application.md index 8f8dd4b6..07c6c77a 100644 --- a/docs/resources/application.md +++ b/docs/resources/application.md @@ -180,3 +180,10 @@ Optional: - `update_body_message` (String) This is deprecated in the UI and will be removed in a future release. - `update_message` (String) This is deprecated in the UI and will be removed in a future release. +## Import + +Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `` should be replaced with the ID of the environment to import from. + +```shell +$ terraform import davinci_application.example / +``` \ No newline at end of file diff --git a/docs/resources/connection.md b/docs/resources/connection.md index 95bd9541..724dba73 100644 --- a/docs/resources/connection.md +++ b/docs/resources/connection.md @@ -68,7 +68,13 @@ Optional: - `type` (String) Type of the property. This is used to cast the value to the correct type. Must be: string or boolean. Use 'string' for array +## Import +Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `` should be replaced with the ID of the environment to import from. + +```shell +$ terraform import davinci_connection.example / +``` ## DaVinci Connection Definitions diff --git a/docs/resources/flow.md b/docs/resources/flow.md index b7ad3969..280642de 100644 --- a/docs/resources/flow.md +++ b/docs/resources/flow.md @@ -120,3 +120,10 @@ Read-Only: - `name` (String) - `type` (String) +## Import + +Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `` should be replaced with the ID of the environment to import from. + +```shell +$ terraform import davinci_flow.example / +``` \ No newline at end of file diff --git a/docs/resources/variable.md b/docs/resources/variable.md index 3ccca0e1..c09609de 100644 --- a/docs/resources/variable.md +++ b/docs/resources/variable.md @@ -44,3 +44,10 @@ resource "davinci_variable" "my_global_var" { - `id` (String) The ID of this resource. +## Import + +Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `` should be replaced with the ID of the environment to import from. + +```shell +$ terraform import davinci_variable.example / +``` \ No newline at end of file diff --git a/examples/resources/davinci_application/import.sh b/examples/resources/davinci_application/import.sh new file mode 100644 index 00000000..18f4a863 --- /dev/null +++ b/examples/resources/davinci_application/import.sh @@ -0,0 +1 @@ +$ terraform import davinci_application.example / \ No newline at end of file diff --git a/examples/resources/davinci_connection/import.sh b/examples/resources/davinci_connection/import.sh new file mode 100644 index 00000000..db986f1d --- /dev/null +++ b/examples/resources/davinci_connection/import.sh @@ -0,0 +1 @@ +$ terraform import davinci_connection.example / \ No newline at end of file diff --git a/examples/resources/davinci_flow/import.sh b/examples/resources/davinci_flow/import.sh new file mode 100644 index 00000000..31767026 --- /dev/null +++ b/examples/resources/davinci_flow/import.sh @@ -0,0 +1 @@ +$ terraform import davinci_flow.example / \ No newline at end of file diff --git a/examples/resources/davinci_variable/import.sh b/examples/resources/davinci_variable/import.sh new file mode 100644 index 00000000..5a7a12b0 --- /dev/null +++ b/examples/resources/davinci_variable/import.sh @@ -0,0 +1 @@ +$ terraform import davinci_variable.example / \ No newline at end of file diff --git a/internal/acctest/flows/p1sessionsubflow.json b/internal/acctest/flows/p1sessionsubflow.json index bbbf8134..567d99a9 100644 --- a/internal/acctest/flows/p1sessionsubflow.json +++ b/internal/acctest/flows/p1sessionsubflow.json @@ -49,8 +49,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -166,8 +166,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -1010,8 +1010,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -2651,7 +2651,7 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", + "name": "Error Message", "label": "errorConnector", "status": "configured", "capabilityName": "customErrorMessage", @@ -2887,7 +2887,7 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", + "name": "Error Message", "label": "errorConnector", "status": "configured", "capabilityName": "customErrorMessage", @@ -4409,8 +4409,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -4592,8 +4592,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -5243,8 +5243,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -5292,8 +5292,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", @@ -5492,8 +5492,8 @@ "nodeType": "CONNECTION", "connectionId": "6d8f6f706c45fd459a86b3f092602544", "connectorId": "errorConnector", - "name": "Error Customize", - "label": "Error Customize", + "name": "Error Message", + "label": "Error Message", "status": "configured", "capabilityName": "customErrorMessage", "type": "action", diff --git a/internal/acctest/testdata.go b/internal/acctest/testdata.go index bb6c12f0..66960e0e 100644 --- a/internal/acctest/testdata.go +++ b/internal/acctest/testdata.go @@ -113,8 +113,13 @@ var bsConnections = map[string]flowConnection{ }, "errorcustomize": { ConnectorId: "errorConnector", - Name: "Error Customize", - Id: "6d8f6f706c45fd459a86b3f092602544", + Name: "Error Message", + Id: "53ab83a4a4ab919d9f2cb02d9e111ac8", + }, + "flow": { + ConnectorId: "flowConnector", + Name: "Flow Connector", + Id: "2581eb287bb1d9bd29ae9886d675f89f", }, "functions": { ConnectorId: "functionsConnector", @@ -126,6 +131,11 @@ var bsConnections = map[string]flowConnection{ Name: "Http", Id: "867ed4363b2bc21c860085ad2baa817d", }, + "node": { + ConnectorId: "nodeConnector", + Name: "Node", + Id: "e7eae662d2ca276e4c6f097fc36a3bb1", + }, "pingid": { ConnectorId: "pingIdConnector", Name: "PingID", @@ -136,6 +146,11 @@ var bsConnections = map[string]flowConnection{ Name: "PingOne Notifications", Id: "cacf3d2861657174d93cbf445d55797a", }, + "pingoneauthentication": { + ConnectorId: "pingOneAuthenticationConnector", + Name: "PingOne Authentication", + Id: "c3e6a164bde107954e93f5c09f0c8bce", + }, "pingonemfa": { ConnectorId: "pingOneMfaConnector", Name: "PingOne MFA", @@ -148,8 +163,8 @@ var bsConnections = map[string]flowConnection{ }, "pingonerisk": { ConnectorId: "pingOneRiskConnector", - Name: "PingOne Risk", - Id: "4c653c375e07bdf8614406113f998666", + Name: "PingOne Protect", + Id: "292873d5ceea806d81373ed0341b5c88", }, "skopenid": { ConnectorId: "skOpenIdConnector", @@ -187,7 +202,7 @@ func getFlowJsons(resourceName string) TestFlowsJson { AnotherMainflow: fmt.Sprintf(`"{\"companyId\":\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\",\"authTokenExpireIds\":[],\"connectorIds\":[\"httpConnector\",\"flowConnector\"],\"createdDate\":1670454819423,\"currentVersion\":2,\"customerId\":\"ee728871d18a3b9b273c87192cee4a18\",\"deployedDate\":1670454822120,\"description\":\"\",\"flowStatus\":\"enabled\",\"name\":\"AnotherMainflow-%[1]s\",\"orx\":\"{\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"94e1b4a6a39ad267434d750a964f2f44\\\",\\\"flowVersionId\\\":2,\\\"version\\\":\\\"4.0.0\\\",\\\"states\\\":[\\\"initialize\\\",\\\"start_0\\\",\\\"inside_0\\\",\\\"end_0\\\"],\\\"currentState\\\":[\\\"initialize\\\"],\\\"transitions\\\":[{\\\"from\\\":[\\\"initialize\\\"],\\\"to\\\":\\\"start_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"initializeFlow\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Http\\\",\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"94e1b4a6a39ad267434d750a964f2f44\\\",\\\"flowVersionId\\\":2,\\\"id\\\":\\\"4xlw7ugv6z\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"customHtmlMessage\\\",\\\"properties\\\":{\\\"message\\\":{\\\"value\\\":\\\"Hello from AnotherMainflow\\\"},\\\"showContinueButton\\\":{\\\"value\\\":true}},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[\\\"global.error\\\"],\\\"respondToUser\\\":true,\\\"transitionId\\\":0,\\\"signalId\\\":0}],\\\"transitionId\\\":0},{\\\"from\\\":[\\\"start_0\\\"],\\\"to\\\":\\\"inside_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"id\\\":\\\"4xlw7ugv6z\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"customHtmlMessage\\\",\\\"success\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Flow\\\",\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"94e1b4a6a39ad267434d750a964f2f44\\\",\\\"flowVersionId\\\":2,\\\"id\\\":\\\"lwm7tdp8wg\\\",\\\"connectionId\\\":\\\"6cfe3583c35bbf54a68eea351b55862d\\\",\\\"connectorId\\\":\\\"flowConnector\\\",\\\"capabilityName\\\":\\\"startUiSubFlow\\\",\\\"properties\\\":{\\\"subFlowId\\\":{\\\"value\\\":{\\\"label\\\":\\\"Subflow-%[1]s\\\",\\\"value\\\":\\\"429812d959aecccd1523576fad6f91e4\\\"}},\\\"subFlowVersionId\\\":{\\\"value\\\":-1}},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[\\\"global.cookies\\\",\\\"global.ip\\\",\\\"global.userAgent\\\",\\\"global.skOpenId\\\",\\\"global.origin\\\",\\\"global.originCookies\\\"],\\\"respondToUser\\\":true,\\\"transitionId\\\":1,\\\"signalId\\\":0}],\\\"evalNodeId\\\":\\\"ygtoiozc7d\\\",\\\"transitionId\\\":1},{\\\"from\\\":[\\\"inside_0\\\"],\\\"to\\\":\\\"end_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"id\\\":\\\"lwm7tdp8wg\\\",\\\"connectionId\\\":\\\"6cfe3583c35bbf54a68eea351b55862d\\\",\\\"connectorId\\\":\\\"flowConnector\\\",\\\"capabilityName\\\":\\\"startUiSubFlow\\\",\\\"success\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Http\\\",\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"94e1b4a6a39ad267434d750a964f2f44\\\",\\\"flowVersionId\\\":2,\\\"id\\\":\\\"nfixv1aq7h\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"customHtmlMessage\\\",\\\"properties\\\":{\\\"message\\\":{\\\"value\\\":\\\"Back in Mainflow\\\"}},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[\\\"global.error\\\"],\\\"respondToUser\\\":true,\\\"transitionId\\\":2,\\\"signalId\\\":0}],\\\"evalNodeId\\\":\\\"s8rurw6ogo\\\",\\\"transitionId\\\":2}],\\\"history\\\":[],\\\"outputs\\\":{\\\"flowConnector_startUiSubFlow\\\":{\\\"localOutputs\\\":[\\\"output\\\"]}},\\\"outputParameters\\\":[],\\\"global\\\":{},\\\"local\\\":{},\\\"idMapping\\\":{},\\\"nodeMappingForTids\\\":{\\\"4xlw7ugv6z\\\":\\\"initialize\\\",\\\"4xlw7ugv6z_customHtmlMessage\\\":\\\"initialize\\\",\\\"lwm7tdp8wg\\\":\\\"4xlw7ugv6z\\\",\\\"lwm7tdp8wg_startUiSubFlow\\\":\\\"4xlw7ugv6z_customHtmlMessage\\\",\\\"nfixv1aq7h\\\":\\\"lwm7tdp8wg\\\",\\\"nfixv1aq7h_customHtmlMessage\\\":\\\"lwm7tdp8wg_startUiSubFlow\\\"},\\\"tids\\\":{},\\\"delayedConditionalStateChangeMappings\\\":{},\\\"delayedConditionalStateChangeMappingsReverse\\\":{},\\\"delayedConditionalStatesList\\\":[],\\\"lbsTransitionIdsToIgnore\\\":[],\\\"lbsTransitionIdsMapping\\\":{},\\\"outputParametersDefault\\\":{},\\\"outputParametersDefaultBlacklist\\\":[],\\\"historyThreshold\\\":70,\\\"errorRewindBlackListIds\\\":[],\\\"nodeMappingForTidsNew\\\":{\\\"4xlw7ugv6z\\\":\\\"initialize\\\",\\\"lwm7tdp8wg\\\":[\\\"4xlw7ugv6z\\\"],\\\"nfixv1aq7h\\\":[\\\"4xlw7ugv6z\\\",\\\"lwm7tdp8wg\\\"]},\\\"nodeStates\\\":{\\\"4xlw7ugv6z\\\":\\\"start_0\\\",\\\"lwm7tdp8wg\\\":\\\"inside_0\\\",\\\"nfixv1aq7h\\\":\\\"end_0\\\"}}\",\"publishedVersion\":2,\"updatedDate\":1670454822120,\"flowId\":\"94e1b4a6a39ad267434d750a964f2f44\",\"versionId\":2,\"graphData\":{\"elements\":{\"nodes\":[{\"data\":{\"id\":\"4xlw7ugv6z\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"867ed4363b2bc21c860085ad2baa817d\",\"connectorId\":\"httpConnector\",\"name\":\"Http\",\"label\":\"Http\",\"status\":\"configured\",\"capabilityName\":\"customHtmlMessage\",\"type\":\"trigger\",\"properties\":{\"message\":{\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"Hello from AnotherMainflow\\\"\\n }\\n ]\\n }\\n]\"},\"showContinueButton\":{\"value\":true}}},\"position\":{\"x\":400,\"y\":400},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"ygtoiozc7d\",\"nodeType\":\"EVAL\",\"label\":\"Evaluator\"},\"position\":{\"x\":564.0012044376399,\"y\":396.26965173824817},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"lwm7tdp8wg\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"6cfe3583c35bbf54a68eea351b55862d\",\"connectorId\":\"flowConnector\",\"name\":\"Flow\",\"label\":\"Flow\",\"status\":\"configured\",\"capabilityName\":\"startUiSubFlow\",\"type\":\"trigger\",\"properties\":{\"subFlowId\":{\"value\":{\"label\":\"Subflow-%[1]s\",\"value\":\"429812d959aecccd1523576fad6f91e4\"}},\"subFlowVersionId\":{\"value\":\"-1\"}}},\"position\":{\"x\":728.0024088752797,\"y\":392.5393034764964},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"s8rurw6ogo\",\"nodeType\":\"EVAL\",\"label\":\"Evaluator\"},\"position\":{\"x\":882.5029769455396,\"y\":389.0392824165202},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"nfixv1aq7h\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"867ed4363b2bc21c860085ad2baa817d\",\"connectorId\":\"httpConnector\",\"name\":\"Http\",\"label\":\"Http\",\"status\":\"configured\",\"capabilityName\":\"customHtmlMessage\",\"type\":\"trigger\",\"properties\":{\"message\":{\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"Back in Mainflow\\\"\\n }\\n ]\\n }\\n]\"}}},\"position\":{\"x\":1037.0035450157993,\"y\":385.5392613565441},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}],\"edges\":[{\"data\":{\"id\":\"jpamko0uag\",\"source\":\"4xlw7ugv6z\",\"target\":\"ygtoiozc7d\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"i9iji3pgoc\",\"source\":\"ygtoiozc7d\",\"target\":\"lwm7tdp8wg\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"9fg3exlq6u\",\"source\":\"lwm7tdp8wg\",\"target\":\"s8rurw6ogo\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"kb903zcmb3\",\"source\":\"s8rurw6ogo\",\"target\":\"nfixv1aq7h\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"}]},\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1e+50,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":true,\"renderer\":{\"name\":\"null\"}},\"flowColor\":\"#AFD5FF\",\"savedDate\":1670454819392,\"variables\":[]}"`, resourceName), AnotherSubflow: fmt.Sprintf(`"{\"companyId\":\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\",\"authTokenExpireIds\":[],\"connectorIds\":[\"httpConnector\"],\"createdDate\":1670454549078,\"currentVersion\":1,\"customerId\":\"ee728871d18a3b9b273c87192cee4a18\",\"deployedDate\":1670454550290,\"description\":\"\",\"flowStatus\":\"enabled\",\"name\":\"AnotherSubflow-%[1]s\",\"orx\":\"{\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"64f06befdbe8170f4da623115b18e58c\\\",\\\"flowVersionId\\\":1,\\\"version\\\":\\\"4.0.0\\\",\\\"states\\\":[\\\"initialize\\\",\\\"start_0\\\",\\\"end_0\\\"],\\\"currentState\\\":[\\\"initialize\\\"],\\\"transitions\\\":[{\\\"from\\\":[\\\"initialize\\\"],\\\"to\\\":\\\"start_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"initializeFlow\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Http\\\",\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"64f06befdbe8170f4da623115b18e58c\\\",\\\"flowVersionId\\\":1,\\\"id\\\":\\\"2eor2o01yd\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"customHtmlMessage\\\",\\\"properties\\\":{\\\"message\\\":{\\\"value\\\":\\\"Hello from AnotherSubflow\\\"},\\\"showContinueButton\\\":{\\\"value\\\":true}},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[\\\"global.error\\\"],\\\"respondToUser\\\":true,\\\"transitionId\\\":0,\\\"signalId\\\":0}],\\\"transitionId\\\":0},{\\\"from\\\":[\\\"start_0\\\"],\\\"to\\\":\\\"end_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"id\\\":\\\"2eor2o01yd\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"customHtmlMessage\\\",\\\"success\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Http\\\",\\\"companyId\\\":\\\"c7d4b54e-7d9d-4bec-a215-53bad73489f0\\\",\\\"flowId\\\":\\\"64f06befdbe8170f4da623115b18e58c\\\",\\\"flowVersionId\\\":1,\\\"id\\\":\\\"v6dd1n2nef\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"createSuccessResponse\\\",\\\"properties\\\":{},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[\\\"*\\\"],\\\"respondToUser\\\":true,\\\"transitionId\\\":1,\\\"signalId\\\":0}],\\\"evalNodeId\\\":\\\"si75sg75j4\\\",\\\"transitionId\\\":1}],\\\"history\\\":[],\\\"outputs\\\":{},\\\"outputParameters\\\":[],\\\"global\\\":{},\\\"local\\\":{},\\\"idMapping\\\":{},\\\"nodeMappingForTids\\\":{\\\"2eor2o01yd\\\":\\\"initialize\\\",\\\"2eor2o01yd_customHtmlMessage\\\":\\\"initialize\\\",\\\"v6dd1n2nef\\\":\\\"2eor2o01yd\\\",\\\"v6dd1n2nef_createSuccessResponse\\\":\\\"2eor2o01yd_customHtmlMessage\\\"},\\\"tids\\\":{},\\\"delayedConditionalStateChangeMappings\\\":{},\\\"delayedConditionalStateChangeMappingsReverse\\\":{},\\\"delayedConditionalStatesList\\\":[],\\\"lbsTransitionIdsToIgnore\\\":[],\\\"lbsTransitionIdsMapping\\\":{},\\\"outputParametersDefault\\\":{},\\\"outputParametersDefaultBlacklist\\\":[],\\\"historyThreshold\\\":70,\\\"errorRewindBlackListIds\\\":[],\\\"nodeMappingForTidsNew\\\":{\\\"2eor2o01yd\\\":\\\"initialize\\\",\\\"v6dd1n2nef\\\":[\\\"2eor2o01yd\\\"]},\\\"nodeStates\\\":{\\\"2eor2o01yd\\\":\\\"start_0\\\",\\\"v6dd1n2nef\\\":\\\"end_0\\\"}}\",\"publishedVersion\":1,\"updatedDate\":1670454550290,\"flowId\":\"64f06befdbe8170f4da623115b18e58c\",\"versionId\":1,\"graphData\":{\"elements\":{\"nodes\":[{\"data\":{\"id\":\"2eor2o01yd\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"867ed4363b2bc21c860085ad2baa817d\",\"connectorId\":\"httpConnector\",\"name\":\"Http\",\"label\":\"Http\",\"status\":\"configured\",\"capabilityName\":\"customHtmlMessage\",\"type\":\"trigger\",\"properties\":{\"message\":{\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"Hello from AnotherSubflow\\\"\\n }\\n ]\\n }\\n]\"},\"showContinueButton\":{\"value\":true}}},\"position\":{\"x\":400,\"y\":400},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"si75sg75j4\",\"nodeType\":\"EVAL\",\"label\":\"Evaluator\"},\"position\":{\"x\":605.0013551876764,\"y\":402.7696908496324},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"v6dd1n2nef\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"867ed4363b2bc21c860085ad2baa817d\",\"connectorId\":\"httpConnector\",\"name\":\"Http\",\"label\":\"Http\",\"status\":\"configured\",\"capabilityName\":\"createSuccessResponse\",\"type\":\"action\",\"properties\":{}},\"position\":{\"x\":810.0027103753529,\"y\":405.5393816992648},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}],\"edges\":[{\"data\":{\"id\":\"49g53utkgw\",\"source\":\"2eor2o01yd\",\"target\":\"si75sg75j4\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"a5e8fky7ns\",\"source\":\"si75sg75j4\",\"target\":\"v6dd1n2nef\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"}]},\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1e+50,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":true,\"renderer\":{\"name\":\"null\"}},\"flowColor\":\"#AFD5FF\",\"savedDate\":1670454549054,\"variables\":[]}"`, resourceName), WithVariableConnector: fmt.Sprintf(`"{\"companyId\":\"83fc9c23-6453-4134-95b2-661fcc1eba49\",\"authTokenExpireIds\":[],\"connectorIds\":[\"variablesConnector\",\"httpConnector\"],\"createdDate\":1675442964401,\"currentVersion\":1,\"customerId\":\"3193f25769a3f1e1591a1ebc82d51b13\",\"deployedDate\":1675442966019,\"description\":\"\",\"enabledGraphData\":{\"elements\":{\"nodes\":[{\"data\":{\"id\":\"zclitlw73r\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"06922a684039827499bdbdd97f49827b\",\"connectorId\":\"variablesConnector\",\"name\":\"Variables\",\"label\":\"Variables\",\"status\":\"configured\",\"capabilityName\":\"saveValue\",\"type\":\"trigger\",\"properties\":{\"saveVariables\":{\"value\":[{\"name\":null,\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"\\\"\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n },\\n {\\n \\\"type\\\": \\\"link\\\",\\n \\\"src\\\": \\\"variable.svg\\\",\\n \\\"url\\\": \\\"simpleCompany\\\",\\n \\\"data\\\": \\\"{{global.company.variables.simpleCompany}}\\\",\\n \\\"tooltip\\\": \\\"{{global.company.variables.simpleCompany}}\\\",\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"simpleCompany\\\"\\n }\\n ]\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n }\\n ]\\n }\\n]\",\"key\":0.7657645725170312,\"type\":\"string\",\"nameDefault\":\"simpleCompany\"}]}}},\"position\":{\"x\":0,\"y\":0},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"igeltxspjk\",\"nodeType\":\"EVAL\",\"label\":\"Evaluator\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"2fwvg7vbmf\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"867ed4363b2bc21c860085ad2baa817d\",\"connectorId\":\"httpConnector\",\"name\":\"Http\",\"label\":\"Http\",\"status\":\"configured\",\"capabilityName\":\"customHtmlMessage\",\"type\":\"trigger\",\"properties\":{\"message\":{\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"variable is: \\\"\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n },\\n {\\n \\\"type\\\": \\\"link\\\",\\n \\\"src\\\": \\\"variables.svg\\\",\\n \\\"url\\\": \\\"output\\\",\\n \\\"data\\\": \\\"{{local.zclitlw73r.payload.output}}\\\",\\n \\\"tooltip\\\": \\\"{{local.zclitlw73r.payload.output}}\\\",\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"output\\\"\\n }\\n ]\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n }\\n ]\\n }\\n]\"}}},\"position\":{\"x\":0,\"y\":0},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}],\"edges\":[{\"data\":{\"id\":\"puuq38mrou\",\"source\":\"zclitlw73r\",\"target\":\"igeltxspjk\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"fx0d54uitd\",\"source\":\"igeltxspjk\",\"target\":\"2fwvg7vbmf\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"}]},\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1e+50,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":true,\"renderer\":{\"name\":\"null\"}},\"flowStatus\":\"enabled\",\"name\":\"printCompanyVar-%[1]s\",\"orx\":\"{\\\"companyId\\\":\\\"83fc9c23-6453-4134-95b2-661fcc1eba49\\\",\\\"flowId\\\":\\\"d5df2d3c437145314a0d195c5283ca3a\\\",\\\"flowVersionId\\\":1,\\\"version\\\":\\\"4.0.0\\\",\\\"states\\\":[\\\"initialize\\\",\\\"start_0\\\",\\\"end_0\\\"],\\\"currentState\\\":[\\\"initialize\\\"],\\\"transitions\\\":[{\\\"from\\\":[\\\"initialize\\\"],\\\"to\\\":\\\"start_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"initializeFlow\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Variables\\\",\\\"companyId\\\":\\\"83fc9c23-6453-4134-95b2-661fcc1eba49\\\",\\\"flowId\\\":\\\"d5df2d3c437145314a0d195c5283ca3a\\\",\\\"flowVersionId\\\":1,\\\"id\\\":\\\"zclitlw73r\\\",\\\"connectionId\\\":\\\"06922a684039827499bdbdd97f49827b\\\",\\\"connectorId\\\":\\\"variablesConnector\\\",\\\"capabilityName\\\":\\\"saveValue\\\",\\\"properties\\\":{\\\"saveVariables\\\":{\\\"value\\\":[{\\\"name\\\":null,\\\"value\\\":\\\"{{global.company.variables.simpleCompany}}\\\",\\\"key\\\":0.7657645725170312,\\\"type\\\":\\\"string\\\",\\\"nameDefault\\\":\\\"simpleCompany\\\"}]}},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[],\\\"transitionId\\\":0,\\\"signalId\\\":0}],\\\"transitionId\\\":0},{\\\"from\\\":[\\\"start_0\\\"],\\\"to\\\":\\\"end_0\\\",\\\"conditions\\\":{\\\"$and\\\":[{\\\"id\\\":\\\"zclitlw73r\\\",\\\"connectionId\\\":\\\"06922a684039827499bdbdd97f49827b\\\",\\\"connectorId\\\":\\\"variablesConnector\\\",\\\"capabilityName\\\":\\\"saveValue\\\",\\\"success\\\":true}]},\\\"signals\\\":[{\\\"name\\\":\\\"Http\\\",\\\"companyId\\\":\\\"83fc9c23-6453-4134-95b2-661fcc1eba49\\\",\\\"flowId\\\":\\\"d5df2d3c437145314a0d195c5283ca3a\\\",\\\"flowVersionId\\\":1,\\\"id\\\":\\\"2fwvg7vbmf\\\",\\\"connectionId\\\":\\\"867ed4363b2bc21c860085ad2baa817d\\\",\\\"connectorId\\\":\\\"httpConnector\\\",\\\"capabilityName\\\":\\\"customHtmlMessage\\\",\\\"properties\\\":{\\\"message\\\":{\\\"value\\\":\\\"variable is: {{local.zclitlw73r.payload.output}}\\\"}},\\\"debugMode\\\":false,\\\"logLevel\\\":null,\\\"isDisabled\\\":false,\\\"inputs\\\":[\\\"global.error\\\"],\\\"respondToUser\\\":true,\\\"transitionId\\\":1,\\\"signalId\\\":0}],\\\"evalNodeId\\\":\\\"igeltxspjk\\\",\\\"transitionId\\\":1}],\\\"history\\\":[],\\\"outputs\\\":{\\\"variablesConnector_saveValue\\\":{\\\"localOutputs\\\":[\\\"output\\\"]}},\\\"outputParameters\\\":[\\\"global.company.variables.simpleCompany\\\",\\\"local.zclitlw73r.payload.output\\\"],\\\"global\\\":{},\\\"local\\\":{},\\\"idMapping\\\":{},\\\"nodeMappingForTids\\\":{\\\"2fwvg7vbmf\\\":\\\"initialize\\\",\\\"2fwvg7vbmf_customHtmlMessage\\\":\\\"initialize\\\"},\\\"tids\\\":{},\\\"delayedConditionalStateChangeMappings\\\":{},\\\"delayedConditionalStateChangeMappingsReverse\\\":{},\\\"delayedConditionalStatesList\\\":[],\\\"lbsTransitionIdsToIgnore\\\":[],\\\"lbsTransitionIdsMapping\\\":{},\\\"outputParametersDefault\\\":{\\\"global.company.variables.simpleCompany\\\":\\\"\\\",\\\"local.zclitlw73r.payload.output\\\":\\\"\\\"},\\\"outputParametersDefaultBlacklist\\\":[],\\\"historyThreshold\\\":70,\\\"errorRewindBlackListIds\\\":[],\\\"nodeMappingForTidsNew\\\":{\\\"2fwvg7vbmf\\\":\\\"initialize\\\"},\\\"nodeStates\\\":{\\\"zclitlw73r\\\":\\\"start_0\\\",\\\"2fwvg7vbmf\\\":\\\"end_0\\\"}}\",\"publishedVersion\":1,\"updatedDate\":1675442966019,\"flowId\":\"d5df2d3c437145314a0d195c5283ca3a\",\"versionId\":1,\"graphData\":{\"elements\":{\"nodes\":[{\"data\":{\"id\":\"zclitlw73r\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"06922a684039827499bdbdd97f49827b\",\"connectorId\":\"variablesConnector\",\"name\":\"Variables\",\"label\":\"Variables\",\"status\":\"configured\",\"capabilityName\":\"saveValue\",\"type\":\"trigger\",\"properties\":{\"saveVariables\":{\"value\":[{\"name\":null,\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"\\\"\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n },\\n {\\n \\\"type\\\": \\\"link\\\",\\n \\\"src\\\": \\\"variable.svg\\\",\\n \\\"url\\\": \\\"simpleCompany\\\",\\n \\\"data\\\": \\\"{{global.company.variables.simpleCompany}}\\\",\\n \\\"tooltip\\\": \\\"{{global.company.variables.simpleCompany}}\\\",\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"simpleCompany\\\"\\n }\\n ]\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n }\\n ]\\n }\\n]\",\"key\":0.7657645725170312,\"type\":\"string\",\"nameDefault\":\"simpleCompany\"}]}}},\"position\":{\"x\":180,\"y\":300},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"igeltxspjk\",\"nodeType\":\"EVAL\",\"label\":\"Evaluator\"},\"position\":{\"x\":321,\"y\":300.83333587646484},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"},{\"data\":{\"id\":\"2fwvg7vbmf\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"867ed4363b2bc21c860085ad2baa817d\",\"connectorId\":\"httpConnector\",\"name\":\"Http\",\"label\":\"Http\",\"status\":\"configured\",\"capabilityName\":\"customHtmlMessage\",\"type\":\"trigger\",\"properties\":{\"message\":{\"value\":\"[\\n {\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"variable is: \\\"\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n },\\n {\\n \\\"type\\\": \\\"link\\\",\\n \\\"src\\\": \\\"variables.svg\\\",\\n \\\"url\\\": \\\"output\\\",\\n \\\"data\\\": \\\"{{local.zclitlw73r.payload.output}}\\\",\\n \\\"tooltip\\\": \\\"{{local.zclitlw73r.payload.output}}\\\",\\n \\\"children\\\": [\\n {\\n \\\"text\\\": \\\"output\\\"\\n }\\n ]\\n },\\n {\\n \\\"text\\\": \\\"\\\"\\n }\\n ]\\n }\\n]\"}}},\"position\":{\"x\":462,\"y\":301.6666717529297},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}],\"edges\":[{\"data\":{\"id\":\"puuq38mrou\",\"source\":\"zclitlw73r\",\"target\":\"igeltxspjk\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"},{\"data\":{\"id\":\"fx0d54uitd\",\"source\":\"igeltxspjk\",\"target\":\"2fwvg7vbmf\"},\"position\":{\"x\":0,\"y\":0},\"group\":\"edges\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":true,\"classes\":\"\"}]},\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1e+50,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":true,\"renderer\":{\"name\":\"null\"}},\"flowColor\":\"#E3F0FF\",\"savedDate\":1675442964375,\"variables\":[]}"`, resourceName), - BrokenFlow: fmt.Sprintf(`"{\"companyId\":\"0a77c43b-3afd-4f08-b88c-61e811f3d0d9\",\"connectorIds\":[\"errorConnector\"],\"createdDate\":1675789456863,\"currentVersion\":0,\"customerId\":\"ee728871d18a3b9b273c87192cee4a18\",\"description\":\"\",\"flowStatus\":\"enabled\",\"name\":\"brokenFlow%[1]s\",\"updatedDate\":1675789456873,\"flowId\":\"ef5eab24ebe4f578cd73ec4acb79b78d\",\"versionId\":0,\"graphData\":{\"elements\":{\"nodes\":[{\"data\":{\"id\":\"zlgncqvws2\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"6d8f6f706c45fd459a86b3f092602544\",\"connectorId\":\"errorConnector\",\"name\":\"Error Customize\",\"label\":\"Error Customize\",\"status\":\"unconfigured\"},\"position\":{\"x\":400,\"y\":409.0909090042114},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}]},\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1e+50,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":true,\"renderer\":{\"name\":\"null\"}},\"flowColor\":\"#FFC8C1\",\"savedDate\":1675789456846,\"variables\":[]}"`, resourceName), + BrokenFlow: fmt.Sprintf(`"{\"companyId\":\"0a77c43b-3afd-4f08-b88c-61e811f3d0d9\",\"connectorIds\":[\"errorConnector\"],\"createdDate\":1675789456863,\"currentVersion\":0,\"customerId\":\"ee728871d18a3b9b273c87192cee4a18\",\"description\":\"\",\"flowStatus\":\"enabled\",\"name\":\"brokenFlow%[1]s\",\"updatedDate\":1675789456873,\"flowId\":\"ef5eab24ebe4f578cd73ec4acb79b78d\",\"versionId\":0,\"graphData\":{\"elements\":{\"nodes\":[{\"data\":{\"id\":\"zlgncqvws2\",\"nodeType\":\"CONNECTION\",\"connectionId\":\"6d8f6f706c45fd459a86b3f092602544\",\"connectorId\":\"errorConnector\",\"name\":\"Error Message\",\"label\":\"Error Message\",\"status\":\"unconfigured\"},\"position\":{\"x\":400,\"y\":409.0909090042114},\"group\":\"nodes\",\"removed\":false,\"selected\":false,\"selectable\":true,\"locked\":false,\"grabbable\":true,\"pannable\":false,\"classes\":\"\"}]},\"data\":{},\"zoomingEnabled\":true,\"userZoomingEnabled\":true,\"zoom\":1,\"minZoom\":1e-50,\"maxZoom\":1e+50,\"panningEnabled\":true,\"userPanningEnabled\":true,\"pan\":{\"x\":0,\"y\":0},\"boxSelectionEnabled\":true,\"renderer\":{\"name\":\"null\"}},\"flowColor\":\"#FFC8C1\",\"savedDate\":1675789456846,\"variables\":[]}"`, resourceName), PingOneSessionMainFlow: readFlowJsonFile("flows/p1sessionmainflow.json", resourceName), PingOneSessionMainFlowUpdate: readFlowJsonFile("flows/p1sessionmainflowupdate.json", resourceName), PingOneSessionSubFlow: readFlowJsonFile("flows/p1sessionsubflow.json", resourceName), diff --git a/internal/service/davinci/resource_application.go b/internal/service/davinci/resource_application.go index 6004a721..5e48198c 100644 --- a/internal/service/davinci/resource_application.go +++ b/internal/service/davinci/resource_application.go @@ -3,12 +3,14 @@ package davinci import ( "context" "fmt" + "regexp" "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/pingidentity/terraform-provider-davinci/internal/sdk" + "github.com/pingidentity/terraform-provider-davinci/internal/utils" dv "github.com/samir-gandhi/davinci-client-go/davinci" ) @@ -382,7 +384,7 @@ func ResourceApplication() *schema.Resource { }, }, Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, + StateContext: resourceApplicationImport, }, } } @@ -580,6 +582,36 @@ func resourceApplicationDelete(ctx context.Context, d *schema.ResourceData, meta return diags } +func resourceApplicationImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + + idComponents := []utils.ImportComponent{ + { + Label: "environment_id", + Regexp: regexp.MustCompile(`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`), + }, + { + Label: "davinci_application_id", + Regexp: regexp.MustCompile(`[a-f0-9]{32}`), + PrimaryID: true, + }, + } + + attributes, err := utils.ParseImportID(d.Id(), idComponents...) + if err != nil { + return nil, err + } + + if err = d.Set("environment_id", attributes["environment_id"]); err != nil { + return nil, err + } + + d.SetId(attributes["davinci_application_id"]) + + resourceApplicationRead(ctx, d, meta) + + return []*schema.ResourceData{d}, nil +} + func expandApp(d *schema.ResourceData) (*dv.AppUpdate, error) { // Set Top layer. a := dv.AppUpdate{ diff --git a/internal/service/davinci/resource_application_test.go b/internal/service/davinci/resource_application_test.go index d7081eb7..c83275ad 100644 --- a/internal/service/davinci/resource_application_test.go +++ b/internal/service/davinci/resource_application_test.go @@ -2,6 +2,7 @@ package davinci_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -102,6 +103,23 @@ func TestAccResourceApplication_WithFlowPolicy(t *testing.T) { resource.TestCheckResourceAttrSet(resourceFullName, "policy.0.policy_id"), ), }, + // Test importing the resource + { + ResourceName: resourceFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{}, + }, }, }) } @@ -225,6 +243,25 @@ func TestAccResourceApplication_P1SessionFlowPolicy(t *testing.T) { resource.TestCheckNoResourceAttr(resourceFullName, "policy.1.policy_id"), ), }, + // Test importing the resource + { + ResourceName: resourceFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "context", // This shouldn't be ignored, can be solved on migration to the plugin framework + }, + }, }, }) } @@ -351,6 +388,47 @@ resource "davinci_application" "%[2]s" { return hcl } +func TestAccResourceApplication_BadParameters(t *testing.T) { + + resourceBase := "davinci_application" + resourceName := acctest.ResourceNameGen() + resourceFullName := fmt.Sprintf("%s.%s", resourceBase, resourceName) + + hcl := testAccResourceApplication_Slim_Hcl(resourceName) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheckPingOneAndTfVars(t) }, + ProviderFactories: acctest.ProviderFactories, + ExternalProviders: acctest.ExternalProviders, + ErrorCheck: acctest.ErrorCheck(t), + CheckDestroy: acctest.CheckResourceDestroy([]string{"davinci_application"}), + Steps: []resource.TestStep{ + // Configure + { + Config: hcl, + }, + // Errors + { + ResourceName: resourceFullName, + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_application_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "/", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_application_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "badformat/badformat", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_application_id" and must match regex: .*`), + }, + }, + }) +} + func testAccGetResourceApplicationIDs(resourceName string, environmentID, resourceID *string) resource.TestCheckFunc { return func(s *terraform.State) error { diff --git a/internal/service/davinci/resource_connection.go b/internal/service/davinci/resource_connection.go index 3de1acfa..d1386600 100644 --- a/internal/service/davinci/resource_connection.go +++ b/internal/service/davinci/resource_connection.go @@ -3,6 +3,7 @@ package davinci import ( "context" "fmt" + "regexp" "strconv" "strings" @@ -10,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/pingidentity/terraform-provider-davinci/internal/sdk" + "github.com/pingidentity/terraform-provider-davinci/internal/utils" dv "github.com/samir-gandhi/davinci-client-go/davinci" ) @@ -75,7 +77,7 @@ func ResourceConnection() *schema.Resource { }, }, Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, + StateContext: resourceConnectionImport, }, } } @@ -273,6 +275,36 @@ func resourceConnectionDelete(ctx context.Context, d *schema.ResourceData, meta return diags } +func resourceConnectionImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + + idComponents := []utils.ImportComponent{ + { + Label: "environment_id", + Regexp: regexp.MustCompile(`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`), + }, + { + Label: "davinci_connection_id", + Regexp: regexp.MustCompile(`[a-f0-9]{32}`), + PrimaryID: true, + }, + } + + attributes, err := utils.ParseImportID(d.Id(), idComponents...) + if err != nil { + return nil, err + } + + if err = d.Set("environment_id", attributes["environment_id"]); err != nil { + return nil, err + } + + d.SetId(attributes["davinci_connection_id"]) + + resourceConnectionRead(ctx, d, meta) + + return []*schema.ResourceData{d}, nil +} + func flattenConnectionProperties(connectionProperties *dv.Properties) ([]map[string]interface{}, error) { if connectionProperties == nil { return nil, fmt.Errorf("no properties") diff --git a/internal/service/davinci/resource_connection_test.go b/internal/service/davinci/resource_connection_test.go index a44a16dd..f5c67c98 100644 --- a/internal/service/davinci/resource_connection_test.go +++ b/internal/service/davinci/resource_connection_test.go @@ -2,6 +2,7 @@ package davinci_test import ( "fmt" + "regexp" "strconv" "strings" "testing" @@ -34,6 +35,25 @@ func TestAccResourceConnection_Slim(t *testing.T) { resource.TestCheckResourceAttr(resourceFullName, "name", resourceName), ), }, + // Test importing the resource + { + ResourceName: resourceFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "property.1.value", + }, + }, }, }) } @@ -257,6 +277,47 @@ data "davinci_application" "http_%[2]s_%[1]s" { return hcl } +func TestAccResourceConnection_BadParameters(t *testing.T) { + + resourceBase := "davinci_connection" + resourceName := acctest.ResourceNameGen() + resourceFullName := fmt.Sprintf("%s.%s", resourceBase, resourceName) + + hcl := testAccResourceConnection_Slim_Hcl(resourceName, "slim") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheckPingOneAndTfVars(t) }, + ProviderFactories: acctest.ProviderFactories, + ExternalProviders: acctest.ExternalProviders, + ErrorCheck: acctest.ErrorCheck(t), + CheckDestroy: acctest.CheckResourceDestroy([]string{"davinci_connection"}), + Steps: []resource.TestStep{ + // Configure + { + Config: hcl, + }, + // Errors + { + ResourceName: resourceFullName, + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_connection_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "/", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_connection_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "badformat/badformat", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_connection_id" and must match regex: .*`), + }, + }, + }) +} + func testAccGetResourceConnectionIDs(resourceName string, environmentID, resourceID *string) resource.TestCheckFunc { return func(s *terraform.State) error { diff --git a/internal/service/davinci/resource_flow.go b/internal/service/davinci/resource_flow.go index bcc29627..627f2dc3 100644 --- a/internal/service/davinci/resource_flow.go +++ b/internal/service/davinci/resource_flow.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "reflect" + "regexp" "sort" "strconv" "strings" @@ -13,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mitchellh/mapstructure" "github.com/pingidentity/terraform-provider-davinci/internal/sdk" + "github.com/pingidentity/terraform-provider-davinci/internal/utils" dv "github.com/samir-gandhi/davinci-client-go/davinci" ) @@ -149,7 +151,7 @@ func ResourceFlow() *schema.Resource { }, }, Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, + StateContext: resourceFlowImport, }, } } @@ -513,6 +515,36 @@ func resourceFlowDelete(ctx context.Context, d *schema.ResourceData, meta interf return diags } +func resourceFlowImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + + idComponents := []utils.ImportComponent{ + { + Label: "environment_id", + Regexp: regexp.MustCompile(`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`), + }, + { + Label: "davinci_flow_id", + Regexp: regexp.MustCompile(`[a-f0-9]{32}`), + PrimaryID: true, + }, + } + + attributes, err := utils.ParseImportID(d.Id(), idComponents...) + if err != nil { + return nil, err + } + + if err = d.Set("environment_id", attributes["environment_id"]); err != nil { + return nil, err + } + + d.SetId(attributes["davinci_flow_id"]) + + resourceFlowRead(ctx, d, meta) + + return []*schema.ResourceData{d}, nil +} + func computeFlowDrift(k, old, new string, d *schema.ResourceData) bool { var err error // exit quickly if new resource diff --git a/internal/service/davinci/resource_flow_test.go b/internal/service/davinci/resource_flow_test.go index fbd43263..060e1ba0 100644 --- a/internal/service/davinci/resource_flow_test.go +++ b/internal/service/davinci/resource_flow_test.go @@ -133,6 +133,25 @@ func TestAccResourceFlow_SubFlows(t *testing.T) { resource.TestCheckResourceAttrSet(resourceAnotherSubflowFullName, "deploy"), ), }, + // Test importing the resource + { + ResourceName: resourceMainflowFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceMainflowFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceMainflowFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "deploy", + }, + }, }, }) } @@ -199,6 +218,7 @@ func TestAccResourceFlow_VariableConnectorFlow(t *testing.T) { resourceFullName := fmt.Sprintf("%s.%s", resourceBase, testFlows.WithVariableConnector.Name) hcl := testAccResourceFlow_VariableConnectorFlows_Hcl(resourceName, []acctest.FlowHcl{testFlows.WithVariableConnector}) + fmt.Printf("hcl: %s\n", hcl) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheckPingOneAndTfVars(t) }, ProviderFactories: acctest.ProviderFactories, @@ -234,6 +254,25 @@ func TestAccResourceFlow_VariableConnectorFlow(t *testing.T) { }), ), }, + // Test importing the resource + { + ResourceName: resourceFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "deploy", + }, + }, }, }) } @@ -531,6 +570,48 @@ func TestAccResourceFlow_FlowContextVarFlow(t *testing.T) { }) } +func TestAccResourceFlow_BadParameters(t *testing.T) { + + resourceBase := "davinci_flow" + resourceName := acctest.ResourceNameGen() + testFlows := acctest.FlowsForTests(resourceName) + resourceFullName := fmt.Sprintf("%s.%s", resourceBase, testFlows.Simple.Name) + + hcl := testAccResourceFlow_SimpleFlows_Hcl(resourceName, []string{testFlows.Simple.Hcl}) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheckPingOneAndTfVars(t) }, + ProviderFactories: acctest.ProviderFactories, + ExternalProviders: acctest.ExternalProviders, + ErrorCheck: acctest.ErrorCheck(t), + CheckDestroy: acctest.CheckResourceDestroy([]string{"davinci_flow"}), + Steps: []resource.TestStep{ + // Configure + { + Config: hcl, + }, + // Errors + { + ResourceName: resourceFullName, + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_flow_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "/", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_flow_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "badformat/badformat", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_flow_id" and must match regex: .*`), + }, + }, + }) +} + func testAccGetResourceFlowIDs(resourceName string, environmentID, resourceID *string) resource.TestCheckFunc { return func(s *terraform.State) error { diff --git a/internal/service/davinci/resource_variable.go b/internal/service/davinci/resource_variable.go index 30fe11aa..3916e645 100644 --- a/internal/service/davinci/resource_variable.go +++ b/internal/service/davinci/resource_variable.go @@ -3,12 +3,14 @@ package davinci import ( "context" "fmt" + "regexp" "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/pingidentity/terraform-provider-davinci/internal/sdk" + "github.com/pingidentity/terraform-provider-davinci/internal/utils" dv "github.com/samir-gandhi/davinci-client-go/davinci" ) @@ -74,7 +76,7 @@ func ResourceVariable() *schema.Resource { }, }, Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, + StateContext: resourceVariableImport, }, } } @@ -235,6 +237,36 @@ func resourceVariableDelete(ctx context.Context, d *schema.ResourceData, meta in return diags } +func resourceVariableImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + + idComponents := []utils.ImportComponent{ + { + Label: "environment_id", + Regexp: regexp.MustCompile(`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`), + }, + { + Label: "davinci_variable_id", + Regexp: regexp.MustCompile(`.*`), + PrimaryID: true, + }, + } + + attributes, err := utils.ParseImportID(d.Id(), idComponents...) + if err != nil { + return nil, err + } + + if err = d.Set("environment_id", attributes["environment_id"]); err != nil { + return nil, err + } + + d.SetId(attributes["davinci_variable_id"]) + + resourceVariableRead(ctx, d, meta) + + return []*schema.ResourceData{d}, nil +} + func getVariableAttributes(d *schema.ResourceData) dv.VariablePayload { variablePayload := dv.VariablePayload{ Name: d.Get("name").(string), diff --git a/internal/service/davinci/resource_variable_test.go b/internal/service/davinci/resource_variable_test.go index 5a7dc149..4f6e3391 100644 --- a/internal/service/davinci/resource_variable_test.go +++ b/internal/service/davinci/resource_variable_test.go @@ -2,6 +2,7 @@ package davinci_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -32,6 +33,25 @@ func TestAccResourceVariable_CompanyContext(t *testing.T) { resource.TestCheckResourceAttrSet(resourceFullName, "value"), ), }, + // Test importing the resource + { + ResourceName: resourceFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "context", // This shouldn't be ignored, can be solved on migration to the plugin framework + }, + }, }, }) } @@ -80,6 +100,25 @@ func TestAccResourceVariable_FlowInstanceContext(t *testing.T) { resource.TestCheckResourceAttr(resourceFullName, "min", "0"), ), }, + // Test importing the resource + { + ResourceName: resourceFullName, + ImportStateIdFunc: func() resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceFullName] + if !ok { + return "", fmt.Errorf("Resource Not found: %s", resourceFullName) + } + + return fmt.Sprintf("%s/%s", rs.Primary.Attributes["environment_id"], rs.Primary.ID), nil + } + }(), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "context", // This shouldn't be ignored, can be solved on migration to the plugin framework + }, + }, }, }) } @@ -104,6 +143,47 @@ resource "davinci_variable" "%[2]s" { return hcl } +func TestAccResourceVariable_BadParameters(t *testing.T) { + + resourceBase := "davinci_variable" + resourceName := acctest.ResourceNameGen() + resourceFullName := fmt.Sprintf("%s.%s", resourceBase, resourceName) + + hcl := testAccResourceVariable_FlowInstanceContext_Hcl(resourceName) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheckPingOneAndTfVars(t) }, + ProviderFactories: acctest.ProviderFactories, + ExternalProviders: acctest.ExternalProviders, + ErrorCheck: acctest.ErrorCheck(t), + CheckDestroy: acctest.CheckResourceDestroy([]string{"davinci_variable"}), + Steps: []resource.TestStep{ + // Configure + { + Config: hcl, + }, + // Errors + { + ResourceName: resourceFullName, + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_variable_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "/", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_variable_id" and must match regex: .*`), + }, + { + ResourceName: resourceFullName, + ImportStateId: "badformat/badformat", + ImportState: true, + ExpectError: regexp.MustCompile(`Invalid import ID specified \(".*"\). The ID should be in the format "environment_id/davinci_variable_id" and must match regex: .*`), + }, + }, + }) +} + func testAccGetResourceVariableIDs(resourceName string, environmentID, resourceID *string) resource.TestCheckFunc { return func(s *terraform.State) error { diff --git a/internal/utils/resource.go b/internal/utils/resource.go new file mode 100644 index 00000000..b8633050 --- /dev/null +++ b/internal/utils/resource.go @@ -0,0 +1,54 @@ +package utils + +import ( + "fmt" + "regexp" + "strings" +) + +type ImportComponent struct { + Label string + Regexp *regexp.Regexp + PrimaryID bool +} + +// Parse Import ID format +func ParseImportID(id string, components ...ImportComponent) (map[string]string, error) { + + keys := make([]string, len(components)) + regexpList := make([]string, len(components)) + + i := 0 + for _, v := range components { + keys[i] = v.Label + regexpList[i] = v.Regexp.String() + i++ + } + + compiledRegexpString := fmt.Sprintf("^%s$", strings.Join(regexpList, `\/`)) + + m, err := regexp.MatchString(compiledRegexpString, id) + if err != nil { + return nil, fmt.Errorf("Cannot verify import ID regex: %s", err) + } + + if !m { + return nil, fmt.Errorf("Invalid import ID specified (\"%s\"). The ID should be in the format \"%s\" and must match regex: %s", id, strings.Join(keys, "/"), compiledRegexpString) + } + + attributeValues := strings.SplitN(id, "/", len(components)) + + if len(attributeValues) != len(components) { + return nil, fmt.Errorf("Invalid import ID specified (\"%s\"). The ID should be in the format \"%s\".", id, strings.Join(keys, "/")) + } + + attributes := make(map[string]string) + + i = 0 + for _, v := range components { + attributes[v.Label] = attributeValues[i] + i++ + } + + return attributes, nil +}