From 2f35e1743e817b1cc30c54603adb4033f7a78a4e Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Sat, 1 Nov 2025 00:38:34 +0000 Subject: [PATCH] ## Terraform SDK Changes Detected: * `SDK.Closing Reason.createClosingReason()`: `request` **Changed** **Breaking** :warning: * `SDK.Workflows.createDefinition()`: * `request` **Changed** * `response` **Changed** **Breaking** :warning: * `SDK.Flows V2.createFlowTemplate()`: **Added** * `SDK.Flows V2.searchFlowTemplates()`: **Added** * `SDK.Closing Reason.deleteClosingReason()`: **Added** * `SDK.Flows V2.deleteFlowTemplate()`: **Added** * `SDK.Flows V2.duplicateFlowTemplate()`: **Added** * `SDK.Flows V2.getFlowTemplate()`: **Added** * `SDK.Flows V2.listFlowTemplates()`: **Added** * `SDK.Closing Reason.updateClosingReason()`: **Added** * `SDK.Flows V2.updateFlowTemplate()`: **Added** * `SDK.Closing Reason.getClosingReasonV1()`: **Added** * `SDK.Closing Reason.getClosingReason()`: **Added** * `SDK.Workflows.getDefinition()`: `response` **Changed** * `SDK.Workflows.getDefinitions()`: `response.[]` **Changed** * `SDK.Workflows.updateDefinition()`: * `request.WorkflowDefinition` **Changed** * `response` **Changed** --- .gitignore | 2 + .speakeasy/gen.lock | 129 +- .speakeasy/workflow.lock | 11 +- README.md | 22 +- RELEASES.md | 12 +- docs/data-sources/closing_reason.md | 29 - docs/data-sources/flow_template.md | 623 ---- docs/data-sources/workflow_definition.md | 75 - docs/index.md | 4 +- docs/resources/closing_reason.md | 53 - docs/resources/flow_template.md | 802 ----- docs/resources/workflow_definition.md | 139 - examples/README.md | 1 - .../data-source.tf | 2 - .../data-source.tf | 2 - .../data-source.tf | 2 - examples/provider/provider.tf | 2 +- .../import-by-string-id.tf | 4 - .../epilot-workflow_closing_reason/import.sh | 1 - .../resource.tf | 4 - .../import-by-string-id.tf | 4 - .../epilot-workflow_flow_template/import.sh | 1 - .../epilot-workflow_flow_template/resource.tf | 153 - .../import-by-string-id.tf | 4 - .../import.sh | 1 - .../resource.tf | 41 - final.yaml | 1263 ++++++- gen.yaml | 7 +- go.mod | 9 +- go.sum | 12 +- .../provider/closingreason_data_source.go | 140 - .../provider/closingreason_data_source_sdk.go | 38 - internal/provider/closingreason_resource.go | 314 -- .../provider/closingreason_resource_sdk.go | 87 - internal/provider/flowtemplate_data_source.go | 1026 ------ .../provider/flowtemplate_data_source_sdk.go | 513 --- internal/provider/flowtemplate_resource.go | 2056 ----------- .../provider/flowtemplate_resource_sdk.go | 3173 ----------------- internal/provider/provider.go | 17 +- internal/provider/types/action_schedule.go | 9 - internal/provider/types/automation_config.go | 11 - internal/provider/types/automation_task.go | 26 - internal/provider/types/automation_trigger.go | 13 - internal/provider/types/closing_reason.go | 15 - internal/provider/types/closing_reason1.go | 15 - internal/provider/types/closing_reason_id.go | 11 - internal/provider/types/condition.go | 14 - internal/provider/types/decision_task.go | 25 - internal/provider/types/delayed_schedule.go | 13 - internal/provider/types/due_date_config.go | 15 - internal/provider/types/dynamic_due_date.go | 15 - internal/provider/types/ecp_details.go | 14 - internal/provider/types/edge.go | 15 - internal/provider/types/enable_requirement.go | 13 - internal/provider/types/evaluation_source.go | 18 - internal/provider/types/immediate_schedule.go | 11 - .../types/journey_submission_trigger.go | 14 - internal/provider/types/manual_trigger.go | 13 - internal/provider/types/phase.go | 16 - internal/provider/types/reference.go | 14 - internal/provider/types/relative_schedule.go | 15 - internal/provider/types/schedule.go | 8 - internal/provider/types/statement.go | 14 - internal/provider/types/step_description.go | 12 - internal/provider/types/step_journey.go | 13 - internal/provider/types/target.go | 12 - internal/provider/types/task.go | 9 - internal/provider/types/task_base.go | 23 - internal/provider/types/trigger.go | 9 - .../types/update_entity_attributes.go | 12 - .../workflowdefinition_data_source.go | 237 -- .../workflowdefinition_data_source_sdk.go | 88 - .../provider/workflowdefinition_resource.go | 487 --- .../workflowdefinition_resource_sdk.go | 259 -- internal/sdk/.gitignore | 2 + internal/sdk/closingreason.go | 736 +--- internal/sdk/docs/models/operations/option.md | 37 - internal/sdk/flowsv2.go | 824 +++-- internal/sdk/internal/utils/form.go | 23 +- internal/sdk/internal/utils/headers.go | 12 + internal/sdk/internal/utils/json.go | 273 +- internal/sdk/internal/utils/pathparams.go | 15 +- internal/sdk/internal/utils/queryparams.go | 22 +- internal/sdk/internal/utils/requestbody.go | 13 + internal/sdk/internal/utils/utils.go | 19 +- .../models/operations/changereasonstatus.go | 36 +- .../models/operations/createclosingreason.go | 24 +- .../sdk/models/operations/createdefinition.go | 30 +- .../models/operations/createflowtemplate.go | 30 +- .../models/operations/deleteclosingreason.go | 36 +- .../sdk/models/operations/deletedefinition.go | 30 +- .../models/operations/deleteflowtemplate.go | 30 +- .../operations/duplicateflowtemplate.go | 67 + .../models/operations/getallclosingreasons.go | 30 +- .../sdk/models/operations/getclosingreason.go | 42 +- .../models/operations/getclosingreasonv1.go | 42 +- .../sdk/models/operations/getdefinition.go | 42 +- .../sdk/models/operations/getdefinitions.go | 30 +- .../sdk/models/operations/getflowtemplate.go | 42 +- .../models/operations/getmaxallowedlimit.go | 30 +- .../operations/getworkflowclosingreasons.go | 30 +- .../models/operations/listflowtemplates.go | 97 +- .../models/operations/searchflowtemplates.go | 76 + .../operations/setworkflowclosingreasons.go | 30 +- .../models/operations/updateclosingreason.go | 48 +- .../sdk/models/operations/updatedefinition.go | 42 +- .../models/operations/updateflowtemplate.go | 42 +- internal/sdk/models/shared/actionschedule.go | 52 +- .../sdk/models/shared/automationconfig.go | 6 +- internal/sdk/models/shared/automationtask.go | 105 +- .../sdk/models/shared/automationtrigger.go | 18 +- .../models/shared/changereasonstatusreq.go | 6 +- internal/sdk/models/shared/closingreason.go | 30 +- internal/sdk/models/shared/closingreasonid.go | 6 +- .../sdk/models/shared/closingreasoninput.go | 12 +- .../shared/closingreasonnotfoundresp.go | 6 +- internal/sdk/models/shared/closingreasons.go | 6 +- .../sdk/models/shared/closingreasonsids.go | 6 +- internal/sdk/models/shared/condition.go | 24 +- .../sdk/models/shared/createflowtemplate.go | 154 +- internal/sdk/models/shared/decisiontask.go | 199 +- .../models/shared/definitionnotfoundresp.go | 6 +- internal/sdk/models/shared/delayedschedule.go | 18 +- internal/sdk/models/shared/duedateconfig.go | 30 +- internal/sdk/models/shared/dynamicduedate.go | 30 +- internal/sdk/models/shared/ecpdetails.go | 24 +- internal/sdk/models/shared/edge.go | 30 +- .../sdk/models/shared/enablerequirement.go | 24 +- internal/sdk/models/shared/errorresp.go | 6 +- .../sdk/models/shared/evaluationsource.go | 48 +- internal/sdk/models/shared/flowtemplate.go | 139 +- .../sdk/models/shared/flowtemplateinput.go | 139 +- .../sdk/models/shared/flowtemplateslist.go | 6 +- .../sdk/models/shared/immediateschedule.go | 6 +- internal/sdk/models/shared/itemtype.go | 34 + .../models/shared/journeyautomationtrigger.go | 71 + .../models/shared/journeysubmissiontrigger.go | 37 +- internal/sdk/models/shared/manualtrigger.go | 18 +- internal/sdk/models/shared/maxallowedlimit.go | 12 +- internal/sdk/models/shared/phase.go | 36 +- .../sdk/models/shared/relativeschedule.go | 54 +- .../sdk/models/shared/searchflowtemplates.go | 168 + internal/sdk/models/shared/section.go | 96 + internal/sdk/models/shared/security.go | 6 +- internal/sdk/models/shared/statement.go | 24 +- internal/sdk/models/shared/step.go | 182 + internal/sdk/models/shared/stepdescription.go | 12 +- internal/sdk/models/shared/stepjourney.go | 33 +- internal/sdk/models/shared/steprequirement.go | 71 + internal/sdk/models/shared/steptype.go | 34 + internal/sdk/models/shared/task.go | 58 +- internal/sdk/models/shared/taskbase.go | 78 +- internal/sdk/models/shared/trigger.go | 94 +- .../models/shared/updateentityattributes.go | 24 +- internal/sdk/models/shared/version.go | 42 + .../sdk/models/shared/workflowdefinition.go | 185 +- .../sdk/optionalnullable/optionalnullable.go | 233 ++ .../optionalnullable/optionalnullable_test.go | 1806 ++++++++++ internal/sdk/sdk.go | 6 +- internal/sdk/types/decimal.go | 20 - internal/sdk/workflows.go | 841 +---- 161 files changed, 6684 insertions(+), 13895 deletions(-) delete mode 100644 docs/data-sources/closing_reason.md delete mode 100644 docs/data-sources/flow_template.md delete mode 100644 docs/data-sources/workflow_definition.md delete mode 100644 docs/resources/closing_reason.md delete mode 100644 docs/resources/flow_template.md delete mode 100644 docs/resources/workflow_definition.md delete mode 100644 examples/README.md delete mode 100644 examples/data-sources/epilot-workflow_closing_reason/data-source.tf delete mode 100644 examples/data-sources/epilot-workflow_flow_template/data-source.tf delete mode 100644 examples/data-sources/epilot-workflow_workflow_definition/data-source.tf delete mode 100644 examples/resources/epilot-workflow_closing_reason/import-by-string-id.tf delete mode 100644 examples/resources/epilot-workflow_closing_reason/import.sh delete mode 100644 examples/resources/epilot-workflow_closing_reason/resource.tf delete mode 100644 examples/resources/epilot-workflow_flow_template/import-by-string-id.tf delete mode 100644 examples/resources/epilot-workflow_flow_template/import.sh delete mode 100644 examples/resources/epilot-workflow_flow_template/resource.tf delete mode 100644 examples/resources/epilot-workflow_workflow_definition/import-by-string-id.tf delete mode 100644 examples/resources/epilot-workflow_workflow_definition/import.sh delete mode 100644 examples/resources/epilot-workflow_workflow_definition/resource.tf delete mode 100644 internal/provider/closingreason_data_source.go delete mode 100644 internal/provider/closingreason_data_source_sdk.go delete mode 100644 internal/provider/closingreason_resource.go delete mode 100644 internal/provider/closingreason_resource_sdk.go delete mode 100644 internal/provider/flowtemplate_data_source.go delete mode 100644 internal/provider/flowtemplate_data_source_sdk.go delete mode 100644 internal/provider/flowtemplate_resource.go delete mode 100644 internal/provider/flowtemplate_resource_sdk.go delete mode 100644 internal/provider/types/action_schedule.go delete mode 100644 internal/provider/types/automation_config.go delete mode 100644 internal/provider/types/automation_task.go delete mode 100644 internal/provider/types/automation_trigger.go delete mode 100644 internal/provider/types/closing_reason.go delete mode 100644 internal/provider/types/closing_reason1.go delete mode 100644 internal/provider/types/closing_reason_id.go delete mode 100644 internal/provider/types/condition.go delete mode 100644 internal/provider/types/decision_task.go delete mode 100644 internal/provider/types/delayed_schedule.go delete mode 100644 internal/provider/types/due_date_config.go delete mode 100644 internal/provider/types/dynamic_due_date.go delete mode 100644 internal/provider/types/ecp_details.go delete mode 100644 internal/provider/types/edge.go delete mode 100644 internal/provider/types/enable_requirement.go delete mode 100644 internal/provider/types/evaluation_source.go delete mode 100644 internal/provider/types/immediate_schedule.go delete mode 100644 internal/provider/types/journey_submission_trigger.go delete mode 100644 internal/provider/types/manual_trigger.go delete mode 100644 internal/provider/types/phase.go delete mode 100644 internal/provider/types/reference.go delete mode 100644 internal/provider/types/relative_schedule.go delete mode 100644 internal/provider/types/schedule.go delete mode 100644 internal/provider/types/statement.go delete mode 100644 internal/provider/types/step_description.go delete mode 100644 internal/provider/types/step_journey.go delete mode 100644 internal/provider/types/target.go delete mode 100644 internal/provider/types/task.go delete mode 100644 internal/provider/types/task_base.go delete mode 100644 internal/provider/types/trigger.go delete mode 100644 internal/provider/types/update_entity_attributes.go delete mode 100644 internal/provider/workflowdefinition_data_source.go delete mode 100644 internal/provider/workflowdefinition_data_source_sdk.go delete mode 100644 internal/provider/workflowdefinition_resource.go delete mode 100644 internal/provider/workflowdefinition_resource_sdk.go delete mode 100644 internal/sdk/docs/models/operations/option.md create mode 100644 internal/sdk/models/operations/duplicateflowtemplate.go create mode 100644 internal/sdk/models/operations/searchflowtemplates.go create mode 100644 internal/sdk/models/shared/itemtype.go create mode 100644 internal/sdk/models/shared/journeyautomationtrigger.go create mode 100644 internal/sdk/models/shared/searchflowtemplates.go create mode 100644 internal/sdk/models/shared/section.go create mode 100644 internal/sdk/models/shared/step.go create mode 100644 internal/sdk/models/shared/steprequirement.go create mode 100644 internal/sdk/models/shared/steptype.go create mode 100644 internal/sdk/models/shared/version.go create mode 100644 internal/sdk/optionalnullable/optionalnullable.go create mode 100644 internal/sdk/optionalnullable/optionalnullable_test.go delete mode 100644 internal/sdk/types/decimal.go diff --git a/.gitignore b/.gitignore index 0dc1b1f..c03e217 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.env +.env.local **/.speakeasy/temp/ **/.speakeasy/logs/ .terraform diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 2524b6e..ba93ce1 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 5a857039-7f4b-42d5-86fd-449767242ed2 management: - docChecksum: 3c59c274c95b2722d9a88a6882f4b520 + docChecksum: a1525f8e8e14a8e43d32321f78d7cfc5 docVersion: 1.0.0 - speakeasyVersion: 1.606.10 - generationVersion: 2.687.13 - releaseVersion: 0.19.0 - configChecksum: e5de877598a12627f8640da593540a00 + speakeasyVersion: 1.645.1 + generationVersion: 2.735.1 + releaseVersion: 0.20.0 + configChecksum: 7f2517218d21ad0d8232622b5e19558e repoURL: https://github.com/epilot-dev/terraform-provider-epilot-workflow.git repoSubDirectory: . published: true @@ -21,32 +21,17 @@ features: unions: 2.85.0 terraform: additionalDependencies: 0.1.0 - constsAndDefaults: 0.2.1 - core: 3.44.1 + constsAndDefaults: 0.3.0 + core: 3.46.5 deprecations: 2.82.0 - globalSecurity: 2.81.12 + globalSecurity: 2.82.1 globalServerURLs: 2.83.0 inputOutputModels: 2.83.0 - retries: 2.81.4 - typeOverrides: 2.81.1 - unions: 2.81.17 + unions: 2.82.2 generatedFiles: - .gitattributes - USAGE.md - - examples/README.md - - examples/data-sources/epilot-workflow_closing_reason/data-source.tf - - examples/data-sources/epilot-workflow_flow_template/data-source.tf - - examples/data-sources/epilot-workflow_workflow_definition/data-source.tf - examples/provider/provider.tf - - examples/resources/epilot-workflow_closing_reason/import-by-string-id.tf - - examples/resources/epilot-workflow_closing_reason/import.sh - - examples/resources/epilot-workflow_closing_reason/resource.tf - - examples/resources/epilot-workflow_flow_template/import-by-string-id.tf - - examples/resources/epilot-workflow_flow_template/import.sh - - examples/resources/epilot-workflow_flow_template/resource.tf - - examples/resources/epilot-workflow_workflow_definition/import-by-string-id.tf - - examples/resources/epilot-workflow_workflow_definition/import.sh - - examples/resources/epilot-workflow_workflow_definition/resource.tf - go.mod - go.sum - internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -61,14 +46,6 @@ generatedFiles: - internal/planmodifiers/setplanmodifier/suppress_diff.go - internal/planmodifiers/stringplanmodifier/suppress_diff.go - internal/planmodifiers/utils/state_check.go - - internal/provider/closingreason_data_source.go - - internal/provider/closingreason_data_source_sdk.go - - internal/provider/closingreason_resource.go - - internal/provider/closingreason_resource_sdk.go - - internal/provider/flowtemplate_data_source.go - - internal/provider/flowtemplate_data_source_sdk.go - - internal/provider/flowtemplate_resource.go - - internal/provider/flowtemplate_resource_sdk.go - internal/provider/provider.go - internal/provider/reflect/diags.go - internal/provider/reflect/doc.go @@ -87,45 +64,9 @@ generatedFiles: - internal/provider/typeconvert/date.go - internal/provider/typeconvert/datetime.go - internal/provider/typeconvert/int.go - - internal/provider/types/action_schedule.go - - internal/provider/types/automation_config.go - - internal/provider/types/automation_task.go - - internal/provider/types/automation_trigger.go - - internal/provider/types/closing_reason.go - - internal/provider/types/closing_reason1.go - - internal/provider/types/closing_reason_id.go - - internal/provider/types/condition.go - - internal/provider/types/decision_task.go - - internal/provider/types/delayed_schedule.go - - internal/provider/types/due_date_config.go - - internal/provider/types/dynamic_due_date.go - - internal/provider/types/ecp_details.go - - internal/provider/types/edge.go - - internal/provider/types/enable_requirement.go - - internal/provider/types/evaluation_source.go - - internal/provider/types/immediate_schedule.go - - internal/provider/types/journey_submission_trigger.go - - internal/provider/types/manual_trigger.go - - internal/provider/types/phase.go - - internal/provider/types/reference.go - - internal/provider/types/relative_schedule.go - - internal/provider/types/schedule.go - - internal/provider/types/statement.go - - internal/provider/types/step_description.go - - internal/provider/types/step_journey.go - - internal/provider/types/target.go - - internal/provider/types/task.go - - internal/provider/types/task_base.go - - internal/provider/types/trigger.go - - internal/provider/types/update_entity_attributes.go - internal/provider/utils.go - - internal/provider/workflowdefinition_data_source.go - - internal/provider/workflowdefinition_data_source_sdk.go - - internal/provider/workflowdefinition_resource.go - - internal/provider/workflowdefinition_resource_sdk.go - internal/sdk/.gitattributes - internal/sdk/closingreason.go - - internal/sdk/docs/models/operations/option.md - internal/sdk/flowsv2.go - internal/sdk/internal/config/sdkconfiguration.go - internal/sdk/internal/hooks/hooks.go @@ -148,6 +89,7 @@ generatedFiles: - internal/sdk/models/operations/deleteclosingreason.go - internal/sdk/models/operations/deletedefinition.go - internal/sdk/models/operations/deleteflowtemplate.go + - internal/sdk/models/operations/duplicateflowtemplate.go - internal/sdk/models/operations/getallclosingreasons.go - internal/sdk/models/operations/getclosingreason.go - internal/sdk/models/operations/getclosingreasonv1.go @@ -158,6 +100,7 @@ generatedFiles: - internal/sdk/models/operations/getworkflowclosingreasons.go - internal/sdk/models/operations/listflowtemplates.go - internal/sdk/models/operations/options.go + - internal/sdk/models/operations/searchflowtemplates.go - internal/sdk/models/operations/setworkflowclosingreasons.go - internal/sdk/models/operations/updateclosingreason.go - internal/sdk/models/operations/updatedefinition.go @@ -190,16 +133,23 @@ generatedFiles: - internal/sdk/models/shared/flowtemplateinput.go - internal/sdk/models/shared/flowtemplateslist.go - internal/sdk/models/shared/immediateschedule.go + - internal/sdk/models/shared/itemtype.go + - internal/sdk/models/shared/journeyautomationtrigger.go - internal/sdk/models/shared/journeysubmissiontrigger.go - internal/sdk/models/shared/manualtrigger.go - internal/sdk/models/shared/maxallowedlimit.go - internal/sdk/models/shared/operator.go - internal/sdk/models/shared/phase.go - internal/sdk/models/shared/relativeschedule.go + - internal/sdk/models/shared/searchflowtemplates.go + - internal/sdk/models/shared/section.go - internal/sdk/models/shared/security.go - internal/sdk/models/shared/statement.go + - internal/sdk/models/shared/step.go - internal/sdk/models/shared/stepdescription.go - internal/sdk/models/shared/stepjourney.go + - internal/sdk/models/shared/steprequirement.go + - internal/sdk/models/shared/steptype.go - internal/sdk/models/shared/task.go - internal/sdk/models/shared/taskbase.go - internal/sdk/models/shared/tasktype.go @@ -207,13 +157,15 @@ generatedFiles: - internal/sdk/models/shared/trigger.go - internal/sdk/models/shared/triggermode.go - internal/sdk/models/shared/updateentityattributes.go + - internal/sdk/models/shared/version.go - internal/sdk/models/shared/workflowdefinition.go + - internal/sdk/optionalnullable/optionalnullable.go + - internal/sdk/optionalnullable/optionalnullable_test.go - internal/sdk/retry/config.go - internal/sdk/sdk.go - internal/sdk/types/bigint.go - internal/sdk/types/date.go - internal/sdk/types/datetime.go - - internal/sdk/types/decimal.go - internal/sdk/types/pointers.go - internal/sdk/workflows.go - internal/validators/DateValidator.go @@ -272,7 +224,7 @@ examples: "500": application/json: {} "201": - application/json: {"closingReasons": [{"id": "x739cew"}], "creationTime": "2021-04-27T12:01:13.000Z", "dueDate": "2021-04-27T12:00:00.000Z", "enabled": true, "flow": "", "lastUpdateTime": "2021-04-27T12:01:13.000Z", "name": "", "updateEntityAttributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + application/json: {"closingReasons": [{"id": "x739cew"}], "creationTime": "2021-04-27T12:01:13.000Z", "dueDate": "2021-04-27T12:00:00.000Z", "enabled": true, "flow": [{"dueDate": "2021-04-27T12:00:00.000Z", "name": "", "order": 3330.41, "type": "SECTION"}], "lastUpdateTime": "2021-04-27T12:01:13.000Z", "name": "", "updateEntityAttributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} deleteDefinition: speakeasy-default-delete-definition: parameters: @@ -391,10 +343,10 @@ examples: createFlowTemplate: speakeasy-default-create-flow-template: requestBody: - application/json: {"closing_reasons": [{"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "is_flow_migrated": false, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"conditions": [], "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "created_automatically": false, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "DECISION"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v3"} responses: "201": - application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "enabled": true, "is_flow_migrated": false, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "created_automatically": false, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v1"} "400": application/json: {} "500": @@ -414,7 +366,7 @@ examples: flowId: "7hj28akg" responses: "200": - application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "is_flow_migrated": false, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "created_automatically": false, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v1"} "400": application/json: {} "404": @@ -423,6 +375,11 @@ examples: application/json: {} listFlowTemplates: speakeasy-default-list-flow-templates: + parameters: + query: + trigger_type: "journey_submission" + trigger_source_id: "j208g0aj-08g9agajggak-g9aug9-892kgl1m" + trigger_schema: "opportunity" responses: "200": application/json: {"results": []} @@ -434,13 +391,35 @@ examples: path: flowId: "7hj28akg" requestBody: - application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "is_flow_migrated": false, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "DECISION"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"automation_config": {"flow_id": ""}, "created_automatically": false, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "DECISION"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v2"} responses: "200": - application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "enabled": true, "is_flow_migrated": false, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v3"} + "400": + application/json: {} + "500": + application/json: {} + duplicateFlowTemplate: + speakeasy-default-duplicate-flow-template: + parameters: + path: + flowId: "7hj28akg" + responses: + "201": + application/json: {"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v3"} "400": application/json: {} "500": application/json: {} + searchFlowTemplates: + speakeasy-default-search-flow-templates: + requestBody: + application/json: {"sort_by": "updated_at", "sort_order": "desc"} + responses: + "200": + application/json: {"results": [{"created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "enabled": true, "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [], "trigger": {"automation_id": "g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg", "type": "automation"}, "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z", "version": "v3"}]} + "500": + application/json: {} examplesVersion: 1.0.2 generatedTests: {} +releaseNotes: "## Terraform SDK Changes Detected:\n* `SDK.Closing Reason.createClosingReason()`: `request` **Changed** **Breaking** :warning:\n* `SDK.Workflows.createDefinition()`: \n * `request` **Changed**\n * `response` **Changed** **Breaking** :warning:\n* `SDK.Flows V2.createFlowTemplate()`: **Added**\n* `SDK.Flows V2.searchFlowTemplates()`: **Added**\n* `SDK.Closing Reason.deleteClosingReason()`: **Added**\n* `SDK.Flows V2.deleteFlowTemplate()`: **Added**\n* `SDK.Flows V2.duplicateFlowTemplate()`: **Added**\n* `SDK.Flows V2.getFlowTemplate()`: **Added**\n* `SDK.Flows V2.listFlowTemplates()`: **Added**\n* `SDK.Closing Reason.updateClosingReason()`: **Added**\n* `SDK.Flows V2.updateFlowTemplate()`: **Added**\n* `SDK.Closing Reason.getClosingReasonV1()`: **Added**\n* `SDK.Closing Reason.getClosingReason()`: **Added**\n* `SDK.Workflows.getDefinition()`: `response` **Changed**\n* `SDK.Workflows.getDefinitions()`: `response.[]` **Changed**\n* `SDK.Workflows.updateDefinition()`: \n * `request.WorkflowDefinition` **Changed**\n * `response` **Changed**\n" diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 2b36614..4ccd639 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,18 +1,19 @@ -speakeasyVersion: 1.606.10 +speakeasyVersion: 1.645.1 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:2ee81d075cfd43eeb48662bce1ecc240dd0dd642c3f5a17946ecdd6902fea272 - sourceBlobDigest: sha256:ca57c9f570036cc2e6be6bc717859bdf514add526b696920bca75f1801c7cace + sourceRevisionDigest: sha256:c52c4814735af276d55ea024eae3b463e0da0fdb4be3bb5350fd5d2a835eb3af + sourceBlobDigest: sha256:457ebd0c094bdb65d3284268d8780ae9973f9bc7dc728d0ff6bacfda53966852 tags: - latest + - speakeasy-sdk-regen-1759279029 - 1.0.0 targets: terraform: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:2ee81d075cfd43eeb48662bce1ecc240dd0dd642c3f5a17946ecdd6902fea272 - sourceBlobDigest: sha256:ca57c9f570036cc2e6be6bc717859bdf514add526b696920bca75f1801c7cace + sourceRevisionDigest: sha256:c52c4814735af276d55ea024eae3b463e0da0fdb4be3bb5350fd5d2a835eb3af + sourceBlobDigest: sha256:457ebd0c094bdb65d3284268d8780ae9973f9bc7dc728d0ff6bacfda53966852 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 5d7abad..c339dab 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ terraform { required_providers { epilot-workflow = { source = "epilot-dev/epilot-workflow" - version = "0.19.0" + version = "0.20.0" } } } @@ -114,19 +114,24 @@ provider_installation { ``` + +## Authentication + +This provider supports authentication configuration via provider configuration. + +Available configuration: + +| Provider Attribute | Description | +|---|---| +| `bearer_auth` | HTTP Bearer. | + + ## Available Resources and Data Sources ### Resources -* [epilot-workflow_closing_reason](docs/resources/closing_reason.md) -* [epilot-workflow_flow_template](docs/resources/flow_template.md) -* [epilot-workflow_workflow_definition](docs/resources/workflow_definition.md) ### Data Sources - -* [epilot-workflow_closing_reason](docs/data-sources/closing_reason.md) -* [epilot-workflow_flow_template](docs/data-sources/flow_template.md) -* [epilot-workflow_workflow_definition](docs/data-sources/workflow_definition.md) @@ -141,6 +146,7 @@ Workflows Definitions: Service for Workflow Definitions for different processes * [epilot-workflow](#epilot-workflow) * [Installation](#installation) * [Testing the provider locally](#testing-the-provider-locally) + * [Authentication](#authentication) * [Available Resources and Data Sources](#available-resources-and-data-sources) diff --git a/RELEASES.md b/RELEASES.md index 3a0103b..ae768e3 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -22,4 +22,14 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.303.0 (2.339.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [terraform v0.8.2] . \ No newline at end of file +- [terraform v0.8.2] . + +## 2025-11-01 00:36:51 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.645.1 (2.735.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.20.0] . +### Releases +- [Terraform v0.20.0] https://registry.terraform.io/providers/epilot-dev/epilot-workflow/0.20.0 - . \ No newline at end of file diff --git a/docs/data-sources/closing_reason.md b/docs/data-sources/closing_reason.md deleted file mode 100644 index 40e29df..0000000 --- a/docs/data-sources/closing_reason.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_closing_reason Data Source - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - ClosingReason DataSource ---- - -# epilot-workflow_closing_reason (Data Source) - -ClosingReason DataSource - -## Example Usage - -```terraform -data "epilot-workflow_closing_reason" "my_closingreason" { -} -``` - - -## Schema - -### Read-Only - -- `creation_time` (String) -- `id` (String) The ID of this resource. -- `last_update_time` (String) -- `status` (String) -- `title` (String) diff --git a/docs/data-sources/flow_template.md b/docs/data-sources/flow_template.md deleted file mode 100644 index 123c550..0000000 --- a/docs/data-sources/flow_template.md +++ /dev/null @@ -1,623 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_flow_template Data Source - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - FlowTemplate DataSource ---- - -# epilot-workflow_flow_template (Data Source) - -FlowTemplate DataSource - -## Example Usage - -```terraform -data "epilot-workflow_flow_template" "my_flowtemplate" { -} -``` - - -## Schema - -### Read-Only - -- `assigned_to` (List of String) -- `available_in_ecp` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `closing_reasons` (Attributes List) (see [below for nested schema](#nestedatt--closing_reasons)) -- `created_at` (String) ISO String Date & Time -- `description` (String) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--due_date_config)) -- `edges` (Attributes List) (see [below for nested schema](#nestedatt--edges)) -- `enabled` (Boolean) Whether the workflow is enabled or not -- `id` (String) The ID of this resource. -- `is_flow_migrated` (Boolean) Whether the workflow is migrated from workflows to flows or not -- `name` (String) -- `org_id` (String) -- `phases` (Attributes List) (see [below for nested schema](#nestedatt--phases)) -- `tasks` (Attributes List) (see [below for nested schema](#nestedatt--tasks)) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering -- `trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger)) -- `update_entity_attributes` (Attributes List) (see [below for nested schema](#nestedatt--update_entity_attributes)) -- `updated_at` (String) ISO String Date & Time - - -### Nested Schema for `closing_reasons` - -Read-Only: - -- `creation_time` (String) -- `id` (String) -- `last_update_time` (String) -- `status` (String) -- `title` (String) - - - -### Nested Schema for `due_date_config` - -Read-Only: - -- `duration` (Number) -- `phase_id` (String) -- `task_id` (String) -- `type` (String) -- `unit` (String) - - - -### Nested Schema for `edges` - -Read-Only: - -- `condition_id` (String) -- `from_id` (String) -- `id` (String) -- `none_met` (Boolean) Indicates a default case for a decision task. Only decision task edges can have this field and the flow advances using this edge if no conditions are met. -- `to_id` (String) - - - -### Nested Schema for `phases` - -Read-Only: - -- `assigned_to` (List of String) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--phases--due_date_config)) -- `id` (String) -- `name` (String) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - - -### Nested Schema for `phases.due_date_config` - -Read-Only: - -- `duration` (Number) -- `phase_id` (String) -- `task_id` (String) -- `type` (String) -- `unit` (String) - - - - -### Nested Schema for `tasks` - -Read-Only: - -- `automation_task` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task)) -- `decision_task` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task)) -- `task_base` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base)) - - -### Nested Schema for `tasks.automation_task` - -Read-Only: - -- `assigned_to` (List of String) -- `automation_config` (Attributes) Configuration for automation execution to run (see [below for nested schema](#nestedatt--tasks--automation_task--automation_config)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--tasks--automation_task--description)) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--tasks--automation_task--due_date_config)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--automation_task--ecp)) -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--automation_task--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--journey)) -- `name` (String) -- `phase_id` (String) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the task while flow instances are running (see [below for nested schema](#nestedatt--tasks--automation_task--requirements)) -- `schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule)) -- `task_type` (String) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering -- `trigger_mode` (String) - - -### Nested Schema for `tasks.automation_task.automation_config` - -Read-Only: - -- `flow_id` (String) Id of the configured automation to run - - - -### Nested Schema for `tasks.automation_task.description` - -Read-Only: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `tasks.automation_task.due_date_config` - -Read-Only: - -- `duration` (Number) -- `phase_id` (String) -- `task_id` (String) -- `type` (String) -- `unit` (String) - - - -### Nested Schema for `tasks.automation_task.ecp` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--ecp--journey)) -- `label` (String) - - -### Nested Schema for `tasks.automation_task.ecp.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.automation_task.installer` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--installer--journey)) -- `label` (String) - - -### Nested Schema for `tasks.automation_task.installer.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.automation_task.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `tasks.automation_task.requirements` - -Read-Only: - -- `phase_id` (String) -- `task_id` (String) -- `when` (String) - - - -### Nested Schema for `tasks.automation_task.schedule` - -Read-Only: - -- `delayed_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--delayed_schedule)) -- `immediate_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--immediate_schedule)) -- `relative_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--relative_schedule)) - - -### Nested Schema for `tasks.automation_task.schedule.delayed_schedule` - -Read-Only: - -- `duration` (Number) -- `mode` (String) -- `unit` (String) - - - -### Nested Schema for `tasks.automation_task.schedule.immediate_schedule` - -Read-Only: - -- `mode` (String) - - - -### Nested Schema for `tasks.automation_task.schedule.relative_schedule` - -Read-Only: - -- `direction` (String) -- `duration` (Number) -- `mode` (String) -- `reference` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--relative_schedule--reference)) -- `unit` (String) - - -### Nested Schema for `tasks.automation_task.schedule.relative_schedule.reference` - -Read-Only: - -- `attribute` (String) An entity attribute that identifies a date / datetime -- `id` (String) The id of the entity / workflow / task, based on the origin of the schedule -- `origin` (String) -- `schema` (String) The schema of the entity - - - - - - -### Nested Schema for `tasks.decision_task` - -Read-Only: - -- `assigned_to` (List of String) -- `conditions` (Attributes List) (see [below for nested schema](#nestedatt--tasks--decision_task--conditions)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--tasks--decision_task--description)) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--tasks--decision_task--due_date_config)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--decision_task--ecp)) -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--decision_task--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--journey)) -- `name` (String) -- `phase_id` (String) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the task while flow instances are running (see [below for nested schema](#nestedatt--tasks--decision_task--requirements)) -- `schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule)) -- `task_type` (String) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - - -### Nested Schema for `tasks.decision_task.conditions` - -Read-Only: - -- `branch_name` (String) The name of the branch -- `id` (String) -- `logical_operator` (String) -- `statements` (Attributes List) (see [below for nested schema](#nestedatt--tasks--decision_task--conditions--statements)) - - -### Nested Schema for `tasks.decision_task.conditions.statements` - -Read-Only: - -- `id` (String) -- `operator` (String) -- `source` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--conditions--statements--source)) -- `values` (List of String) - - -### Nested Schema for `tasks.decision_task.conditions.statements.source` - -Read-Only: - -- `attribute` (String) -- `attribute_operation` (String) -- `attribute_repeatable` (Boolean) -- `attribute_type` (String) -- `id` (String) The id of the action or trigger -- `origin` (String) -- `origin_type` (String) -- `schema` (String) - - - - - -### Nested Schema for `tasks.decision_task.description` - -Read-Only: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `tasks.decision_task.due_date_config` - -Read-Only: - -- `duration` (Number) -- `phase_id` (String) -- `task_id` (String) -- `type` (String) -- `unit` (String) - - - -### Nested Schema for `tasks.decision_task.ecp` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--ecp--journey)) -- `label` (String) - - -### Nested Schema for `tasks.decision_task.ecp.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.decision_task.installer` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--installer--journey)) -- `label` (String) - - -### Nested Schema for `tasks.decision_task.installer.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.decision_task.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `tasks.decision_task.requirements` - -Read-Only: - -- `phase_id` (String) -- `task_id` (String) -- `when` (String) - - - -### Nested Schema for `tasks.decision_task.schedule` - -Read-Only: - -- `delayed_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule--delayed_schedule)) -- `relative_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule--relative_schedule)) - - -### Nested Schema for `tasks.decision_task.schedule.delayed_schedule` - -Read-Only: - -- `duration` (Number) -- `mode` (String) -- `unit` (String) - - - -### Nested Schema for `tasks.decision_task.schedule.relative_schedule` - -Read-Only: - -- `direction` (String) -- `duration` (Number) -- `mode` (String) -- `reference` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule--relative_schedule--reference)) -- `unit` (String) - - -### Nested Schema for `tasks.decision_task.schedule.relative_schedule.reference` - -Read-Only: - -- `attribute` (String) An entity attribute that identifies a date / datetime -- `id` (String) The id of the entity / workflow / task, based on the origin of the schedule -- `origin` (String) -- `schema` (String) The schema of the entity - - - - - - -### Nested Schema for `tasks.task_base` - -Read-Only: - -- `assigned_to` (List of String) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--tasks--task_base--description)) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--tasks--task_base--due_date_config)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--task_base--ecp)) -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--task_base--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base--journey)) -- `name` (String) -- `phase_id` (String) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the task while flow instances are running (see [below for nested schema](#nestedatt--tasks--task_base--requirements)) -- `task_type` (String) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - - -### Nested Schema for `tasks.task_base.description` - -Read-Only: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `tasks.task_base.due_date_config` - -Read-Only: - -- `duration` (Number) -- `phase_id` (String) -- `task_id` (String) -- `type` (String) -- `unit` (String) - - - -### Nested Schema for `tasks.task_base.ecp` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base--ecp--journey)) -- `label` (String) - - -### Nested Schema for `tasks.task_base.ecp.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.task_base.installer` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base--installer--journey)) -- `label` (String) - - -### Nested Schema for `tasks.task_base.installer.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.task_base.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `tasks.task_base.requirements` - -Read-Only: - -- `phase_id` (String) -- `task_id` (String) -- `when` (String) - - - - - -### Nested Schema for `trigger` - -Read-Only: - -- `automation_trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger--automation_trigger)) -- `journey_submission_trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger--journey_submission_trigger)) -- `manual_trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger--manual_trigger)) - - -### Nested Schema for `trigger.automation_trigger` - -Read-Only: - -- `automation_id` (String) Id of the automation config that triggers this workflow -- `id` (String) -- `type` (String) - - - -### Nested Schema for `trigger.journey_submission_trigger` - -Read-Only: - -- `automation_id` (String) -- `id` (String) -- `journey_id` (String) ID of the journey that will trigger this flow -- `type` (String) - - - -### Nested Schema for `trigger.manual_trigger` - -Read-Only: - -- `entity_schema` (String) -- `id` (String) -- `type` (String) - - - - -### Nested Schema for `update_entity_attributes` - -Read-Only: - -- `source` (String) -- `target` (Attributes) (see [below for nested schema](#nestedatt--update_entity_attributes--target)) - - -### Nested Schema for `update_entity_attributes.target` - -Read-Only: - -- `entity_attribute` (String) -- `entity_schema` (String) diff --git a/docs/data-sources/workflow_definition.md b/docs/data-sources/workflow_definition.md deleted file mode 100644 index 65409fa..0000000 --- a/docs/data-sources/workflow_definition.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_workflow_definition Data Source - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - WorkflowDefinition DataSource ---- - -# epilot-workflow_workflow_definition (Data Source) - -WorkflowDefinition DataSource - -## Example Usage - -```terraform -data "epilot-workflow_workflow_definition" "my_workflowdefinition" { -} -``` - - -## Schema - -### Read-Only - -- `assigned_to` (List of String) -- `closing_reasons` (Attributes List) (see [below for nested schema](#nestedatt--closing_reasons)) -- `creation_time` (String) ISO String Date & Time -- `description` (String) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--dynamic_due_date)) -- `enable_ecp_workflow` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `enabled` (Boolean) Whether the workflow is enabled or not -- `flow` (String) Parsed as JSON. -- `id` (String) The ID of this resource. -- `last_update_time` (String) ISO String Date & Time -- `name` (String) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering -- `update_entity_attributes` (Attributes List) (see [below for nested schema](#nestedatt--update_entity_attributes)) -- `user_ids` (List of Number, Deprecated) This field is deprecated. Please use assignedTo - - -### Nested Schema for `closing_reasons` - -Read-Only: - -- `id` (String) - - - -### Nested Schema for `dynamic_due_date` - -Read-Only: - -- `action_type_condition` (String) -- `number_of_units` (Number) -- `phase_id` (String) -- `step_id` (String) -- `time_period` (String) - - - -### Nested Schema for `update_entity_attributes` - -Read-Only: - -- `source` (String) -- `target` (Attributes) (see [below for nested schema](#nestedatt--update_entity_attributes--target)) - - -### Nested Schema for `update_entity_attributes.target` - -Read-Only: - -- `entity_attribute` (String) -- `entity_schema` (String) diff --git a/docs/index.md b/docs/index.md index b4b31ed..b53650f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,7 @@ terraform { required_providers { epilot-workflow = { source = "epilot-dev/epilot-workflow" - version = "0.19.0" + version = "0.20.0" } } } @@ -31,7 +31,7 @@ provider "epilot-workflow" { ### Required -- `bearer_auth` (String, Sensitive) +- `bearer_auth` (String, Sensitive) HTTP Bearer. ### Optional diff --git a/docs/resources/closing_reason.md b/docs/resources/closing_reason.md deleted file mode 100644 index 04f24dc..0000000 --- a/docs/resources/closing_reason.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_closing_reason Resource - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - ClosingReason Resource ---- - -# epilot-workflow_closing_reason (Resource) - -ClosingReason Resource - -## Example Usage - -```terraform -resource "epilot-workflow_closing_reason" "my_closingreason" { - status = "INACTIVE" - title = "...my_title..." -} -``` - - -## Schema - -### Required - -- `status` (String) must be one of ["ACTIVE", "INACTIVE"] -- `title` (String) - -### Read-Only - -- `creation_time` (String) -- `id` (String) The ID of this resource. -- `last_update_time` (String) - -## Import - -Import is supported using the following syntax: - -In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example: - -```terraform -import { - to = epilot-workflow_closing_reason.my_epilot-workflow_closing_reason - id = "..." -} -``` - -The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: - -```shell -terraform import epilot-workflow_closing_reason.my_epilot-workflow_closing_reason "..." -``` diff --git a/docs/resources/flow_template.md b/docs/resources/flow_template.md deleted file mode 100644 index 490b575..0000000 --- a/docs/resources/flow_template.md +++ /dev/null @@ -1,802 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_flow_template Resource - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - FlowTemplate Resource ---- - -# epilot-workflow_flow_template (Resource) - -FlowTemplate Resource - -## Example Usage - -```terraform -resource "epilot-workflow_flow_template" "my_flowtemplate" { - assigned_to = [ - "..." - ] - available_in_ecp = true - closing_reasons = [ - { - id = "x739cew" - } - ] - created_at = "2021-04-27T12:01:13.000Z" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" - due_date_config = { - duration = 0.19 - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - type = "PHASE_FINISHED" - unit = "hours" - } - edges = [ - { - condition_id = "...my_condition_id..." - from_id = "...my_from_id..." - id = "...my_id..." - none_met = true - to_id = "...my_to_id..." - } - ] - enabled = true - id = "...my_id..." - is_flow_migrated = true - name = "...my_name..." - org_id = "...my_org_id..." - phases = [ - { - assigned_to = [ - "..." - ] - due_date = "2021-04-27T12:00:00.000Z" - due_date_config = { - duration = 9.34 - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - type = "TASK_FINISHED" - unit = "days" - } - id = "...my_id..." - name = "...my_name..." - taxonomies = [ - "..." - ] - } - ] - tasks = [ - { - automation_task = { - assigned_to = [ - "..." - ] - automation_config = { - flow_id = "...my_flow_id..." - } - description = { - enabled = false - value = "...my_value..." - } - due_date = "2021-04-27T12:00:00.000Z" - due_date_config = { - duration = 8.65 - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - type = "PHASE_FINISHED" - unit = "days" - } - ecp = { - description = "...my_description..." - enabled = true - journey = { - id = "...my_id..." - journey_id = "...my_journey_id..." - name = "...my_name..." - } - label = "...my_label..." - } - id = "...my_id..." - installer = { - description = "...my_description..." - enabled = false - journey = { - id = "...my_id..." - journey_id = "...my_journey_id..." - name = "...my_name..." - } - label = "...my_label..." - } - journey = { - id = "...my_id..." - journey_id = "...my_journey_id..." - name = "...my_name..." - } - name = "...my_name..." - phase_id = "...my_phase_id..." - requirements = [ - { - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - when = "PHASE_FINISHED" - } - ] - schedule = { - relative_schedule = { - direction = "before" - duration = 3.2 - mode = "relative" - reference = { - attribute = "...my_attribute..." - id = "...my_id..." - origin = "flow_started" - schema = "...my_schema..." - } - unit = "days" - } - } - task_type = "AUTOMATION" - taxonomies = [ - "..." - ] - trigger_mode = "automatic" - } - } - ] - taxonomies = [ - "..." - ] - trigger = { - manual_trigger = { - entity_schema = "...my_entity_schema..." - id = "...my_id..." - type = "manual" - } - } - update_entity_attributes = [ - { - source = "current_step" - target = { - entity_attribute = "my_status" - entity_schema = "opportunity" - } - } - ] - updated_at = "2021-04-27T12:01:13.000Z" -} -``` - - -## Schema - -### Required - -- `edges` (Attributes List) (see [below for nested schema](#nestedatt--edges)) -- `name` (String) -- `tasks` (Attributes List) (see [below for nested schema](#nestedatt--tasks)) - -### Optional - -- `assigned_to` (List of String) -- `available_in_ecp` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `closing_reasons` (Attributes List) (see [below for nested schema](#nestedatt--closing_reasons)) -- `created_at` (String) ISO String Date & Time -- `description` (String) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--due_date_config)) -- `enabled` (Boolean) Whether the workflow is enabled or not. Default: true -- `is_flow_migrated` (Boolean) Whether the workflow is migrated from workflows to flows or not. Default: false -- `org_id` (String) -- `phases` (Attributes List) (see [below for nested schema](#nestedatt--phases)) -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering -- `trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger)) -- `update_entity_attributes` (Attributes List) (see [below for nested schema](#nestedatt--update_entity_attributes)) -- `updated_at` (String) ISO String Date & Time - -### Read-Only - -- `id` (String) The ID of this resource. - - -### Nested Schema for `edges` - -Optional: - -- `condition_id` (String) -- `from_id` (String) Not Null -- `id` (String) Not Null -- `none_met` (Boolean) Indicates a default case for a decision task. Only decision task edges can have this field and the flow advances using this edge if no conditions are met. -- `to_id` (String) Not Null - - - -### Nested Schema for `tasks` - -Optional: - -- `automation_task` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task)) -- `decision_task` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task)) -- `task_base` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base)) - - -### Nested Schema for `tasks.automation_task` - -Optional: - -- `assigned_to` (List of String) -- `automation_config` (Attributes) Configuration for automation execution to run. Not Null (see [below for nested schema](#nestedatt--tasks--automation_task--automation_config)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--tasks--automation_task--description)) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--tasks--automation_task--due_date_config)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--automation_task--ecp)) -- `id` (String) Not Null -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--automation_task--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--journey)) -- `name` (String) Not Null -- `phase_id` (String) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the task while flow instances are running (see [below for nested schema](#nestedatt--tasks--automation_task--requirements)) -- `schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule)) -- `task_type` (String) Not Null; must be one of ["MANUAL", "AUTOMATION", "DECISION"] -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering -- `trigger_mode` (String) must be one of ["manual", "automatic"] - - -### Nested Schema for `tasks.automation_task.automation_config` - -Optional: - -- `flow_id` (String) Id of the configured automation to run. Not Null - - - -### Nested Schema for `tasks.automation_task.description` - -Optional: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `tasks.automation_task.due_date_config` - -Optional: - -- `duration` (Number) Not Null -- `phase_id` (String) -- `task_id` (String) -- `type` (String) Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"] -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `tasks.automation_task.ecp` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--ecp--journey)) -- `label` (String) - - -### Nested Schema for `tasks.automation_task.ecp.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.automation_task.installer` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--installer--journey)) -- `label` (String) - - -### Nested Schema for `tasks.automation_task.installer.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.automation_task.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `tasks.automation_task.requirements` - -Optional: - -- `phase_id` (String) -- `task_id` (String) -- `when` (String) Not Null; must be one of ["TASK_FINISHED", "PHASE_FINISHED"] - - - -### Nested Schema for `tasks.automation_task.schedule` - -Optional: - -- `delayed_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--delayed_schedule)) -- `immediate_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--immediate_schedule)) -- `relative_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--relative_schedule)) - - -### Nested Schema for `tasks.automation_task.schedule.delayed_schedule` - -Optional: - -- `duration` (Number) Not Null -- `mode` (String) Not Null; must be "delayed" -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `tasks.automation_task.schedule.immediate_schedule` - -Optional: - -- `mode` (String) must be "immediate" - - - -### Nested Schema for `tasks.automation_task.schedule.relative_schedule` - -Optional: - -- `direction` (String) Not Null; must be one of ["before", "after"] -- `duration` (Number) Not Null -- `mode` (String) Not Null; must be "relative" -- `reference` (Attributes) Not Null (see [below for nested schema](#nestedatt--tasks--automation_task--schedule--relative_schedule--reference)) -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - -### Nested Schema for `tasks.automation_task.schedule.relative_schedule.reference` - -Optional: - -- `attribute` (String) An entity attribute that identifies a date / datetime -- `id` (String) The id of the entity / workflow / task, based on the origin of the schedule. Not Null -- `origin` (String) Not Null; must be one of ["flow_started", "task_completed", "trigger_entity_attribute"] -- `schema` (String) The schema of the entity - - - - - - -### Nested Schema for `tasks.decision_task` - -Optional: - -- `assigned_to` (List of String) -- `conditions` (Attributes List) Not Null (see [below for nested schema](#nestedatt--tasks--decision_task--conditions)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--tasks--decision_task--description)) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--tasks--decision_task--due_date_config)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--decision_task--ecp)) -- `id` (String) Not Null -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--decision_task--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--journey)) -- `name` (String) Not Null -- `phase_id` (String) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the task while flow instances are running (see [below for nested schema](#nestedatt--tasks--decision_task--requirements)) -- `schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule)) -- `task_type` (String) Not Null; must be one of ["MANUAL", "AUTOMATION", "DECISION"] -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - - -### Nested Schema for `tasks.decision_task.conditions` - -Optional: - -- `branch_name` (String) The name of the branch. Not Null -- `id` (String) Not Null -- `logical_operator` (String) Not Null; must be one of ["AND", "OR"] -- `statements` (Attributes List) Not Null (see [below for nested schema](#nestedatt--tasks--decision_task--conditions--statements)) - - -### Nested Schema for `tasks.decision_task.conditions.statements` - -Optional: - -- `id` (String) Not Null -- `operator` (String) Not Null; must be one of ["equals", "not_equals", "any_of", "none_of", "contains", "not_contains", "starts_with", "ends_with", "greater_than", "less_than", "greater_than_or_equals", "less_than_or_equals", "is_empty", "is_not_empty"] -- `source` (Attributes) Not Null (see [below for nested schema](#nestedatt--tasks--decision_task--conditions--statements--source)) -- `values` (List of String) Not Null - - -### Nested Schema for `tasks.decision_task.conditions.statements.source` - -Optional: - -- `attribute` (String) -- `attribute_operation` (String) must be one of ["all", "updated", "added", "deleted"] -- `attribute_repeatable` (Boolean) -- `attribute_type` (String) must be one of ["string", "text", "number", "boolean", "date", "datetime", "tags", "country", "email", "phone", "product", "price", "status", "relation", "multiselect", "select", "radio", "relation_user", "purpose", "label"] -- `id` (String) The id of the action or trigger -- `origin` (String) must be one of ["trigger", "action"] -- `origin_type` (String) must be one of ["entity", "workflow", "journey_block"] -- `schema` (String) - - - - - -### Nested Schema for `tasks.decision_task.description` - -Optional: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `tasks.decision_task.due_date_config` - -Optional: - -- `duration` (Number) Not Null -- `phase_id` (String) -- `task_id` (String) -- `type` (String) Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"] -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `tasks.decision_task.ecp` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--ecp--journey)) -- `label` (String) - - -### Nested Schema for `tasks.decision_task.ecp.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.decision_task.installer` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--installer--journey)) -- `label` (String) - - -### Nested Schema for `tasks.decision_task.installer.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.decision_task.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `tasks.decision_task.requirements` - -Optional: - -- `phase_id` (String) -- `task_id` (String) -- `when` (String) Not Null; must be one of ["TASK_FINISHED", "PHASE_FINISHED"] - - - -### Nested Schema for `tasks.decision_task.schedule` - -Optional: - -- `delayed_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule--delayed_schedule)) -- `relative_schedule` (Attributes) (see [below for nested schema](#nestedatt--tasks--decision_task--schedule--relative_schedule)) - - -### Nested Schema for `tasks.decision_task.schedule.delayed_schedule` - -Optional: - -- `duration` (Number) Not Null -- `mode` (String) Not Null; must be "delayed" -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `tasks.decision_task.schedule.relative_schedule` - -Optional: - -- `direction` (String) Not Null; must be one of ["before", "after"] -- `duration` (Number) Not Null -- `mode` (String) Not Null; must be "relative" -- `reference` (Attributes) Not Null (see [below for nested schema](#nestedatt--tasks--decision_task--schedule--relative_schedule--reference)) -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - -### Nested Schema for `tasks.decision_task.schedule.relative_schedule.reference` - -Optional: - -- `attribute` (String) An entity attribute that identifies a date / datetime -- `id` (String) The id of the entity / workflow / task, based on the origin of the schedule. Not Null -- `origin` (String) Not Null; must be one of ["flow_started", "task_completed", "trigger_entity_attribute"] -- `schema` (String) The schema of the entity - - - - - - -### Nested Schema for `tasks.task_base` - -Optional: - -- `assigned_to` (List of String) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--tasks--task_base--description)) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--tasks--task_base--due_date_config)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--task_base--ecp)) -- `id` (String) Not Null -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--tasks--task_base--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base--journey)) -- `name` (String) Not Null -- `phase_id` (String) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the task while flow instances are running (see [below for nested schema](#nestedatt--tasks--task_base--requirements)) -- `task_type` (String) Not Null; must be one of ["MANUAL", "AUTOMATION", "DECISION"] -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - - -### Nested Schema for `tasks.task_base.description` - -Optional: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `tasks.task_base.due_date_config` - -Optional: - -- `duration` (Number) Not Null -- `phase_id` (String) -- `task_id` (String) -- `type` (String) Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"] -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `tasks.task_base.ecp` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base--ecp--journey)) -- `label` (String) - - -### Nested Schema for `tasks.task_base.ecp.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.task_base.installer` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--tasks--task_base--installer--journey)) -- `label` (String) - - -### Nested Schema for `tasks.task_base.installer.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `tasks.task_base.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `tasks.task_base.requirements` - -Optional: - -- `phase_id` (String) -- `task_id` (String) -- `when` (String) Not Null; must be one of ["TASK_FINISHED", "PHASE_FINISHED"] - - - - - -### Nested Schema for `closing_reasons` - -Optional: - -- `id` (String) Not Null; Requires replacement if changed. - -Read-Only: - -- `creation_time` (String) -- `last_update_time` (String) -- `status` (String) must be one of ["ACTIVE", "INACTIVE"] -- `title` (String) - - - -### Nested Schema for `due_date_config` - -Optional: - -- `duration` (Number) Not Null -- `phase_id` (String) -- `task_id` (String) -- `type` (String) Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"] -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `phases` - -Optional: - -- `assigned_to` (List of String) -- `due_date` (String) -- `due_date_config` (Attributes) Set due date for the task based on a dynamic condition (see [below for nested schema](#nestedatt--phases--due_date_config)) -- `id` (String) Not Null -- `name` (String) Not Null -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - - -### Nested Schema for `phases.due_date_config` - -Optional: - -- `duration` (Number) Not Null -- `phase_id` (String) -- `task_id` (String) -- `type` (String) Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"] -- `unit` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - - -### Nested Schema for `trigger` - -Optional: - -- `automation_trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger--automation_trigger)) -- `journey_submission_trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger--journey_submission_trigger)) -- `manual_trigger` (Attributes) (see [below for nested schema](#nestedatt--trigger--manual_trigger)) - - -### Nested Schema for `trigger.automation_trigger` - -Optional: - -- `automation_id` (String) Id of the automation config that triggers this workflow. Not Null -- `id` (String) -- `type` (String) Not Null; must be "automation" - - - -### Nested Schema for `trigger.journey_submission_trigger` - -Optional: - -- `automation_id` (String) -- `id` (String) -- `journey_id` (String) ID of the journey that will trigger this flow. Not Null -- `type` (String) Not Null; must be "journey_submission" - - - -### Nested Schema for `trigger.manual_trigger` - -Optional: - -- `entity_schema` (String) -- `id` (String) -- `type` (String) Not Null; must be "manual" - - - - -### Nested Schema for `update_entity_attributes` - -Optional: - -- `source` (String) Not Null; must be one of ["workflow_status", "current_section", "current_step"] -- `target` (Attributes) Not Null (see [below for nested schema](#nestedatt--update_entity_attributes--target)) - - -### Nested Schema for `update_entity_attributes.target` - -Optional: - -- `entity_attribute` (String) Not Null -- `entity_schema` (String) Not Null - -## Import - -Import is supported using the following syntax: - -In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example: - -```terraform -import { - to = epilot-workflow_flow_template.my_epilot-workflow_flow_template - id = "..." -} -``` - -The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: - -```shell -terraform import epilot-workflow_flow_template.my_epilot-workflow_flow_template "..." -``` diff --git a/docs/resources/workflow_definition.md b/docs/resources/workflow_definition.md deleted file mode 100644 index 8ddc247..0000000 --- a/docs/resources/workflow_definition.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_workflow_definition Resource - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - WorkflowDefinition Resource ---- - -# epilot-workflow_workflow_definition (Resource) - -WorkflowDefinition Resource - -## Example Usage - -```terraform -resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - assigned_to = [ - "..." - ] - closing_reasons = [ - { - id = "x739cew" - } - ] - creation_time = "2021-04-27T12:01:13.000Z" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" - dynamic_due_date = { - action_type_condition = "PHASE_FINISHED" - number_of_units = 0.36 - phase_id = "...my_phase_id..." - step_id = "...my_step_id..." - time_period = "days" - } - enable_ecp_workflow = false - enabled = false - flow = "{ \"see\": \"documentation\" }" - id = "...my_id..." - last_update_time = "2021-04-27T12:01:13.000Z" - name = "...my_name..." - taxonomies = [ - "..." - ] - update_entity_attributes = [ - { - source = "current_step" - target = { - entity_attribute = "my_status" - entity_schema = "opportunity" - } - } - ] - user_ids = [ - 5.93 - ] -} -``` - - -## Schema - -### Required - -- `flow` (String) Parsed as JSON. -- `name` (String) - -### Optional - -- `assigned_to` (List of String) -- `closing_reasons` (Attributes List) (see [below for nested schema](#nestedatt--closing_reasons)) -- `creation_time` (String) ISO String Date & Time -- `description` (String) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--dynamic_due_date)) -- `enable_ecp_workflow` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `enabled` (Boolean) Whether the workflow is enabled or not. Default: true -- `last_update_time` (String) ISO String Date & Time -- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering -- `update_entity_attributes` (Attributes List) (see [below for nested schema](#nestedatt--update_entity_attributes)) -- `user_ids` (List of Number, Deprecated) This field is deprecated. Please use assignedTo - -### Read-Only - -- `id` (String) The ID of this resource. - - -### Nested Schema for `closing_reasons` - -Optional: - -- `id` (String) Not Null - - - -### Nested Schema for `dynamic_due_date` - -Optional: - -- `action_type_condition` (String) Not Null; must be one of ["WORKFLOW_STARTED", "STEP_CLOSED", "PHASE_FINISHED"] -- `number_of_units` (Number) Not Null -- `phase_id` (String) -- `step_id` (String) -- `time_period` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] - - - -### Nested Schema for `update_entity_attributes` - -Optional: - -- `source` (String) Not Null; must be one of ["workflow_status", "current_section", "current_step"] -- `target` (Attributes) Not Null (see [below for nested schema](#nestedatt--update_entity_attributes--target)) - - -### Nested Schema for `update_entity_attributes.target` - -Optional: - -- `entity_attribute` (String) Not Null -- `entity_schema` (String) Not Null - -## Import - -Import is supported using the following syntax: - -In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example: - -```terraform -import { - to = epilot-workflow_workflow_definition.my_epilot-workflow_workflow_definition - id = "..." -} -``` - -The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: - -```shell -terraform import epilot-workflow_workflow_definition.my_epilot-workflow_workflow_definition "..." -``` diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index f87f5c1..0000000 --- a/examples/README.md +++ /dev/null @@ -1 +0,0 @@ -# TODO \ No newline at end of file diff --git a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf deleted file mode 100644 index 2d40804..0000000 --- a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf +++ /dev/null @@ -1,2 +0,0 @@ -data "epilot-workflow_closing_reason" "my_closingreason" { -} \ No newline at end of file diff --git a/examples/data-sources/epilot-workflow_flow_template/data-source.tf b/examples/data-sources/epilot-workflow_flow_template/data-source.tf deleted file mode 100644 index ec267cc..0000000 --- a/examples/data-sources/epilot-workflow_flow_template/data-source.tf +++ /dev/null @@ -1,2 +0,0 @@ -data "epilot-workflow_flow_template" "my_flowtemplate" { -} \ No newline at end of file diff --git a/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf b/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf deleted file mode 100644 index 3592e48..0000000 --- a/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf +++ /dev/null @@ -1,2 +0,0 @@ -data "epilot-workflow_workflow_definition" "my_workflowdefinition" { -} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 5afda36..e98bd52 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-workflow = { source = "epilot-dev/epilot-workflow" - version = "0.19.0" + version = "0.20.0" } } } diff --git a/examples/resources/epilot-workflow_closing_reason/import-by-string-id.tf b/examples/resources/epilot-workflow_closing_reason/import-by-string-id.tf deleted file mode 100644 index 730cd82..0000000 --- a/examples/resources/epilot-workflow_closing_reason/import-by-string-id.tf +++ /dev/null @@ -1,4 +0,0 @@ -import { - to = epilot-workflow_closing_reason.my_epilot-workflow_closing_reason - id = "..." -} diff --git a/examples/resources/epilot-workflow_closing_reason/import.sh b/examples/resources/epilot-workflow_closing_reason/import.sh deleted file mode 100644 index 2c59e71..0000000 --- a/examples/resources/epilot-workflow_closing_reason/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-workflow_closing_reason.my_epilot-workflow_closing_reason "..." diff --git a/examples/resources/epilot-workflow_closing_reason/resource.tf b/examples/resources/epilot-workflow_closing_reason/resource.tf deleted file mode 100644 index 725e50f..0000000 --- a/examples/resources/epilot-workflow_closing_reason/resource.tf +++ /dev/null @@ -1,4 +0,0 @@ -resource "epilot-workflow_closing_reason" "my_closingreason" { - status = "INACTIVE" - title = "...my_title..." -} \ No newline at end of file diff --git a/examples/resources/epilot-workflow_flow_template/import-by-string-id.tf b/examples/resources/epilot-workflow_flow_template/import-by-string-id.tf deleted file mode 100644 index 776f99f..0000000 --- a/examples/resources/epilot-workflow_flow_template/import-by-string-id.tf +++ /dev/null @@ -1,4 +0,0 @@ -import { - to = epilot-workflow_flow_template.my_epilot-workflow_flow_template - id = "..." -} diff --git a/examples/resources/epilot-workflow_flow_template/import.sh b/examples/resources/epilot-workflow_flow_template/import.sh deleted file mode 100644 index 125451c..0000000 --- a/examples/resources/epilot-workflow_flow_template/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-workflow_flow_template.my_epilot-workflow_flow_template "..." diff --git a/examples/resources/epilot-workflow_flow_template/resource.tf b/examples/resources/epilot-workflow_flow_template/resource.tf deleted file mode 100644 index 6379fbf..0000000 --- a/examples/resources/epilot-workflow_flow_template/resource.tf +++ /dev/null @@ -1,153 +0,0 @@ -resource "epilot-workflow_flow_template" "my_flowtemplate" { - assigned_to = [ - "..." - ] - available_in_ecp = true - closing_reasons = [ - { - id = "x739cew" - } - ] - created_at = "2021-04-27T12:01:13.000Z" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" - due_date_config = { - duration = 0.19 - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - type = "PHASE_FINISHED" - unit = "hours" - } - edges = [ - { - condition_id = "...my_condition_id..." - from_id = "...my_from_id..." - id = "...my_id..." - none_met = true - to_id = "...my_to_id..." - } - ] - enabled = true - id = "...my_id..." - is_flow_migrated = true - name = "...my_name..." - org_id = "...my_org_id..." - phases = [ - { - assigned_to = [ - "..." - ] - due_date = "2021-04-27T12:00:00.000Z" - due_date_config = { - duration = 9.34 - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - type = "TASK_FINISHED" - unit = "days" - } - id = "...my_id..." - name = "...my_name..." - taxonomies = [ - "..." - ] - } - ] - tasks = [ - { - automation_task = { - assigned_to = [ - "..." - ] - automation_config = { - flow_id = "...my_flow_id..." - } - description = { - enabled = false - value = "...my_value..." - } - due_date = "2021-04-27T12:00:00.000Z" - due_date_config = { - duration = 8.65 - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - type = "PHASE_FINISHED" - unit = "days" - } - ecp = { - description = "...my_description..." - enabled = true - journey = { - id = "...my_id..." - journey_id = "...my_journey_id..." - name = "...my_name..." - } - label = "...my_label..." - } - id = "...my_id..." - installer = { - description = "...my_description..." - enabled = false - journey = { - id = "...my_id..." - journey_id = "...my_journey_id..." - name = "...my_name..." - } - label = "...my_label..." - } - journey = { - id = "...my_id..." - journey_id = "...my_journey_id..." - name = "...my_name..." - } - name = "...my_name..." - phase_id = "...my_phase_id..." - requirements = [ - { - phase_id = "...my_phase_id..." - task_id = "...my_task_id..." - when = "PHASE_FINISHED" - } - ] - schedule = { - relative_schedule = { - direction = "before" - duration = 3.2 - mode = "relative" - reference = { - attribute = "...my_attribute..." - id = "...my_id..." - origin = "flow_started" - schema = "...my_schema..." - } - unit = "days" - } - } - task_type = "AUTOMATION" - taxonomies = [ - "..." - ] - trigger_mode = "automatic" - } - } - ] - taxonomies = [ - "..." - ] - trigger = { - manual_trigger = { - entity_schema = "...my_entity_schema..." - id = "...my_id..." - type = "manual" - } - } - update_entity_attributes = [ - { - source = "current_step" - target = { - entity_attribute = "my_status" - entity_schema = "opportunity" - } - } - ] - updated_at = "2021-04-27T12:01:13.000Z" -} \ No newline at end of file diff --git a/examples/resources/epilot-workflow_workflow_definition/import-by-string-id.tf b/examples/resources/epilot-workflow_workflow_definition/import-by-string-id.tf deleted file mode 100644 index 27eca34..0000000 --- a/examples/resources/epilot-workflow_workflow_definition/import-by-string-id.tf +++ /dev/null @@ -1,4 +0,0 @@ -import { - to = epilot-workflow_workflow_definition.my_epilot-workflow_workflow_definition - id = "..." -} diff --git a/examples/resources/epilot-workflow_workflow_definition/import.sh b/examples/resources/epilot-workflow_workflow_definition/import.sh deleted file mode 100644 index 04bcad2..0000000 --- a/examples/resources/epilot-workflow_workflow_definition/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-workflow_workflow_definition.my_epilot-workflow_workflow_definition "..." diff --git a/examples/resources/epilot-workflow_workflow_definition/resource.tf b/examples/resources/epilot-workflow_workflow_definition/resource.tf deleted file mode 100644 index 44eb251..0000000 --- a/examples/resources/epilot-workflow_workflow_definition/resource.tf +++ /dev/null @@ -1,41 +0,0 @@ -resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - assigned_to = [ - "..." - ] - closing_reasons = [ - { - id = "x739cew" - } - ] - creation_time = "2021-04-27T12:01:13.000Z" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" - dynamic_due_date = { - action_type_condition = "PHASE_FINISHED" - number_of_units = 0.36 - phase_id = "...my_phase_id..." - step_id = "...my_step_id..." - time_period = "days" - } - enable_ecp_workflow = false - enabled = false - flow = "{ \"see\": \"documentation\" }" - id = "...my_id..." - last_update_time = "2021-04-27T12:01:13.000Z" - name = "...my_name..." - taxonomies = [ - "..." - ] - update_entity_attributes = [ - { - source = "current_step" - target = { - entity_attribute = "my_status" - entity_schema = "opportunity" - } - } - ] - user_ids = [ - 5.93 - ] -} \ No newline at end of file diff --git a/final.yaml b/final.yaml index efaf5de..4b6e7e6 100644 --- a/final.yaml +++ b/final.yaml @@ -137,7 +137,7 @@ paths: order: 2 assignedTo: ["123482"] responses: - 200: + 201: description: Success - if the definition is created successfully content: application/json: @@ -198,6 +198,294 @@ paths: schema: $ref: "#/components/schemas/ErrorResp" + /v2/flows/templates: + get: + operationId: listFlowTemplates + summary: listFlowTemplates + description: List all Flow Templates for a customer. Optionally, you can filter flow templates by trigger values. + tags: + - Flows V2 + parameters: + - in: query + name: trigger_type + schema: + type: string + enum: + - automation + - manual + - journey_submission + required: false + description: Type of trigger for whom to filter flow templates + example: journey_submission + - in: query + name: trigger_source_id + schema: + type: string + required: false + description: > + Id of the trigger source to filter flow templates. Interpretation depends on **trigger_type**: + + - **automation**: use an `{automation_flow_id}` value + + - **journey_submission**: use a `{journey_id}` value + + - **manual**: this parameter is ignored; you can optionally filter by `{trigger_schema}` + example: j208g0aj-08g9agajggak-g9aug9-892kgl1m + - in: query + name: trigger_schema + schema: + type: string + required: false + description: > + Schema of the trigger source to filter flow templates. This parameter only makes sense when **trigger_type** is `manual` + example: opportunity + + responses: + 200: + description: Success - flow templates loaded with success. Empty array if customer has no flows defined. + content: + application/json: + schema: + $ref: "#/components/schemas/FlowTemplatesList" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + post: + operationId: createFlowTemplate + summary: createFlowTemplate + description: Create a new Flow Template. + tags: + - Flows V2 + requestBody: + description: Flow Template payload + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateFlowTemplate" + responses: + 201: + description: Success - if the flow template is created successfully + content: + application/json: + schema: + $ref: "#/components/schemas/FlowTemplate" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 401: + description: Authentication Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + /v2/flows/templates:search: + post: + operationId: searchFlowTemplates + summary: searchFlowTemplates + description: Search for flow templates by name, trigger type, enabled status, and more. + tags: + - Flows V2 + requestBody: + description: Search for flow templates by name, trigger type, enabled status, and more. + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/SearchFlowTemplates" + example: + name: "Lead Qualification" + definition_id: "25n2k52ja" + trigger_type: "journey_submission" + enabled: true + from: 0 + size: 10 + responses: + 200: + description: Success - flow templates loaded with success. Empty array if customer has no flows defined. + content: + application/json: + schema: + type: object + properties: + hits: + type: number + results: + type: array + items: + $ref: "#/components/schemas/FlowTemplate" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + + + /v2/flows/templates/{flowId}: + get: + operationId: getFlowTemplate + summary: getFlowTemplate + description: Get specific FLow template for a customer + tags: + - Flows V2 + parameters: + - in: path + name: flowId + schema: + $ref: "#/components/schemas/FlowTemplateId" + required: true + responses: + 200: + description: Returns the Flow Template + content: + application/json: + schema: + $ref: "#/components/schemas/FlowTemplate" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: Definition Not found + content: + application/json: + schema: + $ref: "#/components/schemas/DefinitionNotFoundResp" + 401: + description: Authentication Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + put: + operationId: updateFlowTemplate + summary: updateFlowTemplate + description: Update Flow Template. + tags: + - Flows V2 + parameters: + - in: path + name: flowId + schema: + $ref: "#/components/schemas/FlowTemplateId" + required: true + requestBody: + description: Flow Template payload + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/FlowTemplate" + responses: + 200: + description: Flow template has been updated successfully + content: + application/json: + schema: + $ref: "#/components/schemas/FlowTemplate" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 401: + description: Authentication Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + delete: + operationId: deleteFlowTemplate + summary: deleteFlowTemplate + description: Delete Flow Template. + tags: + - Flows V2 + parameters: + - in: path + name: flowId + schema: + $ref: "#/components/schemas/FlowTemplateId" + required: true + description: Id of the flow template to de deleted. + responses: + 204: + description: Flow template has been deleted successfully + 401: + description: Failed to authenticate + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: No definition found + + /v2/flows/templates/{flowId}/duplicate: + post: + operationId: duplicateFlowTemplate + summary: duplicateFlowTemplate + description: Duplicate a Flow Template from an existing workflow. + tags: + - Flows V2 + parameters: + - in: path + name: flowId + schema: + $ref: "#/components/schemas/FlowTemplateId" + required: true + responses: + 201: + description: Flow template has been duplicated successfully + content: + application/json: + schema: + $ref: "#/components/schemas/FlowTemplate" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 401: + description: Authentication Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + /v1/workflows/definitions/{definitionId}: get: operationId: getDefinition @@ -473,85 +761,255 @@ paths: schema: $ref: "#/components/schemas/ClosingReason" - /v1/workflows/closing-reasons/{reasonId}: - patch: - operationId: changeReasonStatus - summary: changeReasonStatus - description: Change the status of a Closing Reason (eg. ACTIVE to INACTIVE). + /v2/workflows/closing-reasons/{reasonId}: + get: + operationId: getClosingReason + summary: getClosingReason + description: Get specific closing reason by id from the organisation. tags: - Closing Reason parameters: - in: path name: reasonId - required: true schema: type: string - requestBody: - description: change the status of a closing reason - content: - application/json: - schema: - $ref: "#/components/schemas/ChangeReasonStatusReq" - + example: "x739cew" + required: true + description: unique id to identify the closing reason. responses: - 202: - description: The status change was accepted + 200: + description: Returns the closing reason + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" 400: - description: bad request + description: Validation Errors content: application/json: schema: $ref: "#/components/schemas/ErrorResp" - 500: - description: Internal server error + 403: + description: Forbidden content: application/json: schema: $ref: "#/components/schemas/ErrorResp" - - /v1/workflows/definitions/{definitionId}/closing-reasons: - get: - operationId: getWorkflowClosingReasons - summary: getWorkflowClosingReasons - description: Returns all closing reasons defined for the workflow. - parameters: - - in: path - name: definitionId - schema: - type: string - required: true - description: ID of a workflow definition - example: fxcwfw - tags: - - Workflows - responses: - 200: - description: Returns the entire catalog of closing reasons for a specific workflow + 404: + description: Closing reason not found content: application/json: schema: - $ref: "#/components/schemas/ClosingReasonsIds" + $ref: "#/components/schemas/ClosingReasonNotFoundResp" + patch: - operationId: setWorkflowClosingReasons - summary: setWorkflowClosingReasons - description: Sets which closing reasons are defined for this workflow, based on the entire closing reasons catalog. + operationId: updateClosingReason + summary: updateClosingReason + description: Update an existing closing reason tags: - - Workflows + - Closing Reason parameters: - in: path - name: definitionId + name: reasonId schema: type: string + example: "x739cew" required: true - description: ID of a workflow definition - example: 7889 + description: unique id to identify the closing reason. requestBody: - description: set all closing reasons for a specific definition + description: Updated closing reason fields required: true content: application/json: schema: - $ref: "#/components/schemas/ClosingReasonsIds" + $ref: "#/components/schemas/ClosingReason" + responses: + 200: + description: Closing reason updated successfully + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 403: + description: Forbidden + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: Closing reason not found + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasonNotFoundResp" + + delete: + operationId: deleteClosingReason + summary: deleteClosingReason + description: Permanently delete a closing reason (Using INACTIVE status is recommended instead) + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + responses: + 204: + description: Closing reason deleted successfully + 403: + description: Forbidden + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: Closing reason not found + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasonNotFoundResp" + + /v1/workflows/closing-reasons/{reasonId}: + get: + deprecated: true + operationId: getClosingReasonV1 + summary: getClosingReasonV1 + description: Get specific closing reason by id from the organisation. + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + schema: + type: string + required: true + description: uuid to identify the closing reason. + example: -poOAPBa-jFZA_AWV3zN0 + responses: + 200: + description: Returns the closing reason + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + example: + id: -poOAPBa-jFZA_AWV3zN0 + title: Closing due to example reason + status: "ACTIVE" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: Closing reason not found + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasonNotFoundResp" + 401: + description: Authentication Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + patch: + operationId: changeReasonStatus + summary: changeReasonStatus + description: Change the status of a Closing Reason (eg. ACTIVE to INACTIVE). + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + required: true + schema: + type: string + requestBody: + description: change the status of a closing reason + content: + application/json: + schema: + $ref: "#/components/schemas/ChangeReasonStatusReq" + + responses: + 202: + description: The status change was accepted + 400: + description: bad request + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + + /v1/workflows/definitions/{definitionId}/closing-reasons: + get: + operationId: getWorkflowClosingReasons + summary: getWorkflowClosingReasons + description: Returns all closing reasons defined for the workflow. + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: ID of a workflow definition + example: fxcwfw + tags: + - Workflows + responses: + 200: + description: Returns the entire catalog of closing reasons for a specific workflow + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasonsIds" + patch: + operationId: setWorkflowClosingReasons + summary: setWorkflowClosingReasons + description: Sets which closing reasons are defined for this workflow, based on the entire closing reasons catalog. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: ID of a workflow definition + example: 7889 + requestBody: + description: set all closing reasons for a specific definition + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasonsIds" responses: 201: description: closing reasons are set for this workflow @@ -564,6 +1022,651 @@ components: bearerFormat: JWT schemas: + # ------------------------- # + # V2 data structures + # ------------------------- # + FlowTemplateBase: + type: object + required: + - name + - tasks + - edges + properties: + id: + type: string + org_id: + type: string + name: + type: string + description: + type: string + trigger: + $ref: "#/components/schemas/Trigger" + enabled: + type: boolean + description: Whether the workflow is enabled or not + default: true + version: + $ref: "#/components/schemas/Version" + created_at: + type: string + description: ISO String Date & Time + example: "2021-04-27T12:01:13.000Z" + updated_at: + type: string + description: ISO String Date & Time + example: "2021-04-27T12:01:13.000Z" + due_date: + type: string + example: "2021-04-27T12:00:00.000Z" + due_date_config: + $ref: "#/components/schemas/DueDateConfig" + assigned_to: + type: array + items: + type: string + available_in_ecp: + type: boolean + description: Indicates whether this workflow is available for End Customer Portal or not. By default it's not. + phases: + type: array + items: + $ref: "#/components/schemas/Phase" + tasks: + type: array + items: + $ref: "#/components/schemas/Task" + edges: + type: array + items: + $ref: "#/components/schemas/Edge" + update_entity_attributes: + type: array + items: + $ref: "#/components/schemas/UpdateEntityAttributes" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering + + FlowTemplate: + allOf: + - $ref: "#/components/schemas/FlowTemplateBase" + - type: object + properties: + closing_reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReason" + + Version: + type: string + enum: + - v1 + - v2 + - v3 + description: | + Version of the workflow schema. + + - `v1` – *Deprecated*. The initial version of workflows with limited structure and automation capabilities. + - `v2` – Linear workflows. Supports sequential task execution with basic automation triggers. + - `v3` – Advanced workflows. Adds support for branching logic (conditions), parallel paths, and enhanced automation features such as dynamic triggers and flow control. + example: 2 + + Trigger: + anyOf: + - $ref: "#/components/schemas/ManualTrigger" + - $ref: "#/components/schemas/AutomationTrigger" + - $ref: '#/components/schemas/JourneySubmissionTrigger' + - $ref: '#/components/schemas/JourneyAutomationTrigger' + example: + type: automation + automation_id: g92j2-sg9ug92hjt1gh-9s9gajgs-a979gg + + ManualTrigger: + type: object + required: + - type + properties: + id: + type: string + type: + type: string + enum: + - manual + entity_schema: + type: string + + AutomationTrigger: + type: object + required: + - type + - automation_id + properties: + id: + type: string + type: + type: string + enum: + - automation + automation_id: + type: string + description: Id of the automation config that triggers this workflow + + JourneyAutomationTrigger: + type: object + required: + - type + properties: + id: + type: string + type: + type: string + enum: + - journey_automation + entity_schema: + type: string + description: Schema of the main entity where flow will be triggered. The entity will be picked from automation context. + + JourneySubmissionTrigger: + type: object + required: + - type + - journey_id + properties: + id: + type: string + type: + type: string + enum: + - journey_submission + journey_id: + type: string + description: ID of the journey that will trigger this flow + journey_name: + type: string + description: Name of the journey that will trigger this flow + automation_id: + type: string + + CreateFlowTemplate: + allOf: + - $ref: "#/components/schemas/FlowTemplateBase" + - type: object + properties: + closing_reasons: + type: array + items: + type: object + required: + - id + properties: + id: + type: string + SearchFlowTemplates: + type: object + properties: + name: + type: string + definition_id: + type: string + trigger_type: + type: string + enum: + - journey_submission + - manual + - automation + enabled: + type: boolean + from: + type: integer + size: + type: integer + sort_by: + type: string + enum: + - created_at + - updated_at + default: updated_at + sort_order: + type: string + enum: + - asc + - desc + default: desc + FlowTemplatesList: + type: object + properties: + results: + type: array + items: + $ref: "#/components/schemas/FlowTemplate" + required: + - results + + FlowTemplateId: + type: string + description: Short unique id (length 8) to identify the Flow Template. + example: 7hj28akg + + Task: + anyOf: + - $ref: "#/components/schemas/ManualTask" + - $ref: "#/components/schemas/AutomationTask" + - $ref: "#/components/schemas/DecisionTask" + + ManualTask: + allOf: + - $ref: "#/components/schemas/TaskBase" + + AutomationTask: + required: + - automation_config + properties: + automation_config: + $ref: "#/components/schemas/AutomationConfig" + trigger_mode: + $ref: "#/components/schemas/TriggerMode" + schedule: + $ref: "#/components/schemas/ActionSchedule" + created_automatically: + type: boolean + description: Indicates whether this task was created automatically by journeys or manually by an user + default: false + allOf: + - $ref: "#/components/schemas/TaskBase" + + AutomationConfig: + type: object + description: Configuration for automation execution to run + required: + - flow_id + properties: + flow_id: + type: string + description: Id of the configured automation to run + + TriggerMode: + type: string + enum: + - manual + - automatic + + ActionSchedule: + anyOf: + - $ref: "#/components/schemas/ImmediateSchedule" + - $ref: "#/components/schemas/DelayedSchedule" + - $ref: "#/components/schemas/RelativeSchedule" + + ImmediateSchedule: + type: object + properties: + mode: + enum: + - immediate + + DelayedSchedule: + type: object + required: + - mode + - duration + - unit + properties: + mode: + enum: + - delayed + duration: + type: number + unit: + $ref: "#/components/schemas/TimeUnit" + + RelativeSchedule: + type: object + properties: + mode: + enum: + - relative + direction: + type: string + enum: + - before + - after + duration: + type: number + unit: + $ref: "#/components/schemas/TimeUnit" + reference: + type: object + required: + - id + - origin + properties: + id: + type: string + description: The id of the entity / workflow / task, based on the origin of the schedule + origin: + type: string + enum: + - flow_started + - task_completed + - trigger_entity_attribute + schema: + type: string + description: The schema of the entity + attribute: + type: string + description: An entity attribute that identifies a date / datetime + required: + - mode + - direction + - duration + - unit + - reference + + DecisionTask: + allOf: + - $ref: "#/components/schemas/TaskBase" + - type: object + properties: + trigger_mode: + $ref: "#/components/schemas/TriggerMode" + conditions: + type: array + items: + $ref: "#/components/schemas/Condition" + schedule: + anyOf: + - $ref: "#/components/schemas/DelayedSchedule" + - $ref: "#/components/schemas/RelativeSchedule" + loop_config: + type: object + properties: + loop_branch_id: + type: string + description: The id of the branch that will be looped + exit_branch_id: + type: string + description: The id of the branch that will be used to exit the loop + max_iterations: + type: integer + description: Maximum number of iterations for the loop branch + default: 3 + minimum: 1 + maximum: 10 + required: + - loop_branch_id + - exit_branch_id + - max_iterations + required: + - trigger_mode + - conditions + + TaskBase: + type: object + properties: + # common fields + id: + type: string + name: + type: string + description: + $ref: "#/components/schemas/StepDescription" + journey: + $ref: "#/components/schemas/StepJourney" + due_date: + type: string + example: "2021-04-27T12:00:00.000Z" + due_date_config: + $ref: "#/components/schemas/DueDateConfig" + requirements: + type: array + description: requirements that need to be fulfilled in order to enable the task while flow instances are running + items: + $ref: "#/components/schemas/EnableRequirement" + assigned_to: + type: array + items: + type: string + ecp: + $ref: "#/components/schemas/ECPDetails" + installer: + $ref: "#/components/schemas/ECPDetails" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering + # new fields + phase_id: + type: string + task_type: + $ref: "#/components/schemas/TaskType" + required: + - id + - name + - task_type + + Phase: + type: object + properties: + id: + type: string + name: + type: string + due_date: + type: string + example: "2021-04-27T12:00:00.000Z" + due_date_config: + $ref: "#/components/schemas/DueDateConfig" + assigned_to: + type: array + items: + type: string + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering + required: + - id + - name + + TaskType: + type: string + enum: + - MANUAL + - AUTOMATION + - DECISION + + Edge: + type: object + properties: + id: + type: string + from_id: + type: string + to_id: + type: string + condition_id: + type: string + none_met: + type: boolean + description: Indicates a default case for a decision task. Only decision task edges can have this field and the flow advances using this edge if no conditions are met. + required: + - id + - from_id + - to_id + + Condition: + type: object + properties: + id: + type: string + branch_name: + type: string + description: The name of the branch + maxLength: 255 + example: Branch 1 + logical_operator: + type: string + enum: + - AND + - OR + statements: + type: array + items: + $ref: "#/components/schemas/Statement" + required: + - id + - branch_name + - logical_operator + - statements + + Statement: + type: object + properties: + id: + type: string + source: + $ref: "#/components/schemas/EvaluationSource" + operator: + $ref: "#/components/schemas/Operator" + values: + type: array + items: + type: string + required: + - id + - source + - operator + - values + + EvaluationSource: + type: object + properties: + id: + type: string + description: The id of the action or trigger + origin: + type: string + enum: + - trigger + - action + origin_type: + type: string + enum: + - entity + - workflow + - journey_block + schema: + type: string + attribute: + type: string + attribute_type: + type: string + enum: + - string + - text + - number + - boolean + - date + - datetime + - tags + - country + - email + - phone + - product + - price + - status + - relation + - multiselect + - select + - radio + - relation_user + - purpose + - label + attribute_repeatable: + type: boolean + attribute_operation: + enum: + - all + - updated + - added + - deleted + + Operator: + type: string + enum: + - equals + - not_equals + - any_of + - none_of + - contains + - not_contains + - starts_with + - ends_with + - greater_than + - less_than + - greater_than_or_equals + - less_than_or_equals + - is_empty + - is_not_empty + + DueDateConfig: + description: Set due date for the task based on a dynamic condition + type: object + properties: + duration: + type: number + unit: + $ref: "#/components/schemas/TimeUnit" + type: + type: string + enum: + - WORKFLOW_STARTED + - TASK_FINISHED + - PHASE_FINISHED + task_id: + type: string + phase_id: + type: string + required: + - duration + - unit + - type + + TimeUnit: + type: string + enum: + - minutes + - hours + - days + - weeks + - months + + EnableRequirement: + description: describe the requirement for a task to be enabled + type: object + properties: + task_id: + type: string + description: The id of the task that it points to + phase_id: + type: string + description: The id of the phase that it points to + when: + type: string + enum: + - TASK_FINISHED + - PHASE_FINISHED + required: + - when + + # ------------------------- # + # V1 data structures + # ------------------------- # + WorkflowDefinition: type: object properties: @@ -577,6 +1680,10 @@ components: type: string description: ISO String Date & Time example: "2021-04-27T12:01:13.000Z" + enabled: + type: boolean + description: Whether the workflow is enabled or not + default: true lastUpdateTime: type: string description: ISO String Date & Time @@ -613,6 +1720,11 @@ components: type: array items: $ref: "#/components/schemas/UpdateEntityAttributes" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering required: - name - flow @@ -626,9 +1738,9 @@ components: name: type: string description: - $ref: '#/components/schemas/StepDescription' + $ref: "#/components/schemas/StepDescription" executionType: - $ref: '#/components/schemas/StepType' + $ref: "#/components/schemas/StepType" automationConfig: type: object properties: @@ -638,7 +1750,7 @@ components: required: - flowId journey: - $ref: '#/components/schemas/StepJourney' + $ref: "#/components/schemas/StepJourney" order: type: number dueDate: @@ -667,6 +1779,11 @@ components: $ref: "#/components/schemas/ECPDetails" installer: $ref: "#/components/schemas/ECPDetails" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering required: - name - order @@ -684,16 +1801,36 @@ components: type: number type: $ref: "#/components/schemas/ItemType" + dueDate: + type: string + example: "2021-04-27T12:00:00.000Z" + dynamicDueDate: + $ref: "#/components/schemas/DynamicDueDate" + assignedTo: + type: array + items: + type: string steps: type: array items: $ref: "#/components/schemas/Step" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering required: - name - order - type - steps + TriggerType: + type: string + enum: + - MANUAL + - AUTOMATIC + ItemType: type: string enum: @@ -715,6 +1852,10 @@ components: type: string name: type: string + complete_task_automatically: + type: boolean + default: true + description: If true, the task be auto completed when the journey is completed. By default it is true. ECPDetails: type: object @@ -727,7 +1868,7 @@ components: description: type: string journey: - $ref: '#/components/schemas/StepJourney' + $ref: "#/components/schemas/StepJourney" StepDescription: type: object @@ -752,6 +1893,12 @@ components: message: type: string + ClosingReasonNotFoundResp: + description: Closing reason could be not found + properties: + message: + type: string + ChangeReasonStatusReq: type: object properties: @@ -779,14 +1926,17 @@ components: properties: id: type: string + readOnly: true title: type: string status: $ref: "#/components/schemas/ClosingReasonsStatus" lastUpdateTime: type: string + readOnly: true creationTime: type: string + readOnly: true ClosingReasonsStatus: type: string @@ -853,18 +2003,17 @@ components: numberOfUnits: type: number timePeriod: - type: string - enum: - - days - - weeks - - months + $ref: "#/components/schemas/TimeUnit" actionTypeCondition: type: string enum: - WORKFLOW_STARTED - STEP_CLOSED + - PHASE_FINISHED stepId: type: string + phaseId: + type: string required: - numberOfUnits - timePeriod diff --git a/gen.yaml b/gen.yaml index 59744f9..5bbc985 100644 --- a/gen.yaml +++ b/gen.yaml @@ -13,6 +13,9 @@ generation: auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false + hoistGlobalSecurity: true + schemas: + allOfMergeStrategy: shallowMerge tests: generateTests: true generateNewTests: false @@ -35,7 +38,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.19.0 + version: 0.20.0 additionalDataSources: [] additionalDependencies: {} additionalEphemeralResources: [] @@ -57,6 +60,8 @@ terraform: operations: operations shared: shared webhooks: webhooks + includeEmptyObjects: false inputModelSuffix: input outputModelSuffix: output packageName: epilot-workflow + unionDeserializationStrategy: populated-fields diff --git a/go.mod b/go.mod index acdb8e2..1a442b1 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,13 @@ module github.com/epilot-dev/terraform-provider-epilot-workflow go 1.23.7 require ( - github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-docs v0.22.0 - github.com/hashicorp/terraform-plugin-framework v1.15.0 - github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 + github.com/hashicorp/terraform-plugin-framework v1.15.1 + github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 github.com/hashicorp/terraform-plugin-go v0.28.0 github.com/hashicorp/terraform-plugin-log v0.9.0 + github.com/stretchr/testify v1.8.3 ) require ( @@ -25,6 +24,7 @@ require ( github.com/bgentry/speakeasy v0.1.0 // indirect github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect github.com/cloudflare/circl v1.6.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect @@ -52,6 +52,7 @@ require ( github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect diff --git a/go.sum b/go.sum index 039f01f..e91839d 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= -github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= @@ -91,12 +89,10 @@ github.com/hashicorp/terraform-json v0.25.0 h1:rmNqc/CIfcWawGiwXmRuiXJKEiJu1ntGo github.com/hashicorp/terraform-json v0.25.0/go.mod h1:sMKS8fiRDX4rVlR6EJUMudg1WcanxCMoWwTLkgZP/vc= github.com/hashicorp/terraform-plugin-docs v0.22.0 h1:fwIDStbFel1PPNkM+mDPnpB4efHZBdGoMz/zt5FbTDw= github.com/hashicorp/terraform-plugin-docs v0.22.0/go.mod h1:55DJVyZ7BNK4t/lANcQ1YpemRuS6KsvIO1BbGA+xzGE= -github.com/hashicorp/terraform-plugin-framework v1.15.0 h1:LQ2rsOfmDLxcn5EeIwdXFtr03FVsNktbbBci8cOKdb4= -github.com/hashicorp/terraform-plugin-framework v1.15.0/go.mod h1:hxrNI/GY32KPISpWqlCoTLM9JZsGH3CyYlir09bD/fI= -github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 h1:SJXL5FfJJm17554Kpt9jFXngdM6fXbnUnZ6iT2IeiYA= -github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0/go.mod h1:p0phD0IYhsu9bR4+6OetVvvH59I6LwjXGnTVEr8ox6E= -github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 h1:0uYQcqqgW3BMyyve07WJgpKorXST3zkpzvrOnf3mpbg= -github.com/hashicorp/terraform-plugin-framework-validators v0.17.0/go.mod h1:VwdfgE/5Zxm43flraNa0VjcvKQOGVrcO4X8peIri0T0= +github.com/hashicorp/terraform-plugin-framework v1.15.1 h1:2mKDkwb8rlx/tvJTlIcpw0ykcmvdWv+4gY3SIgk8Pq8= +github.com/hashicorp/terraform-plugin-framework v1.15.1/go.mod h1:hxrNI/GY32KPISpWqlCoTLM9JZsGH3CyYlir09bD/fI= +github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua//rCw+QhBbSqfW3QbwtVrcdWeQN5gI3Hw= +github.com/hashicorp/terraform-plugin-framework-validators v0.18.0/go.mod h1:lZvZvagw5hsJwuY7mAY6KUz45/U6fiDR0CzQAwWD0CA= github.com/hashicorp/terraform-plugin-go v0.28.0 h1:zJmu2UDwhVN0J+J20RE5huiF3XXlTYVIleaevHZgKPA= github.com/hashicorp/terraform-plugin-go v0.28.0/go.mod h1:FDa2Bb3uumkTGSkTFpWSOwWJDwA7bf3vdP3ltLDTH6o= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= diff --git a/internal/provider/closingreason_data_source.go b/internal/provider/closingreason_data_source.go deleted file mode 100644 index 0be44c6..0000000 --- a/internal/provider/closingreason_data_source.go +++ /dev/null @@ -1,140 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ datasource.DataSource = &ClosingReasonDataSource{} -var _ datasource.DataSourceWithConfigure = &ClosingReasonDataSource{} - -func NewClosingReasonDataSource() datasource.DataSource { - return &ClosingReasonDataSource{} -} - -// ClosingReasonDataSource is the data source implementation. -type ClosingReasonDataSource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// ClosingReasonDataSourceModel describes the data model. -type ClosingReasonDataSourceModel struct { - CreationTime types.String `tfsdk:"creation_time"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Status types.String `tfsdk:"status"` - Title types.String `tfsdk:"title"` -} - -// Metadata returns the data source type name. -func (r *ClosingReasonDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_closing_reason" -} - -// Schema defines the schema for the data source. -func (r *ClosingReasonDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "ClosingReason DataSource", - - Attributes: map[string]schema.Attribute{ - "creation_time": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - }, - "status": schema.StringAttribute{ - Computed: true, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - }, - } -} - -func (r *ClosingReasonDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected DataSource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *ClosingReasonDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *ClosingReasonDataSourceModel - var item types.Object - - resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsGetClosingReasonRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ClosingReason.GetClosingReason(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedClosingReason(ctx, res.ClosingReason)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/closingreason_data_source_sdk.go b/internal/provider/closingreason_data_source_sdk.go deleted file mode 100644 index 0b1fc64..0000000 --- a/internal/provider/closingreason_data_source_sdk.go +++ /dev/null @@ -1,38 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *ClosingReasonDataSourceModel) RefreshFromSharedClosingReason(ctx context.Context, resp *shared.ClosingReason) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.ID = types.StringPointerValue(resp.ID) - r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) - r.Status = types.StringValue(string(resp.Status)) - r.Title = types.StringValue(resp.Title) - } - - return diags -} - -func (r *ClosingReasonDataSourceModel) ToOperationsGetClosingReasonRequest(ctx context.Context) (*operations.GetClosingReasonRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var reasonID string - reasonID = r.ID.ValueString() - - out := operations.GetClosingReasonRequest{ - ReasonID: reasonID, - } - - return &out, diags -} diff --git a/internal/provider/closingreason_resource.go b/internal/provider/closingreason_resource.go deleted file mode 100644 index 20bba29..0000000 --- a/internal/provider/closingreason_resource.go +++ /dev/null @@ -1,314 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &ClosingReasonResource{} -var _ resource.ResourceWithImportState = &ClosingReasonResource{} - -func NewClosingReasonResource() resource.Resource { - return &ClosingReasonResource{} -} - -// ClosingReasonResource defines the resource implementation. -type ClosingReasonResource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// ClosingReasonResourceModel describes the resource data model. -type ClosingReasonResourceModel struct { - CreationTime types.String `tfsdk:"creation_time"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Status types.String `tfsdk:"status"` - Title types.String `tfsdk:"title"` -} - -func (r *ClosingReasonResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_closing_reason" -} - -func (r *ClosingReasonResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "ClosingReason Resource", - Attributes: map[string]schema.Attribute{ - "creation_time": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - }, - "status": schema.StringAttribute{ - Required: true, - Description: `must be one of ["ACTIVE", "INACTIVE"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "ACTIVE", - "INACTIVE", - ), - }, - }, - "title": schema.StringAttribute{ - Required: true, - }, - }, - } -} - -func (r *ClosingReasonResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *ClosingReasonResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *ClosingReasonResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToSharedClosingReasonInput(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ClosingReason.CreateClosingReason(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedClosingReason(ctx, res.ClosingReason)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *ClosingReasonResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *ClosingReasonResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsGetClosingReasonRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ClosingReason.GetClosingReason(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedClosingReason(ctx, res.ClosingReason)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *ClosingReasonResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *ClosingReasonResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsUpdateClosingReasonRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ClosingReason.UpdateClosingReason(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedClosingReason(ctx, res.ClosingReason)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *ClosingReasonResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *ClosingReasonResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsDeleteClosingReasonRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ClosingReason.DeleteClosingReason(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *ClosingReasonResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/closingreason_resource_sdk.go b/internal/provider/closingreason_resource_sdk.go deleted file mode 100644 index 010cb4b..0000000 --- a/internal/provider/closingreason_resource_sdk.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *ClosingReasonResourceModel) RefreshFromSharedClosingReason(ctx context.Context, resp *shared.ClosingReason) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.ID = types.StringPointerValue(resp.ID) - r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) - r.Status = types.StringValue(string(resp.Status)) - r.Title = types.StringValue(resp.Title) - } - - return diags -} - -func (r *ClosingReasonResourceModel) ToOperationsDeleteClosingReasonRequest(ctx context.Context) (*operations.DeleteClosingReasonRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var reasonID string - reasonID = r.ID.ValueString() - - out := operations.DeleteClosingReasonRequest{ - ReasonID: reasonID, - } - - return &out, diags -} - -func (r *ClosingReasonResourceModel) ToOperationsGetClosingReasonRequest(ctx context.Context) (*operations.GetClosingReasonRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var reasonID string - reasonID = r.ID.ValueString() - - out := operations.GetClosingReasonRequest{ - ReasonID: reasonID, - } - - return &out, diags -} - -func (r *ClosingReasonResourceModel) ToOperationsUpdateClosingReasonRequest(ctx context.Context) (*operations.UpdateClosingReasonRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - closingReason, closingReasonDiags := r.ToSharedClosingReasonInput(ctx) - diags.Append(closingReasonDiags...) - - if diags.HasError() { - return nil, diags - } - - var reasonID string - reasonID = r.ID.ValueString() - - out := operations.UpdateClosingReasonRequest{ - ClosingReason: *closingReason, - ReasonID: reasonID, - } - - return &out, diags -} - -func (r *ClosingReasonResourceModel) ToSharedClosingReasonInput(ctx context.Context) (*shared.ClosingReasonInput, diag.Diagnostics) { - var diags diag.Diagnostics - - status := shared.ClosingReasonsStatus(r.Status.ValueString()) - var title string - title = r.Title.ValueString() - - out := shared.ClosingReasonInput{ - Status: status, - Title: title, - } - - return &out, diags -} diff --git a/internal/provider/flowtemplate_data_source.go b/internal/provider/flowtemplate_data_source.go deleted file mode 100644 index 116af2b..0000000 --- a/internal/provider/flowtemplate_data_source.go +++ /dev/null @@ -1,1026 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ datasource.DataSource = &FlowTemplateDataSource{} -var _ datasource.DataSourceWithConfigure = &FlowTemplateDataSource{} - -func NewFlowTemplateDataSource() datasource.DataSource { - return &FlowTemplateDataSource{} -} - -// FlowTemplateDataSource is the data source implementation. -type FlowTemplateDataSource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// FlowTemplateDataSourceModel describes the data model. -type FlowTemplateDataSourceModel struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - AvailableInEcp types.Bool `tfsdk:"available_in_ecp"` - ClosingReasons []tfTypes.ClosingReason1 `tfsdk:"closing_reasons"` - CreatedAt types.String `tfsdk:"created_at"` - Description types.String `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DueDateConfig *tfTypes.DueDateConfig `tfsdk:"due_date_config"` - Edges []tfTypes.Edge `tfsdk:"edges"` - Enabled types.Bool `tfsdk:"enabled"` - ID types.String `tfsdk:"id"` - IsFlowMigrated types.Bool `tfsdk:"is_flow_migrated"` - Name types.String `tfsdk:"name"` - OrgID types.String `tfsdk:"org_id"` - Phases []tfTypes.Phase `tfsdk:"phases"` - Tasks []tfTypes.Task `tfsdk:"tasks"` - Taxonomies []types.String `tfsdk:"taxonomies"` - Trigger *tfTypes.Trigger `tfsdk:"trigger"` - UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` - UpdatedAt types.String `tfsdk:"updated_at"` -} - -// Metadata returns the data source type name. -func (r *FlowTemplateDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_flow_template" -} - -// Schema defines the schema for the data source. -func (r *FlowTemplateDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "FlowTemplate DataSource", - - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "available_in_ecp": schema.BoolAttribute{ - Computed: true, - Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, - }, - "closing_reasons": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "creation_time": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - }, - "status": schema.StringAttribute{ - Computed: true, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: `ISO String Date & Time`, - }, - "description": schema.StringAttribute{ - Computed: true, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "edges": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "condition_id": schema.StringAttribute{ - Computed: true, - }, - "from_id": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "none_met": schema.BoolAttribute{ - Computed: true, - Description: `Indicates a default case for a decision task. Only decision task edges can have this field and the flow advances using this edge if no conditions are met.`, - }, - "to_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Whether the workflow is enabled or not`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "is_flow_migrated": schema.BoolAttribute{ - Computed: true, - Description: `Whether the workflow is migrated from workflows to flows or not`, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "org_id": schema.StringAttribute{ - Computed: true, - }, - "phases": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - }, - }, - }, - "tasks": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "automation_task": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "automation_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "flow_id": schema.StringAttribute{ - Computed: true, - Description: `Id of the configured automation to run`, - }, - }, - Description: `Configuration for automation execution to run`, - }, - "description": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "value": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Longer information regarding Task`, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "ecp": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "installer": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "requirements": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "when": schema.StringAttribute{ - Computed: true, - }, - }, - }, - Description: `requirements that need to be fulfilled in order to enable the task while flow instances are running`, - }, - "schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "delayed_schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "mode": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "immediate_schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "relative_schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "direction": schema.StringAttribute{ - Computed: true, - }, - "duration": schema.Float64Attribute{ - Computed: true, - }, - "mode": schema.StringAttribute{ - Computed: true, - }, - "reference": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - Description: `An entity attribute that identifies a date / datetime`, - }, - "id": schema.StringAttribute{ - Computed: true, - Description: `The id of the entity / workflow / task, based on the origin of the schedule`, - }, - "origin": schema.StringAttribute{ - Computed: true, - }, - "schema": schema.StringAttribute{ - Computed: true, - Description: `The schema of the entity`, - }, - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - "task_type": schema.StringAttribute{ - Computed: true, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - "trigger_mode": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "decision_task": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "conditions": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "branch_name": schema.StringAttribute{ - Computed: true, - Description: `The name of the branch`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "logical_operator": schema.StringAttribute{ - Computed: true, - }, - "statements": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "operator": schema.StringAttribute{ - Computed: true, - }, - "source": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - }, - "attribute_operation": schema.StringAttribute{ - Computed: true, - }, - "attribute_repeatable": schema.BoolAttribute{ - Computed: true, - }, - "attribute_type": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - Description: `The id of the action or trigger`, - }, - "origin": schema.StringAttribute{ - Computed: true, - }, - "origin_type": schema.StringAttribute{ - Computed: true, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "values": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - }, - }, - }, - }, - }, - "description": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "value": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Longer information regarding Task`, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "ecp": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "installer": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "requirements": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "when": schema.StringAttribute{ - Computed: true, - }, - }, - }, - Description: `requirements that need to be fulfilled in order to enable the task while flow instances are running`, - }, - "schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "delayed_schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "mode": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "relative_schedule": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "direction": schema.StringAttribute{ - Computed: true, - }, - "duration": schema.Float64Attribute{ - Computed: true, - }, - "mode": schema.StringAttribute{ - Computed: true, - }, - "reference": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - Description: `An entity attribute that identifies a date / datetime`, - }, - "id": schema.StringAttribute{ - Computed: true, - Description: `The id of the entity / workflow / task, based on the origin of the schedule`, - }, - "origin": schema.StringAttribute{ - Computed: true, - }, - "schema": schema.StringAttribute{ - Computed: true, - Description: `The schema of the entity`, - }, - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - "task_type": schema.StringAttribute{ - Computed: true, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - }, - }, - "task_base": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "description": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "value": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Longer information regarding Task`, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - "unit": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "ecp": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "installer": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "requirements": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - }, - "when": schema.StringAttribute{ - Computed: true, - }, - }, - }, - Description: `requirements that need to be fulfilled in order to enable the task while flow instances are running`, - }, - "task_type": schema.StringAttribute{ - Computed: true, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - }, - }, - }, - }, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - "trigger": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "automation_trigger": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "automation_id": schema.StringAttribute{ - Computed: true, - Description: `Id of the automation config that triggers this workflow`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "journey_submission_trigger": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "automation_id": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Description: `ID of the journey that will trigger this flow`, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "manual_trigger": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "entity_schema": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - "update_entity_attributes": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "source": schema.StringAttribute{ - Computed: true, - }, - "target": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "entity_attribute": schema.StringAttribute{ - Computed: true, - }, - "entity_schema": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Description: `ISO String Date & Time`, - }, - }, - } -} - -func (r *FlowTemplateDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected DataSource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *FlowTemplateDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *FlowTemplateDataSourceModel - var item types.Object - - resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsGetFlowTemplateRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.FlowsV2.GetFlowTemplate(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.FlowTemplate != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedFlowTemplate(ctx, res.FlowTemplate)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/flowtemplate_data_source_sdk.go b/internal/provider/flowtemplate_data_source_sdk.go deleted file mode 100644 index b2ba974..0000000 --- a/internal/provider/flowtemplate_data_source_sdk.go +++ /dev/null @@ -1,513 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *FlowTemplateDataSourceModel) RefreshFromSharedFlowTemplate(ctx context.Context, resp *shared.FlowTemplate) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.AssignedTo = make([]types.String, 0, len(resp.AssignedTo)) - for _, v := range resp.AssignedTo { - r.AssignedTo = append(r.AssignedTo, types.StringValue(v)) - } - r.AvailableInEcp = types.BoolPointerValue(resp.AvailableInEcp) - r.ClosingReasons = []tfTypes.ClosingReason1{} - - for _, closingReasonsItem := range resp.ClosingReasons { - var closingReasons tfTypes.ClosingReason1 - - closingReasons.CreationTime = types.StringPointerValue(closingReasonsItem.CreationTime) - closingReasons.ID = types.StringPointerValue(closingReasonsItem.ID) - closingReasons.LastUpdateTime = types.StringPointerValue(closingReasonsItem.LastUpdateTime) - closingReasons.Status = types.StringValue(string(closingReasonsItem.Status)) - closingReasons.Title = types.StringValue(closingReasonsItem.Title) - - r.ClosingReasons = append(r.ClosingReasons, closingReasons) - } - r.CreatedAt = types.StringPointerValue(resp.CreatedAt) - r.Description = types.StringPointerValue(resp.Description) - r.DueDate = types.StringPointerValue(resp.DueDate) - if resp.DueDateConfig == nil { - r.DueDateConfig = nil - } else { - r.DueDateConfig = &tfTypes.DueDateConfig{} - r.DueDateConfig.Duration = types.Float64Value(resp.DueDateConfig.Duration) - r.DueDateConfig.PhaseID = types.StringPointerValue(resp.DueDateConfig.PhaseID) - r.DueDateConfig.TaskID = types.StringPointerValue(resp.DueDateConfig.TaskID) - r.DueDateConfig.Type = types.StringValue(string(resp.DueDateConfig.Type)) - r.DueDateConfig.Unit = types.StringValue(string(resp.DueDateConfig.Unit)) - } - r.Edges = []tfTypes.Edge{} - - for _, edgesItem := range resp.Edges { - var edges tfTypes.Edge - - edges.ConditionID = types.StringPointerValue(edgesItem.ConditionID) - edges.FromID = types.StringValue(edgesItem.FromID) - edges.ID = types.StringValue(edgesItem.ID) - edges.NoneMet = types.BoolPointerValue(edgesItem.NoneMet) - edges.ToID = types.StringValue(edgesItem.ToID) - - r.Edges = append(r.Edges, edges) - } - r.Enabled = types.BoolPointerValue(resp.Enabled) - r.ID = types.StringPointerValue(resp.ID) - r.IsFlowMigrated = types.BoolPointerValue(resp.IsFlowMigrated) - r.Name = types.StringValue(resp.Name) - r.OrgID = types.StringPointerValue(resp.OrgID) - r.Phases = []tfTypes.Phase{} - - for _, phasesItem := range resp.Phases { - var phases tfTypes.Phase - - phases.AssignedTo = make([]types.String, 0, len(phasesItem.AssignedTo)) - for _, v := range phasesItem.AssignedTo { - phases.AssignedTo = append(phases.AssignedTo, types.StringValue(v)) - } - phases.DueDate = types.StringPointerValue(phasesItem.DueDate) - if phasesItem.DueDateConfig == nil { - phases.DueDateConfig = nil - } else { - phases.DueDateConfig = &tfTypes.DueDateConfig{} - phases.DueDateConfig.Duration = types.Float64Value(phasesItem.DueDateConfig.Duration) - phases.DueDateConfig.PhaseID = types.StringPointerValue(phasesItem.DueDateConfig.PhaseID) - phases.DueDateConfig.TaskID = types.StringPointerValue(phasesItem.DueDateConfig.TaskID) - phases.DueDateConfig.Type = types.StringValue(string(phasesItem.DueDateConfig.Type)) - phases.DueDateConfig.Unit = types.StringValue(string(phasesItem.DueDateConfig.Unit)) - } - phases.ID = types.StringValue(phasesItem.ID) - phases.Name = types.StringValue(phasesItem.Name) - phases.Taxonomies = make([]types.String, 0, len(phasesItem.Taxonomies)) - for _, v := range phasesItem.Taxonomies { - phases.Taxonomies = append(phases.Taxonomies, types.StringValue(v)) - } - - r.Phases = append(r.Phases, phases) - } - r.Tasks = []tfTypes.Task{} - - for _, tasksItem := range resp.Tasks { - var tasks tfTypes.Task - - if tasksItem.AutomationTask != nil { - tasks.AutomationTask = &tfTypes.AutomationTask{} - tasks.AutomationTask.AssignedTo = make([]types.String, 0, len(tasksItem.AutomationTask.AssignedTo)) - for _, v := range tasksItem.AutomationTask.AssignedTo { - tasks.AutomationTask.AssignedTo = append(tasks.AutomationTask.AssignedTo, types.StringValue(v)) - } - tasks.AutomationTask.AutomationConfig.FlowID = types.StringValue(tasksItem.AutomationTask.AutomationConfig.FlowID) - if tasksItem.AutomationTask.Description == nil { - tasks.AutomationTask.Description = nil - } else { - tasks.AutomationTask.Description = &tfTypes.StepDescription{} - tasks.AutomationTask.Description.Enabled = types.BoolPointerValue(tasksItem.AutomationTask.Description.Enabled) - tasks.AutomationTask.Description.Value = types.StringPointerValue(tasksItem.AutomationTask.Description.Value) - } - tasks.AutomationTask.DueDate = types.StringPointerValue(tasksItem.AutomationTask.DueDate) - if tasksItem.AutomationTask.DueDateConfig == nil { - tasks.AutomationTask.DueDateConfig = nil - } else { - tasks.AutomationTask.DueDateConfig = &tfTypes.DueDateConfig{} - tasks.AutomationTask.DueDateConfig.Duration = types.Float64Value(tasksItem.AutomationTask.DueDateConfig.Duration) - tasks.AutomationTask.DueDateConfig.PhaseID = types.StringPointerValue(tasksItem.AutomationTask.DueDateConfig.PhaseID) - tasks.AutomationTask.DueDateConfig.TaskID = types.StringPointerValue(tasksItem.AutomationTask.DueDateConfig.TaskID) - tasks.AutomationTask.DueDateConfig.Type = types.StringValue(string(tasksItem.AutomationTask.DueDateConfig.Type)) - tasks.AutomationTask.DueDateConfig.Unit = types.StringValue(string(tasksItem.AutomationTask.DueDateConfig.Unit)) - } - if tasksItem.AutomationTask.Ecp == nil { - tasks.AutomationTask.Ecp = nil - } else { - tasks.AutomationTask.Ecp = &tfTypes.ECPDetails{} - tasks.AutomationTask.Ecp.Description = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Description) - tasks.AutomationTask.Ecp.Enabled = types.BoolPointerValue(tasksItem.AutomationTask.Ecp.Enabled) - if tasksItem.AutomationTask.Ecp.Journey == nil { - tasks.AutomationTask.Ecp.Journey = nil - } else { - tasks.AutomationTask.Ecp.Journey = &tfTypes.StepJourney{} - tasks.AutomationTask.Ecp.Journey.ID = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Journey.ID) - tasks.AutomationTask.Ecp.Journey.JourneyID = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Journey.JourneyID) - tasks.AutomationTask.Ecp.Journey.Name = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Journey.Name) - } - tasks.AutomationTask.Ecp.Label = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Label) - } - tasks.AutomationTask.ID = types.StringValue(tasksItem.AutomationTask.ID) - if tasksItem.AutomationTask.Installer == nil { - tasks.AutomationTask.Installer = nil - } else { - tasks.AutomationTask.Installer = &tfTypes.ECPDetails{} - tasks.AutomationTask.Installer.Description = types.StringPointerValue(tasksItem.AutomationTask.Installer.Description) - tasks.AutomationTask.Installer.Enabled = types.BoolPointerValue(tasksItem.AutomationTask.Installer.Enabled) - if tasksItem.AutomationTask.Installer.Journey == nil { - tasks.AutomationTask.Installer.Journey = nil - } else { - tasks.AutomationTask.Installer.Journey = &tfTypes.StepJourney{} - tasks.AutomationTask.Installer.Journey.ID = types.StringPointerValue(tasksItem.AutomationTask.Installer.Journey.ID) - tasks.AutomationTask.Installer.Journey.JourneyID = types.StringPointerValue(tasksItem.AutomationTask.Installer.Journey.JourneyID) - tasks.AutomationTask.Installer.Journey.Name = types.StringPointerValue(tasksItem.AutomationTask.Installer.Journey.Name) - } - tasks.AutomationTask.Installer.Label = types.StringPointerValue(tasksItem.AutomationTask.Installer.Label) - } - if tasksItem.AutomationTask.Journey == nil { - tasks.AutomationTask.Journey = nil - } else { - tasks.AutomationTask.Journey = &tfTypes.StepJourney{} - tasks.AutomationTask.Journey.ID = types.StringPointerValue(tasksItem.AutomationTask.Journey.ID) - tasks.AutomationTask.Journey.JourneyID = types.StringPointerValue(tasksItem.AutomationTask.Journey.JourneyID) - tasks.AutomationTask.Journey.Name = types.StringPointerValue(tasksItem.AutomationTask.Journey.Name) - } - tasks.AutomationTask.Name = types.StringValue(tasksItem.AutomationTask.Name) - tasks.AutomationTask.PhaseID = types.StringPointerValue(tasksItem.AutomationTask.PhaseID) - tasks.AutomationTask.Requirements = []tfTypes.EnableRequirement{} - - for _, requirementsItem := range tasksItem.AutomationTask.Requirements { - var requirements tfTypes.EnableRequirement - - requirements.PhaseID = types.StringPointerValue(requirementsItem.PhaseID) - requirements.TaskID = types.StringPointerValue(requirementsItem.TaskID) - requirements.When = types.StringValue(string(requirementsItem.When)) - - tasks.AutomationTask.Requirements = append(tasks.AutomationTask.Requirements, requirements) - } - if tasksItem.AutomationTask.Schedule != nil { - tasks.AutomationTask.Schedule = &tfTypes.ActionSchedule{} - if tasksItem.AutomationTask.Schedule.DelayedSchedule != nil { - tasks.AutomationTask.Schedule.DelayedSchedule = &tfTypes.DelayedSchedule{} - tasks.AutomationTask.Schedule.DelayedSchedule.Duration = types.Float64Value(tasksItem.AutomationTask.Schedule.DelayedSchedule.Duration) - tasks.AutomationTask.Schedule.DelayedSchedule.Mode = types.StringValue(string(tasksItem.AutomationTask.Schedule.DelayedSchedule.Mode)) - tasks.AutomationTask.Schedule.DelayedSchedule.Unit = types.StringValue(string(tasksItem.AutomationTask.Schedule.DelayedSchedule.Unit)) - } - if tasksItem.AutomationTask.Schedule.ImmediateSchedule != nil { - tasks.AutomationTask.Schedule.ImmediateSchedule = &tfTypes.ImmediateSchedule{} - if tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode != nil { - tasks.AutomationTask.Schedule.ImmediateSchedule.Mode = types.StringValue(string(*tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode)) - } else { - tasks.AutomationTask.Schedule.ImmediateSchedule.Mode = types.StringNull() - } - } - if tasksItem.AutomationTask.Schedule.RelativeSchedule != nil { - tasks.AutomationTask.Schedule.RelativeSchedule = &tfTypes.RelativeSchedule{} - tasks.AutomationTask.Schedule.RelativeSchedule.Direction = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Direction)) - tasks.AutomationTask.Schedule.RelativeSchedule.Duration = types.Float64Value(tasksItem.AutomationTask.Schedule.RelativeSchedule.Duration) - tasks.AutomationTask.Schedule.RelativeSchedule.Mode = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Mode)) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute = types.StringPointerValue(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.ID = types.StringValue(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.ID) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.Origin = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Origin)) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.Schema = types.StringPointerValue(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema) - tasks.AutomationTask.Schedule.RelativeSchedule.Unit = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Unit)) - } - } - tasks.AutomationTask.TaskType = types.StringValue(string(tasksItem.AutomationTask.TaskType)) - tasks.AutomationTask.Taxonomies = make([]types.String, 0, len(tasksItem.AutomationTask.Taxonomies)) - for _, v := range tasksItem.AutomationTask.Taxonomies { - tasks.AutomationTask.Taxonomies = append(tasks.AutomationTask.Taxonomies, types.StringValue(v)) - } - if tasksItem.AutomationTask.TriggerMode != nil { - tasks.AutomationTask.TriggerMode = types.StringValue(string(*tasksItem.AutomationTask.TriggerMode)) - } else { - tasks.AutomationTask.TriggerMode = types.StringNull() - } - } - if tasksItem.DecisionTask != nil { - tasks.DecisionTask = &tfTypes.DecisionTask{} - tasks.DecisionTask.AssignedTo = make([]types.String, 0, len(tasksItem.DecisionTask.AssignedTo)) - for _, v := range tasksItem.DecisionTask.AssignedTo { - tasks.DecisionTask.AssignedTo = append(tasks.DecisionTask.AssignedTo, types.StringValue(v)) - } - tasks.DecisionTask.Conditions = []tfTypes.Condition{} - - for _, conditionsItem := range tasksItem.DecisionTask.Conditions { - var conditions tfTypes.Condition - - conditions.BranchName = types.StringValue(conditionsItem.BranchName) - conditions.ID = types.StringValue(conditionsItem.ID) - conditions.LogicalOperator = types.StringValue(string(conditionsItem.LogicalOperator)) - conditions.Statements = []tfTypes.Statement{} - - for _, statementsItem := range conditionsItem.Statements { - var statements tfTypes.Statement - - statements.ID = types.StringValue(statementsItem.ID) - statements.Operator = types.StringValue(string(statementsItem.Operator)) - statements.Source.Attribute = types.StringPointerValue(statementsItem.Source.Attribute) - if statementsItem.Source.AttributeOperation != nil { - statements.Source.AttributeOperation = types.StringValue(string(*statementsItem.Source.AttributeOperation)) - } else { - statements.Source.AttributeOperation = types.StringNull() - } - statements.Source.AttributeRepeatable = types.BoolPointerValue(statementsItem.Source.AttributeRepeatable) - if statementsItem.Source.AttributeType != nil { - statements.Source.AttributeType = types.StringValue(string(*statementsItem.Source.AttributeType)) - } else { - statements.Source.AttributeType = types.StringNull() - } - statements.Source.ID = types.StringPointerValue(statementsItem.Source.ID) - if statementsItem.Source.Origin != nil { - statements.Source.Origin = types.StringValue(string(*statementsItem.Source.Origin)) - } else { - statements.Source.Origin = types.StringNull() - } - if statementsItem.Source.OriginType != nil { - statements.Source.OriginType = types.StringValue(string(*statementsItem.Source.OriginType)) - } else { - statements.Source.OriginType = types.StringNull() - } - statements.Source.Schema = types.StringPointerValue(statementsItem.Source.Schema) - statements.Values = make([]types.String, 0, len(statementsItem.Values)) - for _, v := range statementsItem.Values { - statements.Values = append(statements.Values, types.StringValue(v)) - } - - conditions.Statements = append(conditions.Statements, statements) - } - - tasks.DecisionTask.Conditions = append(tasks.DecisionTask.Conditions, conditions) - } - if tasksItem.DecisionTask.Description == nil { - tasks.DecisionTask.Description = nil - } else { - tasks.DecisionTask.Description = &tfTypes.StepDescription{} - tasks.DecisionTask.Description.Enabled = types.BoolPointerValue(tasksItem.DecisionTask.Description.Enabled) - tasks.DecisionTask.Description.Value = types.StringPointerValue(tasksItem.DecisionTask.Description.Value) - } - tasks.DecisionTask.DueDate = types.StringPointerValue(tasksItem.DecisionTask.DueDate) - if tasksItem.DecisionTask.DueDateConfig == nil { - tasks.DecisionTask.DueDateConfig = nil - } else { - tasks.DecisionTask.DueDateConfig = &tfTypes.DueDateConfig{} - tasks.DecisionTask.DueDateConfig.Duration = types.Float64Value(tasksItem.DecisionTask.DueDateConfig.Duration) - tasks.DecisionTask.DueDateConfig.PhaseID = types.StringPointerValue(tasksItem.DecisionTask.DueDateConfig.PhaseID) - tasks.DecisionTask.DueDateConfig.TaskID = types.StringPointerValue(tasksItem.DecisionTask.DueDateConfig.TaskID) - tasks.DecisionTask.DueDateConfig.Type = types.StringValue(string(tasksItem.DecisionTask.DueDateConfig.Type)) - tasks.DecisionTask.DueDateConfig.Unit = types.StringValue(string(tasksItem.DecisionTask.DueDateConfig.Unit)) - } - if tasksItem.DecisionTask.Ecp == nil { - tasks.DecisionTask.Ecp = nil - } else { - tasks.DecisionTask.Ecp = &tfTypes.ECPDetails{} - tasks.DecisionTask.Ecp.Description = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Description) - tasks.DecisionTask.Ecp.Enabled = types.BoolPointerValue(tasksItem.DecisionTask.Ecp.Enabled) - if tasksItem.DecisionTask.Ecp.Journey == nil { - tasks.DecisionTask.Ecp.Journey = nil - } else { - tasks.DecisionTask.Ecp.Journey = &tfTypes.StepJourney{} - tasks.DecisionTask.Ecp.Journey.ID = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Journey.ID) - tasks.DecisionTask.Ecp.Journey.JourneyID = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Journey.JourneyID) - tasks.DecisionTask.Ecp.Journey.Name = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Journey.Name) - } - tasks.DecisionTask.Ecp.Label = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Label) - } - tasks.DecisionTask.ID = types.StringValue(tasksItem.DecisionTask.ID) - if tasksItem.DecisionTask.Installer == nil { - tasks.DecisionTask.Installer = nil - } else { - tasks.DecisionTask.Installer = &tfTypes.ECPDetails{} - tasks.DecisionTask.Installer.Description = types.StringPointerValue(tasksItem.DecisionTask.Installer.Description) - tasks.DecisionTask.Installer.Enabled = types.BoolPointerValue(tasksItem.DecisionTask.Installer.Enabled) - if tasksItem.DecisionTask.Installer.Journey == nil { - tasks.DecisionTask.Installer.Journey = nil - } else { - tasks.DecisionTask.Installer.Journey = &tfTypes.StepJourney{} - tasks.DecisionTask.Installer.Journey.ID = types.StringPointerValue(tasksItem.DecisionTask.Installer.Journey.ID) - tasks.DecisionTask.Installer.Journey.JourneyID = types.StringPointerValue(tasksItem.DecisionTask.Installer.Journey.JourneyID) - tasks.DecisionTask.Installer.Journey.Name = types.StringPointerValue(tasksItem.DecisionTask.Installer.Journey.Name) - } - tasks.DecisionTask.Installer.Label = types.StringPointerValue(tasksItem.DecisionTask.Installer.Label) - } - if tasksItem.DecisionTask.Journey == nil { - tasks.DecisionTask.Journey = nil - } else { - tasks.DecisionTask.Journey = &tfTypes.StepJourney{} - tasks.DecisionTask.Journey.ID = types.StringPointerValue(tasksItem.DecisionTask.Journey.ID) - tasks.DecisionTask.Journey.JourneyID = types.StringPointerValue(tasksItem.DecisionTask.Journey.JourneyID) - tasks.DecisionTask.Journey.Name = types.StringPointerValue(tasksItem.DecisionTask.Journey.Name) - } - tasks.DecisionTask.Name = types.StringValue(tasksItem.DecisionTask.Name) - tasks.DecisionTask.PhaseID = types.StringPointerValue(tasksItem.DecisionTask.PhaseID) - tasks.DecisionTask.Requirements = []tfTypes.EnableRequirement{} - - for _, requirementsItem1 := range tasksItem.DecisionTask.Requirements { - var requirements1 tfTypes.EnableRequirement - - requirements1.PhaseID = types.StringPointerValue(requirementsItem1.PhaseID) - requirements1.TaskID = types.StringPointerValue(requirementsItem1.TaskID) - requirements1.When = types.StringValue(string(requirementsItem1.When)) - - tasks.DecisionTask.Requirements = append(tasks.DecisionTask.Requirements, requirements1) - } - if tasksItem.DecisionTask.Schedule != nil { - tasks.DecisionTask.Schedule = &tfTypes.Schedule{} - if tasksItem.DecisionTask.Schedule.DelayedSchedule != nil { - tasks.DecisionTask.Schedule.DelayedSchedule = &tfTypes.DelayedSchedule{} - tasks.DecisionTask.Schedule.DelayedSchedule.Duration = types.Float64Value(tasksItem.DecisionTask.Schedule.DelayedSchedule.Duration) - tasks.DecisionTask.Schedule.DelayedSchedule.Mode = types.StringValue(string(tasksItem.DecisionTask.Schedule.DelayedSchedule.Mode)) - tasks.DecisionTask.Schedule.DelayedSchedule.Unit = types.StringValue(string(tasksItem.DecisionTask.Schedule.DelayedSchedule.Unit)) - } - if tasksItem.DecisionTask.Schedule.RelativeSchedule != nil { - tasks.DecisionTask.Schedule.RelativeSchedule = &tfTypes.RelativeSchedule{} - tasks.DecisionTask.Schedule.RelativeSchedule.Direction = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Direction)) - tasks.DecisionTask.Schedule.RelativeSchedule.Duration = types.Float64Value(tasksItem.DecisionTask.Schedule.RelativeSchedule.Duration) - tasks.DecisionTask.Schedule.RelativeSchedule.Mode = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Mode)) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute = types.StringPointerValue(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.ID = types.StringValue(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.ID) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.Origin = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Origin)) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.Schema = types.StringPointerValue(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema) - tasks.DecisionTask.Schedule.RelativeSchedule.Unit = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Unit)) - } - } - tasks.DecisionTask.TaskType = types.StringValue(string(tasksItem.DecisionTask.TaskType)) - tasks.DecisionTask.Taxonomies = make([]types.String, 0, len(tasksItem.DecisionTask.Taxonomies)) - for _, v := range tasksItem.DecisionTask.Taxonomies { - tasks.DecisionTask.Taxonomies = append(tasks.DecisionTask.Taxonomies, types.StringValue(v)) - } - } - if tasksItem.TaskBase != nil { - tasks.TaskBase = &tfTypes.TaskBase{} - tasks.TaskBase.AssignedTo = make([]types.String, 0, len(tasksItem.TaskBase.AssignedTo)) - for _, v := range tasksItem.TaskBase.AssignedTo { - tasks.TaskBase.AssignedTo = append(tasks.TaskBase.AssignedTo, types.StringValue(v)) - } - if tasksItem.TaskBase.Description == nil { - tasks.TaskBase.Description = nil - } else { - tasks.TaskBase.Description = &tfTypes.StepDescription{} - tasks.TaskBase.Description.Enabled = types.BoolPointerValue(tasksItem.TaskBase.Description.Enabled) - tasks.TaskBase.Description.Value = types.StringPointerValue(tasksItem.TaskBase.Description.Value) - } - tasks.TaskBase.DueDate = types.StringPointerValue(tasksItem.TaskBase.DueDate) - if tasksItem.TaskBase.DueDateConfig == nil { - tasks.TaskBase.DueDateConfig = nil - } else { - tasks.TaskBase.DueDateConfig = &tfTypes.DueDateConfig{} - tasks.TaskBase.DueDateConfig.Duration = types.Float64Value(tasksItem.TaskBase.DueDateConfig.Duration) - tasks.TaskBase.DueDateConfig.PhaseID = types.StringPointerValue(tasksItem.TaskBase.DueDateConfig.PhaseID) - tasks.TaskBase.DueDateConfig.TaskID = types.StringPointerValue(tasksItem.TaskBase.DueDateConfig.TaskID) - tasks.TaskBase.DueDateConfig.Type = types.StringValue(string(tasksItem.TaskBase.DueDateConfig.Type)) - tasks.TaskBase.DueDateConfig.Unit = types.StringValue(string(tasksItem.TaskBase.DueDateConfig.Unit)) - } - if tasksItem.TaskBase.Ecp == nil { - tasks.TaskBase.Ecp = nil - } else { - tasks.TaskBase.Ecp = &tfTypes.ECPDetails{} - tasks.TaskBase.Ecp.Description = types.StringPointerValue(tasksItem.TaskBase.Ecp.Description) - tasks.TaskBase.Ecp.Enabled = types.BoolPointerValue(tasksItem.TaskBase.Ecp.Enabled) - if tasksItem.TaskBase.Ecp.Journey == nil { - tasks.TaskBase.Ecp.Journey = nil - } else { - tasks.TaskBase.Ecp.Journey = &tfTypes.StepJourney{} - tasks.TaskBase.Ecp.Journey.ID = types.StringPointerValue(tasksItem.TaskBase.Ecp.Journey.ID) - tasks.TaskBase.Ecp.Journey.JourneyID = types.StringPointerValue(tasksItem.TaskBase.Ecp.Journey.JourneyID) - tasks.TaskBase.Ecp.Journey.Name = types.StringPointerValue(tasksItem.TaskBase.Ecp.Journey.Name) - } - tasks.TaskBase.Ecp.Label = types.StringPointerValue(tasksItem.TaskBase.Ecp.Label) - } - tasks.TaskBase.ID = types.StringValue(tasksItem.TaskBase.ID) - if tasksItem.TaskBase.Installer == nil { - tasks.TaskBase.Installer = nil - } else { - tasks.TaskBase.Installer = &tfTypes.ECPDetails{} - tasks.TaskBase.Installer.Description = types.StringPointerValue(tasksItem.TaskBase.Installer.Description) - tasks.TaskBase.Installer.Enabled = types.BoolPointerValue(tasksItem.TaskBase.Installer.Enabled) - if tasksItem.TaskBase.Installer.Journey == nil { - tasks.TaskBase.Installer.Journey = nil - } else { - tasks.TaskBase.Installer.Journey = &tfTypes.StepJourney{} - tasks.TaskBase.Installer.Journey.ID = types.StringPointerValue(tasksItem.TaskBase.Installer.Journey.ID) - tasks.TaskBase.Installer.Journey.JourneyID = types.StringPointerValue(tasksItem.TaskBase.Installer.Journey.JourneyID) - tasks.TaskBase.Installer.Journey.Name = types.StringPointerValue(tasksItem.TaskBase.Installer.Journey.Name) - } - tasks.TaskBase.Installer.Label = types.StringPointerValue(tasksItem.TaskBase.Installer.Label) - } - if tasksItem.TaskBase.Journey == nil { - tasks.TaskBase.Journey = nil - } else { - tasks.TaskBase.Journey = &tfTypes.StepJourney{} - tasks.TaskBase.Journey.ID = types.StringPointerValue(tasksItem.TaskBase.Journey.ID) - tasks.TaskBase.Journey.JourneyID = types.StringPointerValue(tasksItem.TaskBase.Journey.JourneyID) - tasks.TaskBase.Journey.Name = types.StringPointerValue(tasksItem.TaskBase.Journey.Name) - } - tasks.TaskBase.Name = types.StringValue(tasksItem.TaskBase.Name) - tasks.TaskBase.PhaseID = types.StringPointerValue(tasksItem.TaskBase.PhaseID) - tasks.TaskBase.Requirements = []tfTypes.EnableRequirement{} - - for _, requirementsItem2 := range tasksItem.TaskBase.Requirements { - var requirements2 tfTypes.EnableRequirement - - requirements2.PhaseID = types.StringPointerValue(requirementsItem2.PhaseID) - requirements2.TaskID = types.StringPointerValue(requirementsItem2.TaskID) - requirements2.When = types.StringValue(string(requirementsItem2.When)) - - tasks.TaskBase.Requirements = append(tasks.TaskBase.Requirements, requirements2) - } - tasks.TaskBase.TaskType = types.StringValue(string(tasksItem.TaskBase.TaskType)) - tasks.TaskBase.Taxonomies = make([]types.String, 0, len(tasksItem.TaskBase.Taxonomies)) - for _, v := range tasksItem.TaskBase.Taxonomies { - tasks.TaskBase.Taxonomies = append(tasks.TaskBase.Taxonomies, types.StringValue(v)) - } - } - - r.Tasks = append(r.Tasks, tasks) - } - r.Taxonomies = make([]types.String, 0, len(resp.Taxonomies)) - for _, v := range resp.Taxonomies { - r.Taxonomies = append(r.Taxonomies, types.StringValue(v)) - } - if resp.Trigger != nil { - r.Trigger = &tfTypes.Trigger{} - if resp.Trigger.AutomationTrigger != nil { - r.Trigger.AutomationTrigger = &tfTypes.AutomationTrigger{} - r.Trigger.AutomationTrigger.AutomationID = types.StringValue(resp.Trigger.AutomationTrigger.AutomationID) - r.Trigger.AutomationTrigger.ID = types.StringPointerValue(resp.Trigger.AutomationTrigger.ID) - r.Trigger.AutomationTrigger.Type = types.StringValue(string(resp.Trigger.AutomationTrigger.Type)) - } - if resp.Trigger.JourneySubmissionTrigger != nil { - r.Trigger.JourneySubmissionTrigger = &tfTypes.JourneySubmissionTrigger{} - r.Trigger.JourneySubmissionTrigger.AutomationID = types.StringPointerValue(resp.Trigger.JourneySubmissionTrigger.AutomationID) - r.Trigger.JourneySubmissionTrigger.ID = types.StringPointerValue(resp.Trigger.JourneySubmissionTrigger.ID) - r.Trigger.JourneySubmissionTrigger.JourneyID = types.StringValue(resp.Trigger.JourneySubmissionTrigger.JourneyID) - r.Trigger.JourneySubmissionTrigger.Type = types.StringValue(string(resp.Trigger.JourneySubmissionTrigger.Type)) - } - if resp.Trigger.ManualTrigger != nil { - r.Trigger.ManualTrigger = &tfTypes.ManualTrigger{} - r.Trigger.ManualTrigger.EntitySchema = types.StringPointerValue(resp.Trigger.ManualTrigger.EntitySchema) - r.Trigger.ManualTrigger.ID = types.StringPointerValue(resp.Trigger.ManualTrigger.ID) - r.Trigger.ManualTrigger.Type = types.StringValue(string(resp.Trigger.ManualTrigger.Type)) - } - } - r.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} - - for _, updateEntityAttributesItem := range resp.UpdateEntityAttributes { - var updateEntityAttributes tfTypes.UpdateEntityAttributes - - updateEntityAttributes.Source = types.StringValue(string(updateEntityAttributesItem.Source)) - updateEntityAttributes.Target.EntityAttribute = types.StringValue(updateEntityAttributesItem.Target.EntityAttribute) - updateEntityAttributes.Target.EntitySchema = types.StringValue(updateEntityAttributesItem.Target.EntitySchema) - - r.UpdateEntityAttributes = append(r.UpdateEntityAttributes, updateEntityAttributes) - } - r.UpdatedAt = types.StringPointerValue(resp.UpdatedAt) - } - - return diags -} - -func (r *FlowTemplateDataSourceModel) ToOperationsGetFlowTemplateRequest(ctx context.Context) (*operations.GetFlowTemplateRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var flowID string - flowID = r.ID.ValueString() - - out := operations.GetFlowTemplateRequest{ - FlowID: flowID, - } - - return &out, diags -} diff --git a/internal/provider/flowtemplate_resource.go b/internal/provider/flowtemplate_resource.go deleted file mode 100644 index 4fa6d1f..0000000 --- a/internal/provider/flowtemplate_resource.go +++ /dev/null @@ -1,2056 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/planmodifiers/stringplanmodifier" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - speakeasy_float64validators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/float64validators" - speakeasy_listvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/listvalidators" - speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/objectvalidators" - speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/stringvalidators" - "github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &FlowTemplateResource{} -var _ resource.ResourceWithImportState = &FlowTemplateResource{} - -func NewFlowTemplateResource() resource.Resource { - return &FlowTemplateResource{} -} - -// FlowTemplateResource defines the resource implementation. -type FlowTemplateResource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// FlowTemplateResourceModel describes the resource data model. -type FlowTemplateResourceModel struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - AvailableInEcp types.Bool `tfsdk:"available_in_ecp"` - ClosingReasons []tfTypes.ClosingReason `tfsdk:"closing_reasons"` - CreatedAt types.String `tfsdk:"created_at"` - Description types.String `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DueDateConfig *tfTypes.DueDateConfig `tfsdk:"due_date_config"` - Edges []tfTypes.Edge `tfsdk:"edges"` - Enabled types.Bool `tfsdk:"enabled"` - ID types.String `tfsdk:"id"` - IsFlowMigrated types.Bool `tfsdk:"is_flow_migrated"` - Name types.String `tfsdk:"name"` - OrgID types.String `tfsdk:"org_id"` - Phases []tfTypes.Phase `tfsdk:"phases"` - Tasks []tfTypes.Task `tfsdk:"tasks"` - Taxonomies []types.String `tfsdk:"taxonomies"` - Trigger *tfTypes.Trigger `tfsdk:"trigger"` - UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` - UpdatedAt types.String `tfsdk:"updated_at"` -} - -func (r *FlowTemplateResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_flow_template" -} - -func (r *FlowTemplateResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "FlowTemplate Resource", - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "available_in_ecp": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, - }, - "closing_reasons": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "creation_time": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Not Null; Requires replacement if changed.`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - }, - "status": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["ACTIVE", "INACTIVE"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "ACTIVE", - "INACTIVE", - ), - }, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ISO String Date & Time`, - }, - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "edges": schema.ListNestedAttribute{ - Required: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "condition_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "from_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "none_met": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Indicates a default case for a decision task. Only decision task edges can have this field and the flow advances using this edge if no conditions are met.`, - }, - "to_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - }, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - Default: booldefault.StaticBool(true), - Description: `Whether the workflow is enabled or not. Default: true`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "is_flow_migrated": schema.BoolAttribute{ - Computed: true, - Optional: true, - Default: booldefault.StaticBool(false), - Description: `Whether the workflow is migrated from workflows to flows or not. Default: false`, - }, - "name": schema.StringAttribute{ - Required: true, - }, - "org_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "phases": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - }, - }, - }, - "tasks": schema.ListNestedAttribute{ - Required: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "automation_task": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "automation_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "flow_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Id of the configured automation to run. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Configuration for automation execution to run. Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - "description": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "value": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Longer information regarding Task`, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "ecp": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "installer": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "requirements": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "when": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - }, - }, - Description: `requirements that need to be fulfilled in order to enable the task while flow instances are running`, - }, - "schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "delayed_schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "mode": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "delayed"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf("delayed"), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("immediate_schedule"), - path.MatchRelative().AtParent().AtName("relative_schedule"), - }...), - }, - }, - "immediate_schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be "immediate"`, - Validators: []validator.String{ - stringvalidator.OneOf( - "immediate", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("delayed_schedule"), - path.MatchRelative().AtParent().AtName("relative_schedule"), - }...), - }, - }, - "relative_schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "direction": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["before", "after"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "before", - "after", - ), - }, - }, - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "mode": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "relative"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf("relative"), - }, - }, - "reference": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `An entity attribute that identifies a date / datetime`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The id of the entity / workflow / task, based on the origin of the schedule. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "origin": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["flow_started", "task_completed", "trigger_entity_attribute"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "flow_started", - "task_completed", - "trigger_entity_attribute", - ), - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The schema of the entity`, - }, - }, - Description: `Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("delayed_schedule"), - path.MatchRelative().AtParent().AtName("immediate_schedule"), - }...), - }, - }, - }, - }, - "task_type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["MANUAL", "AUTOMATION", "DECISION"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "MANUAL", - "AUTOMATION", - "DECISION", - ), - }, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - "trigger_mode": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["manual", "automatic"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "manual", - "automatic", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("decision_task"), - path.MatchRelative().AtParent().AtName("task_base"), - }...), - }, - }, - "decision_task": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "conditions": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "branch_name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The name of the branch. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.UTF8LengthAtMost(255), - }, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "logical_operator": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["AND", "OR"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "AND", - "OR", - ), - }, - }, - "statements": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "operator": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["equals", "not_equals", "any_of", "none_of", "contains", "not_contains", "starts_with", "ends_with", "greater_than", "less_than", "greater_than_or_equals", "less_than_or_equals", "is_empty", "is_not_empty"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "equals", - "not_equals", - "any_of", - "none_of", - "contains", - "not_contains", - "starts_with", - "ends_with", - "greater_than", - "less_than", - "greater_than_or_equals", - "less_than_or_equals", - "is_empty", - "is_not_empty", - ), - }, - }, - "source": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "attribute_operation": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["all", "updated", "added", "deleted"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "all", - "updated", - "added", - "deleted", - ), - }, - }, - "attribute_repeatable": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "attribute_type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["string", "text", "number", "boolean", "date", "datetime", "tags", "country", "email", "phone", "product", "price", "status", "relation", "multiselect", "select", "radio", "relation_user", "purpose", "label"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "string", - "text", - "number", - "boolean", - "date", - "datetime", - "tags", - "country", - "email", - "phone", - "product", - "price", - "status", - "relation", - "multiselect", - "select", - "radio", - "relation_user", - "purpose", - "label", - ), - }, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The id of the action or trigger`, - }, - "origin": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["trigger", "action"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "trigger", - "action", - ), - }, - }, - "origin_type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["entity", "workflow", "journey_block"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "entity", - "workflow", - "journey_block", - ), - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - "values": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Not Null`, - Validators: []validator.List{ - speakeasy_listvalidators.NotNull(), - }, - }, - }, - }, - Description: `Not Null`, - Validators: []validator.List{ - speakeasy_listvalidators.NotNull(), - }, - }, - }, - }, - Description: `Not Null`, - Validators: []validator.List{ - speakeasy_listvalidators.NotNull(), - }, - }, - "description": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "value": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Longer information regarding Task`, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "ecp": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "installer": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "requirements": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "when": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - }, - }, - Description: `requirements that need to be fulfilled in order to enable the task while flow instances are running`, - }, - "schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "delayed_schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "mode": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "delayed"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf("delayed"), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("relative_schedule"), - }...), - }, - }, - "relative_schedule": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "direction": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["before", "after"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "before", - "after", - ), - }, - }, - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "mode": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "relative"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf("relative"), - }, - }, - "reference": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `An entity attribute that identifies a date / datetime`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The id of the entity / workflow / task, based on the origin of the schedule. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "origin": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["flow_started", "task_completed", "trigger_entity_attribute"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "flow_started", - "task_completed", - "trigger_entity_attribute", - ), - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The schema of the entity`, - }, - }, - Description: `Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("delayed_schedule"), - }...), - }, - }, - }, - }, - "task_type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["MANUAL", "AUTOMATION", "DECISION"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "MANUAL", - "AUTOMATION", - "DECISION", - ), - }, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("automation_task"), - path.MatchRelative().AtParent().AtName("task_base"), - }...), - }, - }, - "task_base": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "description": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "value": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Longer information regarding Task`, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "duration": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["WORKFLOW_STARTED", "TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - "unit": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `Set due date for the task based on a dynamic condition`, - }, - "ecp": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "installer": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "label": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - Description: `Details regarding ECP for the workflow step`, - }, - "journey": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "requirements": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "task_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "when": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["TASK_FINISHED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "TASK_FINISHED", - "PHASE_FINISHED", - ), - }, - }, - }, - }, - Description: `requirements that need to be fulfilled in order to enable the task while flow instances are running`, - }, - "task_type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["MANUAL", "AUTOMATION", "DECISION"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "MANUAL", - "AUTOMATION", - "DECISION", - ), - }, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("automation_task"), - path.MatchRelative().AtParent().AtName("decision_task"), - }...), - }, - }, - }, - }, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - "trigger": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "automation_trigger": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "automation_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Id of the automation config that triggers this workflow. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "automation"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "automation", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("journey_submission_trigger"), - path.MatchRelative().AtParent().AtName("manual_trigger"), - }...), - }, - }, - "journey_submission_trigger": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "automation_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ID of the journey that will trigger this flow. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "journey_submission"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "journey_submission", - ), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("automation_trigger"), - path.MatchRelative().AtParent().AtName("manual_trigger"), - }...), - }, - }, - "manual_trigger": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "entity_schema": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be "manual"`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf("manual"), - }, - }, - }, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("automation_trigger"), - path.MatchRelative().AtParent().AtName("journey_submission_trigger"), - }...), - }, - }, - }, - }, - "update_entity_attributes": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "source": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["workflow_status", "current_section", "current_step"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "workflow_status", - "current_section", - "current_step", - ), - }, - }, - "target": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "entity_attribute": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "entity_schema": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - }, - }, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ISO String Date & Time`, - }, - }, - } -} - -func (r *FlowTemplateResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *FlowTemplateResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *FlowTemplateResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToSharedCreateFlowTemplate(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.FlowsV2.CreateFlowTemplate(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.FlowTemplate != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedFlowTemplate(ctx, res.FlowTemplate)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *FlowTemplateResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *FlowTemplateResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsGetFlowTemplateRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.FlowsV2.GetFlowTemplate(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.FlowTemplate != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedFlowTemplate(ctx, res.FlowTemplate)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *FlowTemplateResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *FlowTemplateResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsUpdateFlowTemplateRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.FlowsV2.UpdateFlowTemplate(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.FlowTemplate != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedFlowTemplate(ctx, res.FlowTemplate)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *FlowTemplateResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *FlowTemplateResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsDeleteFlowTemplateRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.FlowsV2.DeleteFlowTemplate(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *FlowTemplateResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/flowtemplate_resource_sdk.go b/internal/provider/flowtemplate_resource_sdk.go deleted file mode 100644 index cb013b6..0000000 --- a/internal/provider/flowtemplate_resource_sdk.go +++ /dev/null @@ -1,3173 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *FlowTemplateResourceModel) RefreshFromSharedFlowTemplate(ctx context.Context, resp *shared.FlowTemplate) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.AssignedTo = make([]types.String, 0, len(resp.AssignedTo)) - for _, v := range resp.AssignedTo { - r.AssignedTo = append(r.AssignedTo, types.StringValue(v)) - } - r.AvailableInEcp = types.BoolPointerValue(resp.AvailableInEcp) - r.ClosingReasons = []tfTypes.ClosingReason{} - - for _, closingReasonsItem := range resp.ClosingReasons { - var closingReasons tfTypes.ClosingReason - - closingReasons.CreationTime = types.StringPointerValue(closingReasonsItem.CreationTime) - closingReasons.ID = types.StringPointerValue(closingReasonsItem.ID) - closingReasons.LastUpdateTime = types.StringPointerValue(closingReasonsItem.LastUpdateTime) - closingReasons.Status = types.StringValue(string(closingReasonsItem.Status)) - closingReasons.Title = types.StringValue(closingReasonsItem.Title) - - r.ClosingReasons = append(r.ClosingReasons, closingReasons) - } - r.CreatedAt = types.StringPointerValue(resp.CreatedAt) - r.Description = types.StringPointerValue(resp.Description) - r.DueDate = types.StringPointerValue(resp.DueDate) - if resp.DueDateConfig == nil { - r.DueDateConfig = nil - } else { - r.DueDateConfig = &tfTypes.DueDateConfig{} - r.DueDateConfig.Duration = types.Float64Value(resp.DueDateConfig.Duration) - r.DueDateConfig.PhaseID = types.StringPointerValue(resp.DueDateConfig.PhaseID) - r.DueDateConfig.TaskID = types.StringPointerValue(resp.DueDateConfig.TaskID) - r.DueDateConfig.Type = types.StringValue(string(resp.DueDateConfig.Type)) - r.DueDateConfig.Unit = types.StringValue(string(resp.DueDateConfig.Unit)) - } - r.Edges = []tfTypes.Edge{} - - for _, edgesItem := range resp.Edges { - var edges tfTypes.Edge - - edges.ConditionID = types.StringPointerValue(edgesItem.ConditionID) - edges.FromID = types.StringValue(edgesItem.FromID) - edges.ID = types.StringValue(edgesItem.ID) - edges.NoneMet = types.BoolPointerValue(edgesItem.NoneMet) - edges.ToID = types.StringValue(edgesItem.ToID) - - r.Edges = append(r.Edges, edges) - } - r.Enabled = types.BoolPointerValue(resp.Enabled) - r.ID = types.StringPointerValue(resp.ID) - r.IsFlowMigrated = types.BoolPointerValue(resp.IsFlowMigrated) - r.Name = types.StringValue(resp.Name) - r.OrgID = types.StringPointerValue(resp.OrgID) - r.Phases = []tfTypes.Phase{} - - for _, phasesItem := range resp.Phases { - var phases tfTypes.Phase - - phases.AssignedTo = make([]types.String, 0, len(phasesItem.AssignedTo)) - for _, v := range phasesItem.AssignedTo { - phases.AssignedTo = append(phases.AssignedTo, types.StringValue(v)) - } - phases.DueDate = types.StringPointerValue(phasesItem.DueDate) - if phasesItem.DueDateConfig == nil { - phases.DueDateConfig = nil - } else { - phases.DueDateConfig = &tfTypes.DueDateConfig{} - phases.DueDateConfig.Duration = types.Float64Value(phasesItem.DueDateConfig.Duration) - phases.DueDateConfig.PhaseID = types.StringPointerValue(phasesItem.DueDateConfig.PhaseID) - phases.DueDateConfig.TaskID = types.StringPointerValue(phasesItem.DueDateConfig.TaskID) - phases.DueDateConfig.Type = types.StringValue(string(phasesItem.DueDateConfig.Type)) - phases.DueDateConfig.Unit = types.StringValue(string(phasesItem.DueDateConfig.Unit)) - } - phases.ID = types.StringValue(phasesItem.ID) - phases.Name = types.StringValue(phasesItem.Name) - phases.Taxonomies = make([]types.String, 0, len(phasesItem.Taxonomies)) - for _, v := range phasesItem.Taxonomies { - phases.Taxonomies = append(phases.Taxonomies, types.StringValue(v)) - } - - r.Phases = append(r.Phases, phases) - } - r.Tasks = []tfTypes.Task{} - - for _, tasksItem := range resp.Tasks { - var tasks tfTypes.Task - - if tasksItem.AutomationTask != nil { - tasks.AutomationTask = &tfTypes.AutomationTask{} - tasks.AutomationTask.AssignedTo = make([]types.String, 0, len(tasksItem.AutomationTask.AssignedTo)) - for _, v := range tasksItem.AutomationTask.AssignedTo { - tasks.AutomationTask.AssignedTo = append(tasks.AutomationTask.AssignedTo, types.StringValue(v)) - } - tasks.AutomationTask.AutomationConfig.FlowID = types.StringValue(tasksItem.AutomationTask.AutomationConfig.FlowID) - if tasksItem.AutomationTask.Description == nil { - tasks.AutomationTask.Description = nil - } else { - tasks.AutomationTask.Description = &tfTypes.StepDescription{} - tasks.AutomationTask.Description.Enabled = types.BoolPointerValue(tasksItem.AutomationTask.Description.Enabled) - tasks.AutomationTask.Description.Value = types.StringPointerValue(tasksItem.AutomationTask.Description.Value) - } - tasks.AutomationTask.DueDate = types.StringPointerValue(tasksItem.AutomationTask.DueDate) - if tasksItem.AutomationTask.DueDateConfig == nil { - tasks.AutomationTask.DueDateConfig = nil - } else { - tasks.AutomationTask.DueDateConfig = &tfTypes.DueDateConfig{} - tasks.AutomationTask.DueDateConfig.Duration = types.Float64Value(tasksItem.AutomationTask.DueDateConfig.Duration) - tasks.AutomationTask.DueDateConfig.PhaseID = types.StringPointerValue(tasksItem.AutomationTask.DueDateConfig.PhaseID) - tasks.AutomationTask.DueDateConfig.TaskID = types.StringPointerValue(tasksItem.AutomationTask.DueDateConfig.TaskID) - tasks.AutomationTask.DueDateConfig.Type = types.StringValue(string(tasksItem.AutomationTask.DueDateConfig.Type)) - tasks.AutomationTask.DueDateConfig.Unit = types.StringValue(string(tasksItem.AutomationTask.DueDateConfig.Unit)) - } - if tasksItem.AutomationTask.Ecp == nil { - tasks.AutomationTask.Ecp = nil - } else { - tasks.AutomationTask.Ecp = &tfTypes.ECPDetails{} - tasks.AutomationTask.Ecp.Description = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Description) - tasks.AutomationTask.Ecp.Enabled = types.BoolPointerValue(tasksItem.AutomationTask.Ecp.Enabled) - if tasksItem.AutomationTask.Ecp.Journey == nil { - tasks.AutomationTask.Ecp.Journey = nil - } else { - tasks.AutomationTask.Ecp.Journey = &tfTypes.StepJourney{} - tasks.AutomationTask.Ecp.Journey.ID = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Journey.ID) - tasks.AutomationTask.Ecp.Journey.JourneyID = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Journey.JourneyID) - tasks.AutomationTask.Ecp.Journey.Name = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Journey.Name) - } - tasks.AutomationTask.Ecp.Label = types.StringPointerValue(tasksItem.AutomationTask.Ecp.Label) - } - tasks.AutomationTask.ID = types.StringValue(tasksItem.AutomationTask.ID) - if tasksItem.AutomationTask.Installer == nil { - tasks.AutomationTask.Installer = nil - } else { - tasks.AutomationTask.Installer = &tfTypes.ECPDetails{} - tasks.AutomationTask.Installer.Description = types.StringPointerValue(tasksItem.AutomationTask.Installer.Description) - tasks.AutomationTask.Installer.Enabled = types.BoolPointerValue(tasksItem.AutomationTask.Installer.Enabled) - if tasksItem.AutomationTask.Installer.Journey == nil { - tasks.AutomationTask.Installer.Journey = nil - } else { - tasks.AutomationTask.Installer.Journey = &tfTypes.StepJourney{} - tasks.AutomationTask.Installer.Journey.ID = types.StringPointerValue(tasksItem.AutomationTask.Installer.Journey.ID) - tasks.AutomationTask.Installer.Journey.JourneyID = types.StringPointerValue(tasksItem.AutomationTask.Installer.Journey.JourneyID) - tasks.AutomationTask.Installer.Journey.Name = types.StringPointerValue(tasksItem.AutomationTask.Installer.Journey.Name) - } - tasks.AutomationTask.Installer.Label = types.StringPointerValue(tasksItem.AutomationTask.Installer.Label) - } - if tasksItem.AutomationTask.Journey == nil { - tasks.AutomationTask.Journey = nil - } else { - tasks.AutomationTask.Journey = &tfTypes.StepJourney{} - tasks.AutomationTask.Journey.ID = types.StringPointerValue(tasksItem.AutomationTask.Journey.ID) - tasks.AutomationTask.Journey.JourneyID = types.StringPointerValue(tasksItem.AutomationTask.Journey.JourneyID) - tasks.AutomationTask.Journey.Name = types.StringPointerValue(tasksItem.AutomationTask.Journey.Name) - } - tasks.AutomationTask.Name = types.StringValue(tasksItem.AutomationTask.Name) - tasks.AutomationTask.PhaseID = types.StringPointerValue(tasksItem.AutomationTask.PhaseID) - tasks.AutomationTask.Requirements = []tfTypes.EnableRequirement{} - - for _, requirementsItem := range tasksItem.AutomationTask.Requirements { - var requirements tfTypes.EnableRequirement - - requirements.PhaseID = types.StringPointerValue(requirementsItem.PhaseID) - requirements.TaskID = types.StringPointerValue(requirementsItem.TaskID) - requirements.When = types.StringValue(string(requirementsItem.When)) - - tasks.AutomationTask.Requirements = append(tasks.AutomationTask.Requirements, requirements) - } - if tasksItem.AutomationTask.Schedule != nil { - tasks.AutomationTask.Schedule = &tfTypes.ActionSchedule{} - if tasksItem.AutomationTask.Schedule.DelayedSchedule != nil { - tasks.AutomationTask.Schedule.DelayedSchedule = &tfTypes.DelayedSchedule{} - tasks.AutomationTask.Schedule.DelayedSchedule.Duration = types.Float64Value(tasksItem.AutomationTask.Schedule.DelayedSchedule.Duration) - tasks.AutomationTask.Schedule.DelayedSchedule.Mode = types.StringValue(string(tasksItem.AutomationTask.Schedule.DelayedSchedule.Mode)) - tasks.AutomationTask.Schedule.DelayedSchedule.Unit = types.StringValue(string(tasksItem.AutomationTask.Schedule.DelayedSchedule.Unit)) - } - if tasksItem.AutomationTask.Schedule.ImmediateSchedule != nil { - tasks.AutomationTask.Schedule.ImmediateSchedule = &tfTypes.ImmediateSchedule{} - if tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode != nil { - tasks.AutomationTask.Schedule.ImmediateSchedule.Mode = types.StringValue(string(*tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode)) - } else { - tasks.AutomationTask.Schedule.ImmediateSchedule.Mode = types.StringNull() - } - } - if tasksItem.AutomationTask.Schedule.RelativeSchedule != nil { - tasks.AutomationTask.Schedule.RelativeSchedule = &tfTypes.RelativeSchedule{} - tasks.AutomationTask.Schedule.RelativeSchedule.Direction = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Direction)) - tasks.AutomationTask.Schedule.RelativeSchedule.Duration = types.Float64Value(tasksItem.AutomationTask.Schedule.RelativeSchedule.Duration) - tasks.AutomationTask.Schedule.RelativeSchedule.Mode = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Mode)) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute = types.StringPointerValue(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.ID = types.StringValue(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.ID) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.Origin = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Origin)) - tasks.AutomationTask.Schedule.RelativeSchedule.Reference.Schema = types.StringPointerValue(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema) - tasks.AutomationTask.Schedule.RelativeSchedule.Unit = types.StringValue(string(tasksItem.AutomationTask.Schedule.RelativeSchedule.Unit)) - } - } - tasks.AutomationTask.TaskType = types.StringValue(string(tasksItem.AutomationTask.TaskType)) - tasks.AutomationTask.Taxonomies = make([]types.String, 0, len(tasksItem.AutomationTask.Taxonomies)) - for _, v := range tasksItem.AutomationTask.Taxonomies { - tasks.AutomationTask.Taxonomies = append(tasks.AutomationTask.Taxonomies, types.StringValue(v)) - } - if tasksItem.AutomationTask.TriggerMode != nil { - tasks.AutomationTask.TriggerMode = types.StringValue(string(*tasksItem.AutomationTask.TriggerMode)) - } else { - tasks.AutomationTask.TriggerMode = types.StringNull() - } - } - if tasksItem.DecisionTask != nil { - tasks.DecisionTask = &tfTypes.DecisionTask{} - tasks.DecisionTask.AssignedTo = make([]types.String, 0, len(tasksItem.DecisionTask.AssignedTo)) - for _, v := range tasksItem.DecisionTask.AssignedTo { - tasks.DecisionTask.AssignedTo = append(tasks.DecisionTask.AssignedTo, types.StringValue(v)) - } - tasks.DecisionTask.Conditions = []tfTypes.Condition{} - - for _, conditionsItem := range tasksItem.DecisionTask.Conditions { - var conditions tfTypes.Condition - - conditions.BranchName = types.StringValue(conditionsItem.BranchName) - conditions.ID = types.StringValue(conditionsItem.ID) - conditions.LogicalOperator = types.StringValue(string(conditionsItem.LogicalOperator)) - conditions.Statements = []tfTypes.Statement{} - - for _, statementsItem := range conditionsItem.Statements { - var statements tfTypes.Statement - - statements.ID = types.StringValue(statementsItem.ID) - statements.Operator = types.StringValue(string(statementsItem.Operator)) - statements.Source.Attribute = types.StringPointerValue(statementsItem.Source.Attribute) - if statementsItem.Source.AttributeOperation != nil { - statements.Source.AttributeOperation = types.StringValue(string(*statementsItem.Source.AttributeOperation)) - } else { - statements.Source.AttributeOperation = types.StringNull() - } - statements.Source.AttributeRepeatable = types.BoolPointerValue(statementsItem.Source.AttributeRepeatable) - if statementsItem.Source.AttributeType != nil { - statements.Source.AttributeType = types.StringValue(string(*statementsItem.Source.AttributeType)) - } else { - statements.Source.AttributeType = types.StringNull() - } - statements.Source.ID = types.StringPointerValue(statementsItem.Source.ID) - if statementsItem.Source.Origin != nil { - statements.Source.Origin = types.StringValue(string(*statementsItem.Source.Origin)) - } else { - statements.Source.Origin = types.StringNull() - } - if statementsItem.Source.OriginType != nil { - statements.Source.OriginType = types.StringValue(string(*statementsItem.Source.OriginType)) - } else { - statements.Source.OriginType = types.StringNull() - } - statements.Source.Schema = types.StringPointerValue(statementsItem.Source.Schema) - statements.Values = make([]types.String, 0, len(statementsItem.Values)) - for _, v := range statementsItem.Values { - statements.Values = append(statements.Values, types.StringValue(v)) - } - - conditions.Statements = append(conditions.Statements, statements) - } - - tasks.DecisionTask.Conditions = append(tasks.DecisionTask.Conditions, conditions) - } - if tasksItem.DecisionTask.Description == nil { - tasks.DecisionTask.Description = nil - } else { - tasks.DecisionTask.Description = &tfTypes.StepDescription{} - tasks.DecisionTask.Description.Enabled = types.BoolPointerValue(tasksItem.DecisionTask.Description.Enabled) - tasks.DecisionTask.Description.Value = types.StringPointerValue(tasksItem.DecisionTask.Description.Value) - } - tasks.DecisionTask.DueDate = types.StringPointerValue(tasksItem.DecisionTask.DueDate) - if tasksItem.DecisionTask.DueDateConfig == nil { - tasks.DecisionTask.DueDateConfig = nil - } else { - tasks.DecisionTask.DueDateConfig = &tfTypes.DueDateConfig{} - tasks.DecisionTask.DueDateConfig.Duration = types.Float64Value(tasksItem.DecisionTask.DueDateConfig.Duration) - tasks.DecisionTask.DueDateConfig.PhaseID = types.StringPointerValue(tasksItem.DecisionTask.DueDateConfig.PhaseID) - tasks.DecisionTask.DueDateConfig.TaskID = types.StringPointerValue(tasksItem.DecisionTask.DueDateConfig.TaskID) - tasks.DecisionTask.DueDateConfig.Type = types.StringValue(string(tasksItem.DecisionTask.DueDateConfig.Type)) - tasks.DecisionTask.DueDateConfig.Unit = types.StringValue(string(tasksItem.DecisionTask.DueDateConfig.Unit)) - } - if tasksItem.DecisionTask.Ecp == nil { - tasks.DecisionTask.Ecp = nil - } else { - tasks.DecisionTask.Ecp = &tfTypes.ECPDetails{} - tasks.DecisionTask.Ecp.Description = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Description) - tasks.DecisionTask.Ecp.Enabled = types.BoolPointerValue(tasksItem.DecisionTask.Ecp.Enabled) - if tasksItem.DecisionTask.Ecp.Journey == nil { - tasks.DecisionTask.Ecp.Journey = nil - } else { - tasks.DecisionTask.Ecp.Journey = &tfTypes.StepJourney{} - tasks.DecisionTask.Ecp.Journey.ID = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Journey.ID) - tasks.DecisionTask.Ecp.Journey.JourneyID = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Journey.JourneyID) - tasks.DecisionTask.Ecp.Journey.Name = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Journey.Name) - } - tasks.DecisionTask.Ecp.Label = types.StringPointerValue(tasksItem.DecisionTask.Ecp.Label) - } - tasks.DecisionTask.ID = types.StringValue(tasksItem.DecisionTask.ID) - if tasksItem.DecisionTask.Installer == nil { - tasks.DecisionTask.Installer = nil - } else { - tasks.DecisionTask.Installer = &tfTypes.ECPDetails{} - tasks.DecisionTask.Installer.Description = types.StringPointerValue(tasksItem.DecisionTask.Installer.Description) - tasks.DecisionTask.Installer.Enabled = types.BoolPointerValue(tasksItem.DecisionTask.Installer.Enabled) - if tasksItem.DecisionTask.Installer.Journey == nil { - tasks.DecisionTask.Installer.Journey = nil - } else { - tasks.DecisionTask.Installer.Journey = &tfTypes.StepJourney{} - tasks.DecisionTask.Installer.Journey.ID = types.StringPointerValue(tasksItem.DecisionTask.Installer.Journey.ID) - tasks.DecisionTask.Installer.Journey.JourneyID = types.StringPointerValue(tasksItem.DecisionTask.Installer.Journey.JourneyID) - tasks.DecisionTask.Installer.Journey.Name = types.StringPointerValue(tasksItem.DecisionTask.Installer.Journey.Name) - } - tasks.DecisionTask.Installer.Label = types.StringPointerValue(tasksItem.DecisionTask.Installer.Label) - } - if tasksItem.DecisionTask.Journey == nil { - tasks.DecisionTask.Journey = nil - } else { - tasks.DecisionTask.Journey = &tfTypes.StepJourney{} - tasks.DecisionTask.Journey.ID = types.StringPointerValue(tasksItem.DecisionTask.Journey.ID) - tasks.DecisionTask.Journey.JourneyID = types.StringPointerValue(tasksItem.DecisionTask.Journey.JourneyID) - tasks.DecisionTask.Journey.Name = types.StringPointerValue(tasksItem.DecisionTask.Journey.Name) - } - tasks.DecisionTask.Name = types.StringValue(tasksItem.DecisionTask.Name) - tasks.DecisionTask.PhaseID = types.StringPointerValue(tasksItem.DecisionTask.PhaseID) - tasks.DecisionTask.Requirements = []tfTypes.EnableRequirement{} - - for _, requirementsItem1 := range tasksItem.DecisionTask.Requirements { - var requirements1 tfTypes.EnableRequirement - - requirements1.PhaseID = types.StringPointerValue(requirementsItem1.PhaseID) - requirements1.TaskID = types.StringPointerValue(requirementsItem1.TaskID) - requirements1.When = types.StringValue(string(requirementsItem1.When)) - - tasks.DecisionTask.Requirements = append(tasks.DecisionTask.Requirements, requirements1) - } - if tasksItem.DecisionTask.Schedule != nil { - tasks.DecisionTask.Schedule = &tfTypes.Schedule{} - if tasksItem.DecisionTask.Schedule.DelayedSchedule != nil { - tasks.DecisionTask.Schedule.DelayedSchedule = &tfTypes.DelayedSchedule{} - tasks.DecisionTask.Schedule.DelayedSchedule.Duration = types.Float64Value(tasksItem.DecisionTask.Schedule.DelayedSchedule.Duration) - tasks.DecisionTask.Schedule.DelayedSchedule.Mode = types.StringValue(string(tasksItem.DecisionTask.Schedule.DelayedSchedule.Mode)) - tasks.DecisionTask.Schedule.DelayedSchedule.Unit = types.StringValue(string(tasksItem.DecisionTask.Schedule.DelayedSchedule.Unit)) - } - if tasksItem.DecisionTask.Schedule.RelativeSchedule != nil { - tasks.DecisionTask.Schedule.RelativeSchedule = &tfTypes.RelativeSchedule{} - tasks.DecisionTask.Schedule.RelativeSchedule.Direction = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Direction)) - tasks.DecisionTask.Schedule.RelativeSchedule.Duration = types.Float64Value(tasksItem.DecisionTask.Schedule.RelativeSchedule.Duration) - tasks.DecisionTask.Schedule.RelativeSchedule.Mode = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Mode)) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute = types.StringPointerValue(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.ID = types.StringValue(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.ID) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.Origin = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Origin)) - tasks.DecisionTask.Schedule.RelativeSchedule.Reference.Schema = types.StringPointerValue(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema) - tasks.DecisionTask.Schedule.RelativeSchedule.Unit = types.StringValue(string(tasksItem.DecisionTask.Schedule.RelativeSchedule.Unit)) - } - } - tasks.DecisionTask.TaskType = types.StringValue(string(tasksItem.DecisionTask.TaskType)) - tasks.DecisionTask.Taxonomies = make([]types.String, 0, len(tasksItem.DecisionTask.Taxonomies)) - for _, v := range tasksItem.DecisionTask.Taxonomies { - tasks.DecisionTask.Taxonomies = append(tasks.DecisionTask.Taxonomies, types.StringValue(v)) - } - } - if tasksItem.TaskBase != nil { - tasks.TaskBase = &tfTypes.TaskBase{} - tasks.TaskBase.AssignedTo = make([]types.String, 0, len(tasksItem.TaskBase.AssignedTo)) - for _, v := range tasksItem.TaskBase.AssignedTo { - tasks.TaskBase.AssignedTo = append(tasks.TaskBase.AssignedTo, types.StringValue(v)) - } - if tasksItem.TaskBase.Description == nil { - tasks.TaskBase.Description = nil - } else { - tasks.TaskBase.Description = &tfTypes.StepDescription{} - tasks.TaskBase.Description.Enabled = types.BoolPointerValue(tasksItem.TaskBase.Description.Enabled) - tasks.TaskBase.Description.Value = types.StringPointerValue(tasksItem.TaskBase.Description.Value) - } - tasks.TaskBase.DueDate = types.StringPointerValue(tasksItem.TaskBase.DueDate) - if tasksItem.TaskBase.DueDateConfig == nil { - tasks.TaskBase.DueDateConfig = nil - } else { - tasks.TaskBase.DueDateConfig = &tfTypes.DueDateConfig{} - tasks.TaskBase.DueDateConfig.Duration = types.Float64Value(tasksItem.TaskBase.DueDateConfig.Duration) - tasks.TaskBase.DueDateConfig.PhaseID = types.StringPointerValue(tasksItem.TaskBase.DueDateConfig.PhaseID) - tasks.TaskBase.DueDateConfig.TaskID = types.StringPointerValue(tasksItem.TaskBase.DueDateConfig.TaskID) - tasks.TaskBase.DueDateConfig.Type = types.StringValue(string(tasksItem.TaskBase.DueDateConfig.Type)) - tasks.TaskBase.DueDateConfig.Unit = types.StringValue(string(tasksItem.TaskBase.DueDateConfig.Unit)) - } - if tasksItem.TaskBase.Ecp == nil { - tasks.TaskBase.Ecp = nil - } else { - tasks.TaskBase.Ecp = &tfTypes.ECPDetails{} - tasks.TaskBase.Ecp.Description = types.StringPointerValue(tasksItem.TaskBase.Ecp.Description) - tasks.TaskBase.Ecp.Enabled = types.BoolPointerValue(tasksItem.TaskBase.Ecp.Enabled) - if tasksItem.TaskBase.Ecp.Journey == nil { - tasks.TaskBase.Ecp.Journey = nil - } else { - tasks.TaskBase.Ecp.Journey = &tfTypes.StepJourney{} - tasks.TaskBase.Ecp.Journey.ID = types.StringPointerValue(tasksItem.TaskBase.Ecp.Journey.ID) - tasks.TaskBase.Ecp.Journey.JourneyID = types.StringPointerValue(tasksItem.TaskBase.Ecp.Journey.JourneyID) - tasks.TaskBase.Ecp.Journey.Name = types.StringPointerValue(tasksItem.TaskBase.Ecp.Journey.Name) - } - tasks.TaskBase.Ecp.Label = types.StringPointerValue(tasksItem.TaskBase.Ecp.Label) - } - tasks.TaskBase.ID = types.StringValue(tasksItem.TaskBase.ID) - if tasksItem.TaskBase.Installer == nil { - tasks.TaskBase.Installer = nil - } else { - tasks.TaskBase.Installer = &tfTypes.ECPDetails{} - tasks.TaskBase.Installer.Description = types.StringPointerValue(tasksItem.TaskBase.Installer.Description) - tasks.TaskBase.Installer.Enabled = types.BoolPointerValue(tasksItem.TaskBase.Installer.Enabled) - if tasksItem.TaskBase.Installer.Journey == nil { - tasks.TaskBase.Installer.Journey = nil - } else { - tasks.TaskBase.Installer.Journey = &tfTypes.StepJourney{} - tasks.TaskBase.Installer.Journey.ID = types.StringPointerValue(tasksItem.TaskBase.Installer.Journey.ID) - tasks.TaskBase.Installer.Journey.JourneyID = types.StringPointerValue(tasksItem.TaskBase.Installer.Journey.JourneyID) - tasks.TaskBase.Installer.Journey.Name = types.StringPointerValue(tasksItem.TaskBase.Installer.Journey.Name) - } - tasks.TaskBase.Installer.Label = types.StringPointerValue(tasksItem.TaskBase.Installer.Label) - } - if tasksItem.TaskBase.Journey == nil { - tasks.TaskBase.Journey = nil - } else { - tasks.TaskBase.Journey = &tfTypes.StepJourney{} - tasks.TaskBase.Journey.ID = types.StringPointerValue(tasksItem.TaskBase.Journey.ID) - tasks.TaskBase.Journey.JourneyID = types.StringPointerValue(tasksItem.TaskBase.Journey.JourneyID) - tasks.TaskBase.Journey.Name = types.StringPointerValue(tasksItem.TaskBase.Journey.Name) - } - tasks.TaskBase.Name = types.StringValue(tasksItem.TaskBase.Name) - tasks.TaskBase.PhaseID = types.StringPointerValue(tasksItem.TaskBase.PhaseID) - tasks.TaskBase.Requirements = []tfTypes.EnableRequirement{} - - for _, requirementsItem2 := range tasksItem.TaskBase.Requirements { - var requirements2 tfTypes.EnableRequirement - - requirements2.PhaseID = types.StringPointerValue(requirementsItem2.PhaseID) - requirements2.TaskID = types.StringPointerValue(requirementsItem2.TaskID) - requirements2.When = types.StringValue(string(requirementsItem2.When)) - - tasks.TaskBase.Requirements = append(tasks.TaskBase.Requirements, requirements2) - } - tasks.TaskBase.TaskType = types.StringValue(string(tasksItem.TaskBase.TaskType)) - tasks.TaskBase.Taxonomies = make([]types.String, 0, len(tasksItem.TaskBase.Taxonomies)) - for _, v := range tasksItem.TaskBase.Taxonomies { - tasks.TaskBase.Taxonomies = append(tasks.TaskBase.Taxonomies, types.StringValue(v)) - } - } - - r.Tasks = append(r.Tasks, tasks) - } - r.Taxonomies = make([]types.String, 0, len(resp.Taxonomies)) - for _, v := range resp.Taxonomies { - r.Taxonomies = append(r.Taxonomies, types.StringValue(v)) - } - if resp.Trigger != nil { - r.Trigger = &tfTypes.Trigger{} - if resp.Trigger.AutomationTrigger != nil { - r.Trigger.AutomationTrigger = &tfTypes.AutomationTrigger{} - r.Trigger.AutomationTrigger.AutomationID = types.StringValue(resp.Trigger.AutomationTrigger.AutomationID) - r.Trigger.AutomationTrigger.ID = types.StringPointerValue(resp.Trigger.AutomationTrigger.ID) - r.Trigger.AutomationTrigger.Type = types.StringValue(string(resp.Trigger.AutomationTrigger.Type)) - } - if resp.Trigger.JourneySubmissionTrigger != nil { - r.Trigger.JourneySubmissionTrigger = &tfTypes.JourneySubmissionTrigger{} - r.Trigger.JourneySubmissionTrigger.AutomationID = types.StringPointerValue(resp.Trigger.JourneySubmissionTrigger.AutomationID) - r.Trigger.JourneySubmissionTrigger.ID = types.StringPointerValue(resp.Trigger.JourneySubmissionTrigger.ID) - r.Trigger.JourneySubmissionTrigger.JourneyID = types.StringValue(resp.Trigger.JourneySubmissionTrigger.JourneyID) - r.Trigger.JourneySubmissionTrigger.Type = types.StringValue(string(resp.Trigger.JourneySubmissionTrigger.Type)) - } - if resp.Trigger.ManualTrigger != nil { - r.Trigger.ManualTrigger = &tfTypes.ManualTrigger{} - r.Trigger.ManualTrigger.EntitySchema = types.StringPointerValue(resp.Trigger.ManualTrigger.EntitySchema) - r.Trigger.ManualTrigger.ID = types.StringPointerValue(resp.Trigger.ManualTrigger.ID) - r.Trigger.ManualTrigger.Type = types.StringValue(string(resp.Trigger.ManualTrigger.Type)) - } - } - r.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} - - for _, updateEntityAttributesItem := range resp.UpdateEntityAttributes { - var updateEntityAttributes tfTypes.UpdateEntityAttributes - - updateEntityAttributes.Source = types.StringValue(string(updateEntityAttributesItem.Source)) - updateEntityAttributes.Target.EntityAttribute = types.StringValue(updateEntityAttributesItem.Target.EntityAttribute) - updateEntityAttributes.Target.EntitySchema = types.StringValue(updateEntityAttributesItem.Target.EntitySchema) - - r.UpdateEntityAttributes = append(r.UpdateEntityAttributes, updateEntityAttributes) - } - r.UpdatedAt = types.StringPointerValue(resp.UpdatedAt) - } - - return diags -} - -func (r *FlowTemplateResourceModel) ToOperationsDeleteFlowTemplateRequest(ctx context.Context) (*operations.DeleteFlowTemplateRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var flowID string - flowID = r.ID.ValueString() - - out := operations.DeleteFlowTemplateRequest{ - FlowID: flowID, - } - - return &out, diags -} - -func (r *FlowTemplateResourceModel) ToOperationsGetFlowTemplateRequest(ctx context.Context) (*operations.GetFlowTemplateRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var flowID string - flowID = r.ID.ValueString() - - out := operations.GetFlowTemplateRequest{ - FlowID: flowID, - } - - return &out, diags -} - -func (r *FlowTemplateResourceModel) ToOperationsUpdateFlowTemplateRequest(ctx context.Context) (*operations.UpdateFlowTemplateRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - flowTemplate, flowTemplateDiags := r.ToSharedFlowTemplateInput(ctx) - diags.Append(flowTemplateDiags...) - - if diags.HasError() { - return nil, diags - } - - var flowID string - flowID = r.ID.ValueString() - - out := operations.UpdateFlowTemplateRequest{ - FlowTemplate: *flowTemplate, - FlowID: flowID, - } - - return &out, diags -} - -func (r *FlowTemplateResourceModel) ToSharedCreateFlowTemplate(ctx context.Context) (*shared.CreateFlowTemplate, diag.Diagnostics) { - var diags diag.Diagnostics - - assignedTo := make([]string, 0, len(r.AssignedTo)) - for _, assignedToItem := range r.AssignedTo { - assignedTo = append(assignedTo, assignedToItem.ValueString()) - } - availableInEcp := new(bool) - if !r.AvailableInEcp.IsUnknown() && !r.AvailableInEcp.IsNull() { - *availableInEcp = r.AvailableInEcp.ValueBool() - } else { - availableInEcp = nil - } - closingReasons := make([]shared.ClosingReasonID, 0, len(r.ClosingReasons)) - for _, closingReasonsItem := range r.ClosingReasons { - var id string - id = closingReasonsItem.ID.ValueString() - - closingReasons = append(closingReasons, shared.ClosingReasonID{ - ID: id, - }) - } - createdAt := new(string) - if !r.CreatedAt.IsUnknown() && !r.CreatedAt.IsNull() { - *createdAt = r.CreatedAt.ValueString() - } else { - createdAt = nil - } - description := new(string) - if !r.Description.IsUnknown() && !r.Description.IsNull() { - *description = r.Description.ValueString() - } else { - description = nil - } - dueDate := new(string) - if !r.DueDate.IsUnknown() && !r.DueDate.IsNull() { - *dueDate = r.DueDate.ValueString() - } else { - dueDate = nil - } - var dueDateConfig *shared.DueDateConfig - if r.DueDateConfig != nil { - var duration float64 - duration = r.DueDateConfig.Duration.ValueFloat64() - - phaseID := new(string) - if !r.DueDateConfig.PhaseID.IsUnknown() && !r.DueDateConfig.PhaseID.IsNull() { - *phaseID = r.DueDateConfig.PhaseID.ValueString() - } else { - phaseID = nil - } - taskID := new(string) - if !r.DueDateConfig.TaskID.IsUnknown() && !r.DueDateConfig.TaskID.IsNull() { - *taskID = r.DueDateConfig.TaskID.ValueString() - } else { - taskID = nil - } - typeVar := shared.DueDateConfigType(r.DueDateConfig.Type.ValueString()) - unit := shared.TimeUnit(r.DueDateConfig.Unit.ValueString()) - dueDateConfig = &shared.DueDateConfig{ - Duration: duration, - PhaseID: phaseID, - TaskID: taskID, - Type: typeVar, - Unit: unit, - } - } - edges := make([]shared.Edge, 0, len(r.Edges)) - for _, edgesItem := range r.Edges { - conditionID := new(string) - if !edgesItem.ConditionID.IsUnknown() && !edgesItem.ConditionID.IsNull() { - *conditionID = edgesItem.ConditionID.ValueString() - } else { - conditionID = nil - } - var fromID string - fromID = edgesItem.FromID.ValueString() - - var id1 string - id1 = edgesItem.ID.ValueString() - - noneMet := new(bool) - if !edgesItem.NoneMet.IsUnknown() && !edgesItem.NoneMet.IsNull() { - *noneMet = edgesItem.NoneMet.ValueBool() - } else { - noneMet = nil - } - var toID string - toID = edgesItem.ToID.ValueString() - - edges = append(edges, shared.Edge{ - ConditionID: conditionID, - FromID: fromID, - ID: id1, - NoneMet: noneMet, - ToID: toID, - }) - } - enabled := new(bool) - if !r.Enabled.IsUnknown() && !r.Enabled.IsNull() { - *enabled = r.Enabled.ValueBool() - } else { - enabled = nil - } - id2 := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id2 = r.ID.ValueString() - } else { - id2 = nil - } - isFlowMigrated := new(bool) - if !r.IsFlowMigrated.IsUnknown() && !r.IsFlowMigrated.IsNull() { - *isFlowMigrated = r.IsFlowMigrated.ValueBool() - } else { - isFlowMigrated = nil - } - var name string - name = r.Name.ValueString() - - orgID := new(string) - if !r.OrgID.IsUnknown() && !r.OrgID.IsNull() { - *orgID = r.OrgID.ValueString() - } else { - orgID = nil - } - phases := make([]shared.Phase, 0, len(r.Phases)) - for _, phasesItem := range r.Phases { - assignedTo1 := make([]string, 0, len(phasesItem.AssignedTo)) - for _, assignedToItem1 := range phasesItem.AssignedTo { - assignedTo1 = append(assignedTo1, assignedToItem1.ValueString()) - } - dueDate1 := new(string) - if !phasesItem.DueDate.IsUnknown() && !phasesItem.DueDate.IsNull() { - *dueDate1 = phasesItem.DueDate.ValueString() - } else { - dueDate1 = nil - } - var dueDateConfig1 *shared.DueDateConfig - if phasesItem.DueDateConfig != nil { - var duration1 float64 - duration1 = phasesItem.DueDateConfig.Duration.ValueFloat64() - - phaseId1 := new(string) - if !phasesItem.DueDateConfig.PhaseID.IsUnknown() && !phasesItem.DueDateConfig.PhaseID.IsNull() { - *phaseId1 = phasesItem.DueDateConfig.PhaseID.ValueString() - } else { - phaseId1 = nil - } - taskId1 := new(string) - if !phasesItem.DueDateConfig.TaskID.IsUnknown() && !phasesItem.DueDateConfig.TaskID.IsNull() { - *taskId1 = phasesItem.DueDateConfig.TaskID.ValueString() - } else { - taskId1 = nil - } - typeVar1 := shared.DueDateConfigType(phasesItem.DueDateConfig.Type.ValueString()) - unit1 := shared.TimeUnit(phasesItem.DueDateConfig.Unit.ValueString()) - dueDateConfig1 = &shared.DueDateConfig{ - Duration: duration1, - PhaseID: phaseId1, - TaskID: taskId1, - Type: typeVar1, - Unit: unit1, - } - } - var id3 string - id3 = phasesItem.ID.ValueString() - - var name1 string - name1 = phasesItem.Name.ValueString() - - taxonomies := make([]string, 0, len(phasesItem.Taxonomies)) - for _, taxonomiesItem := range phasesItem.Taxonomies { - taxonomies = append(taxonomies, taxonomiesItem.ValueString()) - } - phases = append(phases, shared.Phase{ - AssignedTo: assignedTo1, - DueDate: dueDate1, - DueDateConfig: dueDateConfig1, - ID: id3, - Name: name1, - Taxonomies: taxonomies, - }) - } - tasks := make([]shared.Task, 0, len(r.Tasks)) - for _, tasksItem := range r.Tasks { - if tasksItem.TaskBase != nil { - assignedTo2 := make([]string, 0, len(tasksItem.TaskBase.AssignedTo)) - for _, assignedToItem2 := range tasksItem.TaskBase.AssignedTo { - assignedTo2 = append(assignedTo2, assignedToItem2.ValueString()) - } - var description1 *shared.StepDescription - if tasksItem.TaskBase.Description != nil { - enabled1 := new(bool) - if !tasksItem.TaskBase.Description.Enabled.IsUnknown() && !tasksItem.TaskBase.Description.Enabled.IsNull() { - *enabled1 = tasksItem.TaskBase.Description.Enabled.ValueBool() - } else { - enabled1 = nil - } - value := new(string) - if !tasksItem.TaskBase.Description.Value.IsUnknown() && !tasksItem.TaskBase.Description.Value.IsNull() { - *value = tasksItem.TaskBase.Description.Value.ValueString() - } else { - value = nil - } - description1 = &shared.StepDescription{ - Enabled: enabled1, - Value: value, - } - } - dueDate2 := new(string) - if !tasksItem.TaskBase.DueDate.IsUnknown() && !tasksItem.TaskBase.DueDate.IsNull() { - *dueDate2 = tasksItem.TaskBase.DueDate.ValueString() - } else { - dueDate2 = nil - } - var dueDateConfig2 *shared.DueDateConfig - if tasksItem.TaskBase.DueDateConfig != nil { - var duration2 float64 - duration2 = tasksItem.TaskBase.DueDateConfig.Duration.ValueFloat64() - - phaseId2 := new(string) - if !tasksItem.TaskBase.DueDateConfig.PhaseID.IsUnknown() && !tasksItem.TaskBase.DueDateConfig.PhaseID.IsNull() { - *phaseId2 = tasksItem.TaskBase.DueDateConfig.PhaseID.ValueString() - } else { - phaseId2 = nil - } - taskId2 := new(string) - if !tasksItem.TaskBase.DueDateConfig.TaskID.IsUnknown() && !tasksItem.TaskBase.DueDateConfig.TaskID.IsNull() { - *taskId2 = tasksItem.TaskBase.DueDateConfig.TaskID.ValueString() - } else { - taskId2 = nil - } - typeVar2 := shared.DueDateConfigType(tasksItem.TaskBase.DueDateConfig.Type.ValueString()) - unit2 := shared.TimeUnit(tasksItem.TaskBase.DueDateConfig.Unit.ValueString()) - dueDateConfig2 = &shared.DueDateConfig{ - Duration: duration2, - PhaseID: phaseId2, - TaskID: taskId2, - Type: typeVar2, - Unit: unit2, - } - } - var ecp *shared.ECPDetails - if tasksItem.TaskBase.Ecp != nil { - description2 := new(string) - if !tasksItem.TaskBase.Ecp.Description.IsUnknown() && !tasksItem.TaskBase.Ecp.Description.IsNull() { - *description2 = tasksItem.TaskBase.Ecp.Description.ValueString() - } else { - description2 = nil - } - enabled2 := new(bool) - if !tasksItem.TaskBase.Ecp.Enabled.IsUnknown() && !tasksItem.TaskBase.Ecp.Enabled.IsNull() { - *enabled2 = tasksItem.TaskBase.Ecp.Enabled.ValueBool() - } else { - enabled2 = nil - } - var journey *shared.StepJourney - if tasksItem.TaskBase.Ecp.Journey != nil { - id4 := new(string) - if !tasksItem.TaskBase.Ecp.Journey.ID.IsUnknown() && !tasksItem.TaskBase.Ecp.Journey.ID.IsNull() { - *id4 = tasksItem.TaskBase.Ecp.Journey.ID.ValueString() - } else { - id4 = nil - } - journeyID := new(string) - if !tasksItem.TaskBase.Ecp.Journey.JourneyID.IsUnknown() && !tasksItem.TaskBase.Ecp.Journey.JourneyID.IsNull() { - *journeyID = tasksItem.TaskBase.Ecp.Journey.JourneyID.ValueString() - } else { - journeyID = nil - } - name2 := new(string) - if !tasksItem.TaskBase.Ecp.Journey.Name.IsUnknown() && !tasksItem.TaskBase.Ecp.Journey.Name.IsNull() { - *name2 = tasksItem.TaskBase.Ecp.Journey.Name.ValueString() - } else { - name2 = nil - } - journey = &shared.StepJourney{ - ID: id4, - JourneyID: journeyID, - Name: name2, - } - } - label := new(string) - if !tasksItem.TaskBase.Ecp.Label.IsUnknown() && !tasksItem.TaskBase.Ecp.Label.IsNull() { - *label = tasksItem.TaskBase.Ecp.Label.ValueString() - } else { - label = nil - } - ecp = &shared.ECPDetails{ - Description: description2, - Enabled: enabled2, - Journey: journey, - Label: label, - } - } - var id5 string - id5 = tasksItem.TaskBase.ID.ValueString() - - var installer *shared.ECPDetails - if tasksItem.TaskBase.Installer != nil { - description3 := new(string) - if !tasksItem.TaskBase.Installer.Description.IsUnknown() && !tasksItem.TaskBase.Installer.Description.IsNull() { - *description3 = tasksItem.TaskBase.Installer.Description.ValueString() - } else { - description3 = nil - } - enabled3 := new(bool) - if !tasksItem.TaskBase.Installer.Enabled.IsUnknown() && !tasksItem.TaskBase.Installer.Enabled.IsNull() { - *enabled3 = tasksItem.TaskBase.Installer.Enabled.ValueBool() - } else { - enabled3 = nil - } - var journey1 *shared.StepJourney - if tasksItem.TaskBase.Installer.Journey != nil { - id6 := new(string) - if !tasksItem.TaskBase.Installer.Journey.ID.IsUnknown() && !tasksItem.TaskBase.Installer.Journey.ID.IsNull() { - *id6 = tasksItem.TaskBase.Installer.Journey.ID.ValueString() - } else { - id6 = nil - } - journeyId1 := new(string) - if !tasksItem.TaskBase.Installer.Journey.JourneyID.IsUnknown() && !tasksItem.TaskBase.Installer.Journey.JourneyID.IsNull() { - *journeyId1 = tasksItem.TaskBase.Installer.Journey.JourneyID.ValueString() - } else { - journeyId1 = nil - } - name3 := new(string) - if !tasksItem.TaskBase.Installer.Journey.Name.IsUnknown() && !tasksItem.TaskBase.Installer.Journey.Name.IsNull() { - *name3 = tasksItem.TaskBase.Installer.Journey.Name.ValueString() - } else { - name3 = nil - } - journey1 = &shared.StepJourney{ - ID: id6, - JourneyID: journeyId1, - Name: name3, - } - } - label1 := new(string) - if !tasksItem.TaskBase.Installer.Label.IsUnknown() && !tasksItem.TaskBase.Installer.Label.IsNull() { - *label1 = tasksItem.TaskBase.Installer.Label.ValueString() - } else { - label1 = nil - } - installer = &shared.ECPDetails{ - Description: description3, - Enabled: enabled3, - Journey: journey1, - Label: label1, - } - } - var journey2 *shared.StepJourney - if tasksItem.TaskBase.Journey != nil { - id7 := new(string) - if !tasksItem.TaskBase.Journey.ID.IsUnknown() && !tasksItem.TaskBase.Journey.ID.IsNull() { - *id7 = tasksItem.TaskBase.Journey.ID.ValueString() - } else { - id7 = nil - } - journeyId2 := new(string) - if !tasksItem.TaskBase.Journey.JourneyID.IsUnknown() && !tasksItem.TaskBase.Journey.JourneyID.IsNull() { - *journeyId2 = tasksItem.TaskBase.Journey.JourneyID.ValueString() - } else { - journeyId2 = nil - } - name4 := new(string) - if !tasksItem.TaskBase.Journey.Name.IsUnknown() && !tasksItem.TaskBase.Journey.Name.IsNull() { - *name4 = tasksItem.TaskBase.Journey.Name.ValueString() - } else { - name4 = nil - } - journey2 = &shared.StepJourney{ - ID: id7, - JourneyID: journeyId2, - Name: name4, - } - } - var name5 string - name5 = tasksItem.TaskBase.Name.ValueString() - - phaseId3 := new(string) - if !tasksItem.TaskBase.PhaseID.IsUnknown() && !tasksItem.TaskBase.PhaseID.IsNull() { - *phaseId3 = tasksItem.TaskBase.PhaseID.ValueString() - } else { - phaseId3 = nil - } - requirements := make([]shared.EnableRequirement, 0, len(tasksItem.TaskBase.Requirements)) - for _, requirementsItem := range tasksItem.TaskBase.Requirements { - phaseId4 := new(string) - if !requirementsItem.PhaseID.IsUnknown() && !requirementsItem.PhaseID.IsNull() { - *phaseId4 = requirementsItem.PhaseID.ValueString() - } else { - phaseId4 = nil - } - taskId3 := new(string) - if !requirementsItem.TaskID.IsUnknown() && !requirementsItem.TaskID.IsNull() { - *taskId3 = requirementsItem.TaskID.ValueString() - } else { - taskId3 = nil - } - when := shared.When(requirementsItem.When.ValueString()) - requirements = append(requirements, shared.EnableRequirement{ - PhaseID: phaseId4, - TaskID: taskId3, - When: when, - }) - } - taskType := shared.TaskType(tasksItem.TaskBase.TaskType.ValueString()) - taxonomies1 := make([]string, 0, len(tasksItem.TaskBase.Taxonomies)) - for _, taxonomiesItem1 := range tasksItem.TaskBase.Taxonomies { - taxonomies1 = append(taxonomies1, taxonomiesItem1.ValueString()) - } - taskBase := shared.TaskBase{ - AssignedTo: assignedTo2, - Description: description1, - DueDate: dueDate2, - DueDateConfig: dueDateConfig2, - Ecp: ecp, - ID: id5, - Installer: installer, - Journey: journey2, - Name: name5, - PhaseID: phaseId3, - Requirements: requirements, - TaskType: taskType, - Taxonomies: taxonomies1, - } - tasks = append(tasks, shared.Task{ - TaskBase: &taskBase, - }) - } - if tasksItem.AutomationTask != nil { - assignedTo3 := make([]string, 0, len(tasksItem.AutomationTask.AssignedTo)) - for _, assignedToItem3 := range tasksItem.AutomationTask.AssignedTo { - assignedTo3 = append(assignedTo3, assignedToItem3.ValueString()) - } - var flowID string - flowID = tasksItem.AutomationTask.AutomationConfig.FlowID.ValueString() - - automationConfig := shared.AutomationConfig{ - FlowID: flowID, - } - var description4 *shared.StepDescription - if tasksItem.AutomationTask.Description != nil { - enabled4 := new(bool) - if !tasksItem.AutomationTask.Description.Enabled.IsUnknown() && !tasksItem.AutomationTask.Description.Enabled.IsNull() { - *enabled4 = tasksItem.AutomationTask.Description.Enabled.ValueBool() - } else { - enabled4 = nil - } - value1 := new(string) - if !tasksItem.AutomationTask.Description.Value.IsUnknown() && !tasksItem.AutomationTask.Description.Value.IsNull() { - *value1 = tasksItem.AutomationTask.Description.Value.ValueString() - } else { - value1 = nil - } - description4 = &shared.StepDescription{ - Enabled: enabled4, - Value: value1, - } - } - dueDate3 := new(string) - if !tasksItem.AutomationTask.DueDate.IsUnknown() && !tasksItem.AutomationTask.DueDate.IsNull() { - *dueDate3 = tasksItem.AutomationTask.DueDate.ValueString() - } else { - dueDate3 = nil - } - var dueDateConfig3 *shared.DueDateConfig - if tasksItem.AutomationTask.DueDateConfig != nil { - var duration3 float64 - duration3 = tasksItem.AutomationTask.DueDateConfig.Duration.ValueFloat64() - - phaseId5 := new(string) - if !tasksItem.AutomationTask.DueDateConfig.PhaseID.IsUnknown() && !tasksItem.AutomationTask.DueDateConfig.PhaseID.IsNull() { - *phaseId5 = tasksItem.AutomationTask.DueDateConfig.PhaseID.ValueString() - } else { - phaseId5 = nil - } - taskId4 := new(string) - if !tasksItem.AutomationTask.DueDateConfig.TaskID.IsUnknown() && !tasksItem.AutomationTask.DueDateConfig.TaskID.IsNull() { - *taskId4 = tasksItem.AutomationTask.DueDateConfig.TaskID.ValueString() - } else { - taskId4 = nil - } - typeVar3 := shared.DueDateConfigType(tasksItem.AutomationTask.DueDateConfig.Type.ValueString()) - unit3 := shared.TimeUnit(tasksItem.AutomationTask.DueDateConfig.Unit.ValueString()) - dueDateConfig3 = &shared.DueDateConfig{ - Duration: duration3, - PhaseID: phaseId5, - TaskID: taskId4, - Type: typeVar3, - Unit: unit3, - } - } - var ecp1 *shared.ECPDetails - if tasksItem.AutomationTask.Ecp != nil { - description5 := new(string) - if !tasksItem.AutomationTask.Ecp.Description.IsUnknown() && !tasksItem.AutomationTask.Ecp.Description.IsNull() { - *description5 = tasksItem.AutomationTask.Ecp.Description.ValueString() - } else { - description5 = nil - } - enabled5 := new(bool) - if !tasksItem.AutomationTask.Ecp.Enabled.IsUnknown() && !tasksItem.AutomationTask.Ecp.Enabled.IsNull() { - *enabled5 = tasksItem.AutomationTask.Ecp.Enabled.ValueBool() - } else { - enabled5 = nil - } - var journey3 *shared.StepJourney - if tasksItem.AutomationTask.Ecp.Journey != nil { - id8 := new(string) - if !tasksItem.AutomationTask.Ecp.Journey.ID.IsUnknown() && !tasksItem.AutomationTask.Ecp.Journey.ID.IsNull() { - *id8 = tasksItem.AutomationTask.Ecp.Journey.ID.ValueString() - } else { - id8 = nil - } - journeyId3 := new(string) - if !tasksItem.AutomationTask.Ecp.Journey.JourneyID.IsUnknown() && !tasksItem.AutomationTask.Ecp.Journey.JourneyID.IsNull() { - *journeyId3 = tasksItem.AutomationTask.Ecp.Journey.JourneyID.ValueString() - } else { - journeyId3 = nil - } - name6 := new(string) - if !tasksItem.AutomationTask.Ecp.Journey.Name.IsUnknown() && !tasksItem.AutomationTask.Ecp.Journey.Name.IsNull() { - *name6 = tasksItem.AutomationTask.Ecp.Journey.Name.ValueString() - } else { - name6 = nil - } - journey3 = &shared.StepJourney{ - ID: id8, - JourneyID: journeyId3, - Name: name6, - } - } - label2 := new(string) - if !tasksItem.AutomationTask.Ecp.Label.IsUnknown() && !tasksItem.AutomationTask.Ecp.Label.IsNull() { - *label2 = tasksItem.AutomationTask.Ecp.Label.ValueString() - } else { - label2 = nil - } - ecp1 = &shared.ECPDetails{ - Description: description5, - Enabled: enabled5, - Journey: journey3, - Label: label2, - } - } - var id9 string - id9 = tasksItem.AutomationTask.ID.ValueString() - - var installer1 *shared.ECPDetails - if tasksItem.AutomationTask.Installer != nil { - description6 := new(string) - if !tasksItem.AutomationTask.Installer.Description.IsUnknown() && !tasksItem.AutomationTask.Installer.Description.IsNull() { - *description6 = tasksItem.AutomationTask.Installer.Description.ValueString() - } else { - description6 = nil - } - enabled6 := new(bool) - if !tasksItem.AutomationTask.Installer.Enabled.IsUnknown() && !tasksItem.AutomationTask.Installer.Enabled.IsNull() { - *enabled6 = tasksItem.AutomationTask.Installer.Enabled.ValueBool() - } else { - enabled6 = nil - } - var journey4 *shared.StepJourney - if tasksItem.AutomationTask.Installer.Journey != nil { - id10 := new(string) - if !tasksItem.AutomationTask.Installer.Journey.ID.IsUnknown() && !tasksItem.AutomationTask.Installer.Journey.ID.IsNull() { - *id10 = tasksItem.AutomationTask.Installer.Journey.ID.ValueString() - } else { - id10 = nil - } - journeyId4 := new(string) - if !tasksItem.AutomationTask.Installer.Journey.JourneyID.IsUnknown() && !tasksItem.AutomationTask.Installer.Journey.JourneyID.IsNull() { - *journeyId4 = tasksItem.AutomationTask.Installer.Journey.JourneyID.ValueString() - } else { - journeyId4 = nil - } - name7 := new(string) - if !tasksItem.AutomationTask.Installer.Journey.Name.IsUnknown() && !tasksItem.AutomationTask.Installer.Journey.Name.IsNull() { - *name7 = tasksItem.AutomationTask.Installer.Journey.Name.ValueString() - } else { - name7 = nil - } - journey4 = &shared.StepJourney{ - ID: id10, - JourneyID: journeyId4, - Name: name7, - } - } - label3 := new(string) - if !tasksItem.AutomationTask.Installer.Label.IsUnknown() && !tasksItem.AutomationTask.Installer.Label.IsNull() { - *label3 = tasksItem.AutomationTask.Installer.Label.ValueString() - } else { - label3 = nil - } - installer1 = &shared.ECPDetails{ - Description: description6, - Enabled: enabled6, - Journey: journey4, - Label: label3, - } - } - var journey5 *shared.StepJourney - if tasksItem.AutomationTask.Journey != nil { - id11 := new(string) - if !tasksItem.AutomationTask.Journey.ID.IsUnknown() && !tasksItem.AutomationTask.Journey.ID.IsNull() { - *id11 = tasksItem.AutomationTask.Journey.ID.ValueString() - } else { - id11 = nil - } - journeyId5 := new(string) - if !tasksItem.AutomationTask.Journey.JourneyID.IsUnknown() && !tasksItem.AutomationTask.Journey.JourneyID.IsNull() { - *journeyId5 = tasksItem.AutomationTask.Journey.JourneyID.ValueString() - } else { - journeyId5 = nil - } - name8 := new(string) - if !tasksItem.AutomationTask.Journey.Name.IsUnknown() && !tasksItem.AutomationTask.Journey.Name.IsNull() { - *name8 = tasksItem.AutomationTask.Journey.Name.ValueString() - } else { - name8 = nil - } - journey5 = &shared.StepJourney{ - ID: id11, - JourneyID: journeyId5, - Name: name8, - } - } - var name9 string - name9 = tasksItem.AutomationTask.Name.ValueString() - - phaseId6 := new(string) - if !tasksItem.AutomationTask.PhaseID.IsUnknown() && !tasksItem.AutomationTask.PhaseID.IsNull() { - *phaseId6 = tasksItem.AutomationTask.PhaseID.ValueString() - } else { - phaseId6 = nil - } - requirements1 := make([]shared.EnableRequirement, 0, len(tasksItem.AutomationTask.Requirements)) - for _, requirementsItem1 := range tasksItem.AutomationTask.Requirements { - phaseId7 := new(string) - if !requirementsItem1.PhaseID.IsUnknown() && !requirementsItem1.PhaseID.IsNull() { - *phaseId7 = requirementsItem1.PhaseID.ValueString() - } else { - phaseId7 = nil - } - taskId5 := new(string) - if !requirementsItem1.TaskID.IsUnknown() && !requirementsItem1.TaskID.IsNull() { - *taskId5 = requirementsItem1.TaskID.ValueString() - } else { - taskId5 = nil - } - when1 := shared.When(requirementsItem1.When.ValueString()) - requirements1 = append(requirements1, shared.EnableRequirement{ - PhaseID: phaseId7, - TaskID: taskId5, - When: when1, - }) - } - var schedule *shared.ActionSchedule - if tasksItem.AutomationTask.Schedule != nil { - var immediateSchedule *shared.ImmediateSchedule - if tasksItem.AutomationTask.Schedule.ImmediateSchedule != nil { - mode := new(shared.ImmediateScheduleMode) - if !tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode.IsUnknown() && !tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode.IsNull() { - *mode = shared.ImmediateScheduleMode(tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode.ValueString()) - } else { - mode = nil - } - immediateSchedule = &shared.ImmediateSchedule{ - Mode: mode, - } - } - if immediateSchedule != nil { - schedule = &shared.ActionSchedule{ - ImmediateSchedule: immediateSchedule, - } - } - var delayedSchedule *shared.DelayedSchedule - if tasksItem.AutomationTask.Schedule.DelayedSchedule != nil { - var duration4 float64 - duration4 = tasksItem.AutomationTask.Schedule.DelayedSchedule.Duration.ValueFloat64() - - mode1 := shared.Mode(tasksItem.AutomationTask.Schedule.DelayedSchedule.Mode.ValueString()) - unit4 := shared.TimeUnit(tasksItem.AutomationTask.Schedule.DelayedSchedule.Unit.ValueString()) - delayedSchedule = &shared.DelayedSchedule{ - Duration: duration4, - Mode: mode1, - Unit: unit4, - } - } - if delayedSchedule != nil { - schedule = &shared.ActionSchedule{ - DelayedSchedule: delayedSchedule, - } - } - var relativeSchedule *shared.RelativeSchedule - if tasksItem.AutomationTask.Schedule.RelativeSchedule != nil { - direction := shared.Direction(tasksItem.AutomationTask.Schedule.RelativeSchedule.Direction.ValueString()) - var duration5 float64 - duration5 = tasksItem.AutomationTask.Schedule.RelativeSchedule.Duration.ValueFloat64() - - mode2 := shared.RelativeScheduleMode(tasksItem.AutomationTask.Schedule.RelativeSchedule.Mode.ValueString()) - attribute := new(string) - if !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute.IsUnknown() && !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute.IsNull() { - *attribute = tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute.ValueString() - } else { - attribute = nil - } - var id12 string - id12 = tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.ID.ValueString() - - origin := shared.RelativeScheduleOrigin(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Origin.ValueString()) - schema := new(string) - if !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema.IsUnknown() && !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema.IsNull() { - *schema = tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema.ValueString() - } else { - schema = nil - } - reference := shared.Reference{ - Attribute: attribute, - ID: id12, - Origin: origin, - Schema: schema, - } - unit5 := shared.TimeUnit(tasksItem.AutomationTask.Schedule.RelativeSchedule.Unit.ValueString()) - relativeSchedule = &shared.RelativeSchedule{ - Direction: direction, - Duration: duration5, - Mode: mode2, - Reference: reference, - Unit: unit5, - } - } - if relativeSchedule != nil { - schedule = &shared.ActionSchedule{ - RelativeSchedule: relativeSchedule, - } - } - } - taskType1 := shared.TaskType(tasksItem.AutomationTask.TaskType.ValueString()) - taxonomies2 := make([]string, 0, len(tasksItem.AutomationTask.Taxonomies)) - for _, taxonomiesItem2 := range tasksItem.AutomationTask.Taxonomies { - taxonomies2 = append(taxonomies2, taxonomiesItem2.ValueString()) - } - triggerMode := new(shared.TriggerMode) - if !tasksItem.AutomationTask.TriggerMode.IsUnknown() && !tasksItem.AutomationTask.TriggerMode.IsNull() { - *triggerMode = shared.TriggerMode(tasksItem.AutomationTask.TriggerMode.ValueString()) - } else { - triggerMode = nil - } - automationTask := shared.AutomationTask{ - AssignedTo: assignedTo3, - AutomationConfig: automationConfig, - Description: description4, - DueDate: dueDate3, - DueDateConfig: dueDateConfig3, - Ecp: ecp1, - ID: id9, - Installer: installer1, - Journey: journey5, - Name: name9, - PhaseID: phaseId6, - Requirements: requirements1, - Schedule: schedule, - TaskType: taskType1, - Taxonomies: taxonomies2, - TriggerMode: triggerMode, - } - tasks = append(tasks, shared.Task{ - AutomationTask: &automationTask, - }) - } - if tasksItem.DecisionTask != nil { - assignedTo4 := make([]string, 0, len(tasksItem.DecisionTask.AssignedTo)) - for _, assignedToItem4 := range tasksItem.DecisionTask.AssignedTo { - assignedTo4 = append(assignedTo4, assignedToItem4.ValueString()) - } - conditions := make([]shared.Condition, 0, len(tasksItem.DecisionTask.Conditions)) - for _, conditionsItem := range tasksItem.DecisionTask.Conditions { - var branchName string - branchName = conditionsItem.BranchName.ValueString() - - var id13 string - id13 = conditionsItem.ID.ValueString() - - logicalOperator := shared.LogicalOperator(conditionsItem.LogicalOperator.ValueString()) - statements := make([]shared.Statement, 0, len(conditionsItem.Statements)) - for _, statementsItem := range conditionsItem.Statements { - var id14 string - id14 = statementsItem.ID.ValueString() - - operator := shared.Operator(statementsItem.Operator.ValueString()) - attribute1 := new(string) - if !statementsItem.Source.Attribute.IsUnknown() && !statementsItem.Source.Attribute.IsNull() { - *attribute1 = statementsItem.Source.Attribute.ValueString() - } else { - attribute1 = nil - } - attributeOperation := new(shared.AttributeOperation) - if !statementsItem.Source.AttributeOperation.IsUnknown() && !statementsItem.Source.AttributeOperation.IsNull() { - *attributeOperation = shared.AttributeOperation(statementsItem.Source.AttributeOperation.ValueString()) - } else { - attributeOperation = nil - } - attributeRepeatable := new(bool) - if !statementsItem.Source.AttributeRepeatable.IsUnknown() && !statementsItem.Source.AttributeRepeatable.IsNull() { - *attributeRepeatable = statementsItem.Source.AttributeRepeatable.ValueBool() - } else { - attributeRepeatable = nil - } - attributeType := new(shared.AttributeType) - if !statementsItem.Source.AttributeType.IsUnknown() && !statementsItem.Source.AttributeType.IsNull() { - *attributeType = shared.AttributeType(statementsItem.Source.AttributeType.ValueString()) - } else { - attributeType = nil - } - id15 := new(string) - if !statementsItem.Source.ID.IsUnknown() && !statementsItem.Source.ID.IsNull() { - *id15 = statementsItem.Source.ID.ValueString() - } else { - id15 = nil - } - origin1 := new(shared.Origin) - if !statementsItem.Source.Origin.IsUnknown() && !statementsItem.Source.Origin.IsNull() { - *origin1 = shared.Origin(statementsItem.Source.Origin.ValueString()) - } else { - origin1 = nil - } - originType := new(shared.OriginType) - if !statementsItem.Source.OriginType.IsUnknown() && !statementsItem.Source.OriginType.IsNull() { - *originType = shared.OriginType(statementsItem.Source.OriginType.ValueString()) - } else { - originType = nil - } - schema1 := new(string) - if !statementsItem.Source.Schema.IsUnknown() && !statementsItem.Source.Schema.IsNull() { - *schema1 = statementsItem.Source.Schema.ValueString() - } else { - schema1 = nil - } - source := shared.EvaluationSource{ - Attribute: attribute1, - AttributeOperation: attributeOperation, - AttributeRepeatable: attributeRepeatable, - AttributeType: attributeType, - ID: id15, - Origin: origin1, - OriginType: originType, - Schema: schema1, - } - values := make([]string, 0, len(statementsItem.Values)) - for _, valuesItem := range statementsItem.Values { - values = append(values, valuesItem.ValueString()) - } - statements = append(statements, shared.Statement{ - ID: id14, - Operator: operator, - Source: source, - Values: values, - }) - } - conditions = append(conditions, shared.Condition{ - BranchName: branchName, - ID: id13, - LogicalOperator: logicalOperator, - Statements: statements, - }) - } - var description7 *shared.StepDescription - if tasksItem.DecisionTask.Description != nil { - enabled7 := new(bool) - if !tasksItem.DecisionTask.Description.Enabled.IsUnknown() && !tasksItem.DecisionTask.Description.Enabled.IsNull() { - *enabled7 = tasksItem.DecisionTask.Description.Enabled.ValueBool() - } else { - enabled7 = nil - } - value2 := new(string) - if !tasksItem.DecisionTask.Description.Value.IsUnknown() && !tasksItem.DecisionTask.Description.Value.IsNull() { - *value2 = tasksItem.DecisionTask.Description.Value.ValueString() - } else { - value2 = nil - } - description7 = &shared.StepDescription{ - Enabled: enabled7, - Value: value2, - } - } - dueDate4 := new(string) - if !tasksItem.DecisionTask.DueDate.IsUnknown() && !tasksItem.DecisionTask.DueDate.IsNull() { - *dueDate4 = tasksItem.DecisionTask.DueDate.ValueString() - } else { - dueDate4 = nil - } - var dueDateConfig4 *shared.DueDateConfig - if tasksItem.DecisionTask.DueDateConfig != nil { - var duration6 float64 - duration6 = tasksItem.DecisionTask.DueDateConfig.Duration.ValueFloat64() - - phaseId8 := new(string) - if !tasksItem.DecisionTask.DueDateConfig.PhaseID.IsUnknown() && !tasksItem.DecisionTask.DueDateConfig.PhaseID.IsNull() { - *phaseId8 = tasksItem.DecisionTask.DueDateConfig.PhaseID.ValueString() - } else { - phaseId8 = nil - } - taskId6 := new(string) - if !tasksItem.DecisionTask.DueDateConfig.TaskID.IsUnknown() && !tasksItem.DecisionTask.DueDateConfig.TaskID.IsNull() { - *taskId6 = tasksItem.DecisionTask.DueDateConfig.TaskID.ValueString() - } else { - taskId6 = nil - } - typeVar4 := shared.DueDateConfigType(tasksItem.DecisionTask.DueDateConfig.Type.ValueString()) - unit6 := shared.TimeUnit(tasksItem.DecisionTask.DueDateConfig.Unit.ValueString()) - dueDateConfig4 = &shared.DueDateConfig{ - Duration: duration6, - PhaseID: phaseId8, - TaskID: taskId6, - Type: typeVar4, - Unit: unit6, - } - } - var ecp2 *shared.ECPDetails - if tasksItem.DecisionTask.Ecp != nil { - description8 := new(string) - if !tasksItem.DecisionTask.Ecp.Description.IsUnknown() && !tasksItem.DecisionTask.Ecp.Description.IsNull() { - *description8 = tasksItem.DecisionTask.Ecp.Description.ValueString() - } else { - description8 = nil - } - enabled8 := new(bool) - if !tasksItem.DecisionTask.Ecp.Enabled.IsUnknown() && !tasksItem.DecisionTask.Ecp.Enabled.IsNull() { - *enabled8 = tasksItem.DecisionTask.Ecp.Enabled.ValueBool() - } else { - enabled8 = nil - } - var journey6 *shared.StepJourney - if tasksItem.DecisionTask.Ecp.Journey != nil { - id16 := new(string) - if !tasksItem.DecisionTask.Ecp.Journey.ID.IsUnknown() && !tasksItem.DecisionTask.Ecp.Journey.ID.IsNull() { - *id16 = tasksItem.DecisionTask.Ecp.Journey.ID.ValueString() - } else { - id16 = nil - } - journeyId6 := new(string) - if !tasksItem.DecisionTask.Ecp.Journey.JourneyID.IsUnknown() && !tasksItem.DecisionTask.Ecp.Journey.JourneyID.IsNull() { - *journeyId6 = tasksItem.DecisionTask.Ecp.Journey.JourneyID.ValueString() - } else { - journeyId6 = nil - } - name10 := new(string) - if !tasksItem.DecisionTask.Ecp.Journey.Name.IsUnknown() && !tasksItem.DecisionTask.Ecp.Journey.Name.IsNull() { - *name10 = tasksItem.DecisionTask.Ecp.Journey.Name.ValueString() - } else { - name10 = nil - } - journey6 = &shared.StepJourney{ - ID: id16, - JourneyID: journeyId6, - Name: name10, - } - } - label4 := new(string) - if !tasksItem.DecisionTask.Ecp.Label.IsUnknown() && !tasksItem.DecisionTask.Ecp.Label.IsNull() { - *label4 = tasksItem.DecisionTask.Ecp.Label.ValueString() - } else { - label4 = nil - } - ecp2 = &shared.ECPDetails{ - Description: description8, - Enabled: enabled8, - Journey: journey6, - Label: label4, - } - } - var id17 string - id17 = tasksItem.DecisionTask.ID.ValueString() - - var installer2 *shared.ECPDetails - if tasksItem.DecisionTask.Installer != nil { - description9 := new(string) - if !tasksItem.DecisionTask.Installer.Description.IsUnknown() && !tasksItem.DecisionTask.Installer.Description.IsNull() { - *description9 = tasksItem.DecisionTask.Installer.Description.ValueString() - } else { - description9 = nil - } - enabled9 := new(bool) - if !tasksItem.DecisionTask.Installer.Enabled.IsUnknown() && !tasksItem.DecisionTask.Installer.Enabled.IsNull() { - *enabled9 = tasksItem.DecisionTask.Installer.Enabled.ValueBool() - } else { - enabled9 = nil - } - var journey7 *shared.StepJourney - if tasksItem.DecisionTask.Installer.Journey != nil { - id18 := new(string) - if !tasksItem.DecisionTask.Installer.Journey.ID.IsUnknown() && !tasksItem.DecisionTask.Installer.Journey.ID.IsNull() { - *id18 = tasksItem.DecisionTask.Installer.Journey.ID.ValueString() - } else { - id18 = nil - } - journeyId7 := new(string) - if !tasksItem.DecisionTask.Installer.Journey.JourneyID.IsUnknown() && !tasksItem.DecisionTask.Installer.Journey.JourneyID.IsNull() { - *journeyId7 = tasksItem.DecisionTask.Installer.Journey.JourneyID.ValueString() - } else { - journeyId7 = nil - } - name11 := new(string) - if !tasksItem.DecisionTask.Installer.Journey.Name.IsUnknown() && !tasksItem.DecisionTask.Installer.Journey.Name.IsNull() { - *name11 = tasksItem.DecisionTask.Installer.Journey.Name.ValueString() - } else { - name11 = nil - } - journey7 = &shared.StepJourney{ - ID: id18, - JourneyID: journeyId7, - Name: name11, - } - } - label5 := new(string) - if !tasksItem.DecisionTask.Installer.Label.IsUnknown() && !tasksItem.DecisionTask.Installer.Label.IsNull() { - *label5 = tasksItem.DecisionTask.Installer.Label.ValueString() - } else { - label5 = nil - } - installer2 = &shared.ECPDetails{ - Description: description9, - Enabled: enabled9, - Journey: journey7, - Label: label5, - } - } - var journey8 *shared.StepJourney - if tasksItem.DecisionTask.Journey != nil { - id19 := new(string) - if !tasksItem.DecisionTask.Journey.ID.IsUnknown() && !tasksItem.DecisionTask.Journey.ID.IsNull() { - *id19 = tasksItem.DecisionTask.Journey.ID.ValueString() - } else { - id19 = nil - } - journeyId8 := new(string) - if !tasksItem.DecisionTask.Journey.JourneyID.IsUnknown() && !tasksItem.DecisionTask.Journey.JourneyID.IsNull() { - *journeyId8 = tasksItem.DecisionTask.Journey.JourneyID.ValueString() - } else { - journeyId8 = nil - } - name12 := new(string) - if !tasksItem.DecisionTask.Journey.Name.IsUnknown() && !tasksItem.DecisionTask.Journey.Name.IsNull() { - *name12 = tasksItem.DecisionTask.Journey.Name.ValueString() - } else { - name12 = nil - } - journey8 = &shared.StepJourney{ - ID: id19, - JourneyID: journeyId8, - Name: name12, - } - } - var name13 string - name13 = tasksItem.DecisionTask.Name.ValueString() - - phaseId9 := new(string) - if !tasksItem.DecisionTask.PhaseID.IsUnknown() && !tasksItem.DecisionTask.PhaseID.IsNull() { - *phaseId9 = tasksItem.DecisionTask.PhaseID.ValueString() - } else { - phaseId9 = nil - } - requirements2 := make([]shared.EnableRequirement, 0, len(tasksItem.DecisionTask.Requirements)) - for _, requirementsItem2 := range tasksItem.DecisionTask.Requirements { - phaseId10 := new(string) - if !requirementsItem2.PhaseID.IsUnknown() && !requirementsItem2.PhaseID.IsNull() { - *phaseId10 = requirementsItem2.PhaseID.ValueString() - } else { - phaseId10 = nil - } - taskId7 := new(string) - if !requirementsItem2.TaskID.IsUnknown() && !requirementsItem2.TaskID.IsNull() { - *taskId7 = requirementsItem2.TaskID.ValueString() - } else { - taskId7 = nil - } - when2 := shared.When(requirementsItem2.When.ValueString()) - requirements2 = append(requirements2, shared.EnableRequirement{ - PhaseID: phaseId10, - TaskID: taskId7, - When: when2, - }) - } - var schedule1 *shared.Schedule - if tasksItem.DecisionTask.Schedule != nil { - var delayedSchedule1 *shared.DelayedSchedule - if tasksItem.DecisionTask.Schedule.DelayedSchedule != nil { - var duration7 float64 - duration7 = tasksItem.DecisionTask.Schedule.DelayedSchedule.Duration.ValueFloat64() - - mode3 := shared.Mode(tasksItem.DecisionTask.Schedule.DelayedSchedule.Mode.ValueString()) - unit7 := shared.TimeUnit(tasksItem.DecisionTask.Schedule.DelayedSchedule.Unit.ValueString()) - delayedSchedule1 = &shared.DelayedSchedule{ - Duration: duration7, - Mode: mode3, - Unit: unit7, - } - } - if delayedSchedule1 != nil { - schedule1 = &shared.Schedule{ - DelayedSchedule: delayedSchedule1, - } - } - var relativeSchedule1 *shared.RelativeSchedule - if tasksItem.DecisionTask.Schedule.RelativeSchedule != nil { - direction1 := shared.Direction(tasksItem.DecisionTask.Schedule.RelativeSchedule.Direction.ValueString()) - var duration8 float64 - duration8 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Duration.ValueFloat64() - - mode4 := shared.RelativeScheduleMode(tasksItem.DecisionTask.Schedule.RelativeSchedule.Mode.ValueString()) - attribute2 := new(string) - if !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute.IsUnknown() && !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute.IsNull() { - *attribute2 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute.ValueString() - } else { - attribute2 = nil - } - var id20 string - id20 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.ID.ValueString() - - origin2 := shared.RelativeScheduleOrigin(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Origin.ValueString()) - schema2 := new(string) - if !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema.IsUnknown() && !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema.IsNull() { - *schema2 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema.ValueString() - } else { - schema2 = nil - } - reference1 := shared.Reference{ - Attribute: attribute2, - ID: id20, - Origin: origin2, - Schema: schema2, - } - unit8 := shared.TimeUnit(tasksItem.DecisionTask.Schedule.RelativeSchedule.Unit.ValueString()) - relativeSchedule1 = &shared.RelativeSchedule{ - Direction: direction1, - Duration: duration8, - Mode: mode4, - Reference: reference1, - Unit: unit8, - } - } - if relativeSchedule1 != nil { - schedule1 = &shared.Schedule{ - RelativeSchedule: relativeSchedule1, - } - } - } - taskType2 := shared.TaskType(tasksItem.DecisionTask.TaskType.ValueString()) - taxonomies3 := make([]string, 0, len(tasksItem.DecisionTask.Taxonomies)) - for _, taxonomiesItem3 := range tasksItem.DecisionTask.Taxonomies { - taxonomies3 = append(taxonomies3, taxonomiesItem3.ValueString()) - } - decisionTask := shared.DecisionTask{ - AssignedTo: assignedTo4, - Conditions: conditions, - Description: description7, - DueDate: dueDate4, - DueDateConfig: dueDateConfig4, - Ecp: ecp2, - ID: id17, - Installer: installer2, - Journey: journey8, - Name: name13, - PhaseID: phaseId9, - Requirements: requirements2, - Schedule: schedule1, - TaskType: taskType2, - Taxonomies: taxonomies3, - } - tasks = append(tasks, shared.Task{ - DecisionTask: &decisionTask, - }) - } - } - taxonomies4 := make([]string, 0, len(r.Taxonomies)) - for _, taxonomiesItem4 := range r.Taxonomies { - taxonomies4 = append(taxonomies4, taxonomiesItem4.ValueString()) - } - var trigger *shared.Trigger - if r.Trigger != nil { - var manualTrigger *shared.ManualTrigger - if r.Trigger.ManualTrigger != nil { - entitySchema := new(string) - if !r.Trigger.ManualTrigger.EntitySchema.IsUnknown() && !r.Trigger.ManualTrigger.EntitySchema.IsNull() { - *entitySchema = r.Trigger.ManualTrigger.EntitySchema.ValueString() - } else { - entitySchema = nil - } - id21 := new(string) - if !r.Trigger.ManualTrigger.ID.IsUnknown() && !r.Trigger.ManualTrigger.ID.IsNull() { - *id21 = r.Trigger.ManualTrigger.ID.ValueString() - } else { - id21 = nil - } - typeVar5 := shared.ManualTriggerType(r.Trigger.ManualTrigger.Type.ValueString()) - manualTrigger = &shared.ManualTrigger{ - EntitySchema: entitySchema, - ID: id21, - Type: typeVar5, - } - } - if manualTrigger != nil { - trigger = &shared.Trigger{ - ManualTrigger: manualTrigger, - } - } - var automationTrigger *shared.AutomationTrigger - if r.Trigger.AutomationTrigger != nil { - var automationID string - automationID = r.Trigger.AutomationTrigger.AutomationID.ValueString() - - id22 := new(string) - if !r.Trigger.AutomationTrigger.ID.IsUnknown() && !r.Trigger.AutomationTrigger.ID.IsNull() { - *id22 = r.Trigger.AutomationTrigger.ID.ValueString() - } else { - id22 = nil - } - typeVar6 := shared.Type(r.Trigger.AutomationTrigger.Type.ValueString()) - automationTrigger = &shared.AutomationTrigger{ - AutomationID: automationID, - ID: id22, - Type: typeVar6, - } - } - if automationTrigger != nil { - trigger = &shared.Trigger{ - AutomationTrigger: automationTrigger, - } - } - var journeySubmissionTrigger *shared.JourneySubmissionTrigger - if r.Trigger.JourneySubmissionTrigger != nil { - automationId1 := new(string) - if !r.Trigger.JourneySubmissionTrigger.AutomationID.IsUnknown() && !r.Trigger.JourneySubmissionTrigger.AutomationID.IsNull() { - *automationId1 = r.Trigger.JourneySubmissionTrigger.AutomationID.ValueString() - } else { - automationId1 = nil - } - id23 := new(string) - if !r.Trigger.JourneySubmissionTrigger.ID.IsUnknown() && !r.Trigger.JourneySubmissionTrigger.ID.IsNull() { - *id23 = r.Trigger.JourneySubmissionTrigger.ID.ValueString() - } else { - id23 = nil - } - var journeyId9 string - journeyId9 = r.Trigger.JourneySubmissionTrigger.JourneyID.ValueString() - - typeVar7 := shared.JourneySubmissionTriggerType(r.Trigger.JourneySubmissionTrigger.Type.ValueString()) - journeySubmissionTrigger = &shared.JourneySubmissionTrigger{ - AutomationID: automationId1, - ID: id23, - JourneyID: journeyId9, - Type: typeVar7, - } - } - if journeySubmissionTrigger != nil { - trigger = &shared.Trigger{ - JourneySubmissionTrigger: journeySubmissionTrigger, - } - } - } - updateEntityAttributes := make([]shared.UpdateEntityAttributes, 0, len(r.UpdateEntityAttributes)) - for _, updateEntityAttributesItem := range r.UpdateEntityAttributes { - source1 := shared.Source(updateEntityAttributesItem.Source.ValueString()) - var entityAttribute string - entityAttribute = updateEntityAttributesItem.Target.EntityAttribute.ValueString() - - var entitySchema1 string - entitySchema1 = updateEntityAttributesItem.Target.EntitySchema.ValueString() - - target := shared.Target{ - EntityAttribute: entityAttribute, - EntitySchema: entitySchema1, - } - updateEntityAttributes = append(updateEntityAttributes, shared.UpdateEntityAttributes{ - Source: source1, - Target: target, - }) - } - updatedAt := new(string) - if !r.UpdatedAt.IsUnknown() && !r.UpdatedAt.IsNull() { - *updatedAt = r.UpdatedAt.ValueString() - } else { - updatedAt = nil - } - out := shared.CreateFlowTemplate{ - AssignedTo: assignedTo, - AvailableInEcp: availableInEcp, - ClosingReasons: closingReasons, - CreatedAt: createdAt, - Description: description, - DueDate: dueDate, - DueDateConfig: dueDateConfig, - Edges: edges, - Enabled: enabled, - ID: id2, - IsFlowMigrated: isFlowMigrated, - Name: name, - OrgID: orgID, - Phases: phases, - Tasks: tasks, - Taxonomies: taxonomies4, - Trigger: trigger, - UpdateEntityAttributes: updateEntityAttributes, - UpdatedAt: updatedAt, - } - - return &out, diags -} - -func (r *FlowTemplateResourceModel) ToSharedFlowTemplateInput(ctx context.Context) (*shared.FlowTemplateInput, diag.Diagnostics) { - var diags diag.Diagnostics - - assignedTo := make([]string, 0, len(r.AssignedTo)) - for _, assignedToItem := range r.AssignedTo { - assignedTo = append(assignedTo, assignedToItem.ValueString()) - } - availableInEcp := new(bool) - if !r.AvailableInEcp.IsUnknown() && !r.AvailableInEcp.IsNull() { - *availableInEcp = r.AvailableInEcp.ValueBool() - } else { - availableInEcp = nil - } - closingReasons := make([]shared.ClosingReasonInput, 0, len(r.ClosingReasons)) - for _, closingReasonsItem := range r.ClosingReasons { - status := shared.ClosingReasonsStatus(closingReasonsItem.Status.ValueString()) - var title string - title = closingReasonsItem.Title.ValueString() - - closingReasons = append(closingReasons, shared.ClosingReasonInput{ - Status: status, - Title: title, - }) - } - createdAt := new(string) - if !r.CreatedAt.IsUnknown() && !r.CreatedAt.IsNull() { - *createdAt = r.CreatedAt.ValueString() - } else { - createdAt = nil - } - description := new(string) - if !r.Description.IsUnknown() && !r.Description.IsNull() { - *description = r.Description.ValueString() - } else { - description = nil - } - dueDate := new(string) - if !r.DueDate.IsUnknown() && !r.DueDate.IsNull() { - *dueDate = r.DueDate.ValueString() - } else { - dueDate = nil - } - var dueDateConfig *shared.DueDateConfig - if r.DueDateConfig != nil { - var duration float64 - duration = r.DueDateConfig.Duration.ValueFloat64() - - phaseID := new(string) - if !r.DueDateConfig.PhaseID.IsUnknown() && !r.DueDateConfig.PhaseID.IsNull() { - *phaseID = r.DueDateConfig.PhaseID.ValueString() - } else { - phaseID = nil - } - taskID := new(string) - if !r.DueDateConfig.TaskID.IsUnknown() && !r.DueDateConfig.TaskID.IsNull() { - *taskID = r.DueDateConfig.TaskID.ValueString() - } else { - taskID = nil - } - typeVar := shared.DueDateConfigType(r.DueDateConfig.Type.ValueString()) - unit := shared.TimeUnit(r.DueDateConfig.Unit.ValueString()) - dueDateConfig = &shared.DueDateConfig{ - Duration: duration, - PhaseID: phaseID, - TaskID: taskID, - Type: typeVar, - Unit: unit, - } - } - edges := make([]shared.Edge, 0, len(r.Edges)) - for _, edgesItem := range r.Edges { - conditionID := new(string) - if !edgesItem.ConditionID.IsUnknown() && !edgesItem.ConditionID.IsNull() { - *conditionID = edgesItem.ConditionID.ValueString() - } else { - conditionID = nil - } - var fromID string - fromID = edgesItem.FromID.ValueString() - - var id string - id = edgesItem.ID.ValueString() - - noneMet := new(bool) - if !edgesItem.NoneMet.IsUnknown() && !edgesItem.NoneMet.IsNull() { - *noneMet = edgesItem.NoneMet.ValueBool() - } else { - noneMet = nil - } - var toID string - toID = edgesItem.ToID.ValueString() - - edges = append(edges, shared.Edge{ - ConditionID: conditionID, - FromID: fromID, - ID: id, - NoneMet: noneMet, - ToID: toID, - }) - } - enabled := new(bool) - if !r.Enabled.IsUnknown() && !r.Enabled.IsNull() { - *enabled = r.Enabled.ValueBool() - } else { - enabled = nil - } - id1 := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id1 = r.ID.ValueString() - } else { - id1 = nil - } - isFlowMigrated := new(bool) - if !r.IsFlowMigrated.IsUnknown() && !r.IsFlowMigrated.IsNull() { - *isFlowMigrated = r.IsFlowMigrated.ValueBool() - } else { - isFlowMigrated = nil - } - var name string - name = r.Name.ValueString() - - orgID := new(string) - if !r.OrgID.IsUnknown() && !r.OrgID.IsNull() { - *orgID = r.OrgID.ValueString() - } else { - orgID = nil - } - phases := make([]shared.Phase, 0, len(r.Phases)) - for _, phasesItem := range r.Phases { - assignedTo1 := make([]string, 0, len(phasesItem.AssignedTo)) - for _, assignedToItem1 := range phasesItem.AssignedTo { - assignedTo1 = append(assignedTo1, assignedToItem1.ValueString()) - } - dueDate1 := new(string) - if !phasesItem.DueDate.IsUnknown() && !phasesItem.DueDate.IsNull() { - *dueDate1 = phasesItem.DueDate.ValueString() - } else { - dueDate1 = nil - } - var dueDateConfig1 *shared.DueDateConfig - if phasesItem.DueDateConfig != nil { - var duration1 float64 - duration1 = phasesItem.DueDateConfig.Duration.ValueFloat64() - - phaseId1 := new(string) - if !phasesItem.DueDateConfig.PhaseID.IsUnknown() && !phasesItem.DueDateConfig.PhaseID.IsNull() { - *phaseId1 = phasesItem.DueDateConfig.PhaseID.ValueString() - } else { - phaseId1 = nil - } - taskId1 := new(string) - if !phasesItem.DueDateConfig.TaskID.IsUnknown() && !phasesItem.DueDateConfig.TaskID.IsNull() { - *taskId1 = phasesItem.DueDateConfig.TaskID.ValueString() - } else { - taskId1 = nil - } - typeVar1 := shared.DueDateConfigType(phasesItem.DueDateConfig.Type.ValueString()) - unit1 := shared.TimeUnit(phasesItem.DueDateConfig.Unit.ValueString()) - dueDateConfig1 = &shared.DueDateConfig{ - Duration: duration1, - PhaseID: phaseId1, - TaskID: taskId1, - Type: typeVar1, - Unit: unit1, - } - } - var id2 string - id2 = phasesItem.ID.ValueString() - - var name1 string - name1 = phasesItem.Name.ValueString() - - taxonomies := make([]string, 0, len(phasesItem.Taxonomies)) - for _, taxonomiesItem := range phasesItem.Taxonomies { - taxonomies = append(taxonomies, taxonomiesItem.ValueString()) - } - phases = append(phases, shared.Phase{ - AssignedTo: assignedTo1, - DueDate: dueDate1, - DueDateConfig: dueDateConfig1, - ID: id2, - Name: name1, - Taxonomies: taxonomies, - }) - } - tasks := make([]shared.Task, 0, len(r.Tasks)) - for _, tasksItem := range r.Tasks { - if tasksItem.TaskBase != nil { - assignedTo2 := make([]string, 0, len(tasksItem.TaskBase.AssignedTo)) - for _, assignedToItem2 := range tasksItem.TaskBase.AssignedTo { - assignedTo2 = append(assignedTo2, assignedToItem2.ValueString()) - } - var description1 *shared.StepDescription - if tasksItem.TaskBase.Description != nil { - enabled1 := new(bool) - if !tasksItem.TaskBase.Description.Enabled.IsUnknown() && !tasksItem.TaskBase.Description.Enabled.IsNull() { - *enabled1 = tasksItem.TaskBase.Description.Enabled.ValueBool() - } else { - enabled1 = nil - } - value := new(string) - if !tasksItem.TaskBase.Description.Value.IsUnknown() && !tasksItem.TaskBase.Description.Value.IsNull() { - *value = tasksItem.TaskBase.Description.Value.ValueString() - } else { - value = nil - } - description1 = &shared.StepDescription{ - Enabled: enabled1, - Value: value, - } - } - dueDate2 := new(string) - if !tasksItem.TaskBase.DueDate.IsUnknown() && !tasksItem.TaskBase.DueDate.IsNull() { - *dueDate2 = tasksItem.TaskBase.DueDate.ValueString() - } else { - dueDate2 = nil - } - var dueDateConfig2 *shared.DueDateConfig - if tasksItem.TaskBase.DueDateConfig != nil { - var duration2 float64 - duration2 = tasksItem.TaskBase.DueDateConfig.Duration.ValueFloat64() - - phaseId2 := new(string) - if !tasksItem.TaskBase.DueDateConfig.PhaseID.IsUnknown() && !tasksItem.TaskBase.DueDateConfig.PhaseID.IsNull() { - *phaseId2 = tasksItem.TaskBase.DueDateConfig.PhaseID.ValueString() - } else { - phaseId2 = nil - } - taskId2 := new(string) - if !tasksItem.TaskBase.DueDateConfig.TaskID.IsUnknown() && !tasksItem.TaskBase.DueDateConfig.TaskID.IsNull() { - *taskId2 = tasksItem.TaskBase.DueDateConfig.TaskID.ValueString() - } else { - taskId2 = nil - } - typeVar2 := shared.DueDateConfigType(tasksItem.TaskBase.DueDateConfig.Type.ValueString()) - unit2 := shared.TimeUnit(tasksItem.TaskBase.DueDateConfig.Unit.ValueString()) - dueDateConfig2 = &shared.DueDateConfig{ - Duration: duration2, - PhaseID: phaseId2, - TaskID: taskId2, - Type: typeVar2, - Unit: unit2, - } - } - var ecp *shared.ECPDetails - if tasksItem.TaskBase.Ecp != nil { - description2 := new(string) - if !tasksItem.TaskBase.Ecp.Description.IsUnknown() && !tasksItem.TaskBase.Ecp.Description.IsNull() { - *description2 = tasksItem.TaskBase.Ecp.Description.ValueString() - } else { - description2 = nil - } - enabled2 := new(bool) - if !tasksItem.TaskBase.Ecp.Enabled.IsUnknown() && !tasksItem.TaskBase.Ecp.Enabled.IsNull() { - *enabled2 = tasksItem.TaskBase.Ecp.Enabled.ValueBool() - } else { - enabled2 = nil - } - var journey *shared.StepJourney - if tasksItem.TaskBase.Ecp.Journey != nil { - id3 := new(string) - if !tasksItem.TaskBase.Ecp.Journey.ID.IsUnknown() && !tasksItem.TaskBase.Ecp.Journey.ID.IsNull() { - *id3 = tasksItem.TaskBase.Ecp.Journey.ID.ValueString() - } else { - id3 = nil - } - journeyID := new(string) - if !tasksItem.TaskBase.Ecp.Journey.JourneyID.IsUnknown() && !tasksItem.TaskBase.Ecp.Journey.JourneyID.IsNull() { - *journeyID = tasksItem.TaskBase.Ecp.Journey.JourneyID.ValueString() - } else { - journeyID = nil - } - name2 := new(string) - if !tasksItem.TaskBase.Ecp.Journey.Name.IsUnknown() && !tasksItem.TaskBase.Ecp.Journey.Name.IsNull() { - *name2 = tasksItem.TaskBase.Ecp.Journey.Name.ValueString() - } else { - name2 = nil - } - journey = &shared.StepJourney{ - ID: id3, - JourneyID: journeyID, - Name: name2, - } - } - label := new(string) - if !tasksItem.TaskBase.Ecp.Label.IsUnknown() && !tasksItem.TaskBase.Ecp.Label.IsNull() { - *label = tasksItem.TaskBase.Ecp.Label.ValueString() - } else { - label = nil - } - ecp = &shared.ECPDetails{ - Description: description2, - Enabled: enabled2, - Journey: journey, - Label: label, - } - } - var id4 string - id4 = tasksItem.TaskBase.ID.ValueString() - - var installer *shared.ECPDetails - if tasksItem.TaskBase.Installer != nil { - description3 := new(string) - if !tasksItem.TaskBase.Installer.Description.IsUnknown() && !tasksItem.TaskBase.Installer.Description.IsNull() { - *description3 = tasksItem.TaskBase.Installer.Description.ValueString() - } else { - description3 = nil - } - enabled3 := new(bool) - if !tasksItem.TaskBase.Installer.Enabled.IsUnknown() && !tasksItem.TaskBase.Installer.Enabled.IsNull() { - *enabled3 = tasksItem.TaskBase.Installer.Enabled.ValueBool() - } else { - enabled3 = nil - } - var journey1 *shared.StepJourney - if tasksItem.TaskBase.Installer.Journey != nil { - id5 := new(string) - if !tasksItem.TaskBase.Installer.Journey.ID.IsUnknown() && !tasksItem.TaskBase.Installer.Journey.ID.IsNull() { - *id5 = tasksItem.TaskBase.Installer.Journey.ID.ValueString() - } else { - id5 = nil - } - journeyId1 := new(string) - if !tasksItem.TaskBase.Installer.Journey.JourneyID.IsUnknown() && !tasksItem.TaskBase.Installer.Journey.JourneyID.IsNull() { - *journeyId1 = tasksItem.TaskBase.Installer.Journey.JourneyID.ValueString() - } else { - journeyId1 = nil - } - name3 := new(string) - if !tasksItem.TaskBase.Installer.Journey.Name.IsUnknown() && !tasksItem.TaskBase.Installer.Journey.Name.IsNull() { - *name3 = tasksItem.TaskBase.Installer.Journey.Name.ValueString() - } else { - name3 = nil - } - journey1 = &shared.StepJourney{ - ID: id5, - JourneyID: journeyId1, - Name: name3, - } - } - label1 := new(string) - if !tasksItem.TaskBase.Installer.Label.IsUnknown() && !tasksItem.TaskBase.Installer.Label.IsNull() { - *label1 = tasksItem.TaskBase.Installer.Label.ValueString() - } else { - label1 = nil - } - installer = &shared.ECPDetails{ - Description: description3, - Enabled: enabled3, - Journey: journey1, - Label: label1, - } - } - var journey2 *shared.StepJourney - if tasksItem.TaskBase.Journey != nil { - id6 := new(string) - if !tasksItem.TaskBase.Journey.ID.IsUnknown() && !tasksItem.TaskBase.Journey.ID.IsNull() { - *id6 = tasksItem.TaskBase.Journey.ID.ValueString() - } else { - id6 = nil - } - journeyId2 := new(string) - if !tasksItem.TaskBase.Journey.JourneyID.IsUnknown() && !tasksItem.TaskBase.Journey.JourneyID.IsNull() { - *journeyId2 = tasksItem.TaskBase.Journey.JourneyID.ValueString() - } else { - journeyId2 = nil - } - name4 := new(string) - if !tasksItem.TaskBase.Journey.Name.IsUnknown() && !tasksItem.TaskBase.Journey.Name.IsNull() { - *name4 = tasksItem.TaskBase.Journey.Name.ValueString() - } else { - name4 = nil - } - journey2 = &shared.StepJourney{ - ID: id6, - JourneyID: journeyId2, - Name: name4, - } - } - var name5 string - name5 = tasksItem.TaskBase.Name.ValueString() - - phaseId3 := new(string) - if !tasksItem.TaskBase.PhaseID.IsUnknown() && !tasksItem.TaskBase.PhaseID.IsNull() { - *phaseId3 = tasksItem.TaskBase.PhaseID.ValueString() - } else { - phaseId3 = nil - } - requirements := make([]shared.EnableRequirement, 0, len(tasksItem.TaskBase.Requirements)) - for _, requirementsItem := range tasksItem.TaskBase.Requirements { - phaseId4 := new(string) - if !requirementsItem.PhaseID.IsUnknown() && !requirementsItem.PhaseID.IsNull() { - *phaseId4 = requirementsItem.PhaseID.ValueString() - } else { - phaseId4 = nil - } - taskId3 := new(string) - if !requirementsItem.TaskID.IsUnknown() && !requirementsItem.TaskID.IsNull() { - *taskId3 = requirementsItem.TaskID.ValueString() - } else { - taskId3 = nil - } - when := shared.When(requirementsItem.When.ValueString()) - requirements = append(requirements, shared.EnableRequirement{ - PhaseID: phaseId4, - TaskID: taskId3, - When: when, - }) - } - taskType := shared.TaskType(tasksItem.TaskBase.TaskType.ValueString()) - taxonomies1 := make([]string, 0, len(tasksItem.TaskBase.Taxonomies)) - for _, taxonomiesItem1 := range tasksItem.TaskBase.Taxonomies { - taxonomies1 = append(taxonomies1, taxonomiesItem1.ValueString()) - } - taskBase := shared.TaskBase{ - AssignedTo: assignedTo2, - Description: description1, - DueDate: dueDate2, - DueDateConfig: dueDateConfig2, - Ecp: ecp, - ID: id4, - Installer: installer, - Journey: journey2, - Name: name5, - PhaseID: phaseId3, - Requirements: requirements, - TaskType: taskType, - Taxonomies: taxonomies1, - } - tasks = append(tasks, shared.Task{ - TaskBase: &taskBase, - }) - } - if tasksItem.AutomationTask != nil { - assignedTo3 := make([]string, 0, len(tasksItem.AutomationTask.AssignedTo)) - for _, assignedToItem3 := range tasksItem.AutomationTask.AssignedTo { - assignedTo3 = append(assignedTo3, assignedToItem3.ValueString()) - } - var flowID string - flowID = tasksItem.AutomationTask.AutomationConfig.FlowID.ValueString() - - automationConfig := shared.AutomationConfig{ - FlowID: flowID, - } - var description4 *shared.StepDescription - if tasksItem.AutomationTask.Description != nil { - enabled4 := new(bool) - if !tasksItem.AutomationTask.Description.Enabled.IsUnknown() && !tasksItem.AutomationTask.Description.Enabled.IsNull() { - *enabled4 = tasksItem.AutomationTask.Description.Enabled.ValueBool() - } else { - enabled4 = nil - } - value1 := new(string) - if !tasksItem.AutomationTask.Description.Value.IsUnknown() && !tasksItem.AutomationTask.Description.Value.IsNull() { - *value1 = tasksItem.AutomationTask.Description.Value.ValueString() - } else { - value1 = nil - } - description4 = &shared.StepDescription{ - Enabled: enabled4, - Value: value1, - } - } - dueDate3 := new(string) - if !tasksItem.AutomationTask.DueDate.IsUnknown() && !tasksItem.AutomationTask.DueDate.IsNull() { - *dueDate3 = tasksItem.AutomationTask.DueDate.ValueString() - } else { - dueDate3 = nil - } - var dueDateConfig3 *shared.DueDateConfig - if tasksItem.AutomationTask.DueDateConfig != nil { - var duration3 float64 - duration3 = tasksItem.AutomationTask.DueDateConfig.Duration.ValueFloat64() - - phaseId5 := new(string) - if !tasksItem.AutomationTask.DueDateConfig.PhaseID.IsUnknown() && !tasksItem.AutomationTask.DueDateConfig.PhaseID.IsNull() { - *phaseId5 = tasksItem.AutomationTask.DueDateConfig.PhaseID.ValueString() - } else { - phaseId5 = nil - } - taskId4 := new(string) - if !tasksItem.AutomationTask.DueDateConfig.TaskID.IsUnknown() && !tasksItem.AutomationTask.DueDateConfig.TaskID.IsNull() { - *taskId4 = tasksItem.AutomationTask.DueDateConfig.TaskID.ValueString() - } else { - taskId4 = nil - } - typeVar3 := shared.DueDateConfigType(tasksItem.AutomationTask.DueDateConfig.Type.ValueString()) - unit3 := shared.TimeUnit(tasksItem.AutomationTask.DueDateConfig.Unit.ValueString()) - dueDateConfig3 = &shared.DueDateConfig{ - Duration: duration3, - PhaseID: phaseId5, - TaskID: taskId4, - Type: typeVar3, - Unit: unit3, - } - } - var ecp1 *shared.ECPDetails - if tasksItem.AutomationTask.Ecp != nil { - description5 := new(string) - if !tasksItem.AutomationTask.Ecp.Description.IsUnknown() && !tasksItem.AutomationTask.Ecp.Description.IsNull() { - *description5 = tasksItem.AutomationTask.Ecp.Description.ValueString() - } else { - description5 = nil - } - enabled5 := new(bool) - if !tasksItem.AutomationTask.Ecp.Enabled.IsUnknown() && !tasksItem.AutomationTask.Ecp.Enabled.IsNull() { - *enabled5 = tasksItem.AutomationTask.Ecp.Enabled.ValueBool() - } else { - enabled5 = nil - } - var journey3 *shared.StepJourney - if tasksItem.AutomationTask.Ecp.Journey != nil { - id7 := new(string) - if !tasksItem.AutomationTask.Ecp.Journey.ID.IsUnknown() && !tasksItem.AutomationTask.Ecp.Journey.ID.IsNull() { - *id7 = tasksItem.AutomationTask.Ecp.Journey.ID.ValueString() - } else { - id7 = nil - } - journeyId3 := new(string) - if !tasksItem.AutomationTask.Ecp.Journey.JourneyID.IsUnknown() && !tasksItem.AutomationTask.Ecp.Journey.JourneyID.IsNull() { - *journeyId3 = tasksItem.AutomationTask.Ecp.Journey.JourneyID.ValueString() - } else { - journeyId3 = nil - } - name6 := new(string) - if !tasksItem.AutomationTask.Ecp.Journey.Name.IsUnknown() && !tasksItem.AutomationTask.Ecp.Journey.Name.IsNull() { - *name6 = tasksItem.AutomationTask.Ecp.Journey.Name.ValueString() - } else { - name6 = nil - } - journey3 = &shared.StepJourney{ - ID: id7, - JourneyID: journeyId3, - Name: name6, - } - } - label2 := new(string) - if !tasksItem.AutomationTask.Ecp.Label.IsUnknown() && !tasksItem.AutomationTask.Ecp.Label.IsNull() { - *label2 = tasksItem.AutomationTask.Ecp.Label.ValueString() - } else { - label2 = nil - } - ecp1 = &shared.ECPDetails{ - Description: description5, - Enabled: enabled5, - Journey: journey3, - Label: label2, - } - } - var id8 string - id8 = tasksItem.AutomationTask.ID.ValueString() - - var installer1 *shared.ECPDetails - if tasksItem.AutomationTask.Installer != nil { - description6 := new(string) - if !tasksItem.AutomationTask.Installer.Description.IsUnknown() && !tasksItem.AutomationTask.Installer.Description.IsNull() { - *description6 = tasksItem.AutomationTask.Installer.Description.ValueString() - } else { - description6 = nil - } - enabled6 := new(bool) - if !tasksItem.AutomationTask.Installer.Enabled.IsUnknown() && !tasksItem.AutomationTask.Installer.Enabled.IsNull() { - *enabled6 = tasksItem.AutomationTask.Installer.Enabled.ValueBool() - } else { - enabled6 = nil - } - var journey4 *shared.StepJourney - if tasksItem.AutomationTask.Installer.Journey != nil { - id9 := new(string) - if !tasksItem.AutomationTask.Installer.Journey.ID.IsUnknown() && !tasksItem.AutomationTask.Installer.Journey.ID.IsNull() { - *id9 = tasksItem.AutomationTask.Installer.Journey.ID.ValueString() - } else { - id9 = nil - } - journeyId4 := new(string) - if !tasksItem.AutomationTask.Installer.Journey.JourneyID.IsUnknown() && !tasksItem.AutomationTask.Installer.Journey.JourneyID.IsNull() { - *journeyId4 = tasksItem.AutomationTask.Installer.Journey.JourneyID.ValueString() - } else { - journeyId4 = nil - } - name7 := new(string) - if !tasksItem.AutomationTask.Installer.Journey.Name.IsUnknown() && !tasksItem.AutomationTask.Installer.Journey.Name.IsNull() { - *name7 = tasksItem.AutomationTask.Installer.Journey.Name.ValueString() - } else { - name7 = nil - } - journey4 = &shared.StepJourney{ - ID: id9, - JourneyID: journeyId4, - Name: name7, - } - } - label3 := new(string) - if !tasksItem.AutomationTask.Installer.Label.IsUnknown() && !tasksItem.AutomationTask.Installer.Label.IsNull() { - *label3 = tasksItem.AutomationTask.Installer.Label.ValueString() - } else { - label3 = nil - } - installer1 = &shared.ECPDetails{ - Description: description6, - Enabled: enabled6, - Journey: journey4, - Label: label3, - } - } - var journey5 *shared.StepJourney - if tasksItem.AutomationTask.Journey != nil { - id10 := new(string) - if !tasksItem.AutomationTask.Journey.ID.IsUnknown() && !tasksItem.AutomationTask.Journey.ID.IsNull() { - *id10 = tasksItem.AutomationTask.Journey.ID.ValueString() - } else { - id10 = nil - } - journeyId5 := new(string) - if !tasksItem.AutomationTask.Journey.JourneyID.IsUnknown() && !tasksItem.AutomationTask.Journey.JourneyID.IsNull() { - *journeyId5 = tasksItem.AutomationTask.Journey.JourneyID.ValueString() - } else { - journeyId5 = nil - } - name8 := new(string) - if !tasksItem.AutomationTask.Journey.Name.IsUnknown() && !tasksItem.AutomationTask.Journey.Name.IsNull() { - *name8 = tasksItem.AutomationTask.Journey.Name.ValueString() - } else { - name8 = nil - } - journey5 = &shared.StepJourney{ - ID: id10, - JourneyID: journeyId5, - Name: name8, - } - } - var name9 string - name9 = tasksItem.AutomationTask.Name.ValueString() - - phaseId6 := new(string) - if !tasksItem.AutomationTask.PhaseID.IsUnknown() && !tasksItem.AutomationTask.PhaseID.IsNull() { - *phaseId6 = tasksItem.AutomationTask.PhaseID.ValueString() - } else { - phaseId6 = nil - } - requirements1 := make([]shared.EnableRequirement, 0, len(tasksItem.AutomationTask.Requirements)) - for _, requirementsItem1 := range tasksItem.AutomationTask.Requirements { - phaseId7 := new(string) - if !requirementsItem1.PhaseID.IsUnknown() && !requirementsItem1.PhaseID.IsNull() { - *phaseId7 = requirementsItem1.PhaseID.ValueString() - } else { - phaseId7 = nil - } - taskId5 := new(string) - if !requirementsItem1.TaskID.IsUnknown() && !requirementsItem1.TaskID.IsNull() { - *taskId5 = requirementsItem1.TaskID.ValueString() - } else { - taskId5 = nil - } - when1 := shared.When(requirementsItem1.When.ValueString()) - requirements1 = append(requirements1, shared.EnableRequirement{ - PhaseID: phaseId7, - TaskID: taskId5, - When: when1, - }) - } - var schedule *shared.ActionSchedule - if tasksItem.AutomationTask.Schedule != nil { - var immediateSchedule *shared.ImmediateSchedule - if tasksItem.AutomationTask.Schedule.ImmediateSchedule != nil { - mode := new(shared.ImmediateScheduleMode) - if !tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode.IsUnknown() && !tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode.IsNull() { - *mode = shared.ImmediateScheduleMode(tasksItem.AutomationTask.Schedule.ImmediateSchedule.Mode.ValueString()) - } else { - mode = nil - } - immediateSchedule = &shared.ImmediateSchedule{ - Mode: mode, - } - } - if immediateSchedule != nil { - schedule = &shared.ActionSchedule{ - ImmediateSchedule: immediateSchedule, - } - } - var delayedSchedule *shared.DelayedSchedule - if tasksItem.AutomationTask.Schedule.DelayedSchedule != nil { - var duration4 float64 - duration4 = tasksItem.AutomationTask.Schedule.DelayedSchedule.Duration.ValueFloat64() - - mode1 := shared.Mode(tasksItem.AutomationTask.Schedule.DelayedSchedule.Mode.ValueString()) - unit4 := shared.TimeUnit(tasksItem.AutomationTask.Schedule.DelayedSchedule.Unit.ValueString()) - delayedSchedule = &shared.DelayedSchedule{ - Duration: duration4, - Mode: mode1, - Unit: unit4, - } - } - if delayedSchedule != nil { - schedule = &shared.ActionSchedule{ - DelayedSchedule: delayedSchedule, - } - } - var relativeSchedule *shared.RelativeSchedule - if tasksItem.AutomationTask.Schedule.RelativeSchedule != nil { - direction := shared.Direction(tasksItem.AutomationTask.Schedule.RelativeSchedule.Direction.ValueString()) - var duration5 float64 - duration5 = tasksItem.AutomationTask.Schedule.RelativeSchedule.Duration.ValueFloat64() - - mode2 := shared.RelativeScheduleMode(tasksItem.AutomationTask.Schedule.RelativeSchedule.Mode.ValueString()) - attribute := new(string) - if !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute.IsUnknown() && !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute.IsNull() { - *attribute = tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Attribute.ValueString() - } else { - attribute = nil - } - var id11 string - id11 = tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.ID.ValueString() - - origin := shared.RelativeScheduleOrigin(tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Origin.ValueString()) - schema := new(string) - if !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema.IsUnknown() && !tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema.IsNull() { - *schema = tasksItem.AutomationTask.Schedule.RelativeSchedule.Reference.Schema.ValueString() - } else { - schema = nil - } - reference := shared.Reference{ - Attribute: attribute, - ID: id11, - Origin: origin, - Schema: schema, - } - unit5 := shared.TimeUnit(tasksItem.AutomationTask.Schedule.RelativeSchedule.Unit.ValueString()) - relativeSchedule = &shared.RelativeSchedule{ - Direction: direction, - Duration: duration5, - Mode: mode2, - Reference: reference, - Unit: unit5, - } - } - if relativeSchedule != nil { - schedule = &shared.ActionSchedule{ - RelativeSchedule: relativeSchedule, - } - } - } - taskType1 := shared.TaskType(tasksItem.AutomationTask.TaskType.ValueString()) - taxonomies2 := make([]string, 0, len(tasksItem.AutomationTask.Taxonomies)) - for _, taxonomiesItem2 := range tasksItem.AutomationTask.Taxonomies { - taxonomies2 = append(taxonomies2, taxonomiesItem2.ValueString()) - } - triggerMode := new(shared.TriggerMode) - if !tasksItem.AutomationTask.TriggerMode.IsUnknown() && !tasksItem.AutomationTask.TriggerMode.IsNull() { - *triggerMode = shared.TriggerMode(tasksItem.AutomationTask.TriggerMode.ValueString()) - } else { - triggerMode = nil - } - automationTask := shared.AutomationTask{ - AssignedTo: assignedTo3, - AutomationConfig: automationConfig, - Description: description4, - DueDate: dueDate3, - DueDateConfig: dueDateConfig3, - Ecp: ecp1, - ID: id8, - Installer: installer1, - Journey: journey5, - Name: name9, - PhaseID: phaseId6, - Requirements: requirements1, - Schedule: schedule, - TaskType: taskType1, - Taxonomies: taxonomies2, - TriggerMode: triggerMode, - } - tasks = append(tasks, shared.Task{ - AutomationTask: &automationTask, - }) - } - if tasksItem.DecisionTask != nil { - assignedTo4 := make([]string, 0, len(tasksItem.DecisionTask.AssignedTo)) - for _, assignedToItem4 := range tasksItem.DecisionTask.AssignedTo { - assignedTo4 = append(assignedTo4, assignedToItem4.ValueString()) - } - conditions := make([]shared.Condition, 0, len(tasksItem.DecisionTask.Conditions)) - for _, conditionsItem := range tasksItem.DecisionTask.Conditions { - var branchName string - branchName = conditionsItem.BranchName.ValueString() - - var id12 string - id12 = conditionsItem.ID.ValueString() - - logicalOperator := shared.LogicalOperator(conditionsItem.LogicalOperator.ValueString()) - statements := make([]shared.Statement, 0, len(conditionsItem.Statements)) - for _, statementsItem := range conditionsItem.Statements { - var id13 string - id13 = statementsItem.ID.ValueString() - - operator := shared.Operator(statementsItem.Operator.ValueString()) - attribute1 := new(string) - if !statementsItem.Source.Attribute.IsUnknown() && !statementsItem.Source.Attribute.IsNull() { - *attribute1 = statementsItem.Source.Attribute.ValueString() - } else { - attribute1 = nil - } - attributeOperation := new(shared.AttributeOperation) - if !statementsItem.Source.AttributeOperation.IsUnknown() && !statementsItem.Source.AttributeOperation.IsNull() { - *attributeOperation = shared.AttributeOperation(statementsItem.Source.AttributeOperation.ValueString()) - } else { - attributeOperation = nil - } - attributeRepeatable := new(bool) - if !statementsItem.Source.AttributeRepeatable.IsUnknown() && !statementsItem.Source.AttributeRepeatable.IsNull() { - *attributeRepeatable = statementsItem.Source.AttributeRepeatable.ValueBool() - } else { - attributeRepeatable = nil - } - attributeType := new(shared.AttributeType) - if !statementsItem.Source.AttributeType.IsUnknown() && !statementsItem.Source.AttributeType.IsNull() { - *attributeType = shared.AttributeType(statementsItem.Source.AttributeType.ValueString()) - } else { - attributeType = nil - } - id14 := new(string) - if !statementsItem.Source.ID.IsUnknown() && !statementsItem.Source.ID.IsNull() { - *id14 = statementsItem.Source.ID.ValueString() - } else { - id14 = nil - } - origin1 := new(shared.Origin) - if !statementsItem.Source.Origin.IsUnknown() && !statementsItem.Source.Origin.IsNull() { - *origin1 = shared.Origin(statementsItem.Source.Origin.ValueString()) - } else { - origin1 = nil - } - originType := new(shared.OriginType) - if !statementsItem.Source.OriginType.IsUnknown() && !statementsItem.Source.OriginType.IsNull() { - *originType = shared.OriginType(statementsItem.Source.OriginType.ValueString()) - } else { - originType = nil - } - schema1 := new(string) - if !statementsItem.Source.Schema.IsUnknown() && !statementsItem.Source.Schema.IsNull() { - *schema1 = statementsItem.Source.Schema.ValueString() - } else { - schema1 = nil - } - source := shared.EvaluationSource{ - Attribute: attribute1, - AttributeOperation: attributeOperation, - AttributeRepeatable: attributeRepeatable, - AttributeType: attributeType, - ID: id14, - Origin: origin1, - OriginType: originType, - Schema: schema1, - } - values := make([]string, 0, len(statementsItem.Values)) - for _, valuesItem := range statementsItem.Values { - values = append(values, valuesItem.ValueString()) - } - statements = append(statements, shared.Statement{ - ID: id13, - Operator: operator, - Source: source, - Values: values, - }) - } - conditions = append(conditions, shared.Condition{ - BranchName: branchName, - ID: id12, - LogicalOperator: logicalOperator, - Statements: statements, - }) - } - var description7 *shared.StepDescription - if tasksItem.DecisionTask.Description != nil { - enabled7 := new(bool) - if !tasksItem.DecisionTask.Description.Enabled.IsUnknown() && !tasksItem.DecisionTask.Description.Enabled.IsNull() { - *enabled7 = tasksItem.DecisionTask.Description.Enabled.ValueBool() - } else { - enabled7 = nil - } - value2 := new(string) - if !tasksItem.DecisionTask.Description.Value.IsUnknown() && !tasksItem.DecisionTask.Description.Value.IsNull() { - *value2 = tasksItem.DecisionTask.Description.Value.ValueString() - } else { - value2 = nil - } - description7 = &shared.StepDescription{ - Enabled: enabled7, - Value: value2, - } - } - dueDate4 := new(string) - if !tasksItem.DecisionTask.DueDate.IsUnknown() && !tasksItem.DecisionTask.DueDate.IsNull() { - *dueDate4 = tasksItem.DecisionTask.DueDate.ValueString() - } else { - dueDate4 = nil - } - var dueDateConfig4 *shared.DueDateConfig - if tasksItem.DecisionTask.DueDateConfig != nil { - var duration6 float64 - duration6 = tasksItem.DecisionTask.DueDateConfig.Duration.ValueFloat64() - - phaseId8 := new(string) - if !tasksItem.DecisionTask.DueDateConfig.PhaseID.IsUnknown() && !tasksItem.DecisionTask.DueDateConfig.PhaseID.IsNull() { - *phaseId8 = tasksItem.DecisionTask.DueDateConfig.PhaseID.ValueString() - } else { - phaseId8 = nil - } - taskId6 := new(string) - if !tasksItem.DecisionTask.DueDateConfig.TaskID.IsUnknown() && !tasksItem.DecisionTask.DueDateConfig.TaskID.IsNull() { - *taskId6 = tasksItem.DecisionTask.DueDateConfig.TaskID.ValueString() - } else { - taskId6 = nil - } - typeVar4 := shared.DueDateConfigType(tasksItem.DecisionTask.DueDateConfig.Type.ValueString()) - unit6 := shared.TimeUnit(tasksItem.DecisionTask.DueDateConfig.Unit.ValueString()) - dueDateConfig4 = &shared.DueDateConfig{ - Duration: duration6, - PhaseID: phaseId8, - TaskID: taskId6, - Type: typeVar4, - Unit: unit6, - } - } - var ecp2 *shared.ECPDetails - if tasksItem.DecisionTask.Ecp != nil { - description8 := new(string) - if !tasksItem.DecisionTask.Ecp.Description.IsUnknown() && !tasksItem.DecisionTask.Ecp.Description.IsNull() { - *description8 = tasksItem.DecisionTask.Ecp.Description.ValueString() - } else { - description8 = nil - } - enabled8 := new(bool) - if !tasksItem.DecisionTask.Ecp.Enabled.IsUnknown() && !tasksItem.DecisionTask.Ecp.Enabled.IsNull() { - *enabled8 = tasksItem.DecisionTask.Ecp.Enabled.ValueBool() - } else { - enabled8 = nil - } - var journey6 *shared.StepJourney - if tasksItem.DecisionTask.Ecp.Journey != nil { - id15 := new(string) - if !tasksItem.DecisionTask.Ecp.Journey.ID.IsUnknown() && !tasksItem.DecisionTask.Ecp.Journey.ID.IsNull() { - *id15 = tasksItem.DecisionTask.Ecp.Journey.ID.ValueString() - } else { - id15 = nil - } - journeyId6 := new(string) - if !tasksItem.DecisionTask.Ecp.Journey.JourneyID.IsUnknown() && !tasksItem.DecisionTask.Ecp.Journey.JourneyID.IsNull() { - *journeyId6 = tasksItem.DecisionTask.Ecp.Journey.JourneyID.ValueString() - } else { - journeyId6 = nil - } - name10 := new(string) - if !tasksItem.DecisionTask.Ecp.Journey.Name.IsUnknown() && !tasksItem.DecisionTask.Ecp.Journey.Name.IsNull() { - *name10 = tasksItem.DecisionTask.Ecp.Journey.Name.ValueString() - } else { - name10 = nil - } - journey6 = &shared.StepJourney{ - ID: id15, - JourneyID: journeyId6, - Name: name10, - } - } - label4 := new(string) - if !tasksItem.DecisionTask.Ecp.Label.IsUnknown() && !tasksItem.DecisionTask.Ecp.Label.IsNull() { - *label4 = tasksItem.DecisionTask.Ecp.Label.ValueString() - } else { - label4 = nil - } - ecp2 = &shared.ECPDetails{ - Description: description8, - Enabled: enabled8, - Journey: journey6, - Label: label4, - } - } - var id16 string - id16 = tasksItem.DecisionTask.ID.ValueString() - - var installer2 *shared.ECPDetails - if tasksItem.DecisionTask.Installer != nil { - description9 := new(string) - if !tasksItem.DecisionTask.Installer.Description.IsUnknown() && !tasksItem.DecisionTask.Installer.Description.IsNull() { - *description9 = tasksItem.DecisionTask.Installer.Description.ValueString() - } else { - description9 = nil - } - enabled9 := new(bool) - if !tasksItem.DecisionTask.Installer.Enabled.IsUnknown() && !tasksItem.DecisionTask.Installer.Enabled.IsNull() { - *enabled9 = tasksItem.DecisionTask.Installer.Enabled.ValueBool() - } else { - enabled9 = nil - } - var journey7 *shared.StepJourney - if tasksItem.DecisionTask.Installer.Journey != nil { - id17 := new(string) - if !tasksItem.DecisionTask.Installer.Journey.ID.IsUnknown() && !tasksItem.DecisionTask.Installer.Journey.ID.IsNull() { - *id17 = tasksItem.DecisionTask.Installer.Journey.ID.ValueString() - } else { - id17 = nil - } - journeyId7 := new(string) - if !tasksItem.DecisionTask.Installer.Journey.JourneyID.IsUnknown() && !tasksItem.DecisionTask.Installer.Journey.JourneyID.IsNull() { - *journeyId7 = tasksItem.DecisionTask.Installer.Journey.JourneyID.ValueString() - } else { - journeyId7 = nil - } - name11 := new(string) - if !tasksItem.DecisionTask.Installer.Journey.Name.IsUnknown() && !tasksItem.DecisionTask.Installer.Journey.Name.IsNull() { - *name11 = tasksItem.DecisionTask.Installer.Journey.Name.ValueString() - } else { - name11 = nil - } - journey7 = &shared.StepJourney{ - ID: id17, - JourneyID: journeyId7, - Name: name11, - } - } - label5 := new(string) - if !tasksItem.DecisionTask.Installer.Label.IsUnknown() && !tasksItem.DecisionTask.Installer.Label.IsNull() { - *label5 = tasksItem.DecisionTask.Installer.Label.ValueString() - } else { - label5 = nil - } - installer2 = &shared.ECPDetails{ - Description: description9, - Enabled: enabled9, - Journey: journey7, - Label: label5, - } - } - var journey8 *shared.StepJourney - if tasksItem.DecisionTask.Journey != nil { - id18 := new(string) - if !tasksItem.DecisionTask.Journey.ID.IsUnknown() && !tasksItem.DecisionTask.Journey.ID.IsNull() { - *id18 = tasksItem.DecisionTask.Journey.ID.ValueString() - } else { - id18 = nil - } - journeyId8 := new(string) - if !tasksItem.DecisionTask.Journey.JourneyID.IsUnknown() && !tasksItem.DecisionTask.Journey.JourneyID.IsNull() { - *journeyId8 = tasksItem.DecisionTask.Journey.JourneyID.ValueString() - } else { - journeyId8 = nil - } - name12 := new(string) - if !tasksItem.DecisionTask.Journey.Name.IsUnknown() && !tasksItem.DecisionTask.Journey.Name.IsNull() { - *name12 = tasksItem.DecisionTask.Journey.Name.ValueString() - } else { - name12 = nil - } - journey8 = &shared.StepJourney{ - ID: id18, - JourneyID: journeyId8, - Name: name12, - } - } - var name13 string - name13 = tasksItem.DecisionTask.Name.ValueString() - - phaseId9 := new(string) - if !tasksItem.DecisionTask.PhaseID.IsUnknown() && !tasksItem.DecisionTask.PhaseID.IsNull() { - *phaseId9 = tasksItem.DecisionTask.PhaseID.ValueString() - } else { - phaseId9 = nil - } - requirements2 := make([]shared.EnableRequirement, 0, len(tasksItem.DecisionTask.Requirements)) - for _, requirementsItem2 := range tasksItem.DecisionTask.Requirements { - phaseId10 := new(string) - if !requirementsItem2.PhaseID.IsUnknown() && !requirementsItem2.PhaseID.IsNull() { - *phaseId10 = requirementsItem2.PhaseID.ValueString() - } else { - phaseId10 = nil - } - taskId7 := new(string) - if !requirementsItem2.TaskID.IsUnknown() && !requirementsItem2.TaskID.IsNull() { - *taskId7 = requirementsItem2.TaskID.ValueString() - } else { - taskId7 = nil - } - when2 := shared.When(requirementsItem2.When.ValueString()) - requirements2 = append(requirements2, shared.EnableRequirement{ - PhaseID: phaseId10, - TaskID: taskId7, - When: when2, - }) - } - var schedule1 *shared.Schedule - if tasksItem.DecisionTask.Schedule != nil { - var delayedSchedule1 *shared.DelayedSchedule - if tasksItem.DecisionTask.Schedule.DelayedSchedule != nil { - var duration7 float64 - duration7 = tasksItem.DecisionTask.Schedule.DelayedSchedule.Duration.ValueFloat64() - - mode3 := shared.Mode(tasksItem.DecisionTask.Schedule.DelayedSchedule.Mode.ValueString()) - unit7 := shared.TimeUnit(tasksItem.DecisionTask.Schedule.DelayedSchedule.Unit.ValueString()) - delayedSchedule1 = &shared.DelayedSchedule{ - Duration: duration7, - Mode: mode3, - Unit: unit7, - } - } - if delayedSchedule1 != nil { - schedule1 = &shared.Schedule{ - DelayedSchedule: delayedSchedule1, - } - } - var relativeSchedule1 *shared.RelativeSchedule - if tasksItem.DecisionTask.Schedule.RelativeSchedule != nil { - direction1 := shared.Direction(tasksItem.DecisionTask.Schedule.RelativeSchedule.Direction.ValueString()) - var duration8 float64 - duration8 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Duration.ValueFloat64() - - mode4 := shared.RelativeScheduleMode(tasksItem.DecisionTask.Schedule.RelativeSchedule.Mode.ValueString()) - attribute2 := new(string) - if !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute.IsUnknown() && !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute.IsNull() { - *attribute2 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Attribute.ValueString() - } else { - attribute2 = nil - } - var id19 string - id19 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.ID.ValueString() - - origin2 := shared.RelativeScheduleOrigin(tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Origin.ValueString()) - schema2 := new(string) - if !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema.IsUnknown() && !tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema.IsNull() { - *schema2 = tasksItem.DecisionTask.Schedule.RelativeSchedule.Reference.Schema.ValueString() - } else { - schema2 = nil - } - reference1 := shared.Reference{ - Attribute: attribute2, - ID: id19, - Origin: origin2, - Schema: schema2, - } - unit8 := shared.TimeUnit(tasksItem.DecisionTask.Schedule.RelativeSchedule.Unit.ValueString()) - relativeSchedule1 = &shared.RelativeSchedule{ - Direction: direction1, - Duration: duration8, - Mode: mode4, - Reference: reference1, - Unit: unit8, - } - } - if relativeSchedule1 != nil { - schedule1 = &shared.Schedule{ - RelativeSchedule: relativeSchedule1, - } - } - } - taskType2 := shared.TaskType(tasksItem.DecisionTask.TaskType.ValueString()) - taxonomies3 := make([]string, 0, len(tasksItem.DecisionTask.Taxonomies)) - for _, taxonomiesItem3 := range tasksItem.DecisionTask.Taxonomies { - taxonomies3 = append(taxonomies3, taxonomiesItem3.ValueString()) - } - decisionTask := shared.DecisionTask{ - AssignedTo: assignedTo4, - Conditions: conditions, - Description: description7, - DueDate: dueDate4, - DueDateConfig: dueDateConfig4, - Ecp: ecp2, - ID: id16, - Installer: installer2, - Journey: journey8, - Name: name13, - PhaseID: phaseId9, - Requirements: requirements2, - Schedule: schedule1, - TaskType: taskType2, - Taxonomies: taxonomies3, - } - tasks = append(tasks, shared.Task{ - DecisionTask: &decisionTask, - }) - } - } - taxonomies4 := make([]string, 0, len(r.Taxonomies)) - for _, taxonomiesItem4 := range r.Taxonomies { - taxonomies4 = append(taxonomies4, taxonomiesItem4.ValueString()) - } - var trigger *shared.Trigger - if r.Trigger != nil { - var manualTrigger *shared.ManualTrigger - if r.Trigger.ManualTrigger != nil { - entitySchema := new(string) - if !r.Trigger.ManualTrigger.EntitySchema.IsUnknown() && !r.Trigger.ManualTrigger.EntitySchema.IsNull() { - *entitySchema = r.Trigger.ManualTrigger.EntitySchema.ValueString() - } else { - entitySchema = nil - } - id20 := new(string) - if !r.Trigger.ManualTrigger.ID.IsUnknown() && !r.Trigger.ManualTrigger.ID.IsNull() { - *id20 = r.Trigger.ManualTrigger.ID.ValueString() - } else { - id20 = nil - } - typeVar5 := shared.ManualTriggerType(r.Trigger.ManualTrigger.Type.ValueString()) - manualTrigger = &shared.ManualTrigger{ - EntitySchema: entitySchema, - ID: id20, - Type: typeVar5, - } - } - if manualTrigger != nil { - trigger = &shared.Trigger{ - ManualTrigger: manualTrigger, - } - } - var automationTrigger *shared.AutomationTrigger - if r.Trigger.AutomationTrigger != nil { - var automationID string - automationID = r.Trigger.AutomationTrigger.AutomationID.ValueString() - - id21 := new(string) - if !r.Trigger.AutomationTrigger.ID.IsUnknown() && !r.Trigger.AutomationTrigger.ID.IsNull() { - *id21 = r.Trigger.AutomationTrigger.ID.ValueString() - } else { - id21 = nil - } - typeVar6 := shared.Type(r.Trigger.AutomationTrigger.Type.ValueString()) - automationTrigger = &shared.AutomationTrigger{ - AutomationID: automationID, - ID: id21, - Type: typeVar6, - } - } - if automationTrigger != nil { - trigger = &shared.Trigger{ - AutomationTrigger: automationTrigger, - } - } - var journeySubmissionTrigger *shared.JourneySubmissionTrigger - if r.Trigger.JourneySubmissionTrigger != nil { - automationId1 := new(string) - if !r.Trigger.JourneySubmissionTrigger.AutomationID.IsUnknown() && !r.Trigger.JourneySubmissionTrigger.AutomationID.IsNull() { - *automationId1 = r.Trigger.JourneySubmissionTrigger.AutomationID.ValueString() - } else { - automationId1 = nil - } - id22 := new(string) - if !r.Trigger.JourneySubmissionTrigger.ID.IsUnknown() && !r.Trigger.JourneySubmissionTrigger.ID.IsNull() { - *id22 = r.Trigger.JourneySubmissionTrigger.ID.ValueString() - } else { - id22 = nil - } - var journeyId9 string - journeyId9 = r.Trigger.JourneySubmissionTrigger.JourneyID.ValueString() - - typeVar7 := shared.JourneySubmissionTriggerType(r.Trigger.JourneySubmissionTrigger.Type.ValueString()) - journeySubmissionTrigger = &shared.JourneySubmissionTrigger{ - AutomationID: automationId1, - ID: id22, - JourneyID: journeyId9, - Type: typeVar7, - } - } - if journeySubmissionTrigger != nil { - trigger = &shared.Trigger{ - JourneySubmissionTrigger: journeySubmissionTrigger, - } - } - } - updateEntityAttributes := make([]shared.UpdateEntityAttributes, 0, len(r.UpdateEntityAttributes)) - for _, updateEntityAttributesItem := range r.UpdateEntityAttributes { - source1 := shared.Source(updateEntityAttributesItem.Source.ValueString()) - var entityAttribute string - entityAttribute = updateEntityAttributesItem.Target.EntityAttribute.ValueString() - - var entitySchema1 string - entitySchema1 = updateEntityAttributesItem.Target.EntitySchema.ValueString() - - target := shared.Target{ - EntityAttribute: entityAttribute, - EntitySchema: entitySchema1, - } - updateEntityAttributes = append(updateEntityAttributes, shared.UpdateEntityAttributes{ - Source: source1, - Target: target, - }) - } - updatedAt := new(string) - if !r.UpdatedAt.IsUnknown() && !r.UpdatedAt.IsNull() { - *updatedAt = r.UpdatedAt.ValueString() - } else { - updatedAt = nil - } - out := shared.FlowTemplateInput{ - AssignedTo: assignedTo, - AvailableInEcp: availableInEcp, - ClosingReasons: closingReasons, - CreatedAt: createdAt, - Description: description, - DueDate: dueDate, - DueDateConfig: dueDateConfig, - Edges: edges, - Enabled: enabled, - ID: id1, - IsFlowMigrated: isFlowMigrated, - Name: name, - OrgID: orgID, - Phases: phases, - Tasks: tasks, - Taxonomies: taxonomies4, - Trigger: trigger, - UpdateEntityAttributes: updateEntityAttributes, - UpdatedAt: updatedAt, - } - - return &out, diags -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index bee0059..47d92a8 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -40,8 +40,9 @@ func (p *EpilotWorkflowProvider) Schema(ctx context.Context, req provider.Schema resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bearer_auth": schema.StringAttribute{ - Required: true, - Sensitive: true, + MarkdownDescription: `HTTP Bearer.`, + Required: true, + Sensitive: true, }, "server_url": schema.StringAttribute{ Description: `Server URL (defaults to https://workflows-definition.sls.epilot.io)`, @@ -101,19 +102,11 @@ func (p *EpilotWorkflowProvider) Configure(ctx context.Context, req provider.Con } func (p *EpilotWorkflowProvider) Resources(ctx context.Context) []func() resource.Resource { - return []func() resource.Resource{ - NewClosingReasonResource, - NewFlowTemplateResource, - NewWorkflowDefinitionResource, - } + return []func() resource.Resource{} } func (p *EpilotWorkflowProvider) DataSources(ctx context.Context) []func() datasource.DataSource { - return []func() datasource.DataSource{ - NewClosingReasonDataSource, - NewFlowTemplateDataSource, - NewWorkflowDefinitionDataSource, - } + return []func() datasource.DataSource{} } func (p *EpilotWorkflowProvider) EphemeralResources(ctx context.Context) []func() ephemeral.EphemeralResource { diff --git a/internal/provider/types/action_schedule.go b/internal/provider/types/action_schedule.go deleted file mode 100644 index 14fd831..0000000 --- a/internal/provider/types/action_schedule.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type ActionSchedule struct { - DelayedSchedule *DelayedSchedule `queryParam:"inline" tfsdk:"delayed_schedule" tfPlanOnly:"true"` - ImmediateSchedule *ImmediateSchedule `queryParam:"inline" tfsdk:"immediate_schedule" tfPlanOnly:"true"` - RelativeSchedule *RelativeSchedule `queryParam:"inline" tfsdk:"relative_schedule" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/automation_config.go b/internal/provider/types/automation_config.go deleted file mode 100644 index de80804..0000000 --- a/internal/provider/types/automation_config.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type AutomationConfig struct { - FlowID types.String `tfsdk:"flow_id"` -} diff --git a/internal/provider/types/automation_task.go b/internal/provider/types/automation_task.go deleted file mode 100644 index 190d2f8..0000000 --- a/internal/provider/types/automation_task.go +++ /dev/null @@ -1,26 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type AutomationTask struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - AutomationConfig AutomationConfig `tfsdk:"automation_config"` - Description *StepDescription `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DueDateConfig *DueDateConfig `tfsdk:"due_date_config"` - Ecp *ECPDetails `tfsdk:"ecp"` - ID types.String `tfsdk:"id"` - Installer *ECPDetails `tfsdk:"installer"` - Journey *StepJourney `tfsdk:"journey"` - Name types.String `tfsdk:"name"` - PhaseID types.String `tfsdk:"phase_id"` - Requirements []EnableRequirement `tfsdk:"requirements"` - Schedule *ActionSchedule `tfsdk:"schedule"` - TaskType types.String `tfsdk:"task_type"` - Taxonomies []types.String `tfsdk:"taxonomies"` - TriggerMode types.String `tfsdk:"trigger_mode"` -} diff --git a/internal/provider/types/automation_trigger.go b/internal/provider/types/automation_trigger.go deleted file mode 100644 index 34070e8..0000000 --- a/internal/provider/types/automation_trigger.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type AutomationTrigger struct { - AutomationID types.String `tfsdk:"automation_id"` - ID types.String `tfsdk:"id"` - Type types.String `tfsdk:"type"` -} diff --git a/internal/provider/types/closing_reason.go b/internal/provider/types/closing_reason.go deleted file mode 100644 index f1250a2..0000000 --- a/internal/provider/types/closing_reason.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ClosingReason struct { - CreationTime types.String `tfsdk:"creation_time"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Status types.String `tfsdk:"status"` - Title types.String `tfsdk:"title"` -} diff --git a/internal/provider/types/closing_reason1.go b/internal/provider/types/closing_reason1.go deleted file mode 100644 index 898d090..0000000 --- a/internal/provider/types/closing_reason1.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ClosingReason1 struct { - CreationTime types.String `tfsdk:"creation_time"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Status types.String `tfsdk:"status"` - Title types.String `tfsdk:"title"` -} diff --git a/internal/provider/types/closing_reason_id.go b/internal/provider/types/closing_reason_id.go deleted file mode 100644 index e6dc049..0000000 --- a/internal/provider/types/closing_reason_id.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ClosingReasonID struct { - ID types.String `tfsdk:"id"` -} diff --git a/internal/provider/types/condition.go b/internal/provider/types/condition.go deleted file mode 100644 index 18b6f19..0000000 --- a/internal/provider/types/condition.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Condition struct { - BranchName types.String `tfsdk:"branch_name"` - ID types.String `tfsdk:"id"` - LogicalOperator types.String `tfsdk:"logical_operator"` - Statements []Statement `tfsdk:"statements"` -} diff --git a/internal/provider/types/decision_task.go b/internal/provider/types/decision_task.go deleted file mode 100644 index bd14c3a..0000000 --- a/internal/provider/types/decision_task.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type DecisionTask struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - Conditions []Condition `tfsdk:"conditions"` - Description *StepDescription `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DueDateConfig *DueDateConfig `tfsdk:"due_date_config"` - Ecp *ECPDetails `tfsdk:"ecp"` - ID types.String `tfsdk:"id"` - Installer *ECPDetails `tfsdk:"installer"` - Journey *StepJourney `tfsdk:"journey"` - Name types.String `tfsdk:"name"` - PhaseID types.String `tfsdk:"phase_id"` - Requirements []EnableRequirement `tfsdk:"requirements"` - Schedule *Schedule `tfsdk:"schedule"` - TaskType types.String `tfsdk:"task_type"` - Taxonomies []types.String `tfsdk:"taxonomies"` -} diff --git a/internal/provider/types/delayed_schedule.go b/internal/provider/types/delayed_schedule.go deleted file mode 100644 index f92e044..0000000 --- a/internal/provider/types/delayed_schedule.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type DelayedSchedule struct { - Duration types.Float64 `tfsdk:"duration"` - Mode types.String `tfsdk:"mode"` - Unit types.String `tfsdk:"unit"` -} diff --git a/internal/provider/types/due_date_config.go b/internal/provider/types/due_date_config.go deleted file mode 100644 index d6a2a63..0000000 --- a/internal/provider/types/due_date_config.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type DueDateConfig struct { - Duration types.Float64 `tfsdk:"duration"` - PhaseID types.String `tfsdk:"phase_id"` - TaskID types.String `tfsdk:"task_id"` - Type types.String `tfsdk:"type"` - Unit types.String `tfsdk:"unit"` -} diff --git a/internal/provider/types/dynamic_due_date.go b/internal/provider/types/dynamic_due_date.go deleted file mode 100644 index f4835e2..0000000 --- a/internal/provider/types/dynamic_due_date.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type DynamicDueDate struct { - ActionTypeCondition types.String `tfsdk:"action_type_condition"` - NumberOfUnits types.Float64 `tfsdk:"number_of_units"` - PhaseID types.String `tfsdk:"phase_id"` - StepID types.String `tfsdk:"step_id"` - TimePeriod types.String `tfsdk:"time_period"` -} diff --git a/internal/provider/types/ecp_details.go b/internal/provider/types/ecp_details.go deleted file mode 100644 index 7930629..0000000 --- a/internal/provider/types/ecp_details.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ECPDetails struct { - Description types.String `tfsdk:"description"` - Enabled types.Bool `tfsdk:"enabled"` - Journey *StepJourney `tfsdk:"journey"` - Label types.String `tfsdk:"label"` -} diff --git a/internal/provider/types/edge.go b/internal/provider/types/edge.go deleted file mode 100644 index b3fc51e..0000000 --- a/internal/provider/types/edge.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Edge struct { - ConditionID types.String `tfsdk:"condition_id"` - FromID types.String `tfsdk:"from_id"` - ID types.String `tfsdk:"id"` - NoneMet types.Bool `tfsdk:"none_met"` - ToID types.String `tfsdk:"to_id"` -} diff --git a/internal/provider/types/enable_requirement.go b/internal/provider/types/enable_requirement.go deleted file mode 100644 index 7102c9d..0000000 --- a/internal/provider/types/enable_requirement.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type EnableRequirement struct { - PhaseID types.String `tfsdk:"phase_id"` - TaskID types.String `tfsdk:"task_id"` - When types.String `tfsdk:"when"` -} diff --git a/internal/provider/types/evaluation_source.go b/internal/provider/types/evaluation_source.go deleted file mode 100644 index 4767a0e..0000000 --- a/internal/provider/types/evaluation_source.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type EvaluationSource struct { - Attribute types.String `tfsdk:"attribute"` - AttributeOperation types.String `tfsdk:"attribute_operation"` - AttributeRepeatable types.Bool `tfsdk:"attribute_repeatable"` - AttributeType types.String `tfsdk:"attribute_type"` - ID types.String `tfsdk:"id"` - Origin types.String `tfsdk:"origin"` - OriginType types.String `tfsdk:"origin_type"` - Schema types.String `tfsdk:"schema"` -} diff --git a/internal/provider/types/immediate_schedule.go b/internal/provider/types/immediate_schedule.go deleted file mode 100644 index b240e1e..0000000 --- a/internal/provider/types/immediate_schedule.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ImmediateSchedule struct { - Mode types.String `tfsdk:"mode"` -} diff --git a/internal/provider/types/journey_submission_trigger.go b/internal/provider/types/journey_submission_trigger.go deleted file mode 100644 index 8da7f7a..0000000 --- a/internal/provider/types/journey_submission_trigger.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type JourneySubmissionTrigger struct { - AutomationID types.String `tfsdk:"automation_id"` - ID types.String `tfsdk:"id"` - JourneyID types.String `tfsdk:"journey_id"` - Type types.String `tfsdk:"type"` -} diff --git a/internal/provider/types/manual_trigger.go b/internal/provider/types/manual_trigger.go deleted file mode 100644 index eb7305b..0000000 --- a/internal/provider/types/manual_trigger.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ManualTrigger struct { - EntitySchema types.String `tfsdk:"entity_schema"` - ID types.String `tfsdk:"id"` - Type types.String `tfsdk:"type"` -} diff --git a/internal/provider/types/phase.go b/internal/provider/types/phase.go deleted file mode 100644 index 385facd..0000000 --- a/internal/provider/types/phase.go +++ /dev/null @@ -1,16 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Phase struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - DueDate types.String `tfsdk:"due_date"` - DueDateConfig *DueDateConfig `tfsdk:"due_date_config"` - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Taxonomies []types.String `tfsdk:"taxonomies"` -} diff --git a/internal/provider/types/reference.go b/internal/provider/types/reference.go deleted file mode 100644 index 566966c..0000000 --- a/internal/provider/types/reference.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Reference struct { - Attribute types.String `tfsdk:"attribute"` - ID types.String `tfsdk:"id"` - Origin types.String `tfsdk:"origin"` - Schema types.String `tfsdk:"schema"` -} diff --git a/internal/provider/types/relative_schedule.go b/internal/provider/types/relative_schedule.go deleted file mode 100644 index 1d622e0..0000000 --- a/internal/provider/types/relative_schedule.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type RelativeSchedule struct { - Direction types.String `tfsdk:"direction"` - Duration types.Float64 `tfsdk:"duration"` - Mode types.String `tfsdk:"mode"` - Reference Reference `tfsdk:"reference"` - Unit types.String `tfsdk:"unit"` -} diff --git a/internal/provider/types/schedule.go b/internal/provider/types/schedule.go deleted file mode 100644 index 0813acf..0000000 --- a/internal/provider/types/schedule.go +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type Schedule struct { - DelayedSchedule *DelayedSchedule `queryParam:"inline" tfsdk:"delayed_schedule" tfPlanOnly:"true"` - RelativeSchedule *RelativeSchedule `queryParam:"inline" tfsdk:"relative_schedule" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/statement.go b/internal/provider/types/statement.go deleted file mode 100644 index c882905..0000000 --- a/internal/provider/types/statement.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Statement struct { - ID types.String `tfsdk:"id"` - Operator types.String `tfsdk:"operator"` - Source EvaluationSource `tfsdk:"source"` - Values []types.String `tfsdk:"values"` -} diff --git a/internal/provider/types/step_description.go b/internal/provider/types/step_description.go deleted file mode 100644 index f46358d..0000000 --- a/internal/provider/types/step_description.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type StepDescription struct { - Enabled types.Bool `tfsdk:"enabled"` - Value types.String `tfsdk:"value"` -} diff --git a/internal/provider/types/step_journey.go b/internal/provider/types/step_journey.go deleted file mode 100644 index b9c9241..0000000 --- a/internal/provider/types/step_journey.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type StepJourney struct { - ID types.String `tfsdk:"id"` - JourneyID types.String `tfsdk:"journey_id"` - Name types.String `tfsdk:"name"` -} diff --git a/internal/provider/types/target.go b/internal/provider/types/target.go deleted file mode 100644 index d96d8eb..0000000 --- a/internal/provider/types/target.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Target struct { - EntityAttribute types.String `tfsdk:"entity_attribute"` - EntitySchema types.String `tfsdk:"entity_schema"` -} diff --git a/internal/provider/types/task.go b/internal/provider/types/task.go deleted file mode 100644 index 3e84a16..0000000 --- a/internal/provider/types/task.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type Task struct { - AutomationTask *AutomationTask `queryParam:"inline" tfsdk:"automation_task" tfPlanOnly:"true"` - DecisionTask *DecisionTask `queryParam:"inline" tfsdk:"decision_task" tfPlanOnly:"true"` - TaskBase *TaskBase `queryParam:"inline" tfsdk:"task_base" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/task_base.go b/internal/provider/types/task_base.go deleted file mode 100644 index 0a9809b..0000000 --- a/internal/provider/types/task_base.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type TaskBase struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - Description *StepDescription `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DueDateConfig *DueDateConfig `tfsdk:"due_date_config"` - Ecp *ECPDetails `tfsdk:"ecp"` - ID types.String `tfsdk:"id"` - Installer *ECPDetails `tfsdk:"installer"` - Journey *StepJourney `tfsdk:"journey"` - Name types.String `tfsdk:"name"` - PhaseID types.String `tfsdk:"phase_id"` - Requirements []EnableRequirement `tfsdk:"requirements"` - TaskType types.String `tfsdk:"task_type"` - Taxonomies []types.String `tfsdk:"taxonomies"` -} diff --git a/internal/provider/types/trigger.go b/internal/provider/types/trigger.go deleted file mode 100644 index d51a84d..0000000 --- a/internal/provider/types/trigger.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type Trigger struct { - AutomationTrigger *AutomationTrigger `queryParam:"inline" tfsdk:"automation_trigger" tfPlanOnly:"true"` - JourneySubmissionTrigger *JourneySubmissionTrigger `queryParam:"inline" tfsdk:"journey_submission_trigger" tfPlanOnly:"true"` - ManualTrigger *ManualTrigger `queryParam:"inline" tfsdk:"manual_trigger" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/update_entity_attributes.go b/internal/provider/types/update_entity_attributes.go deleted file mode 100644 index d33b558..0000000 --- a/internal/provider/types/update_entity_attributes.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpdateEntityAttributes struct { - Source types.String `tfsdk:"source"` - Target Target `tfsdk:"target"` -} diff --git a/internal/provider/workflowdefinition_data_source.go b/internal/provider/workflowdefinition_data_source.go deleted file mode 100644 index 66dc2ee..0000000 --- a/internal/provider/workflowdefinition_data_source.go +++ /dev/null @@ -1,237 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ datasource.DataSource = &WorkflowDefinitionDataSource{} -var _ datasource.DataSourceWithConfigure = &WorkflowDefinitionDataSource{} - -func NewWorkflowDefinitionDataSource() datasource.DataSource { - return &WorkflowDefinitionDataSource{} -} - -// WorkflowDefinitionDataSource is the data source implementation. -type WorkflowDefinitionDataSource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// WorkflowDefinitionDataSourceModel describes the data model. -type WorkflowDefinitionDataSourceModel struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - ClosingReasons []tfTypes.ClosingReasonID `tfsdk:"closing_reasons"` - CreationTime types.String `tfsdk:"creation_time"` - Description types.String `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DynamicDueDate *tfTypes.DynamicDueDate `tfsdk:"dynamic_due_date"` - EnableECPWorkflow types.Bool `tfsdk:"enable_ecp_workflow"` - Enabled types.Bool `tfsdk:"enabled"` - Flow jsontypes.Normalized `tfsdk:"flow"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Name types.String `tfsdk:"name"` - Taxonomies []types.String `tfsdk:"taxonomies"` - UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` - UserIds []types.Float64 `tfsdk:"user_ids"` -} - -// Metadata returns the data source type name. -func (r *WorkflowDefinitionDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_workflow_definition" -} - -// Schema defines the schema for the data source. -func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "WorkflowDefinition DataSource", - - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "closing_reasons": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "creation_time": schema.StringAttribute{ - Computed: true, - Description: `ISO String Date & Time`, - }, - "description": schema.StringAttribute{ - Computed: true, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "dynamic_due_date": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "action_type_condition": schema.StringAttribute{ - Computed: true, - }, - "number_of_units": schema.Float64Attribute{ - Computed: true, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - }, - "step_id": schema.StringAttribute{ - Computed: true, - }, - "time_period": schema.StringAttribute{ - Computed: true, - }, - }, - Description: `set a Duedate for a step then a specific`, - }, - "enable_ecp_workflow": schema.BoolAttribute{ - Computed: true, - Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Whether the workflow is enabled or not`, - }, - "flow": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - Description: `ISO String Date & Time`, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - "update_entity_attributes": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "source": schema.StringAttribute{ - Computed: true, - }, - "target": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "entity_attribute": schema.StringAttribute{ - Computed: true, - }, - "entity_schema": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - }, - "user_ids": schema.ListAttribute{ - Computed: true, - ElementType: types.Float64Type, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `This field is deprecated. Please use assignedTo`, - }, - }, - } -} - -func (r *WorkflowDefinitionDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected DataSource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *WorkflowDefinitionDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *WorkflowDefinitionDataSourceModel - var item types.Object - - resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsGetDefinitionRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.Workflows.GetDefinition(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedWorkflowDefinition(ctx, res.WorkflowDefinition)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/workflowdefinition_data_source_sdk.go b/internal/provider/workflowdefinition_data_source_sdk.go deleted file mode 100644 index 19b2378..0000000 --- a/internal/provider/workflowdefinition_data_source_sdk.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "encoding/json" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *WorkflowDefinitionDataSourceModel) RefreshFromSharedWorkflowDefinition(ctx context.Context, resp *shared.WorkflowDefinition) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.AssignedTo = make([]types.String, 0, len(resp.AssignedTo)) - for _, v := range resp.AssignedTo { - r.AssignedTo = append(r.AssignedTo, types.StringValue(v)) - } - r.ClosingReasons = []tfTypes.ClosingReasonID{} - - for _, closingReasonsItem := range resp.ClosingReasons { - var closingReasons tfTypes.ClosingReasonID - - closingReasons.ID = types.StringValue(closingReasonsItem.ID) - - r.ClosingReasons = append(r.ClosingReasons, closingReasons) - } - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.Description = types.StringPointerValue(resp.Description) - r.DueDate = types.StringPointerValue(resp.DueDate) - if resp.DynamicDueDate == nil { - r.DynamicDueDate = nil - } else { - r.DynamicDueDate = &tfTypes.DynamicDueDate{} - r.DynamicDueDate.ActionTypeCondition = types.StringValue(string(resp.DynamicDueDate.ActionTypeCondition)) - r.DynamicDueDate.NumberOfUnits = types.Float64Value(resp.DynamicDueDate.NumberOfUnits) - r.DynamicDueDate.PhaseID = types.StringPointerValue(resp.DynamicDueDate.PhaseID) - r.DynamicDueDate.StepID = types.StringPointerValue(resp.DynamicDueDate.StepID) - r.DynamicDueDate.TimePeriod = types.StringValue(string(resp.DynamicDueDate.TimePeriod)) - } - r.Enabled = types.BoolPointerValue(resp.Enabled) - r.EnableECPWorkflow = types.BoolPointerValue(resp.EnableECPWorkflow) - flowResult, _ := json.Marshal(resp.Flow) - r.Flow = jsontypes.NewNormalizedValue(string(flowResult)) - r.ID = types.StringPointerValue(resp.ID) - r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) - r.Name = types.StringValue(resp.Name) - r.Taxonomies = make([]types.String, 0, len(resp.Taxonomies)) - for _, v := range resp.Taxonomies { - r.Taxonomies = append(r.Taxonomies, types.StringValue(v)) - } - r.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} - - for _, updateEntityAttributesItem := range resp.UpdateEntityAttributes { - var updateEntityAttributes tfTypes.UpdateEntityAttributes - - updateEntityAttributes.Source = types.StringValue(string(updateEntityAttributesItem.Source)) - updateEntityAttributes.Target.EntityAttribute = types.StringValue(updateEntityAttributesItem.Target.EntityAttribute) - updateEntityAttributes.Target.EntitySchema = types.StringValue(updateEntityAttributesItem.Target.EntitySchema) - - r.UpdateEntityAttributes = append(r.UpdateEntityAttributes, updateEntityAttributes) - } - r.UserIds = make([]types.Float64, 0, len(resp.UserIds)) - for _, v := range resp.UserIds { - r.UserIds = append(r.UserIds, types.Float64Value(v)) - } - } - - return diags -} - -func (r *WorkflowDefinitionDataSourceModel) ToOperationsGetDefinitionRequest(ctx context.Context) (*operations.GetDefinitionRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var definitionID string - definitionID = r.ID.ValueString() - - out := operations.GetDefinitionRequest{ - DefinitionID: definitionID, - } - - return &out, diags -} diff --git a/internal/provider/workflowdefinition_resource.go b/internal/provider/workflowdefinition_resource.go deleted file mode 100644 index c801b90..0000000 --- a/internal/provider/workflowdefinition_resource.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - speakeasy_float64validators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/float64validators" - speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/objectvalidators" - speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/stringvalidators" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &WorkflowDefinitionResource{} -var _ resource.ResourceWithImportState = &WorkflowDefinitionResource{} - -func NewWorkflowDefinitionResource() resource.Resource { - return &WorkflowDefinitionResource{} -} - -// WorkflowDefinitionResource defines the resource implementation. -type WorkflowDefinitionResource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// WorkflowDefinitionResourceModel describes the resource data model. -type WorkflowDefinitionResourceModel struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - ClosingReasons []tfTypes.ClosingReasonID `tfsdk:"closing_reasons"` - CreationTime types.String `tfsdk:"creation_time"` - Description types.String `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DynamicDueDate *tfTypes.DynamicDueDate `tfsdk:"dynamic_due_date"` - EnableECPWorkflow types.Bool `tfsdk:"enable_ecp_workflow"` - Enabled types.Bool `tfsdk:"enabled"` - Flow jsontypes.Normalized `tfsdk:"flow"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Name types.String `tfsdk:"name"` - Taxonomies []types.String `tfsdk:"taxonomies"` - UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` - UserIds []types.Float64 `tfsdk:"user_ids"` -} - -func (r *WorkflowDefinitionResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_workflow_definition" -} - -func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "WorkflowDefinition Resource", - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "closing_reasons": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - }, - }, - "creation_time": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ISO String Date & Time`, - }, - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "dynamic_due_date": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "action_type_condition": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["WORKFLOW_STARTED", "STEP_CLOSED", "PHASE_FINISHED"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "STEP_CLOSED", - "PHASE_FINISHED", - ), - }, - }, - "number_of_units": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "phase_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "step_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "time_period": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "minutes", - "hours", - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `set a Duedate for a step then a specific`, - }, - "enable_ecp_workflow": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - Default: booldefault.StaticBool(true), - Description: `Whether the workflow is enabled or not. Default: true`, - }, - "flow": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Required: true, - Description: `Parsed as JSON.`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ISO String Date & Time`, - }, - "name": schema.StringAttribute{ - Required: true, - }, - "taxonomies": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Taxonomy ids that are associated with this workflow and used for filtering`, - }, - "update_entity_attributes": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "source": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["workflow_status", "current_section", "current_step"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "workflow_status", - "current_section", - "current_step", - ), - }, - }, - "target": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "entity_attribute": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "entity_schema": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - }, - }, - }, - "user_ids": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.Float64Type, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `This field is deprecated. Please use assignedTo`, - }, - }, - } -} - -func (r *WorkflowDefinitionResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *WorkflowDefinitionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *WorkflowDefinitionResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToSharedWorkflowDefinition(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.Workflows.CreateDefinition(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedWorkflowDefinition(ctx, res.WorkflowDefinition)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *WorkflowDefinitionResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *WorkflowDefinitionResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsGetDefinitionRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.Workflows.GetDefinition(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedWorkflowDefinition(ctx, res.WorkflowDefinition)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *WorkflowDefinitionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *WorkflowDefinitionResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsUpdateDefinitionRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.Workflows.UpdateDefinition(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedWorkflowDefinition(ctx, res.WorkflowDefinition)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *WorkflowDefinitionResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *WorkflowDefinitionResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsDeleteDefinitionRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.Workflows.DeleteDefinition(ctx, *request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *WorkflowDefinitionResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/workflowdefinition_resource_sdk.go b/internal/provider/workflowdefinition_resource_sdk.go deleted file mode 100644 index acaae6e..0000000 --- a/internal/provider/workflowdefinition_resource_sdk.go +++ /dev/null @@ -1,259 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "encoding/json" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *WorkflowDefinitionResourceModel) RefreshFromSharedWorkflowDefinition(ctx context.Context, resp *shared.WorkflowDefinition) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.AssignedTo = make([]types.String, 0, len(resp.AssignedTo)) - for _, v := range resp.AssignedTo { - r.AssignedTo = append(r.AssignedTo, types.StringValue(v)) - } - r.ClosingReasons = []tfTypes.ClosingReasonID{} - - for _, closingReasonsItem := range resp.ClosingReasons { - var closingReasons tfTypes.ClosingReasonID - - closingReasons.ID = types.StringValue(closingReasonsItem.ID) - - r.ClosingReasons = append(r.ClosingReasons, closingReasons) - } - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.Description = types.StringPointerValue(resp.Description) - r.DueDate = types.StringPointerValue(resp.DueDate) - if resp.DynamicDueDate == nil { - r.DynamicDueDate = nil - } else { - r.DynamicDueDate = &tfTypes.DynamicDueDate{} - r.DynamicDueDate.ActionTypeCondition = types.StringValue(string(resp.DynamicDueDate.ActionTypeCondition)) - r.DynamicDueDate.NumberOfUnits = types.Float64Value(resp.DynamicDueDate.NumberOfUnits) - r.DynamicDueDate.PhaseID = types.StringPointerValue(resp.DynamicDueDate.PhaseID) - r.DynamicDueDate.StepID = types.StringPointerValue(resp.DynamicDueDate.StepID) - r.DynamicDueDate.TimePeriod = types.StringValue(string(resp.DynamicDueDate.TimePeriod)) - } - r.Enabled = types.BoolPointerValue(resp.Enabled) - r.EnableECPWorkflow = types.BoolPointerValue(resp.EnableECPWorkflow) - flowResult, _ := json.Marshal(resp.Flow) - r.Flow = jsontypes.NewNormalizedValue(string(flowResult)) - r.ID = types.StringPointerValue(resp.ID) - r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) - r.Name = types.StringValue(resp.Name) - r.Taxonomies = make([]types.String, 0, len(resp.Taxonomies)) - for _, v := range resp.Taxonomies { - r.Taxonomies = append(r.Taxonomies, types.StringValue(v)) - } - r.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} - - for _, updateEntityAttributesItem := range resp.UpdateEntityAttributes { - var updateEntityAttributes tfTypes.UpdateEntityAttributes - - updateEntityAttributes.Source = types.StringValue(string(updateEntityAttributesItem.Source)) - updateEntityAttributes.Target.EntityAttribute = types.StringValue(updateEntityAttributesItem.Target.EntityAttribute) - updateEntityAttributes.Target.EntitySchema = types.StringValue(updateEntityAttributesItem.Target.EntitySchema) - - r.UpdateEntityAttributes = append(r.UpdateEntityAttributes, updateEntityAttributes) - } - r.UserIds = make([]types.Float64, 0, len(resp.UserIds)) - for _, v := range resp.UserIds { - r.UserIds = append(r.UserIds, types.Float64Value(v)) - } - } - - return diags -} - -func (r *WorkflowDefinitionResourceModel) ToOperationsDeleteDefinitionRequest(ctx context.Context) (*operations.DeleteDefinitionRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var definitionID string - definitionID = r.ID.ValueString() - - out := operations.DeleteDefinitionRequest{ - DefinitionID: definitionID, - } - - return &out, diags -} - -func (r *WorkflowDefinitionResourceModel) ToOperationsGetDefinitionRequest(ctx context.Context) (*operations.GetDefinitionRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var definitionID string - definitionID = r.ID.ValueString() - - out := operations.GetDefinitionRequest{ - DefinitionID: definitionID, - } - - return &out, diags -} - -func (r *WorkflowDefinitionResourceModel) ToOperationsUpdateDefinitionRequest(ctx context.Context) (*operations.UpdateDefinitionRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - workflowDefinition, workflowDefinitionDiags := r.ToSharedWorkflowDefinition(ctx) - diags.Append(workflowDefinitionDiags...) - - if diags.HasError() { - return nil, diags - } - - var definitionID string - definitionID = r.ID.ValueString() - - out := operations.UpdateDefinitionRequest{ - WorkflowDefinition: *workflowDefinition, - DefinitionID: definitionID, - } - - return &out, diags -} - -func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition(ctx context.Context) (*shared.WorkflowDefinition, diag.Diagnostics) { - var diags diag.Diagnostics - - assignedTo := make([]string, 0, len(r.AssignedTo)) - for _, assignedToItem := range r.AssignedTo { - assignedTo = append(assignedTo, assignedToItem.ValueString()) - } - closingReasons := make([]shared.ClosingReasonID, 0, len(r.ClosingReasons)) - for _, closingReasonsItem := range r.ClosingReasons { - var id string - id = closingReasonsItem.ID.ValueString() - - closingReasons = append(closingReasons, shared.ClosingReasonID{ - ID: id, - }) - } - creationTime := new(string) - if !r.CreationTime.IsUnknown() && !r.CreationTime.IsNull() { - *creationTime = r.CreationTime.ValueString() - } else { - creationTime = nil - } - description := new(string) - if !r.Description.IsUnknown() && !r.Description.IsNull() { - *description = r.Description.ValueString() - } else { - description = nil - } - dueDate := new(string) - if !r.DueDate.IsUnknown() && !r.DueDate.IsNull() { - *dueDate = r.DueDate.ValueString() - } else { - dueDate = nil - } - var dynamicDueDate *shared.DynamicDueDate - if r.DynamicDueDate != nil { - actionTypeCondition := shared.ActionTypeCondition(r.DynamicDueDate.ActionTypeCondition.ValueString()) - var numberOfUnits float64 - numberOfUnits = r.DynamicDueDate.NumberOfUnits.ValueFloat64() - - phaseID := new(string) - if !r.DynamicDueDate.PhaseID.IsUnknown() && !r.DynamicDueDate.PhaseID.IsNull() { - *phaseID = r.DynamicDueDate.PhaseID.ValueString() - } else { - phaseID = nil - } - stepID := new(string) - if !r.DynamicDueDate.StepID.IsUnknown() && !r.DynamicDueDate.StepID.IsNull() { - *stepID = r.DynamicDueDate.StepID.ValueString() - } else { - stepID = nil - } - timePeriod := shared.TimeUnit(r.DynamicDueDate.TimePeriod.ValueString()) - dynamicDueDate = &shared.DynamicDueDate{ - ActionTypeCondition: actionTypeCondition, - NumberOfUnits: numberOfUnits, - PhaseID: phaseID, - StepID: stepID, - TimePeriod: timePeriod, - } - } - enableECPWorkflow := new(bool) - if !r.EnableECPWorkflow.IsUnknown() && !r.EnableECPWorkflow.IsNull() { - *enableECPWorkflow = r.EnableECPWorkflow.ValueBool() - } else { - enableECPWorkflow = nil - } - enabled := new(bool) - if !r.Enabled.IsUnknown() && !r.Enabled.IsNull() { - *enabled = r.Enabled.ValueBool() - } else { - enabled = nil - } - var flow interface{} - _ = json.Unmarshal([]byte(r.Flow.ValueString()), &flow) - id1 := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id1 = r.ID.ValueString() - } else { - id1 = nil - } - lastUpdateTime := new(string) - if !r.LastUpdateTime.IsUnknown() && !r.LastUpdateTime.IsNull() { - *lastUpdateTime = r.LastUpdateTime.ValueString() - } else { - lastUpdateTime = nil - } - var name string - name = r.Name.ValueString() - - taxonomies := make([]string, 0, len(r.Taxonomies)) - for _, taxonomiesItem := range r.Taxonomies { - taxonomies = append(taxonomies, taxonomiesItem.ValueString()) - } - updateEntityAttributes := make([]shared.UpdateEntityAttributes, 0, len(r.UpdateEntityAttributes)) - for _, updateEntityAttributesItem := range r.UpdateEntityAttributes { - source := shared.Source(updateEntityAttributesItem.Source.ValueString()) - var entityAttribute string - entityAttribute = updateEntityAttributesItem.Target.EntityAttribute.ValueString() - - var entitySchema string - entitySchema = updateEntityAttributesItem.Target.EntitySchema.ValueString() - - target := shared.Target{ - EntityAttribute: entityAttribute, - EntitySchema: entitySchema, - } - updateEntityAttributes = append(updateEntityAttributes, shared.UpdateEntityAttributes{ - Source: source, - Target: target, - }) - } - userIds := make([]float64, 0, len(r.UserIds)) - for _, userIdsItem := range r.UserIds { - userIds = append(userIds, userIdsItem.ValueFloat64()) - } - out := shared.WorkflowDefinition{ - AssignedTo: assignedTo, - ClosingReasons: closingReasons, - CreationTime: creationTime, - Description: description, - DueDate: dueDate, - DynamicDueDate: dynamicDueDate, - EnableECPWorkflow: enableECPWorkflow, - Enabled: enabled, - Flow: flow, - ID: id1, - LastUpdateTime: lastUpdateTime, - Name: name, - Taxonomies: taxonomies, - UpdateEntityAttributes: updateEntityAttributes, - UserIds: userIds, - } - - return &out, diags -} diff --git a/internal/sdk/.gitignore b/internal/sdk/.gitignore index 5f88fc7..1094509 100644 --- a/internal/sdk/.gitignore +++ b/internal/sdk/.gitignore @@ -1,3 +1,5 @@ +.env +.env.local .DS_Store **/.speakeasy/temp/ **/.speakeasy/logs/ diff --git a/internal/sdk/closingreason.go b/internal/sdk/closingreason.go index 86d2c03..2d057ab 100644 --- a/internal/sdk/closingreason.go +++ b/internal/sdk/closingreason.go @@ -12,7 +12,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" "net/http" "net/url" ) @@ -36,7 +35,6 @@ func newClosingReason(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *ho func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operations.ChangeReasonStatusRequest, opts ...operations.Option) (*operations.ChangeReasonStatusResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -63,7 +61,7 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio BaseURL: baseURL, Context: ctx, OperationID: "changeReasonStatus", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "ChangeReasonStatusReq", "json", `request:"mediaType=application/json"`) @@ -100,101 +98,33 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + } else if _httpRes != nil { + httpRes = _httpRes } } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } } res := &operations.ChangeReasonStatusResponse{ @@ -264,7 +194,6 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared.ClosingReasonInput, opts ...operations.Option) (*operations.CreateClosingReasonResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -291,7 +220,7 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. BaseURL: baseURL, Context: ctx, OperationID: "createClosingReason", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) @@ -328,100 +257,32 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -470,7 +331,6 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. func (s *ClosingReason) DeleteClosingReason(ctx context.Context, request operations.DeleteClosingReasonRequest, opts ...operations.Option) (*operations.DeleteClosingReasonResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -497,7 +357,7 @@ func (s *ClosingReason) DeleteClosingReason(ctx context.Context, request operati BaseURL: baseURL, Context: ctx, OperationID: "deleteClosingReason", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -527,100 +387,32 @@ func (s *ClosingReason) DeleteClosingReason(ctx context.Context, request operati req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -691,7 +483,6 @@ func (s *ClosingReason) DeleteClosingReason(ctx context.Context, request operati func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operations.GetAllClosingReasonsRequest, opts ...operations.Option) (*operations.GetAllClosingReasonsResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -718,7 +509,7 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat BaseURL: baseURL, Context: ctx, OperationID: "getAllClosingReasons", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -752,100 +543,32 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -894,7 +617,6 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations.GetClosingReasonRequest, opts ...operations.Option) (*operations.GetClosingReasonResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -921,7 +643,7 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations BaseURL: baseURL, Context: ctx, OperationID: "getClosingReason", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -951,101 +673,33 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + } else if _httpRes != nil { + httpRes = _httpRes } } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } } res := &operations.GetClosingReasonResponse{ @@ -1139,7 +793,6 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations func (s *ClosingReason) GetClosingReasonV1(ctx context.Context, request operations.GetClosingReasonV1Request, opts ...operations.Option) (*operations.GetClosingReasonV1Response, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1166,7 +819,7 @@ func (s *ClosingReason) GetClosingReasonV1(ctx context.Context, request operatio BaseURL: baseURL, Context: ctx, OperationID: "getClosingReasonV1", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -1196,100 +849,32 @@ func (s *ClosingReason) GetClosingReasonV1(ctx context.Context, request operatio req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -1403,7 +988,6 @@ func (s *ClosingReason) GetClosingReasonV1(ctx context.Context, request operatio func (s *ClosingReason) UpdateClosingReason(ctx context.Context, request operations.UpdateClosingReasonRequest, opts ...operations.Option) (*operations.UpdateClosingReasonResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1430,7 +1014,7 @@ func (s *ClosingReason) UpdateClosingReason(ctx context.Context, request operati BaseURL: baseURL, Context: ctx, OperationID: "updateClosingReason", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "ClosingReason", "json", `request:"mediaType=application/json"`) @@ -1467,100 +1051,32 @@ func (s *ClosingReason) UpdateClosingReason(ctx context.Context, request operati req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } diff --git a/internal/sdk/docs/models/operations/option.md b/internal/sdk/docs/models/operations/option.md deleted file mode 100644 index 35d8a1e..0000000 --- a/internal/sdk/docs/models/operations/option.md +++ /dev/null @@ -1,37 +0,0 @@ -## Options - -### WithServerURL - -WithServerURL allows providing an alternative server URL. - -```go -operations.WithServerURL("http://api.example.com") -``` - -## WithTemplatedServerURL - -WithTemplatedServerURL allows providing an alternative server URL with templated parameters. - -```go -operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ - "host": "api.example.com", - "port": "8080", -}) -``` - -### WithRetries - -WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries. - -```go -operations.WithRetries(retry.Config{ - Strategy: "backoff", - Backoff: retry.BackoffStrategy{ - InitialInterval: 500 * time.Millisecond, - MaxInterval: 60 * time.Second, - Exponent: 1.5, - MaxElapsedTime: 5 * time.Minute, - }, - RetryConnectionErrors: true, -}) -``` \ No newline at end of file diff --git a/internal/sdk/flowsv2.go b/internal/sdk/flowsv2.go index 06a8440..a3d208d 100644 --- a/internal/sdk/flowsv2.go +++ b/internal/sdk/flowsv2.go @@ -12,7 +12,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" "net/http" "net/url" ) @@ -36,7 +35,6 @@ func newFlowsV2(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Ho func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.CreateFlowTemplate, opts ...operations.Option) (*operations.CreateFlowTemplateResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -63,7 +61,7 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.CreateF BaseURL: baseURL, Context: ctx, OperationID: "createFlowTemplate", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) @@ -100,100 +98,32 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.CreateF req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -286,7 +216,6 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.CreateF func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.DeleteFlowTemplateRequest, opts ...operations.Option) (*operations.DeleteFlowTemplateResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -313,7 +242,7 @@ func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.Del BaseURL: baseURL, Context: ctx, OperationID: "deleteFlowTemplate", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -343,100 +272,32 @@ func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.Del req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -482,12 +343,11 @@ func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.Del } -// GetFlowTemplate - getFlowTemplate -// Get specific FLow template for a customer -func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlowTemplateRequest, opts ...operations.Option) (*operations.GetFlowTemplateResponse, error) { +// DuplicateFlowTemplate - duplicateFlowTemplate +// Duplicate a Flow Template from an existing workflow. +func (s *FlowsV2) DuplicateFlowTemplate(ctx context.Context, request operations.DuplicateFlowTemplateRequest, opts ...operations.Option) (*operations.DuplicateFlowTemplateResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -503,7 +363,7 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo } else { baseURL = *o.ServerURL } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/flows/templates/{flowId}", request, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/flows/templates/{flowId}/duplicate", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -513,8 +373,8 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo SDKConfiguration: s.sdkConfiguration, BaseURL: baseURL, Context: ctx, - OperationID: "getFlowTemplate", - OAuth2Scopes: []string{}, + OperationID: "duplicateFlowTemplate", + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -529,7 +389,7 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo defer cancel() } - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } @@ -544,100 +404,206 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err } } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() + res := &operations.DuplicateFlowTemplateResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } - if err != nil { - return nil, err - } + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } - req.Body = copyBody + var out shared.FlowTemplate + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err } - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + res.FlowTemplate = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err } - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err } - return httpRes, err - }) - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") + return nil, err } - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err - } else if _httpRes != nil { - httpRes = _httpRes } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetFlowTemplate - getFlowTemplate +// Get specific FLow template for a customer +func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlowTemplateRequest, opts ...operations.Option) (*operations.GetFlowTemplateResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/flows/templates/{flowId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getFlowTemplate", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err } } @@ -747,11 +713,10 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo } // ListFlowTemplates - listFlowTemplates -// List all Flow Templates for a customer -func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Option) (*operations.ListFlowTemplatesResponse, error) { +// List all Flow Templates for a customer. Optionally, you can filter flow templates by trigger values. +func (s *FlowsV2) ListFlowTemplates(ctx context.Context, request operations.ListFlowTemplatesRequest, opts ...operations.Option) (*operations.ListFlowTemplatesResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -778,7 +743,7 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti BaseURL: baseURL, Context: ctx, OperationID: "listFlowTemplates", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -800,6 +765,10 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } @@ -808,104 +777,194 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err } } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() + res := &operations.ListFlowTemplatesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } - if err != nil { - return nil, err - } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } - req.Body = copyBody + var out shared.FlowTemplatesList + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err } - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + res.FlowTemplatesList = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err } - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err } - return httpRes, err - }) - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } + return res, nil - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } +} + +// SearchFlowTemplates - searchFlowTemplates +// Search for flow templates by name, trigger type, enabled status, and more. +func (s *FlowsV2) SearchFlowTemplates(ctx context.Context, request shared.SearchFlowTemplates, opts ...operations.Option) (*operations.SearchFlowTemplatesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v2/flows/templates:search") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "searchFlowTemplates", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err } } - res := &operations.ListFlowTemplatesResponse{ + res := &operations.SearchFlowTemplatesResponse{ StatusCode: httpRes.StatusCode, ContentType: httpRes.Header.Get("Content-Type"), RawResponse: httpRes, @@ -920,12 +979,12 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti return nil, err } - var out shared.FlowTemplatesList + var out operations.SearchFlowTemplatesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.FlowTemplatesList = &out + res.Object = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -971,7 +1030,6 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.UpdateFlowTemplateRequest, opts ...operations.Option) (*operations.UpdateFlowTemplateResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -998,7 +1056,7 @@ func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.Upd BaseURL: baseURL, Context: ctx, OperationID: "updateFlowTemplate", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "FlowTemplate", "json", `request:"mediaType=application/json"`) @@ -1035,100 +1093,32 @@ func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.Upd req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } diff --git a/internal/sdk/internal/utils/form.go b/internal/sdk/internal/utils/form.go index 145f542..f816dd5 100644 --- a/internal/sdk/internal/utils/form.go +++ b/internal/sdk/internal/utils/form.go @@ -10,8 +10,7 @@ import ( "strings" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/types" ) @@ -41,8 +40,6 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue formValues.Add(paramName, valToString(objValue.Interface())) case big.Int: formValues.Add(paramName, valToString(objValue.Interface())) - case decimal.Big: - formValues.Add(paramName, valToString(objValue.Interface())) default: var items []string @@ -64,7 +61,13 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue } if explode { - formValues.Add(fieldName, valToString(valType.Interface())) + if valType.Kind() == reflect.Slice || valType.Kind() == reflect.Array { + for i := 0; i < valType.Len(); i++ { + formValues.Add(fieldName, valToString(valType.Index(i).Interface())) + } + } else { + formValues.Add(fieldName, valToString(valType.Interface())) + } } else { items = append(items, fmt.Sprintf("%s%s%s", fieldName, delimiter, valToString(valType.Interface()))) } @@ -75,6 +78,16 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue } } case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + formValues.Add(paramName, valToString(value)) + } + // If not set or explicitly null, skip adding to form + return formValues + } + items := []string{} iter := objValue.MapRange() diff --git a/internal/sdk/internal/utils/headers.go b/internal/sdk/internal/utils/headers.go index a07608b..7a08892 100644 --- a/internal/sdk/internal/utils/headers.go +++ b/internal/sdk/internal/utils/headers.go @@ -8,6 +8,8 @@ import ( "net/http" "reflect" "strings" + + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/optionalnullable" ) func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) { @@ -98,6 +100,16 @@ func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) return strings.Join(items, ",") case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + return valToString(value) + } + // If not set or explicitly null, return empty string + return "" + } + items := []string{} iter := objValue.MapRange() diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index 4e49711..97f5261 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -15,8 +15,6 @@ import ( "unsafe" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/types" - - "github.com/ericlagergren/decimal" ) func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error) { @@ -41,21 +39,30 @@ func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, e fieldName := field.Name omitEmpty := false + omitZero := false jsonTag := field.Tag.Get("json") if jsonTag != "" { for _, tag := range strings.Split(jsonTag, ",") { if tag == "omitempty" { omitEmpty = true + } else if tag == "omitzero" { + omitZero = true } else { fieldName = tag } } } - if isNil(field.Type, fieldVal) && field.Tag.Get("const") == "" { - if omitEmpty { + if (omitEmpty || omitZero) && field.Tag.Get("const") == "" { + // Both omitempty and omitzero skip zero values (including nil) + if isNil(field.Type, fieldVal) { + continue + } + + if omitZero && fieldVal.IsZero() { continue } + } if !field.IsExported() && field.Tag.Get("const") == "" { @@ -156,7 +163,7 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool jsonTag := field.Tag.Get("json") if jsonTag != "" { for _, tag := range strings.Split(jsonTag, ",") { - if tag != "omitempty" { + if tag != "omitempty" && tag != "omitzero" { fieldName = tag } } @@ -287,6 +294,11 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) return []byte("null"), nil } + // Check if the map implements json.Marshaler (like optionalnullable.OptionalNullable[T]) + if marshaler, ok := val.Interface().(json.Marshaler); ok { + return marshaler.MarshalJSON() + } + out := map[string]json.RawMessage{} for _, key := range val.MapKeys() { @@ -340,17 +352,6 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) b := val.Interface().(big.Int) return []byte(fmt.Sprintf(`"%s"`, (&b).String())), nil } - case reflect.TypeOf(decimal.Big{}): - format := tag.Get("decimal") - if format == "number" { - b := val.Interface().(decimal.Big) - f, ok := (&b).Float64() - if ok { - return []byte(b.String()), nil - } - - return []byte(fmt.Sprintf(`%f`, f)), nil - } } } @@ -381,11 +382,6 @@ func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.Struc if format == "string" { return []byte(fmt.Sprintf(`"%s"`, tagValue)) } - case reflect.TypeOf(decimal.Big{}): - decimalTag := tag.Get("decimal") - if decimalTag != "number" { - return []byte(fmt.Sprintf(`"%s"`, tagValue)) - } case reflect.TypeOf(types.Date{}): return []byte(fmt.Sprintf(`"%s"`, tagValue)) default: @@ -566,27 +562,6 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa v.Set(reflect.ValueOf(b)) return nil - case reflect.TypeOf(decimal.Big{}): - var d *decimal.Big - format := tag.Get("decimal") - if format == "number" { - var ok bool - d, ok = new(decimal.Big).SetString(string(value)) - if !ok { - return fmt.Errorf("failed to parse number as decimal.Big") - } - } else { - if err := json.Unmarshal(value, &d); err != nil { - return err - } - } - - if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { - v = v.Elem() - } - - v.Set(reflect.ValueOf(d)) - return nil case reflect.TypeOf(types.Date{}): var s string @@ -651,8 +626,6 @@ func isComplexValueType(typ reflect.Type) bool { fallthrough case reflect.TypeOf(big.Int{}): fallthrough - case reflect.TypeOf(decimal.Big{}): - fallthrough case reflect.TypeOf(types.Date{}): return true } @@ -672,3 +645,215 @@ func isModelType(typ reflect.Type) bool { return false } + +// CalculateJSONSize returns the byte size of the JSON representation of a value. +// This is used to determine which union type variant has the most data. +func CalculateJSONSize(v interface{}) int { + data, err := json.Marshal(v) + if err != nil { + return 0 + } + return len(data) +} + +// UnionCandidate represents a candidate type during union deserialization +type UnionCandidate struct { + FieldCount int + Size int + Type any // The union type enum value + Value any // The unmarshaled value +} + +// CountFields recursively counts the number of valid (non-nil, non-zero) fields set in a value. +// This is used as the primary discriminator for union types, with JSON size as a tiebreaker. +func CountFields(v interface{}) int { + if v == nil { + return 0 + } + + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + + // Dereference pointers + for typ.Kind() == reflect.Ptr { + if val.IsNil() { + return 0 + } + typ = typ.Elem() + val = val.Elem() + } + + return countFieldsRecursive(typ, val) +} + +// PickBestCandidate selects the best union type candidate using a multi-stage filtering approach: +// 1. If multiple candidates, filter by field count (keep only those with max field count) +// 2. If still multiple, filter by JSON size (keep only those with max size) +// 3. Return the first remaining candidate +func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { + if len(candidates) == 0 { + return nil + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by field count if we have multiple candidates + if len(candidates) > 1 { + maxFieldCount := -1 + for i := range candidates { + candidates[i].FieldCount = CountFields(candidates[i].Value) + if candidates[i].FieldCount > maxFieldCount { + maxFieldCount = candidates[i].FieldCount + } + } + + // Keep only candidates with maximum field count + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.FieldCount == maxFieldCount { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by JSON size if we still have multiple candidates + if len(candidates) > 1 { + maxSize := -1 + for i := range candidates { + candidates[i].Size = CalculateJSONSize(candidates[i].Value) + if candidates[i].Size > maxSize { + maxSize = candidates[i].Size + } + } + + // Keep only candidates with maximum size + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.Size == maxSize { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + // Pick the first remaining candidate + return &candidates[0] +} + +func countFieldsRecursive(typ reflect.Type, val reflect.Value) int { + count := 0 + + switch typ.Kind() { + case reflect.Struct: + // Handle special types + switch typ { + case reflect.TypeOf(time.Time{}): + if !val.Interface().(time.Time).IsZero() { + return 1 + } + return 0 + case reflect.TypeOf(big.Int{}): + b := val.Interface().(big.Int) + if b.Sign() != 0 { + return 1 + } + return 0 + case reflect.TypeOf(types.Date{}): + // Date is always counted if it exists + return 1 + } + + // For regular structs, count non-zero fields + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + // Skip unexported fields and const fields + if !field.IsExported() || field.Tag.Get("const") != "" { + continue + } + + // Skip fields tagged with json:"-" + jsonTag := field.Tag.Get("json") + if jsonTag == "-" { + continue + } + + fieldTyp := field.Type + // Dereference pointer types for the field + for fieldTyp.Kind() == reflect.Ptr { + if fieldVal.IsNil() { + break + } + fieldTyp = fieldTyp.Elem() + fieldVal = fieldVal.Elem() + } + + if !isNil(field.Type, val.Field(i)) { + count += countFieldsRecursive(fieldTyp, fieldVal) + } + } + + case reflect.Slice, reflect.Array: + if val.IsNil() || val.Len() == 0 { + return 0 + } + // Count each array/slice element + for i := 0; i < val.Len(); i++ { + itemVal := val.Index(i) + itemTyp := itemVal.Type() + + // Dereference pointer types + for itemTyp.Kind() == reflect.Ptr { + if itemVal.IsNil() { + break + } + itemTyp = itemTyp.Elem() + itemVal = itemVal.Elem() + } + + if !isNil(itemTyp, itemVal) { + count += countFieldsRecursive(itemTyp, itemVal) + } + } + + case reflect.String: + if val.String() != "" { + count = 1 + } + + case reflect.Bool: + // Bools always count as a field (even if false) + count = 1 + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if val.Int() != 0 { + count = 1 + } + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + if val.Uint() != 0 { + count = 1 + } + + case reflect.Float32, reflect.Float64: + if val.Float() != 0 { + count = 1 + } + + default: + // For any other type, if it's not zero, count it as 1 + if !val.IsZero() { + count = 1 + } + } + + return count +} diff --git a/internal/sdk/internal/utils/pathparams.go b/internal/sdk/internal/utils/pathparams.go index 440bb9d..bb474d0 100644 --- a/internal/sdk/internal/utils/pathparams.go +++ b/internal/sdk/internal/utils/pathparams.go @@ -11,8 +11,7 @@ import ( "strings" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/types" ) @@ -114,6 +113,16 @@ func getSimplePathParams(parentName string, objType reflect.Type, objValue refle } pathParams[parentName] = strings.Join(ppVals, ",") case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + pathParams[parentName] = valToString(value) + } + // If not set or explicitly null, return nil (skip parameter) + return pathParams + } + if objValue.Len() == 0 { return nil } @@ -135,8 +144,6 @@ func getSimplePathParams(parentName string, objType reflect.Type, objValue refle pathParams[parentName] = valToString(objValue.Interface()) case big.Int: pathParams[parentName] = valToString(objValue.Interface()) - case decimal.Big: - pathParams[parentName] = valToString(objValue.Interface()) default: var ppVals []string for i := 0; i < objType.NumField(); i++ { diff --git a/internal/sdk/internal/utils/queryparams.go b/internal/sdk/internal/utils/queryparams.go index 0833b1c..885feec 100644 --- a/internal/sdk/internal/utils/queryparams.go +++ b/internal/sdk/internal/utils/queryparams.go @@ -12,8 +12,7 @@ import ( "reflect" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/types" ) @@ -43,10 +42,13 @@ func PopulateQueryParams(_ context.Context, req *http.Request, queryParams inter } func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { - queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), reflect.ValueOf(queryParams)) + queryParamsVal := reflect.ValueOf(queryParams) + if queryParamsVal.Kind() == reflect.Pointer && queryParamsVal.IsNil() { + return nil, nil + } + queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), queryParamsVal) globalsAlreadyPopulated := []string{} - for i := 0; i < queryParamsStructType.NumField(); i++ { fieldType := queryParamsStructType.Field(i) valType := queryParamsValType.Field(i) @@ -157,6 +159,16 @@ func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue refl switch objValue.Kind() { case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + values.Add(tag.ParamName, valToString(value)) + } + // If not set or explicitly null, skip adding to values + return values + } + populateDeepObjectParamsMap(values, tag.ParamName, objValue) case reflect.Struct: populateDeepObjectParamsStruct(values, tag.ParamName, objValue) @@ -235,7 +247,7 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru populateDeepObjectParamsMap(qsValues, scope, fieldValue) case reflect.Struct: switch fieldValue.Type() { - case reflect.TypeOf(big.Int{}), reflect.TypeOf(decimal.Big{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): + case reflect.TypeOf(big.Int{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): qsValues.Add(scope, valToString(fieldValue.Interface())) continue diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index 8622ec5..775b65b 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -14,6 +14,8 @@ import ( "path/filepath" "reflect" "regexp" + + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/optionalnullable" ) const ( @@ -340,6 +342,17 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { } } case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(requestValType); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + dataValues.Set(fieldName, valToString(value)) + } + // If not set or explicitly null, skip adding to form + break + } + + // Handle regular map for _, k := range requestValType.MapKeys() { v := requestValType.MapIndex(k) dataValues.Set(fmt.Sprintf("%v", k.Interface()), valToString(v.Interface())) diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index ea624e7..0415b53 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -14,8 +14,6 @@ import ( "strconv" "strings" "time" - - "github.com/ericlagergren/decimal" ) const ( @@ -183,8 +181,6 @@ func valToString(val interface{}) string { return v.Format(time.RFC3339Nano) case big.Int: return v.String() - case decimal.Big: - return v.String() default: return fmt.Sprintf("%v", v) } @@ -245,6 +241,21 @@ func isNil(typ reflect.Type, val reflect.Value) bool { return false } +func isEmptyContainer(typ reflect.Type, val reflect.Value) bool { + if isNil(typ, val) { + return true + } + + switch typ.Kind() { + case reflect.Slice, reflect.Array: + return val.Len() == 0 + case reflect.Map: + return val.Len() == 0 + default: + return false + } +} + func contains(arr []string, str string) bool { for _, a := range arr { if a == str { diff --git a/internal/sdk/models/operations/changereasonstatus.go b/internal/sdk/models/operations/changereasonstatus.go index 72e457e..8be7a67 100644 --- a/internal/sdk/models/operations/changereasonstatus.go +++ b/internal/sdk/models/operations/changereasonstatus.go @@ -13,18 +13,18 @@ type ChangeReasonStatusRequest struct { ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` } -func (o *ChangeReasonStatusRequest) GetChangeReasonStatusReq() *shared.ChangeReasonStatusReq { - if o == nil { +func (c *ChangeReasonStatusRequest) GetChangeReasonStatusReq() *shared.ChangeReasonStatusReq { + if c == nil { return nil } - return o.ChangeReasonStatusReq + return c.ChangeReasonStatusReq } -func (o *ChangeReasonStatusRequest) GetReasonID() string { - if o == nil { +func (c *ChangeReasonStatusRequest) GetReasonID() string { + if c == nil { return "" } - return o.ReasonID + return c.ReasonID } type ChangeReasonStatusResponse struct { @@ -38,30 +38,30 @@ type ChangeReasonStatusResponse struct { RawResponse *http.Response } -func (o *ChangeReasonStatusResponse) GetContentType() string { - if o == nil { +func (c *ChangeReasonStatusResponse) GetContentType() string { + if c == nil { return "" } - return o.ContentType + return c.ContentType } -func (o *ChangeReasonStatusResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (c *ChangeReasonStatusResponse) GetErrorResp() *shared.ErrorResp { + if c == nil { return nil } - return o.ErrorResp + return c.ErrorResp } -func (o *ChangeReasonStatusResponse) GetStatusCode() int { - if o == nil { +func (c *ChangeReasonStatusResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *ChangeReasonStatusResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *ChangeReasonStatusResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } diff --git a/internal/sdk/models/operations/createclosingreason.go b/internal/sdk/models/operations/createclosingreason.go index abbfad6..530d5c5 100644 --- a/internal/sdk/models/operations/createclosingreason.go +++ b/internal/sdk/models/operations/createclosingreason.go @@ -18,30 +18,30 @@ type CreateClosingReasonResponse struct { RawResponse *http.Response } -func (o *CreateClosingReasonResponse) GetClosingReason() *shared.ClosingReason { - if o == nil { +func (c *CreateClosingReasonResponse) GetClosingReason() *shared.ClosingReason { + if c == nil { return nil } - return o.ClosingReason + return c.ClosingReason } -func (o *CreateClosingReasonResponse) GetContentType() string { - if o == nil { +func (c *CreateClosingReasonResponse) GetContentType() string { + if c == nil { return "" } - return o.ContentType + return c.ContentType } -func (o *CreateClosingReasonResponse) GetStatusCode() int { - if o == nil { +func (c *CreateClosingReasonResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *CreateClosingReasonResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *CreateClosingReasonResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } diff --git a/internal/sdk/models/operations/createdefinition.go b/internal/sdk/models/operations/createdefinition.go index c435e88..832f97b 100644 --- a/internal/sdk/models/operations/createdefinition.go +++ b/internal/sdk/models/operations/createdefinition.go @@ -20,37 +20,37 @@ type CreateDefinitionResponse struct { WorkflowDefinition *shared.WorkflowDefinition } -func (o *CreateDefinitionResponse) GetContentType() string { - if o == nil { +func (c *CreateDefinitionResponse) GetContentType() string { + if c == nil { return "" } - return o.ContentType + return c.ContentType } -func (o *CreateDefinitionResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (c *CreateDefinitionResponse) GetErrorResp() *shared.ErrorResp { + if c == nil { return nil } - return o.ErrorResp + return c.ErrorResp } -func (o *CreateDefinitionResponse) GetStatusCode() int { - if o == nil { +func (c *CreateDefinitionResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *CreateDefinitionResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *CreateDefinitionResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } -func (o *CreateDefinitionResponse) GetWorkflowDefinition() *shared.WorkflowDefinition { - if o == nil { +func (c *CreateDefinitionResponse) GetWorkflowDefinition() *shared.WorkflowDefinition { + if c == nil { return nil } - return o.WorkflowDefinition + return c.WorkflowDefinition } diff --git a/internal/sdk/models/operations/createflowtemplate.go b/internal/sdk/models/operations/createflowtemplate.go index f88ddf5..fbcdcff 100644 --- a/internal/sdk/models/operations/createflowtemplate.go +++ b/internal/sdk/models/operations/createflowtemplate.go @@ -20,37 +20,37 @@ type CreateFlowTemplateResponse struct { RawResponse *http.Response } -func (o *CreateFlowTemplateResponse) GetContentType() string { - if o == nil { +func (c *CreateFlowTemplateResponse) GetContentType() string { + if c == nil { return "" } - return o.ContentType + return c.ContentType } -func (o *CreateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (c *CreateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if c == nil { return nil } - return o.ErrorResp + return c.ErrorResp } -func (o *CreateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { - if o == nil { +func (c *CreateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if c == nil { return nil } - return o.FlowTemplate + return c.FlowTemplate } -func (o *CreateFlowTemplateResponse) GetStatusCode() int { - if o == nil { +func (c *CreateFlowTemplateResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *CreateFlowTemplateResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *CreateFlowTemplateResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } diff --git a/internal/sdk/models/operations/deleteclosingreason.go b/internal/sdk/models/operations/deleteclosingreason.go index 5fdfff7..5f4dc5d 100644 --- a/internal/sdk/models/operations/deleteclosingreason.go +++ b/internal/sdk/models/operations/deleteclosingreason.go @@ -12,11 +12,11 @@ type DeleteClosingReasonRequest struct { ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` } -func (o *DeleteClosingReasonRequest) GetReasonID() string { - if o == nil { +func (d *DeleteClosingReasonRequest) GetReasonID() string { + if d == nil { return "" } - return o.ReasonID + return d.ReasonID } type DeleteClosingReasonResponse struct { @@ -32,37 +32,37 @@ type DeleteClosingReasonResponse struct { RawResponse *http.Response } -func (o *DeleteClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { - if o == nil { +func (d *DeleteClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if d == nil { return nil } - return o.ClosingReasonNotFoundResp + return d.ClosingReasonNotFoundResp } -func (o *DeleteClosingReasonResponse) GetContentType() string { - if o == nil { +func (d *DeleteClosingReasonResponse) GetContentType() string { + if d == nil { return "" } - return o.ContentType + return d.ContentType } -func (o *DeleteClosingReasonResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (d *DeleteClosingReasonResponse) GetErrorResp() *shared.ErrorResp { + if d == nil { return nil } - return o.ErrorResp + return d.ErrorResp } -func (o *DeleteClosingReasonResponse) GetStatusCode() int { - if o == nil { +func (d *DeleteClosingReasonResponse) GetStatusCode() int { + if d == nil { return 0 } - return o.StatusCode + return d.StatusCode } -func (o *DeleteClosingReasonResponse) GetRawResponse() *http.Response { - if o == nil { +func (d *DeleteClosingReasonResponse) GetRawResponse() *http.Response { + if d == nil { return nil } - return o.RawResponse + return d.RawResponse } diff --git a/internal/sdk/models/operations/deletedefinition.go b/internal/sdk/models/operations/deletedefinition.go index d553a6b..a4009e9 100644 --- a/internal/sdk/models/operations/deletedefinition.go +++ b/internal/sdk/models/operations/deletedefinition.go @@ -12,11 +12,11 @@ type DeleteDefinitionRequest struct { DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` } -func (o *DeleteDefinitionRequest) GetDefinitionID() string { - if o == nil { +func (d *DeleteDefinitionRequest) GetDefinitionID() string { + if d == nil { return "" } - return o.DefinitionID + return d.DefinitionID } type DeleteDefinitionResponse struct { @@ -30,30 +30,30 @@ type DeleteDefinitionResponse struct { RawResponse *http.Response } -func (o *DeleteDefinitionResponse) GetContentType() string { - if o == nil { +func (d *DeleteDefinitionResponse) GetContentType() string { + if d == nil { return "" } - return o.ContentType + return d.ContentType } -func (o *DeleteDefinitionResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (d *DeleteDefinitionResponse) GetErrorResp() *shared.ErrorResp { + if d == nil { return nil } - return o.ErrorResp + return d.ErrorResp } -func (o *DeleteDefinitionResponse) GetStatusCode() int { - if o == nil { +func (d *DeleteDefinitionResponse) GetStatusCode() int { + if d == nil { return 0 } - return o.StatusCode + return d.StatusCode } -func (o *DeleteDefinitionResponse) GetRawResponse() *http.Response { - if o == nil { +func (d *DeleteDefinitionResponse) GetRawResponse() *http.Response { + if d == nil { return nil } - return o.RawResponse + return d.RawResponse } diff --git a/internal/sdk/models/operations/deleteflowtemplate.go b/internal/sdk/models/operations/deleteflowtemplate.go index e146494..e69b415 100644 --- a/internal/sdk/models/operations/deleteflowtemplate.go +++ b/internal/sdk/models/operations/deleteflowtemplate.go @@ -12,11 +12,11 @@ type DeleteFlowTemplateRequest struct { FlowID string `pathParam:"style=simple,explode=false,name=flowId"` } -func (o *DeleteFlowTemplateRequest) GetFlowID() string { - if o == nil { +func (d *DeleteFlowTemplateRequest) GetFlowID() string { + if d == nil { return "" } - return o.FlowID + return d.FlowID } type DeleteFlowTemplateResponse struct { @@ -30,30 +30,30 @@ type DeleteFlowTemplateResponse struct { RawResponse *http.Response } -func (o *DeleteFlowTemplateResponse) GetContentType() string { - if o == nil { +func (d *DeleteFlowTemplateResponse) GetContentType() string { + if d == nil { return "" } - return o.ContentType + return d.ContentType } -func (o *DeleteFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (d *DeleteFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if d == nil { return nil } - return o.ErrorResp + return d.ErrorResp } -func (o *DeleteFlowTemplateResponse) GetStatusCode() int { - if o == nil { +func (d *DeleteFlowTemplateResponse) GetStatusCode() int { + if d == nil { return 0 } - return o.StatusCode + return d.StatusCode } -func (o *DeleteFlowTemplateResponse) GetRawResponse() *http.Response { - if o == nil { +func (d *DeleteFlowTemplateResponse) GetRawResponse() *http.Response { + if d == nil { return nil } - return o.RawResponse + return d.RawResponse } diff --git a/internal/sdk/models/operations/duplicateflowtemplate.go b/internal/sdk/models/operations/duplicateflowtemplate.go new file mode 100644 index 0000000..19f01d4 --- /dev/null +++ b/internal/sdk/models/operations/duplicateflowtemplate.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" + "net/http" +) + +type DuplicateFlowTemplateRequest struct { + FlowID string `pathParam:"style=simple,explode=false,name=flowId"` +} + +func (d *DuplicateFlowTemplateRequest) GetFlowID() string { + if d == nil { + return "" + } + return d.FlowID +} + +type DuplicateFlowTemplateResponse struct { + // HTTP response content type for this operation + ContentType string + // Validation Errors + ErrorResp *shared.ErrorResp + // Flow template has been duplicated successfully + FlowTemplate *shared.FlowTemplate + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (d *DuplicateFlowTemplateResponse) GetContentType() string { + if d == nil { + return "" + } + return d.ContentType +} + +func (d *DuplicateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if d == nil { + return nil + } + return d.ErrorResp +} + +func (d *DuplicateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if d == nil { + return nil + } + return d.FlowTemplate +} + +func (d *DuplicateFlowTemplateResponse) GetStatusCode() int { + if d == nil { + return 0 + } + return d.StatusCode +} + +func (d *DuplicateFlowTemplateResponse) GetRawResponse() *http.Response { + if d == nil { + return nil + } + return d.RawResponse +} diff --git a/internal/sdk/models/operations/getallclosingreasons.go b/internal/sdk/models/operations/getallclosingreasons.go index 10f6b8c..fc9ef8f 100644 --- a/internal/sdk/models/operations/getallclosingreasons.go +++ b/internal/sdk/models/operations/getallclosingreasons.go @@ -12,11 +12,11 @@ type GetAllClosingReasonsRequest struct { IncludeInactive *bool `queryParam:"style=form,explode=true,name=includeInactive"` } -func (o *GetAllClosingReasonsRequest) GetIncludeInactive() *bool { - if o == nil { +func (g *GetAllClosingReasonsRequest) GetIncludeInactive() *bool { + if g == nil { return nil } - return o.IncludeInactive + return g.IncludeInactive } type GetAllClosingReasonsResponse struct { @@ -30,30 +30,30 @@ type GetAllClosingReasonsResponse struct { RawResponse *http.Response } -func (o *GetAllClosingReasonsResponse) GetClosingReasons() *shared.ClosingReasons { - if o == nil { +func (g *GetAllClosingReasonsResponse) GetClosingReasons() *shared.ClosingReasons { + if g == nil { return nil } - return o.ClosingReasons + return g.ClosingReasons } -func (o *GetAllClosingReasonsResponse) GetContentType() string { - if o == nil { +func (g *GetAllClosingReasonsResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetAllClosingReasonsResponse) GetStatusCode() int { - if o == nil { +func (g *GetAllClosingReasonsResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetAllClosingReasonsResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetAllClosingReasonsResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } diff --git a/internal/sdk/models/operations/getclosingreason.go b/internal/sdk/models/operations/getclosingreason.go index 39ba554..eb42c04 100644 --- a/internal/sdk/models/operations/getclosingreason.go +++ b/internal/sdk/models/operations/getclosingreason.go @@ -12,11 +12,11 @@ type GetClosingReasonRequest struct { ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` } -func (o *GetClosingReasonRequest) GetReasonID() string { - if o == nil { +func (g *GetClosingReasonRequest) GetReasonID() string { + if g == nil { return "" } - return o.ReasonID + return g.ReasonID } type GetClosingReasonResponse struct { @@ -34,44 +34,44 @@ type GetClosingReasonResponse struct { RawResponse *http.Response } -func (o *GetClosingReasonResponse) GetClosingReason() *shared.ClosingReason { - if o == nil { +func (g *GetClosingReasonResponse) GetClosingReason() *shared.ClosingReason { + if g == nil { return nil } - return o.ClosingReason + return g.ClosingReason } -func (o *GetClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { - if o == nil { +func (g *GetClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if g == nil { return nil } - return o.ClosingReasonNotFoundResp + return g.ClosingReasonNotFoundResp } -func (o *GetClosingReasonResponse) GetContentType() string { - if o == nil { +func (g *GetClosingReasonResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetClosingReasonResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (g *GetClosingReasonResponse) GetErrorResp() *shared.ErrorResp { + if g == nil { return nil } - return o.ErrorResp + return g.ErrorResp } -func (o *GetClosingReasonResponse) GetStatusCode() int { - if o == nil { +func (g *GetClosingReasonResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetClosingReasonResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetClosingReasonResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } diff --git a/internal/sdk/models/operations/getclosingreasonv1.go b/internal/sdk/models/operations/getclosingreasonv1.go index 2ff49e1..81a4a63 100644 --- a/internal/sdk/models/operations/getclosingreasonv1.go +++ b/internal/sdk/models/operations/getclosingreasonv1.go @@ -12,11 +12,11 @@ type GetClosingReasonV1Request struct { ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` } -func (o *GetClosingReasonV1Request) GetReasonID() string { - if o == nil { +func (g *GetClosingReasonV1Request) GetReasonID() string { + if g == nil { return "" } - return o.ReasonID + return g.ReasonID } type GetClosingReasonV1Response struct { @@ -34,44 +34,44 @@ type GetClosingReasonV1Response struct { RawResponse *http.Response } -func (o *GetClosingReasonV1Response) GetClosingReason() *shared.ClosingReason { - if o == nil { +func (g *GetClosingReasonV1Response) GetClosingReason() *shared.ClosingReason { + if g == nil { return nil } - return o.ClosingReason + return g.ClosingReason } -func (o *GetClosingReasonV1Response) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { - if o == nil { +func (g *GetClosingReasonV1Response) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if g == nil { return nil } - return o.ClosingReasonNotFoundResp + return g.ClosingReasonNotFoundResp } -func (o *GetClosingReasonV1Response) GetContentType() string { - if o == nil { +func (g *GetClosingReasonV1Response) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetClosingReasonV1Response) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (g *GetClosingReasonV1Response) GetErrorResp() *shared.ErrorResp { + if g == nil { return nil } - return o.ErrorResp + return g.ErrorResp } -func (o *GetClosingReasonV1Response) GetStatusCode() int { - if o == nil { +func (g *GetClosingReasonV1Response) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetClosingReasonV1Response) GetRawResponse() *http.Response { - if o == nil { +func (g *GetClosingReasonV1Response) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } diff --git a/internal/sdk/models/operations/getdefinition.go b/internal/sdk/models/operations/getdefinition.go index 94a3f32..032fccf 100644 --- a/internal/sdk/models/operations/getdefinition.go +++ b/internal/sdk/models/operations/getdefinition.go @@ -12,11 +12,11 @@ type GetDefinitionRequest struct { DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` } -func (o *GetDefinitionRequest) GetDefinitionID() string { - if o == nil { +func (g *GetDefinitionRequest) GetDefinitionID() string { + if g == nil { return "" } - return o.DefinitionID + return g.DefinitionID } type GetDefinitionResponse struct { @@ -34,44 +34,44 @@ type GetDefinitionResponse struct { WorkflowDefinition *shared.WorkflowDefinition } -func (o *GetDefinitionResponse) GetContentType() string { - if o == nil { +func (g *GetDefinitionResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetDefinitionResponse) GetDefinitionNotFoundResp() *shared.DefinitionNotFoundResp { - if o == nil { +func (g *GetDefinitionResponse) GetDefinitionNotFoundResp() *shared.DefinitionNotFoundResp { + if g == nil { return nil } - return o.DefinitionNotFoundResp + return g.DefinitionNotFoundResp } -func (o *GetDefinitionResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (g *GetDefinitionResponse) GetErrorResp() *shared.ErrorResp { + if g == nil { return nil } - return o.ErrorResp + return g.ErrorResp } -func (o *GetDefinitionResponse) GetStatusCode() int { - if o == nil { +func (g *GetDefinitionResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetDefinitionResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetDefinitionResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetDefinitionResponse) GetWorkflowDefinition() *shared.WorkflowDefinition { - if o == nil { +func (g *GetDefinitionResponse) GetWorkflowDefinition() *shared.WorkflowDefinition { + if g == nil { return nil } - return o.WorkflowDefinition + return g.WorkflowDefinition } diff --git a/internal/sdk/models/operations/getdefinitions.go b/internal/sdk/models/operations/getdefinitions.go index e479278..318c757 100644 --- a/internal/sdk/models/operations/getdefinitions.go +++ b/internal/sdk/models/operations/getdefinitions.go @@ -20,37 +20,37 @@ type GetDefinitionsResponse struct { Classes []shared.WorkflowDefinition } -func (o *GetDefinitionsResponse) GetContentType() string { - if o == nil { +func (g *GetDefinitionsResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetDefinitionsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (g *GetDefinitionsResponse) GetErrorResp() *shared.ErrorResp { + if g == nil { return nil } - return o.ErrorResp + return g.ErrorResp } -func (o *GetDefinitionsResponse) GetStatusCode() int { - if o == nil { +func (g *GetDefinitionsResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetDefinitionsResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetDefinitionsResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetDefinitionsResponse) GetClasses() []shared.WorkflowDefinition { - if o == nil { +func (g *GetDefinitionsResponse) GetClasses() []shared.WorkflowDefinition { + if g == nil { return nil } - return o.Classes + return g.Classes } diff --git a/internal/sdk/models/operations/getflowtemplate.go b/internal/sdk/models/operations/getflowtemplate.go index f956ebe..e2a90ef 100644 --- a/internal/sdk/models/operations/getflowtemplate.go +++ b/internal/sdk/models/operations/getflowtemplate.go @@ -11,11 +11,11 @@ type GetFlowTemplateRequest struct { FlowID string `pathParam:"style=simple,explode=false,name=flowId"` } -func (o *GetFlowTemplateRequest) GetFlowID() string { - if o == nil { +func (g *GetFlowTemplateRequest) GetFlowID() string { + if g == nil { return "" } - return o.FlowID + return g.FlowID } type GetFlowTemplateResponse struct { @@ -33,44 +33,44 @@ type GetFlowTemplateResponse struct { RawResponse *http.Response } -func (o *GetFlowTemplateResponse) GetContentType() string { - if o == nil { +func (g *GetFlowTemplateResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetFlowTemplateResponse) GetDefinitionNotFoundResp() *shared.DefinitionNotFoundResp { - if o == nil { +func (g *GetFlowTemplateResponse) GetDefinitionNotFoundResp() *shared.DefinitionNotFoundResp { + if g == nil { return nil } - return o.DefinitionNotFoundResp + return g.DefinitionNotFoundResp } -func (o *GetFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (g *GetFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if g == nil { return nil } - return o.ErrorResp + return g.ErrorResp } -func (o *GetFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { - if o == nil { +func (g *GetFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if g == nil { return nil } - return o.FlowTemplate + return g.FlowTemplate } -func (o *GetFlowTemplateResponse) GetStatusCode() int { - if o == nil { +func (g *GetFlowTemplateResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetFlowTemplateResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetFlowTemplateResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } diff --git a/internal/sdk/models/operations/getmaxallowedlimit.go b/internal/sdk/models/operations/getmaxallowedlimit.go index d9703ef..a22e23c 100644 --- a/internal/sdk/models/operations/getmaxallowedlimit.go +++ b/internal/sdk/models/operations/getmaxallowedlimit.go @@ -20,37 +20,37 @@ type GetMaxAllowedLimitResponse struct { RawResponse *http.Response } -func (o *GetMaxAllowedLimitResponse) GetContentType() string { - if o == nil { +func (g *GetMaxAllowedLimitResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetMaxAllowedLimitResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (g *GetMaxAllowedLimitResponse) GetErrorResp() *shared.ErrorResp { + if g == nil { return nil } - return o.ErrorResp + return g.ErrorResp } -func (o *GetMaxAllowedLimitResponse) GetMaxAllowedLimit() *shared.MaxAllowedLimit { - if o == nil { +func (g *GetMaxAllowedLimitResponse) GetMaxAllowedLimit() *shared.MaxAllowedLimit { + if g == nil { return nil } - return o.MaxAllowedLimit + return g.MaxAllowedLimit } -func (o *GetMaxAllowedLimitResponse) GetStatusCode() int { - if o == nil { +func (g *GetMaxAllowedLimitResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetMaxAllowedLimitResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetMaxAllowedLimitResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } diff --git a/internal/sdk/models/operations/getworkflowclosingreasons.go b/internal/sdk/models/operations/getworkflowclosingreasons.go index e9c6d00..86ba3b6 100644 --- a/internal/sdk/models/operations/getworkflowclosingreasons.go +++ b/internal/sdk/models/operations/getworkflowclosingreasons.go @@ -12,11 +12,11 @@ type GetWorkflowClosingReasonsRequest struct { DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` } -func (o *GetWorkflowClosingReasonsRequest) GetDefinitionID() string { - if o == nil { +func (g *GetWorkflowClosingReasonsRequest) GetDefinitionID() string { + if g == nil { return "" } - return o.DefinitionID + return g.DefinitionID } type GetWorkflowClosingReasonsResponse struct { @@ -30,30 +30,30 @@ type GetWorkflowClosingReasonsResponse struct { RawResponse *http.Response } -func (o *GetWorkflowClosingReasonsResponse) GetClosingReasonsIds() *shared.ClosingReasonsIds { - if o == nil { +func (g *GetWorkflowClosingReasonsResponse) GetClosingReasonsIds() *shared.ClosingReasonsIds { + if g == nil { return nil } - return o.ClosingReasonsIds + return g.ClosingReasonsIds } -func (o *GetWorkflowClosingReasonsResponse) GetContentType() string { - if o == nil { +func (g *GetWorkflowClosingReasonsResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetWorkflowClosingReasonsResponse) GetStatusCode() int { - if o == nil { +func (g *GetWorkflowClosingReasonsResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetWorkflowClosingReasonsResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetWorkflowClosingReasonsResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } diff --git a/internal/sdk/models/operations/listflowtemplates.go b/internal/sdk/models/operations/listflowtemplates.go index 4570a13..7d2ef93 100644 --- a/internal/sdk/models/operations/listflowtemplates.go +++ b/internal/sdk/models/operations/listflowtemplates.go @@ -3,10 +3,77 @@ package operations import ( + "encoding/json" + "fmt" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" "net/http" ) +// TriggerType - Type of trigger for whom to filter flow templates +type TriggerType string + +const ( + TriggerTypeAutomation TriggerType = "automation" + TriggerTypeManual TriggerType = "manual" + TriggerTypeJourneySubmission TriggerType = "journey_submission" +) + +func (e TriggerType) ToPointer() *TriggerType { + return &e +} +func (e *TriggerType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "automation": + fallthrough + case "manual": + fallthrough + case "journey_submission": + *e = TriggerType(v) + return nil + default: + return fmt.Errorf("invalid value for TriggerType: %v", v) + } +} + +type ListFlowTemplatesRequest struct { + // Schema of the trigger source to filter flow templates. This parameter only makes sense when **trigger_type** is `manual` + // + TriggerSchema *string `queryParam:"style=form,explode=true,name=trigger_schema"` + // Id of the trigger source to filter flow templates. Interpretation depends on **trigger_type**: + // - **automation**: use an `{automation_flow_id}` value + // - **journey_submission**: use a `{journey_id}` value + // - **manual**: this parameter is ignored; you can optionally filter by `{trigger_schema}` + // + TriggerSourceID *string `queryParam:"style=form,explode=true,name=trigger_source_id"` + // Type of trigger for whom to filter flow templates + TriggerType *TriggerType `queryParam:"style=form,explode=true,name=trigger_type"` +} + +func (l *ListFlowTemplatesRequest) GetTriggerSchema() *string { + if l == nil { + return nil + } + return l.TriggerSchema +} + +func (l *ListFlowTemplatesRequest) GetTriggerSourceID() *string { + if l == nil { + return nil + } + return l.TriggerSourceID +} + +func (l *ListFlowTemplatesRequest) GetTriggerType() *TriggerType { + if l == nil { + return nil + } + return l.TriggerType +} + type ListFlowTemplatesResponse struct { // HTTP response content type for this operation ContentType string @@ -20,37 +87,37 @@ type ListFlowTemplatesResponse struct { RawResponse *http.Response } -func (o *ListFlowTemplatesResponse) GetContentType() string { - if o == nil { +func (l *ListFlowTemplatesResponse) GetContentType() string { + if l == nil { return "" } - return o.ContentType + return l.ContentType } -func (o *ListFlowTemplatesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (l *ListFlowTemplatesResponse) GetErrorResp() *shared.ErrorResp { + if l == nil { return nil } - return o.ErrorResp + return l.ErrorResp } -func (o *ListFlowTemplatesResponse) GetFlowTemplatesList() *shared.FlowTemplatesList { - if o == nil { +func (l *ListFlowTemplatesResponse) GetFlowTemplatesList() *shared.FlowTemplatesList { + if l == nil { return nil } - return o.FlowTemplatesList + return l.FlowTemplatesList } -func (o *ListFlowTemplatesResponse) GetStatusCode() int { - if o == nil { +func (l *ListFlowTemplatesResponse) GetStatusCode() int { + if l == nil { return 0 } - return o.StatusCode + return l.StatusCode } -func (o *ListFlowTemplatesResponse) GetRawResponse() *http.Response { - if o == nil { +func (l *ListFlowTemplatesResponse) GetRawResponse() *http.Response { + if l == nil { return nil } - return o.RawResponse + return l.RawResponse } diff --git a/internal/sdk/models/operations/searchflowtemplates.go b/internal/sdk/models/operations/searchflowtemplates.go new file mode 100644 index 0000000..bbee13d --- /dev/null +++ b/internal/sdk/models/operations/searchflowtemplates.go @@ -0,0 +1,76 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" + "net/http" +) + +// SearchFlowTemplatesResponseBody - Success - flow templates loaded with success. Empty array if customer has no flows defined. +type SearchFlowTemplatesResponseBody struct { + Hits *float64 `json:"hits,omitempty"` + Results []shared.FlowTemplate `json:"results,omitempty"` +} + +func (s *SearchFlowTemplatesResponseBody) GetHits() *float64 { + if s == nil { + return nil + } + return s.Hits +} + +func (s *SearchFlowTemplatesResponseBody) GetResults() []shared.FlowTemplate { + if s == nil { + return nil + } + return s.Results +} + +type SearchFlowTemplatesResponse struct { + // HTTP response content type for this operation + ContentType string + // Other errors + ErrorResp *shared.ErrorResp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // Success - flow templates loaded with success. Empty array if customer has no flows defined. + Object *SearchFlowTemplatesResponseBody +} + +func (s *SearchFlowTemplatesResponse) GetContentType() string { + if s == nil { + return "" + } + return s.ContentType +} + +func (s *SearchFlowTemplatesResponse) GetErrorResp() *shared.ErrorResp { + if s == nil { + return nil + } + return s.ErrorResp +} + +func (s *SearchFlowTemplatesResponse) GetStatusCode() int { + if s == nil { + return 0 + } + return s.StatusCode +} + +func (s *SearchFlowTemplatesResponse) GetRawResponse() *http.Response { + if s == nil { + return nil + } + return s.RawResponse +} + +func (s *SearchFlowTemplatesResponse) GetObject() *SearchFlowTemplatesResponseBody { + if s == nil { + return nil + } + return s.Object +} diff --git a/internal/sdk/models/operations/setworkflowclosingreasons.go b/internal/sdk/models/operations/setworkflowclosingreasons.go index e676d5d..f5a5b04 100644 --- a/internal/sdk/models/operations/setworkflowclosingreasons.go +++ b/internal/sdk/models/operations/setworkflowclosingreasons.go @@ -14,18 +14,18 @@ type SetWorkflowClosingReasonsRequest struct { DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` } -func (o *SetWorkflowClosingReasonsRequest) GetClosingReasonsIds() shared.ClosingReasonsIds { - if o == nil { +func (s *SetWorkflowClosingReasonsRequest) GetClosingReasonsIds() shared.ClosingReasonsIds { + if s == nil { return shared.ClosingReasonsIds{} } - return o.ClosingReasonsIds + return s.ClosingReasonsIds } -func (o *SetWorkflowClosingReasonsRequest) GetDefinitionID() string { - if o == nil { +func (s *SetWorkflowClosingReasonsRequest) GetDefinitionID() string { + if s == nil { return "" } - return o.DefinitionID + return s.DefinitionID } type SetWorkflowClosingReasonsResponse struct { @@ -37,23 +37,23 @@ type SetWorkflowClosingReasonsResponse struct { RawResponse *http.Response } -func (o *SetWorkflowClosingReasonsResponse) GetContentType() string { - if o == nil { +func (s *SetWorkflowClosingReasonsResponse) GetContentType() string { + if s == nil { return "" } - return o.ContentType + return s.ContentType } -func (o *SetWorkflowClosingReasonsResponse) GetStatusCode() int { - if o == nil { +func (s *SetWorkflowClosingReasonsResponse) GetStatusCode() int { + if s == nil { return 0 } - return o.StatusCode + return s.StatusCode } -func (o *SetWorkflowClosingReasonsResponse) GetRawResponse() *http.Response { - if o == nil { +func (s *SetWorkflowClosingReasonsResponse) GetRawResponse() *http.Response { + if s == nil { return nil } - return o.RawResponse + return s.RawResponse } diff --git a/internal/sdk/models/operations/updateclosingreason.go b/internal/sdk/models/operations/updateclosingreason.go index b5cfd90..84f07b6 100644 --- a/internal/sdk/models/operations/updateclosingreason.go +++ b/internal/sdk/models/operations/updateclosingreason.go @@ -14,18 +14,18 @@ type UpdateClosingReasonRequest struct { ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` } -func (o *UpdateClosingReasonRequest) GetClosingReason() shared.ClosingReasonInput { - if o == nil { +func (u *UpdateClosingReasonRequest) GetClosingReason() shared.ClosingReasonInput { + if u == nil { return shared.ClosingReasonInput{} } - return o.ClosingReason + return u.ClosingReason } -func (o *UpdateClosingReasonRequest) GetReasonID() string { - if o == nil { +func (u *UpdateClosingReasonRequest) GetReasonID() string { + if u == nil { return "" } - return o.ReasonID + return u.ReasonID } type UpdateClosingReasonResponse struct { @@ -43,44 +43,44 @@ type UpdateClosingReasonResponse struct { RawResponse *http.Response } -func (o *UpdateClosingReasonResponse) GetClosingReason() *shared.ClosingReason { - if o == nil { +func (u *UpdateClosingReasonResponse) GetClosingReason() *shared.ClosingReason { + if u == nil { return nil } - return o.ClosingReason + return u.ClosingReason } -func (o *UpdateClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { - if o == nil { +func (u *UpdateClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if u == nil { return nil } - return o.ClosingReasonNotFoundResp + return u.ClosingReasonNotFoundResp } -func (o *UpdateClosingReasonResponse) GetContentType() string { - if o == nil { +func (u *UpdateClosingReasonResponse) GetContentType() string { + if u == nil { return "" } - return o.ContentType + return u.ContentType } -func (o *UpdateClosingReasonResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (u *UpdateClosingReasonResponse) GetErrorResp() *shared.ErrorResp { + if u == nil { return nil } - return o.ErrorResp + return u.ErrorResp } -func (o *UpdateClosingReasonResponse) GetStatusCode() int { - if o == nil { +func (u *UpdateClosingReasonResponse) GetStatusCode() int { + if u == nil { return 0 } - return o.StatusCode + return u.StatusCode } -func (o *UpdateClosingReasonResponse) GetRawResponse() *http.Response { - if o == nil { +func (u *UpdateClosingReasonResponse) GetRawResponse() *http.Response { + if u == nil { return nil } - return o.RawResponse + return u.RawResponse } diff --git a/internal/sdk/models/operations/updatedefinition.go b/internal/sdk/models/operations/updatedefinition.go index 8a087da..7f3867f 100644 --- a/internal/sdk/models/operations/updatedefinition.go +++ b/internal/sdk/models/operations/updatedefinition.go @@ -14,18 +14,18 @@ type UpdateDefinitionRequest struct { DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` } -func (o *UpdateDefinitionRequest) GetWorkflowDefinition() shared.WorkflowDefinition { - if o == nil { +func (u *UpdateDefinitionRequest) GetWorkflowDefinition() shared.WorkflowDefinition { + if u == nil { return shared.WorkflowDefinition{} } - return o.WorkflowDefinition + return u.WorkflowDefinition } -func (o *UpdateDefinitionRequest) GetDefinitionID() string { - if o == nil { +func (u *UpdateDefinitionRequest) GetDefinitionID() string { + if u == nil { return "" } - return o.DefinitionID + return u.DefinitionID } type UpdateDefinitionResponse struct { @@ -41,37 +41,37 @@ type UpdateDefinitionResponse struct { WorkflowDefinition *shared.WorkflowDefinition } -func (o *UpdateDefinitionResponse) GetContentType() string { - if o == nil { +func (u *UpdateDefinitionResponse) GetContentType() string { + if u == nil { return "" } - return o.ContentType + return u.ContentType } -func (o *UpdateDefinitionResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (u *UpdateDefinitionResponse) GetErrorResp() *shared.ErrorResp { + if u == nil { return nil } - return o.ErrorResp + return u.ErrorResp } -func (o *UpdateDefinitionResponse) GetStatusCode() int { - if o == nil { +func (u *UpdateDefinitionResponse) GetStatusCode() int { + if u == nil { return 0 } - return o.StatusCode + return u.StatusCode } -func (o *UpdateDefinitionResponse) GetRawResponse() *http.Response { - if o == nil { +func (u *UpdateDefinitionResponse) GetRawResponse() *http.Response { + if u == nil { return nil } - return o.RawResponse + return u.RawResponse } -func (o *UpdateDefinitionResponse) GetWorkflowDefinition() *shared.WorkflowDefinition { - if o == nil { +func (u *UpdateDefinitionResponse) GetWorkflowDefinition() *shared.WorkflowDefinition { + if u == nil { return nil } - return o.WorkflowDefinition + return u.WorkflowDefinition } diff --git a/internal/sdk/models/operations/updateflowtemplate.go b/internal/sdk/models/operations/updateflowtemplate.go index 6dedf27..a734a0e 100644 --- a/internal/sdk/models/operations/updateflowtemplate.go +++ b/internal/sdk/models/operations/updateflowtemplate.go @@ -13,18 +13,18 @@ type UpdateFlowTemplateRequest struct { FlowID string `pathParam:"style=simple,explode=false,name=flowId"` } -func (o *UpdateFlowTemplateRequest) GetFlowTemplate() shared.FlowTemplateInput { - if o == nil { +func (u *UpdateFlowTemplateRequest) GetFlowTemplate() shared.FlowTemplateInput { + if u == nil { return shared.FlowTemplateInput{} } - return o.FlowTemplate + return u.FlowTemplate } -func (o *UpdateFlowTemplateRequest) GetFlowID() string { - if o == nil { +func (u *UpdateFlowTemplateRequest) GetFlowID() string { + if u == nil { return "" } - return o.FlowID + return u.FlowID } type UpdateFlowTemplateResponse struct { @@ -40,37 +40,37 @@ type UpdateFlowTemplateResponse struct { RawResponse *http.Response } -func (o *UpdateFlowTemplateResponse) GetContentType() string { - if o == nil { +func (u *UpdateFlowTemplateResponse) GetContentType() string { + if u == nil { return "" } - return o.ContentType + return u.ContentType } -func (o *UpdateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { +func (u *UpdateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if u == nil { return nil } - return o.ErrorResp + return u.ErrorResp } -func (o *UpdateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { - if o == nil { +func (u *UpdateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if u == nil { return nil } - return o.FlowTemplate + return u.FlowTemplate } -func (o *UpdateFlowTemplateResponse) GetStatusCode() int { - if o == nil { +func (u *UpdateFlowTemplateResponse) GetStatusCode() int { + if u == nil { return 0 } - return o.StatusCode + return u.StatusCode } -func (o *UpdateFlowTemplateResponse) GetRawResponse() *http.Response { - if o == nil { +func (u *UpdateFlowTemplateResponse) GetRawResponse() *http.Response { + if u == nil { return nil } - return o.RawResponse + return u.RawResponse } diff --git a/internal/sdk/models/shared/actionschedule.go b/internal/sdk/models/shared/actionschedule.go index 4715fab..ee02245 100644 --- a/internal/sdk/models/shared/actionschedule.go +++ b/internal/sdk/models/shared/actionschedule.go @@ -17,9 +17,9 @@ const ( ) type ActionSchedule struct { - ImmediateSchedule *ImmediateSchedule `queryParam:"inline"` - DelayedSchedule *DelayedSchedule `queryParam:"inline"` - RelativeSchedule *RelativeSchedule `queryParam:"inline"` + ImmediateSchedule *ImmediateSchedule `queryParam:"inline,name=ActionSchedule"` + DelayedSchedule *DelayedSchedule `queryParam:"inline,name=ActionSchedule"` + RelativeSchedule *RelativeSchedule `queryParam:"inline,name=ActionSchedule"` Type ActionScheduleType } @@ -53,24 +53,54 @@ func CreateActionScheduleRelativeSchedule(relativeSchedule RelativeSchedule) Act func (u *ActionSchedule) UnmarshalJSON(data []byte) error { + var candidates []utils.UnionCandidate + + // Collect all valid candidates var relativeSchedule RelativeSchedule = RelativeSchedule{} if err := utils.UnmarshalJSON(data, &relativeSchedule, "", true, nil); err == nil { - u.RelativeSchedule = &relativeSchedule - u.Type = ActionScheduleTypeRelativeSchedule - return nil + candidates = append(candidates, utils.UnionCandidate{ + Type: ActionScheduleTypeRelativeSchedule, + Value: &relativeSchedule, + }) } var delayedSchedule DelayedSchedule = DelayedSchedule{} if err := utils.UnmarshalJSON(data, &delayedSchedule, "", true, nil); err == nil { - u.DelayedSchedule = &delayedSchedule - u.Type = ActionScheduleTypeDelayedSchedule - return nil + candidates = append(candidates, utils.UnionCandidate{ + Type: ActionScheduleTypeDelayedSchedule, + Value: &delayedSchedule, + }) } var immediateSchedule ImmediateSchedule = ImmediateSchedule{} if err := utils.UnmarshalJSON(data, &immediateSchedule, "", true, nil); err == nil { - u.ImmediateSchedule = &immediateSchedule - u.Type = ActionScheduleTypeImmediateSchedule + candidates = append(candidates, utils.UnionCandidate{ + Type: ActionScheduleTypeImmediateSchedule, + Value: &immediateSchedule, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for ActionSchedule", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for ActionSchedule", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(ActionScheduleType) + switch best.Type { + case ActionScheduleTypeRelativeSchedule: + u.RelativeSchedule = best.Value.(*RelativeSchedule) + return nil + case ActionScheduleTypeDelayedSchedule: + u.DelayedSchedule = best.Value.(*DelayedSchedule) + return nil + case ActionScheduleTypeImmediateSchedule: + u.ImmediateSchedule = best.Value.(*ImmediateSchedule) return nil } diff --git a/internal/sdk/models/shared/automationconfig.go b/internal/sdk/models/shared/automationconfig.go index 7128cc1..2b786d2 100644 --- a/internal/sdk/models/shared/automationconfig.go +++ b/internal/sdk/models/shared/automationconfig.go @@ -23,9 +23,9 @@ func (a *AutomationConfig) UnmarshalJSON(data []byte) error { return nil } -func (o *AutomationConfig) GetFlowID() string { - if o == nil { +func (a *AutomationConfig) GetFlowID() string { + if a == nil { return "" } - return o.FlowID + return a.FlowID } diff --git a/internal/sdk/models/shared/automationtask.go b/internal/sdk/models/shared/automationtask.go index e8a1fc8..31fba73 100644 --- a/internal/sdk/models/shared/automationtask.go +++ b/internal/sdk/models/shared/automationtask.go @@ -10,6 +10,8 @@ type AutomationTask struct { AssignedTo []string `json:"assigned_to,omitempty"` // Configuration for automation execution to run AutomationConfig AutomationConfig `json:"automation_config"` + // Indicates whether this task was created automatically by journeys or manually by an user + CreatedAutomatically *bool `default:"false" json:"created_automatically"` // Longer information regarding Task Description *StepDescription `json:"description,omitempty"` DueDate *string `json:"due_date,omitempty"` @@ -43,114 +45,121 @@ func (a *AutomationTask) UnmarshalJSON(data []byte) error { return nil } -func (o *AutomationTask) GetAssignedTo() []string { - if o == nil { +func (a *AutomationTask) GetAssignedTo() []string { + if a == nil { return nil } - return o.AssignedTo + return a.AssignedTo } -func (o *AutomationTask) GetAutomationConfig() AutomationConfig { - if o == nil { +func (a *AutomationTask) GetAutomationConfig() AutomationConfig { + if a == nil { return AutomationConfig{} } - return o.AutomationConfig + return a.AutomationConfig } -func (o *AutomationTask) GetDescription() *StepDescription { - if o == nil { +func (a *AutomationTask) GetCreatedAutomatically() *bool { + if a == nil { return nil } - return o.Description + return a.CreatedAutomatically } -func (o *AutomationTask) GetDueDate() *string { - if o == nil { +func (a *AutomationTask) GetDescription() *StepDescription { + if a == nil { return nil } - return o.DueDate + return a.Description } -func (o *AutomationTask) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (a *AutomationTask) GetDueDate() *string { + if a == nil { return nil } - return o.DueDateConfig + return a.DueDate } -func (o *AutomationTask) GetEcp() *ECPDetails { - if o == nil { +func (a *AutomationTask) GetDueDateConfig() *DueDateConfig { + if a == nil { return nil } - return o.Ecp + return a.DueDateConfig } -func (o *AutomationTask) GetID() string { - if o == nil { +func (a *AutomationTask) GetEcp() *ECPDetails { + if a == nil { + return nil + } + return a.Ecp +} + +func (a *AutomationTask) GetID() string { + if a == nil { return "" } - return o.ID + return a.ID } -func (o *AutomationTask) GetInstaller() *ECPDetails { - if o == nil { +func (a *AutomationTask) GetInstaller() *ECPDetails { + if a == nil { return nil } - return o.Installer + return a.Installer } -func (o *AutomationTask) GetJourney() *StepJourney { - if o == nil { +func (a *AutomationTask) GetJourney() *StepJourney { + if a == nil { return nil } - return o.Journey + return a.Journey } -func (o *AutomationTask) GetName() string { - if o == nil { +func (a *AutomationTask) GetName() string { + if a == nil { return "" } - return o.Name + return a.Name } -func (o *AutomationTask) GetPhaseID() *string { - if o == nil { +func (a *AutomationTask) GetPhaseID() *string { + if a == nil { return nil } - return o.PhaseID + return a.PhaseID } -func (o *AutomationTask) GetRequirements() []EnableRequirement { - if o == nil { +func (a *AutomationTask) GetRequirements() []EnableRequirement { + if a == nil { return nil } - return o.Requirements + return a.Requirements } -func (o *AutomationTask) GetSchedule() *ActionSchedule { - if o == nil { +func (a *AutomationTask) GetSchedule() *ActionSchedule { + if a == nil { return nil } - return o.Schedule + return a.Schedule } -func (o *AutomationTask) GetTaskType() TaskType { - if o == nil { +func (a *AutomationTask) GetTaskType() TaskType { + if a == nil { return TaskType("") } - return o.TaskType + return a.TaskType } -func (o *AutomationTask) GetTaxonomies() []string { - if o == nil { +func (a *AutomationTask) GetTaxonomies() []string { + if a == nil { return nil } - return o.Taxonomies + return a.Taxonomies } -func (o *AutomationTask) GetTriggerMode() *TriggerMode { - if o == nil { +func (a *AutomationTask) GetTriggerMode() *TriggerMode { + if a == nil { return nil } - return o.TriggerMode + return a.TriggerMode } diff --git a/internal/sdk/models/shared/automationtrigger.go b/internal/sdk/models/shared/automationtrigger.go index f9b09a8..af2d577 100644 --- a/internal/sdk/models/shared/automationtrigger.go +++ b/internal/sdk/models/shared/automationtrigger.go @@ -49,23 +49,23 @@ func (a *AutomationTrigger) UnmarshalJSON(data []byte) error { return nil } -func (o *AutomationTrigger) GetAutomationID() string { - if o == nil { +func (a *AutomationTrigger) GetAutomationID() string { + if a == nil { return "" } - return o.AutomationID + return a.AutomationID } -func (o *AutomationTrigger) GetID() *string { - if o == nil { +func (a *AutomationTrigger) GetID() *string { + if a == nil { return nil } - return o.ID + return a.ID } -func (o *AutomationTrigger) GetType() Type { - if o == nil { +func (a *AutomationTrigger) GetType() Type { + if a == nil { return Type("") } - return o.Type + return a.Type } diff --git a/internal/sdk/models/shared/changereasonstatusreq.go b/internal/sdk/models/shared/changereasonstatusreq.go index 938e8f2..8391d27 100644 --- a/internal/sdk/models/shared/changereasonstatusreq.go +++ b/internal/sdk/models/shared/changereasonstatusreq.go @@ -6,9 +6,9 @@ type ChangeReasonStatusReq struct { Status ClosingReasonsStatus `json:"status"` } -func (o *ChangeReasonStatusReq) GetStatus() ClosingReasonsStatus { - if o == nil { +func (c *ChangeReasonStatusReq) GetStatus() ClosingReasonsStatus { + if c == nil { return ClosingReasonsStatus("") } - return o.Status + return c.Status } diff --git a/internal/sdk/models/shared/closingreason.go b/internal/sdk/models/shared/closingreason.go index 098a3e4..29306ef 100644 --- a/internal/sdk/models/shared/closingreason.go +++ b/internal/sdk/models/shared/closingreason.go @@ -11,37 +11,37 @@ type ClosingReason struct { Title string `json:"title"` } -func (o *ClosingReason) GetCreationTime() *string { - if o == nil { +func (c *ClosingReason) GetCreationTime() *string { + if c == nil { return nil } - return o.CreationTime + return c.CreationTime } -func (o *ClosingReason) GetID() *string { - if o == nil { +func (c *ClosingReason) GetID() *string { + if c == nil { return nil } - return o.ID + return c.ID } -func (o *ClosingReason) GetLastUpdateTime() *string { - if o == nil { +func (c *ClosingReason) GetLastUpdateTime() *string { + if c == nil { return nil } - return o.LastUpdateTime + return c.LastUpdateTime } -func (o *ClosingReason) GetStatus() ClosingReasonsStatus { - if o == nil { +func (c *ClosingReason) GetStatus() ClosingReasonsStatus { + if c == nil { return ClosingReasonsStatus("") } - return o.Status + return c.Status } -func (o *ClosingReason) GetTitle() string { - if o == nil { +func (c *ClosingReason) GetTitle() string { + if c == nil { return "" } - return o.Title + return c.Title } diff --git a/internal/sdk/models/shared/closingreasonid.go b/internal/sdk/models/shared/closingreasonid.go index ab5a29c..4a04589 100644 --- a/internal/sdk/models/shared/closingreasonid.go +++ b/internal/sdk/models/shared/closingreasonid.go @@ -6,9 +6,9 @@ type ClosingReasonID struct { ID string `json:"id"` } -func (o *ClosingReasonID) GetID() string { - if o == nil { +func (c *ClosingReasonID) GetID() string { + if c == nil { return "" } - return o.ID + return c.ID } diff --git a/internal/sdk/models/shared/closingreasoninput.go b/internal/sdk/models/shared/closingreasoninput.go index 47eadf7..fa6309c 100644 --- a/internal/sdk/models/shared/closingreasoninput.go +++ b/internal/sdk/models/shared/closingreasoninput.go @@ -8,16 +8,16 @@ type ClosingReasonInput struct { Title string `json:"title"` } -func (o *ClosingReasonInput) GetStatus() ClosingReasonsStatus { - if o == nil { +func (c *ClosingReasonInput) GetStatus() ClosingReasonsStatus { + if c == nil { return ClosingReasonsStatus("") } - return o.Status + return c.Status } -func (o *ClosingReasonInput) GetTitle() string { - if o == nil { +func (c *ClosingReasonInput) GetTitle() string { + if c == nil { return "" } - return o.Title + return c.Title } diff --git a/internal/sdk/models/shared/closingreasonnotfoundresp.go b/internal/sdk/models/shared/closingreasonnotfoundresp.go index 2bbfab4..f54c5b9 100644 --- a/internal/sdk/models/shared/closingreasonnotfoundresp.go +++ b/internal/sdk/models/shared/closingreasonnotfoundresp.go @@ -7,9 +7,9 @@ type ClosingReasonNotFoundResp struct { Message *string `json:"message,omitempty"` } -func (o *ClosingReasonNotFoundResp) GetMessage() *string { - if o == nil { +func (c *ClosingReasonNotFoundResp) GetMessage() *string { + if c == nil { return nil } - return o.Message + return c.Message } diff --git a/internal/sdk/models/shared/closingreasons.go b/internal/sdk/models/shared/closingreasons.go index 7c0d9b4..0a21260 100644 --- a/internal/sdk/models/shared/closingreasons.go +++ b/internal/sdk/models/shared/closingreasons.go @@ -6,9 +6,9 @@ type ClosingReasons struct { Reasons []ClosingReason `json:"reasons"` } -func (o *ClosingReasons) GetReasons() []ClosingReason { - if o == nil { +func (c *ClosingReasons) GetReasons() []ClosingReason { + if c == nil { return []ClosingReason{} } - return o.Reasons + return c.Reasons } diff --git a/internal/sdk/models/shared/closingreasonsids.go b/internal/sdk/models/shared/closingreasonsids.go index 05dd280..8896872 100644 --- a/internal/sdk/models/shared/closingreasonsids.go +++ b/internal/sdk/models/shared/closingreasonsids.go @@ -6,9 +6,9 @@ type ClosingReasonsIds struct { Reasons []ClosingReasonID `json:"reasons"` } -func (o *ClosingReasonsIds) GetReasons() []ClosingReasonID { - if o == nil { +func (c *ClosingReasonsIds) GetReasons() []ClosingReasonID { + if c == nil { return []ClosingReasonID{} } - return o.Reasons + return c.Reasons } diff --git a/internal/sdk/models/shared/condition.go b/internal/sdk/models/shared/condition.go index 65543e1..0c0af4d 100644 --- a/internal/sdk/models/shared/condition.go +++ b/internal/sdk/models/shared/condition.go @@ -53,30 +53,30 @@ func (c *Condition) UnmarshalJSON(data []byte) error { return nil } -func (o *Condition) GetBranchName() string { - if o == nil { +func (c *Condition) GetBranchName() string { + if c == nil { return "" } - return o.BranchName + return c.BranchName } -func (o *Condition) GetID() string { - if o == nil { +func (c *Condition) GetID() string { + if c == nil { return "" } - return o.ID + return c.ID } -func (o *Condition) GetLogicalOperator() LogicalOperator { - if o == nil { +func (c *Condition) GetLogicalOperator() LogicalOperator { + if c == nil { return LogicalOperator("") } - return o.LogicalOperator + return c.LogicalOperator } -func (o *Condition) GetStatements() []Statement { - if o == nil { +func (c *Condition) GetStatements() []Statement { + if c == nil { return []Statement{} } - return o.Statements + return c.Statements } diff --git a/internal/sdk/models/shared/createflowtemplate.go b/internal/sdk/models/shared/createflowtemplate.go index 434cc13..8beb22f 100644 --- a/internal/sdk/models/shared/createflowtemplate.go +++ b/internal/sdk/models/shared/createflowtemplate.go @@ -6,11 +6,22 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" ) +type CreateFlowTemplateClosingReasons struct { + ID string `json:"id"` +} + +func (c *CreateFlowTemplateClosingReasons) GetID() string { + if c == nil { + return "" + } + return c.ID +} + type CreateFlowTemplate struct { AssignedTo []string `json:"assigned_to,omitempty"` // Indicates whether this workflow is available for End Customer Portal or not. By default it's not. - AvailableInEcp *bool `json:"available_in_ecp,omitempty"` - ClosingReasons []ClosingReasonID `json:"closing_reasons,omitempty"` + AvailableInEcp *bool `json:"available_in_ecp,omitempty"` + ClosingReasons []CreateFlowTemplateClosingReasons `json:"closing_reasons,omitempty"` // ISO String Date & Time CreatedAt *string `json:"created_at,omitempty"` Description *string `json:"description,omitempty"` @@ -21,18 +32,23 @@ type CreateFlowTemplate struct { // Whether the workflow is enabled or not Enabled *bool `default:"true" json:"enabled"` ID *string `json:"id,omitempty"` - // Whether the workflow is migrated from workflows to flows or not - IsFlowMigrated *bool `default:"false" json:"is_flow_migrated"` - Name string `json:"name"` - OrgID *string `json:"org_id,omitempty"` - Phases []Phase `json:"phases,omitempty"` - Tasks []Task `json:"tasks"` + Name string `json:"name"` + OrgID *string `json:"org_id,omitempty"` + Phases []Phase `json:"phases,omitempty"` + Tasks []Task `json:"tasks"` // Taxonomy ids that are associated with this workflow and used for filtering Taxonomies []string `json:"taxonomies,omitempty"` Trigger *Trigger `json:"trigger,omitempty"` UpdateEntityAttributes []UpdateEntityAttributes `json:"update_entity_attributes,omitempty"` // ISO String Date & Time UpdatedAt *string `json:"updated_at,omitempty"` + // Version of the workflow schema. + // + // - `v1` – *Deprecated*. The initial version of workflows with limited structure and automation capabilities. + // - `v2` – Linear workflows. Supports sequential task execution with basic automation triggers. + // - `v3` – Advanced workflows. Adds support for branching logic (conditions), parallel paths, and enhanced automation features such as dynamic triggers and flow control. + // + Version *Version `json:"version,omitempty"` } func (c CreateFlowTemplate) MarshalJSON() ([]byte, error) { @@ -46,135 +62,135 @@ func (c *CreateFlowTemplate) UnmarshalJSON(data []byte) error { return nil } -func (o *CreateFlowTemplate) GetAssignedTo() []string { - if o == nil { +func (c *CreateFlowTemplate) GetAssignedTo() []string { + if c == nil { return nil } - return o.AssignedTo + return c.AssignedTo } -func (o *CreateFlowTemplate) GetAvailableInEcp() *bool { - if o == nil { +func (c *CreateFlowTemplate) GetAvailableInEcp() *bool { + if c == nil { return nil } - return o.AvailableInEcp + return c.AvailableInEcp } -func (o *CreateFlowTemplate) GetClosingReasons() []ClosingReasonID { - if o == nil { +func (c *CreateFlowTemplate) GetClosingReasons() []CreateFlowTemplateClosingReasons { + if c == nil { return nil } - return o.ClosingReasons + return c.ClosingReasons } -func (o *CreateFlowTemplate) GetCreatedAt() *string { - if o == nil { +func (c *CreateFlowTemplate) GetCreatedAt() *string { + if c == nil { return nil } - return o.CreatedAt + return c.CreatedAt } -func (o *CreateFlowTemplate) GetDescription() *string { - if o == nil { +func (c *CreateFlowTemplate) GetDescription() *string { + if c == nil { return nil } - return o.Description + return c.Description } -func (o *CreateFlowTemplate) GetDueDate() *string { - if o == nil { +func (c *CreateFlowTemplate) GetDueDate() *string { + if c == nil { return nil } - return o.DueDate + return c.DueDate } -func (o *CreateFlowTemplate) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (c *CreateFlowTemplate) GetDueDateConfig() *DueDateConfig { + if c == nil { return nil } - return o.DueDateConfig + return c.DueDateConfig } -func (o *CreateFlowTemplate) GetEdges() []Edge { - if o == nil { +func (c *CreateFlowTemplate) GetEdges() []Edge { + if c == nil { return []Edge{} } - return o.Edges -} - -func (o *CreateFlowTemplate) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled + return c.Edges } -func (o *CreateFlowTemplate) GetID() *string { - if o == nil { +func (c *CreateFlowTemplate) GetEnabled() *bool { + if c == nil { return nil } - return o.ID + return c.Enabled } -func (o *CreateFlowTemplate) GetIsFlowMigrated() *bool { - if o == nil { +func (c *CreateFlowTemplate) GetID() *string { + if c == nil { return nil } - return o.IsFlowMigrated + return c.ID } -func (o *CreateFlowTemplate) GetName() string { - if o == nil { +func (c *CreateFlowTemplate) GetName() string { + if c == nil { return "" } - return o.Name + return c.Name } -func (o *CreateFlowTemplate) GetOrgID() *string { - if o == nil { +func (c *CreateFlowTemplate) GetOrgID() *string { + if c == nil { return nil } - return o.OrgID + return c.OrgID } -func (o *CreateFlowTemplate) GetPhases() []Phase { - if o == nil { +func (c *CreateFlowTemplate) GetPhases() []Phase { + if c == nil { return nil } - return o.Phases + return c.Phases } -func (o *CreateFlowTemplate) GetTasks() []Task { - if o == nil { +func (c *CreateFlowTemplate) GetTasks() []Task { + if c == nil { return []Task{} } - return o.Tasks + return c.Tasks +} + +func (c *CreateFlowTemplate) GetTaxonomies() []string { + if c == nil { + return nil + } + return c.Taxonomies } -func (o *CreateFlowTemplate) GetTaxonomies() []string { - if o == nil { +func (c *CreateFlowTemplate) GetTrigger() *Trigger { + if c == nil { return nil } - return o.Taxonomies + return c.Trigger } -func (o *CreateFlowTemplate) GetTrigger() *Trigger { - if o == nil { +func (c *CreateFlowTemplate) GetUpdateEntityAttributes() []UpdateEntityAttributes { + if c == nil { return nil } - return o.Trigger + return c.UpdateEntityAttributes } -func (o *CreateFlowTemplate) GetUpdateEntityAttributes() []UpdateEntityAttributes { - if o == nil { +func (c *CreateFlowTemplate) GetUpdatedAt() *string { + if c == nil { return nil } - return o.UpdateEntityAttributes + return c.UpdatedAt } -func (o *CreateFlowTemplate) GetUpdatedAt() *string { - if o == nil { +func (c *CreateFlowTemplate) GetVersion() *Version { + if c == nil { return nil } - return o.UpdatedAt + return c.Version } diff --git a/internal/sdk/models/shared/decisiontask.go b/internal/sdk/models/shared/decisiontask.go index fc8bc7f..9b63ce5 100644 --- a/internal/sdk/models/shared/decisiontask.go +++ b/internal/sdk/models/shared/decisiontask.go @@ -8,6 +8,47 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" ) +type LoopConfig struct { + // The id of the branch that will be used to exit the loop + ExitBranchID string `json:"exit_branch_id"` + // The id of the branch that will be looped + LoopBranchID string `json:"loop_branch_id"` + // Maximum number of iterations for the loop branch + MaxIterations *int64 `default:"3" json:"max_iterations"` +} + +func (l LoopConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *LoopConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"exit_branch_id", "loop_branch_id"}); err != nil { + return err + } + return nil +} + +func (l *LoopConfig) GetExitBranchID() string { + if l == nil { + return "" + } + return l.ExitBranchID +} + +func (l *LoopConfig) GetLoopBranchID() string { + if l == nil { + return "" + } + return l.LoopBranchID +} + +func (l *LoopConfig) GetMaxIterations() *int64 { + if l == nil { + return nil + } + return l.MaxIterations +} + type ScheduleType string const ( @@ -16,8 +57,8 @@ const ( ) type Schedule struct { - DelayedSchedule *DelayedSchedule `queryParam:"inline"` - RelativeSchedule *RelativeSchedule `queryParam:"inline"` + DelayedSchedule *DelayedSchedule `queryParam:"inline,name=schedule"` + RelativeSchedule *RelativeSchedule `queryParam:"inline,name=schedule"` Type ScheduleType } @@ -42,17 +83,43 @@ func CreateScheduleRelativeSchedule(relativeSchedule RelativeSchedule) Schedule func (u *Schedule) UnmarshalJSON(data []byte) error { + var candidates []utils.UnionCandidate + + // Collect all valid candidates var relativeSchedule RelativeSchedule = RelativeSchedule{} if err := utils.UnmarshalJSON(data, &relativeSchedule, "", true, nil); err == nil { - u.RelativeSchedule = &relativeSchedule - u.Type = ScheduleTypeRelativeSchedule - return nil + candidates = append(candidates, utils.UnionCandidate{ + Type: ScheduleTypeRelativeSchedule, + Value: &relativeSchedule, + }) } var delayedSchedule DelayedSchedule = DelayedSchedule{} if err := utils.UnmarshalJSON(data, &delayedSchedule, "", true, nil); err == nil { - u.DelayedSchedule = &delayedSchedule - u.Type = ScheduleTypeDelayedSchedule + candidates = append(candidates, utils.UnionCandidate{ + Type: ScheduleTypeDelayedSchedule, + Value: &delayedSchedule, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Schedule", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Schedule", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(ScheduleType) + switch best.Type { + case ScheduleTypeRelativeSchedule: + u.RelativeSchedule = best.Value.(*RelativeSchedule) + return nil + case ScheduleTypeDelayedSchedule: + u.DelayedSchedule = best.Value.(*DelayedSchedule) return nil } @@ -83,16 +150,18 @@ type DecisionTask struct { Ecp *ECPDetails `json:"ecp,omitempty"` ID string `json:"id"` // Details regarding ECP for the workflow step - Installer *ECPDetails `json:"installer,omitempty"` - Journey *StepJourney `json:"journey,omitempty"` - Name string `json:"name"` - PhaseID *string `json:"phase_id,omitempty"` + Installer *ECPDetails `json:"installer,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + LoopConfig *LoopConfig `json:"loop_config,omitempty"` + Name string `json:"name"` + PhaseID *string `json:"phase_id,omitempty"` // requirements that need to be fulfilled in order to enable the task while flow instances are running Requirements []EnableRequirement `json:"requirements,omitempty"` Schedule *Schedule `json:"schedule,omitempty"` TaskType TaskType `json:"task_type"` // Taxonomy ids that are associated with this workflow and used for filtering - Taxonomies []string `json:"taxonomies,omitempty"` + Taxonomies []string `json:"taxonomies,omitempty"` + TriggerMode TriggerMode `json:"trigger_mode"` } func (d DecisionTask) MarshalJSON() ([]byte, error) { @@ -100,113 +169,127 @@ func (d DecisionTask) MarshalJSON() ([]byte, error) { } func (d *DecisionTask) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &d, "", false, []string{"conditions", "id", "name", "task_type"}); err != nil { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"conditions", "id", "name", "task_type", "trigger_mode"}); err != nil { return err } return nil } -func (o *DecisionTask) GetAssignedTo() []string { - if o == nil { +func (d *DecisionTask) GetAssignedTo() []string { + if d == nil { return nil } - return o.AssignedTo + return d.AssignedTo } -func (o *DecisionTask) GetConditions() []Condition { - if o == nil { +func (d *DecisionTask) GetConditions() []Condition { + if d == nil { return []Condition{} } - return o.Conditions + return d.Conditions } -func (o *DecisionTask) GetDescription() *StepDescription { - if o == nil { +func (d *DecisionTask) GetDescription() *StepDescription { + if d == nil { return nil } - return o.Description + return d.Description } -func (o *DecisionTask) GetDueDate() *string { - if o == nil { +func (d *DecisionTask) GetDueDate() *string { + if d == nil { return nil } - return o.DueDate + return d.DueDate } -func (o *DecisionTask) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (d *DecisionTask) GetDueDateConfig() *DueDateConfig { + if d == nil { return nil } - return o.DueDateConfig + return d.DueDateConfig } -func (o *DecisionTask) GetEcp() *ECPDetails { - if o == nil { +func (d *DecisionTask) GetEcp() *ECPDetails { + if d == nil { return nil } - return o.Ecp + return d.Ecp } -func (o *DecisionTask) GetID() string { - if o == nil { +func (d *DecisionTask) GetID() string { + if d == nil { return "" } - return o.ID + return d.ID } -func (o *DecisionTask) GetInstaller() *ECPDetails { - if o == nil { +func (d *DecisionTask) GetInstaller() *ECPDetails { + if d == nil { return nil } - return o.Installer + return d.Installer } -func (o *DecisionTask) GetJourney() *StepJourney { - if o == nil { +func (d *DecisionTask) GetJourney() *StepJourney { + if d == nil { return nil } - return o.Journey + return d.Journey } -func (o *DecisionTask) GetName() string { - if o == nil { +func (d *DecisionTask) GetLoopConfig() *LoopConfig { + if d == nil { + return nil + } + return d.LoopConfig +} + +func (d *DecisionTask) GetName() string { + if d == nil { return "" } - return o.Name + return d.Name } -func (o *DecisionTask) GetPhaseID() *string { - if o == nil { +func (d *DecisionTask) GetPhaseID() *string { + if d == nil { return nil } - return o.PhaseID + return d.PhaseID } -func (o *DecisionTask) GetRequirements() []EnableRequirement { - if o == nil { +func (d *DecisionTask) GetRequirements() []EnableRequirement { + if d == nil { return nil } - return o.Requirements + return d.Requirements } -func (o *DecisionTask) GetSchedule() *Schedule { - if o == nil { +func (d *DecisionTask) GetSchedule() *Schedule { + if d == nil { return nil } - return o.Schedule + return d.Schedule } -func (o *DecisionTask) GetTaskType() TaskType { - if o == nil { +func (d *DecisionTask) GetTaskType() TaskType { + if d == nil { return TaskType("") } - return o.TaskType + return d.TaskType } -func (o *DecisionTask) GetTaxonomies() []string { - if o == nil { +func (d *DecisionTask) GetTaxonomies() []string { + if d == nil { return nil } - return o.Taxonomies + return d.Taxonomies +} + +func (d *DecisionTask) GetTriggerMode() TriggerMode { + if d == nil { + return TriggerMode("") + } + return d.TriggerMode } diff --git a/internal/sdk/models/shared/definitionnotfoundresp.go b/internal/sdk/models/shared/definitionnotfoundresp.go index a7235aa..d40977d 100644 --- a/internal/sdk/models/shared/definitionnotfoundresp.go +++ b/internal/sdk/models/shared/definitionnotfoundresp.go @@ -7,9 +7,9 @@ type DefinitionNotFoundResp struct { Message *string `json:"message,omitempty"` } -func (o *DefinitionNotFoundResp) GetMessage() *string { - if o == nil { +func (d *DefinitionNotFoundResp) GetMessage() *string { + if d == nil { return nil } - return o.Message + return d.Message } diff --git a/internal/sdk/models/shared/delayedschedule.go b/internal/sdk/models/shared/delayedschedule.go index 207c78e..9b93ec5 100644 --- a/internal/sdk/models/shared/delayedschedule.go +++ b/internal/sdk/models/shared/delayedschedule.go @@ -48,23 +48,23 @@ func (d *DelayedSchedule) UnmarshalJSON(data []byte) error { return nil } -func (o *DelayedSchedule) GetDuration() float64 { - if o == nil { +func (d *DelayedSchedule) GetDuration() float64 { + if d == nil { return 0.0 } - return o.Duration + return d.Duration } -func (o *DelayedSchedule) GetMode() Mode { - if o == nil { +func (d *DelayedSchedule) GetMode() Mode { + if d == nil { return Mode("") } - return o.Mode + return d.Mode } -func (o *DelayedSchedule) GetUnit() TimeUnit { - if o == nil { +func (d *DelayedSchedule) GetUnit() TimeUnit { + if d == nil { return TimeUnit("") } - return o.Unit + return d.Unit } diff --git a/internal/sdk/models/shared/duedateconfig.go b/internal/sdk/models/shared/duedateconfig.go index c9513e3..2102d64 100644 --- a/internal/sdk/models/shared/duedateconfig.go +++ b/internal/sdk/models/shared/duedateconfig.go @@ -45,37 +45,37 @@ type DueDateConfig struct { Unit TimeUnit `json:"unit"` } -func (o *DueDateConfig) GetDuration() float64 { - if o == nil { +func (d *DueDateConfig) GetDuration() float64 { + if d == nil { return 0.0 } - return o.Duration + return d.Duration } -func (o *DueDateConfig) GetPhaseID() *string { - if o == nil { +func (d *DueDateConfig) GetPhaseID() *string { + if d == nil { return nil } - return o.PhaseID + return d.PhaseID } -func (o *DueDateConfig) GetTaskID() *string { - if o == nil { +func (d *DueDateConfig) GetTaskID() *string { + if d == nil { return nil } - return o.TaskID + return d.TaskID } -func (o *DueDateConfig) GetType() DueDateConfigType { - if o == nil { +func (d *DueDateConfig) GetType() DueDateConfigType { + if d == nil { return DueDateConfigType("") } - return o.Type + return d.Type } -func (o *DueDateConfig) GetUnit() TimeUnit { - if o == nil { +func (d *DueDateConfig) GetUnit() TimeUnit { + if d == nil { return TimeUnit("") } - return o.Unit + return d.Unit } diff --git a/internal/sdk/models/shared/dynamicduedate.go b/internal/sdk/models/shared/dynamicduedate.go index 1c49469..67bfa7f 100644 --- a/internal/sdk/models/shared/dynamicduedate.go +++ b/internal/sdk/models/shared/dynamicduedate.go @@ -45,37 +45,37 @@ type DynamicDueDate struct { TimePeriod TimeUnit `json:"timePeriod"` } -func (o *DynamicDueDate) GetActionTypeCondition() ActionTypeCondition { - if o == nil { +func (d *DynamicDueDate) GetActionTypeCondition() ActionTypeCondition { + if d == nil { return ActionTypeCondition("") } - return o.ActionTypeCondition + return d.ActionTypeCondition } -func (o *DynamicDueDate) GetNumberOfUnits() float64 { - if o == nil { +func (d *DynamicDueDate) GetNumberOfUnits() float64 { + if d == nil { return 0.0 } - return o.NumberOfUnits + return d.NumberOfUnits } -func (o *DynamicDueDate) GetPhaseID() *string { - if o == nil { +func (d *DynamicDueDate) GetPhaseID() *string { + if d == nil { return nil } - return o.PhaseID + return d.PhaseID } -func (o *DynamicDueDate) GetStepID() *string { - if o == nil { +func (d *DynamicDueDate) GetStepID() *string { + if d == nil { return nil } - return o.StepID + return d.StepID } -func (o *DynamicDueDate) GetTimePeriod() TimeUnit { - if o == nil { +func (d *DynamicDueDate) GetTimePeriod() TimeUnit { + if d == nil { return TimeUnit("") } - return o.TimePeriod + return d.TimePeriod } diff --git a/internal/sdk/models/shared/ecpdetails.go b/internal/sdk/models/shared/ecpdetails.go index a27a60a..6fbbf7a 100644 --- a/internal/sdk/models/shared/ecpdetails.go +++ b/internal/sdk/models/shared/ecpdetails.go @@ -25,30 +25,30 @@ func (e *ECPDetails) UnmarshalJSON(data []byte) error { return nil } -func (o *ECPDetails) GetDescription() *string { - if o == nil { +func (e *ECPDetails) GetDescription() *string { + if e == nil { return nil } - return o.Description + return e.Description } -func (o *ECPDetails) GetEnabled() *bool { - if o == nil { +func (e *ECPDetails) GetEnabled() *bool { + if e == nil { return nil } - return o.Enabled + return e.Enabled } -func (o *ECPDetails) GetJourney() *StepJourney { - if o == nil { +func (e *ECPDetails) GetJourney() *StepJourney { + if e == nil { return nil } - return o.Journey + return e.Journey } -func (o *ECPDetails) GetLabel() *string { - if o == nil { +func (e *ECPDetails) GetLabel() *string { + if e == nil { return nil } - return o.Label + return e.Label } diff --git a/internal/sdk/models/shared/edge.go b/internal/sdk/models/shared/edge.go index f5df588..8971bea 100644 --- a/internal/sdk/models/shared/edge.go +++ b/internal/sdk/models/shared/edge.go @@ -11,37 +11,37 @@ type Edge struct { ToID string `json:"to_id"` } -func (o *Edge) GetConditionID() *string { - if o == nil { +func (e *Edge) GetConditionID() *string { + if e == nil { return nil } - return o.ConditionID + return e.ConditionID } -func (o *Edge) GetFromID() string { - if o == nil { +func (e *Edge) GetFromID() string { + if e == nil { return "" } - return o.FromID + return e.FromID } -func (o *Edge) GetID() string { - if o == nil { +func (e *Edge) GetID() string { + if e == nil { return "" } - return o.ID + return e.ID } -func (o *Edge) GetNoneMet() *bool { - if o == nil { +func (e *Edge) GetNoneMet() *bool { + if e == nil { return nil } - return o.NoneMet + return e.NoneMet } -func (o *Edge) GetToID() string { - if o == nil { +func (e *Edge) GetToID() string { + if e == nil { return "" } - return o.ToID + return e.ToID } diff --git a/internal/sdk/models/shared/enablerequirement.go b/internal/sdk/models/shared/enablerequirement.go index 4f2c0c5..1b1488f 100644 --- a/internal/sdk/models/shared/enablerequirement.go +++ b/internal/sdk/models/shared/enablerequirement.go @@ -36,9 +36,11 @@ func (e *When) UnmarshalJSON(data []byte) error { // EnableRequirement - describe the requirement for a task to be enabled type EnableRequirement struct { + // The id of the phase that it points to PhaseID *string `json:"phase_id,omitempty"` - TaskID *string `json:"task_id,omitempty"` - When When `json:"when"` + // The id of the task that it points to + TaskID *string `json:"task_id,omitempty"` + When When `json:"when"` } func (e EnableRequirement) MarshalJSON() ([]byte, error) { @@ -52,23 +54,23 @@ func (e *EnableRequirement) UnmarshalJSON(data []byte) error { return nil } -func (o *EnableRequirement) GetPhaseID() *string { - if o == nil { +func (e *EnableRequirement) GetPhaseID() *string { + if e == nil { return nil } - return o.PhaseID + return e.PhaseID } -func (o *EnableRequirement) GetTaskID() *string { - if o == nil { +func (e *EnableRequirement) GetTaskID() *string { + if e == nil { return nil } - return o.TaskID + return e.TaskID } -func (o *EnableRequirement) GetWhen() When { - if o == nil { +func (e *EnableRequirement) GetWhen() When { + if e == nil { return When("") } - return o.When + return e.When } diff --git a/internal/sdk/models/shared/errorresp.go b/internal/sdk/models/shared/errorresp.go index 4f53535..5e7b1d6 100644 --- a/internal/sdk/models/shared/errorresp.go +++ b/internal/sdk/models/shared/errorresp.go @@ -6,9 +6,9 @@ type ErrorResp struct { Message *string `json:"message,omitempty"` } -func (o *ErrorResp) GetMessage() *string { - if o == nil { +func (e *ErrorResp) GetMessage() *string { + if e == nil { return nil } - return o.Message + return e.Message } diff --git a/internal/sdk/models/shared/evaluationsource.go b/internal/sdk/models/shared/evaluationsource.go index afbb227..07713f0 100644 --- a/internal/sdk/models/shared/evaluationsource.go +++ b/internal/sdk/models/shared/evaluationsource.go @@ -198,58 +198,58 @@ func (e *EvaluationSource) UnmarshalJSON(data []byte) error { return nil } -func (o *EvaluationSource) GetAttribute() *string { - if o == nil { +func (e *EvaluationSource) GetAttribute() *string { + if e == nil { return nil } - return o.Attribute + return e.Attribute } -func (o *EvaluationSource) GetAttributeOperation() *AttributeOperation { - if o == nil { +func (e *EvaluationSource) GetAttributeOperation() *AttributeOperation { + if e == nil { return nil } - return o.AttributeOperation + return e.AttributeOperation } -func (o *EvaluationSource) GetAttributeRepeatable() *bool { - if o == nil { +func (e *EvaluationSource) GetAttributeRepeatable() *bool { + if e == nil { return nil } - return o.AttributeRepeatable + return e.AttributeRepeatable } -func (o *EvaluationSource) GetAttributeType() *AttributeType { - if o == nil { +func (e *EvaluationSource) GetAttributeType() *AttributeType { + if e == nil { return nil } - return o.AttributeType + return e.AttributeType } -func (o *EvaluationSource) GetID() *string { - if o == nil { +func (e *EvaluationSource) GetID() *string { + if e == nil { return nil } - return o.ID + return e.ID } -func (o *EvaluationSource) GetOrigin() *Origin { - if o == nil { +func (e *EvaluationSource) GetOrigin() *Origin { + if e == nil { return nil } - return o.Origin + return e.Origin } -func (o *EvaluationSource) GetOriginType() *OriginType { - if o == nil { +func (e *EvaluationSource) GetOriginType() *OriginType { + if e == nil { return nil } - return o.OriginType + return e.OriginType } -func (o *EvaluationSource) GetSchema() *string { - if o == nil { +func (e *EvaluationSource) GetSchema() *string { + if e == nil { return nil } - return o.Schema + return e.Schema } diff --git a/internal/sdk/models/shared/flowtemplate.go b/internal/sdk/models/shared/flowtemplate.go index 8a2ba3d..ac04538 100644 --- a/internal/sdk/models/shared/flowtemplate.go +++ b/internal/sdk/models/shared/flowtemplate.go @@ -21,18 +21,23 @@ type FlowTemplate struct { // Whether the workflow is enabled or not Enabled *bool `default:"true" json:"enabled"` ID *string `json:"id,omitempty"` - // Whether the workflow is migrated from workflows to flows or not - IsFlowMigrated *bool `default:"false" json:"is_flow_migrated"` - Name string `json:"name"` - OrgID *string `json:"org_id,omitempty"` - Phases []Phase `json:"phases,omitempty"` - Tasks []Task `json:"tasks"` + Name string `json:"name"` + OrgID *string `json:"org_id,omitempty"` + Phases []Phase `json:"phases,omitempty"` + Tasks []Task `json:"tasks"` // Taxonomy ids that are associated with this workflow and used for filtering Taxonomies []string `json:"taxonomies,omitempty"` Trigger *Trigger `json:"trigger,omitempty"` UpdateEntityAttributes []UpdateEntityAttributes `json:"update_entity_attributes,omitempty"` // ISO String Date & Time UpdatedAt *string `json:"updated_at,omitempty"` + // Version of the workflow schema. + // + // - `v1` – *Deprecated*. The initial version of workflows with limited structure and automation capabilities. + // - `v2` – Linear workflows. Supports sequential task execution with basic automation triggers. + // - `v3` – Advanced workflows. Adds support for branching logic (conditions), parallel paths, and enhanced automation features such as dynamic triggers and flow control. + // + Version *Version `json:"version,omitempty"` } func (f FlowTemplate) MarshalJSON() ([]byte, error) { @@ -46,135 +51,135 @@ func (f *FlowTemplate) UnmarshalJSON(data []byte) error { return nil } -func (o *FlowTemplate) GetAssignedTo() []string { - if o == nil { +func (f *FlowTemplate) GetAssignedTo() []string { + if f == nil { return nil } - return o.AssignedTo + return f.AssignedTo } -func (o *FlowTemplate) GetAvailableInEcp() *bool { - if o == nil { +func (f *FlowTemplate) GetAvailableInEcp() *bool { + if f == nil { return nil } - return o.AvailableInEcp + return f.AvailableInEcp } -func (o *FlowTemplate) GetClosingReasons() []ClosingReason { - if o == nil { +func (f *FlowTemplate) GetClosingReasons() []ClosingReason { + if f == nil { return nil } - return o.ClosingReasons + return f.ClosingReasons } -func (o *FlowTemplate) GetCreatedAt() *string { - if o == nil { +func (f *FlowTemplate) GetCreatedAt() *string { + if f == nil { return nil } - return o.CreatedAt + return f.CreatedAt } -func (o *FlowTemplate) GetDescription() *string { - if o == nil { +func (f *FlowTemplate) GetDescription() *string { + if f == nil { return nil } - return o.Description + return f.Description } -func (o *FlowTemplate) GetDueDate() *string { - if o == nil { +func (f *FlowTemplate) GetDueDate() *string { + if f == nil { return nil } - return o.DueDate + return f.DueDate } -func (o *FlowTemplate) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (f *FlowTemplate) GetDueDateConfig() *DueDateConfig { + if f == nil { return nil } - return o.DueDateConfig + return f.DueDateConfig } -func (o *FlowTemplate) GetEdges() []Edge { - if o == nil { +func (f *FlowTemplate) GetEdges() []Edge { + if f == nil { return []Edge{} } - return o.Edges + return f.Edges } -func (o *FlowTemplate) GetEnabled() *bool { - if o == nil { +func (f *FlowTemplate) GetEnabled() *bool { + if f == nil { return nil } - return o.Enabled + return f.Enabled } -func (o *FlowTemplate) GetID() *string { - if o == nil { +func (f *FlowTemplate) GetID() *string { + if f == nil { return nil } - return o.ID + return f.ID } -func (o *FlowTemplate) GetIsFlowMigrated() *bool { - if o == nil { - return nil - } - return o.IsFlowMigrated -} - -func (o *FlowTemplate) GetName() string { - if o == nil { +func (f *FlowTemplate) GetName() string { + if f == nil { return "" } - return o.Name + return f.Name } -func (o *FlowTemplate) GetOrgID() *string { - if o == nil { +func (f *FlowTemplate) GetOrgID() *string { + if f == nil { return nil } - return o.OrgID + return f.OrgID } -func (o *FlowTemplate) GetPhases() []Phase { - if o == nil { +func (f *FlowTemplate) GetPhases() []Phase { + if f == nil { return nil } - return o.Phases + return f.Phases } -func (o *FlowTemplate) GetTasks() []Task { - if o == nil { +func (f *FlowTemplate) GetTasks() []Task { + if f == nil { return []Task{} } - return o.Tasks + return f.Tasks +} + +func (f *FlowTemplate) GetTaxonomies() []string { + if f == nil { + return nil + } + return f.Taxonomies } -func (o *FlowTemplate) GetTaxonomies() []string { - if o == nil { +func (f *FlowTemplate) GetTrigger() *Trigger { + if f == nil { return nil } - return o.Taxonomies + return f.Trigger } -func (o *FlowTemplate) GetTrigger() *Trigger { - if o == nil { +func (f *FlowTemplate) GetUpdateEntityAttributes() []UpdateEntityAttributes { + if f == nil { return nil } - return o.Trigger + return f.UpdateEntityAttributes } -func (o *FlowTemplate) GetUpdateEntityAttributes() []UpdateEntityAttributes { - if o == nil { +func (f *FlowTemplate) GetUpdatedAt() *string { + if f == nil { return nil } - return o.UpdateEntityAttributes + return f.UpdatedAt } -func (o *FlowTemplate) GetUpdatedAt() *string { - if o == nil { +func (f *FlowTemplate) GetVersion() *Version { + if f == nil { return nil } - return o.UpdatedAt + return f.Version } diff --git a/internal/sdk/models/shared/flowtemplateinput.go b/internal/sdk/models/shared/flowtemplateinput.go index 0efd66d..6ed829e 100644 --- a/internal/sdk/models/shared/flowtemplateinput.go +++ b/internal/sdk/models/shared/flowtemplateinput.go @@ -21,18 +21,23 @@ type FlowTemplateInput struct { // Whether the workflow is enabled or not Enabled *bool `default:"true" json:"enabled"` ID *string `json:"id,omitempty"` - // Whether the workflow is migrated from workflows to flows or not - IsFlowMigrated *bool `default:"false" json:"is_flow_migrated"` - Name string `json:"name"` - OrgID *string `json:"org_id,omitempty"` - Phases []Phase `json:"phases,omitempty"` - Tasks []Task `json:"tasks"` + Name string `json:"name"` + OrgID *string `json:"org_id,omitempty"` + Phases []Phase `json:"phases,omitempty"` + Tasks []Task `json:"tasks"` // Taxonomy ids that are associated with this workflow and used for filtering Taxonomies []string `json:"taxonomies,omitempty"` Trigger *Trigger `json:"trigger,omitempty"` UpdateEntityAttributes []UpdateEntityAttributes `json:"update_entity_attributes,omitempty"` // ISO String Date & Time UpdatedAt *string `json:"updated_at,omitempty"` + // Version of the workflow schema. + // + // - `v1` – *Deprecated*. The initial version of workflows with limited structure and automation capabilities. + // - `v2` – Linear workflows. Supports sequential task execution with basic automation triggers. + // - `v3` – Advanced workflows. Adds support for branching logic (conditions), parallel paths, and enhanced automation features such as dynamic triggers and flow control. + // + Version *Version `json:"version,omitempty"` } func (f FlowTemplateInput) MarshalJSON() ([]byte, error) { @@ -46,135 +51,135 @@ func (f *FlowTemplateInput) UnmarshalJSON(data []byte) error { return nil } -func (o *FlowTemplateInput) GetAssignedTo() []string { - if o == nil { +func (f *FlowTemplateInput) GetAssignedTo() []string { + if f == nil { return nil } - return o.AssignedTo + return f.AssignedTo } -func (o *FlowTemplateInput) GetAvailableInEcp() *bool { - if o == nil { +func (f *FlowTemplateInput) GetAvailableInEcp() *bool { + if f == nil { return nil } - return o.AvailableInEcp + return f.AvailableInEcp } -func (o *FlowTemplateInput) GetClosingReasons() []ClosingReasonInput { - if o == nil { +func (f *FlowTemplateInput) GetClosingReasons() []ClosingReasonInput { + if f == nil { return nil } - return o.ClosingReasons + return f.ClosingReasons } -func (o *FlowTemplateInput) GetCreatedAt() *string { - if o == nil { +func (f *FlowTemplateInput) GetCreatedAt() *string { + if f == nil { return nil } - return o.CreatedAt + return f.CreatedAt } -func (o *FlowTemplateInput) GetDescription() *string { - if o == nil { +func (f *FlowTemplateInput) GetDescription() *string { + if f == nil { return nil } - return o.Description + return f.Description } -func (o *FlowTemplateInput) GetDueDate() *string { - if o == nil { +func (f *FlowTemplateInput) GetDueDate() *string { + if f == nil { return nil } - return o.DueDate + return f.DueDate } -func (o *FlowTemplateInput) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (f *FlowTemplateInput) GetDueDateConfig() *DueDateConfig { + if f == nil { return nil } - return o.DueDateConfig + return f.DueDateConfig } -func (o *FlowTemplateInput) GetEdges() []Edge { - if o == nil { +func (f *FlowTemplateInput) GetEdges() []Edge { + if f == nil { return []Edge{} } - return o.Edges + return f.Edges } -func (o *FlowTemplateInput) GetEnabled() *bool { - if o == nil { +func (f *FlowTemplateInput) GetEnabled() *bool { + if f == nil { return nil } - return o.Enabled + return f.Enabled } -func (o *FlowTemplateInput) GetID() *string { - if o == nil { +func (f *FlowTemplateInput) GetID() *string { + if f == nil { return nil } - return o.ID + return f.ID } -func (o *FlowTemplateInput) GetIsFlowMigrated() *bool { - if o == nil { - return nil - } - return o.IsFlowMigrated -} - -func (o *FlowTemplateInput) GetName() string { - if o == nil { +func (f *FlowTemplateInput) GetName() string { + if f == nil { return "" } - return o.Name + return f.Name } -func (o *FlowTemplateInput) GetOrgID() *string { - if o == nil { +func (f *FlowTemplateInput) GetOrgID() *string { + if f == nil { return nil } - return o.OrgID + return f.OrgID } -func (o *FlowTemplateInput) GetPhases() []Phase { - if o == nil { +func (f *FlowTemplateInput) GetPhases() []Phase { + if f == nil { return nil } - return o.Phases + return f.Phases } -func (o *FlowTemplateInput) GetTasks() []Task { - if o == nil { +func (f *FlowTemplateInput) GetTasks() []Task { + if f == nil { return []Task{} } - return o.Tasks + return f.Tasks +} + +func (f *FlowTemplateInput) GetTaxonomies() []string { + if f == nil { + return nil + } + return f.Taxonomies } -func (o *FlowTemplateInput) GetTaxonomies() []string { - if o == nil { +func (f *FlowTemplateInput) GetTrigger() *Trigger { + if f == nil { return nil } - return o.Taxonomies + return f.Trigger } -func (o *FlowTemplateInput) GetTrigger() *Trigger { - if o == nil { +func (f *FlowTemplateInput) GetUpdateEntityAttributes() []UpdateEntityAttributes { + if f == nil { return nil } - return o.Trigger + return f.UpdateEntityAttributes } -func (o *FlowTemplateInput) GetUpdateEntityAttributes() []UpdateEntityAttributes { - if o == nil { +func (f *FlowTemplateInput) GetUpdatedAt() *string { + if f == nil { return nil } - return o.UpdateEntityAttributes + return f.UpdatedAt } -func (o *FlowTemplateInput) GetUpdatedAt() *string { - if o == nil { +func (f *FlowTemplateInput) GetVersion() *Version { + if f == nil { return nil } - return o.UpdatedAt + return f.Version } diff --git a/internal/sdk/models/shared/flowtemplateslist.go b/internal/sdk/models/shared/flowtemplateslist.go index bebfa65..12951ca 100644 --- a/internal/sdk/models/shared/flowtemplateslist.go +++ b/internal/sdk/models/shared/flowtemplateslist.go @@ -6,9 +6,9 @@ type FlowTemplatesList struct { Results []FlowTemplate `json:"results"` } -func (o *FlowTemplatesList) GetResults() []FlowTemplate { - if o == nil { +func (f *FlowTemplatesList) GetResults() []FlowTemplate { + if f == nil { return []FlowTemplate{} } - return o.Results + return f.Results } diff --git a/internal/sdk/models/shared/immediateschedule.go b/internal/sdk/models/shared/immediateschedule.go index 94bd14a..b452ab9 100644 --- a/internal/sdk/models/shared/immediateschedule.go +++ b/internal/sdk/models/shared/immediateschedule.go @@ -46,9 +46,9 @@ func (i *ImmediateSchedule) UnmarshalJSON(data []byte) error { return nil } -func (o *ImmediateSchedule) GetMode() *ImmediateScheduleMode { - if o == nil { +func (i *ImmediateSchedule) GetMode() *ImmediateScheduleMode { + if i == nil { return nil } - return o.Mode + return i.Mode } diff --git a/internal/sdk/models/shared/itemtype.go b/internal/sdk/models/shared/itemtype.go new file mode 100644 index 0000000..a5c671f --- /dev/null +++ b/internal/sdk/models/shared/itemtype.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type ItemType string + +const ( + ItemTypeStep ItemType = "STEP" + ItemTypeSection ItemType = "SECTION" +) + +func (e ItemType) ToPointer() *ItemType { + return &e +} +func (e *ItemType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "STEP": + fallthrough + case "SECTION": + *e = ItemType(v) + return nil + default: + return fmt.Errorf("invalid value for ItemType: %v", v) + } +} diff --git a/internal/sdk/models/shared/journeyautomationtrigger.go b/internal/sdk/models/shared/journeyautomationtrigger.go new file mode 100644 index 0000000..08baa25 --- /dev/null +++ b/internal/sdk/models/shared/journeyautomationtrigger.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +type JourneyAutomationTriggerType string + +const ( + JourneyAutomationTriggerTypeJourneyAutomation JourneyAutomationTriggerType = "journey_automation" +) + +func (e JourneyAutomationTriggerType) ToPointer() *JourneyAutomationTriggerType { + return &e +} +func (e *JourneyAutomationTriggerType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "journey_automation": + *e = JourneyAutomationTriggerType(v) + return nil + default: + return fmt.Errorf("invalid value for JourneyAutomationTriggerType: %v", v) + } +} + +type JourneyAutomationTrigger struct { + // Schema of the main entity where flow will be triggered. The entity will be picked from automation context. + EntitySchema *string `json:"entity_schema,omitempty"` + ID *string `json:"id,omitempty"` + Type JourneyAutomationTriggerType `json:"type"` +} + +func (j JourneyAutomationTrigger) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(j, "", false) +} + +func (j *JourneyAutomationTrigger) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &j, "", false, []string{"type"}); err != nil { + return err + } + return nil +} + +func (j *JourneyAutomationTrigger) GetEntitySchema() *string { + if j == nil { + return nil + } + return j.EntitySchema +} + +func (j *JourneyAutomationTrigger) GetID() *string { + if j == nil { + return nil + } + return j.ID +} + +func (j *JourneyAutomationTrigger) GetType() JourneyAutomationTriggerType { + if j == nil { + return JourneyAutomationTriggerType("") + } + return j.Type +} diff --git a/internal/sdk/models/shared/journeysubmissiontrigger.go b/internal/sdk/models/shared/journeysubmissiontrigger.go index 8c5792d..6aed3c6 100644 --- a/internal/sdk/models/shared/journeysubmissiontrigger.go +++ b/internal/sdk/models/shared/journeysubmissiontrigger.go @@ -35,8 +35,10 @@ type JourneySubmissionTrigger struct { AutomationID *string `json:"automation_id,omitempty"` ID *string `json:"id,omitempty"` // ID of the journey that will trigger this flow - JourneyID string `json:"journey_id"` - Type JourneySubmissionTriggerType `json:"type"` + JourneyID string `json:"journey_id"` + // Name of the journey that will trigger this flow + JourneyName *string `json:"journey_name,omitempty"` + Type JourneySubmissionTriggerType `json:"type"` } func (j JourneySubmissionTrigger) MarshalJSON() ([]byte, error) { @@ -50,30 +52,37 @@ func (j *JourneySubmissionTrigger) UnmarshalJSON(data []byte) error { return nil } -func (o *JourneySubmissionTrigger) GetAutomationID() *string { - if o == nil { +func (j *JourneySubmissionTrigger) GetAutomationID() *string { + if j == nil { return nil } - return o.AutomationID + return j.AutomationID } -func (o *JourneySubmissionTrigger) GetID() *string { - if o == nil { +func (j *JourneySubmissionTrigger) GetID() *string { + if j == nil { return nil } - return o.ID + return j.ID } -func (o *JourneySubmissionTrigger) GetJourneyID() string { - if o == nil { +func (j *JourneySubmissionTrigger) GetJourneyID() string { + if j == nil { return "" } - return o.JourneyID + return j.JourneyID } -func (o *JourneySubmissionTrigger) GetType() JourneySubmissionTriggerType { - if o == nil { +func (j *JourneySubmissionTrigger) GetJourneyName() *string { + if j == nil { + return nil + } + return j.JourneyName +} + +func (j *JourneySubmissionTrigger) GetType() JourneySubmissionTriggerType { + if j == nil { return JourneySubmissionTriggerType("") } - return o.Type + return j.Type } diff --git a/internal/sdk/models/shared/manualtrigger.go b/internal/sdk/models/shared/manualtrigger.go index e6e1d0f..1f31105 100644 --- a/internal/sdk/models/shared/manualtrigger.go +++ b/internal/sdk/models/shared/manualtrigger.go @@ -48,23 +48,23 @@ func (m *ManualTrigger) UnmarshalJSON(data []byte) error { return nil } -func (o *ManualTrigger) GetEntitySchema() *string { - if o == nil { +func (m *ManualTrigger) GetEntitySchema() *string { + if m == nil { return nil } - return o.EntitySchema + return m.EntitySchema } -func (o *ManualTrigger) GetID() *string { - if o == nil { +func (m *ManualTrigger) GetID() *string { + if m == nil { return nil } - return o.ID + return m.ID } -func (o *ManualTrigger) GetType() ManualTriggerType { - if o == nil { +func (m *ManualTrigger) GetType() ManualTriggerType { + if m == nil { return ManualTriggerType("") } - return o.Type + return m.Type } diff --git a/internal/sdk/models/shared/maxallowedlimit.go b/internal/sdk/models/shared/maxallowedlimit.go index 40dc1fa..8eddb7c 100644 --- a/internal/sdk/models/shared/maxallowedlimit.go +++ b/internal/sdk/models/shared/maxallowedlimit.go @@ -7,16 +7,16 @@ type MaxAllowedLimit struct { MaxAllowed *float64 `json:"maxAllowed,omitempty"` } -func (o *MaxAllowedLimit) GetCurrentNoOfWorkflows() *float64 { - if o == nil { +func (m *MaxAllowedLimit) GetCurrentNoOfWorkflows() *float64 { + if m == nil { return nil } - return o.CurrentNoOfWorkflows + return m.CurrentNoOfWorkflows } -func (o *MaxAllowedLimit) GetMaxAllowed() *float64 { - if o == nil { +func (m *MaxAllowedLimit) GetMaxAllowed() *float64 { + if m == nil { return nil } - return o.MaxAllowed + return m.MaxAllowed } diff --git a/internal/sdk/models/shared/phase.go b/internal/sdk/models/shared/phase.go index 7c954b5..2ba0ce7 100644 --- a/internal/sdk/models/shared/phase.go +++ b/internal/sdk/models/shared/phase.go @@ -13,44 +13,44 @@ type Phase struct { Taxonomies []string `json:"taxonomies,omitempty"` } -func (o *Phase) GetAssignedTo() []string { - if o == nil { +func (p *Phase) GetAssignedTo() []string { + if p == nil { return nil } - return o.AssignedTo + return p.AssignedTo } -func (o *Phase) GetDueDate() *string { - if o == nil { +func (p *Phase) GetDueDate() *string { + if p == nil { return nil } - return o.DueDate + return p.DueDate } -func (o *Phase) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (p *Phase) GetDueDateConfig() *DueDateConfig { + if p == nil { return nil } - return o.DueDateConfig + return p.DueDateConfig } -func (o *Phase) GetID() string { - if o == nil { +func (p *Phase) GetID() string { + if p == nil { return "" } - return o.ID + return p.ID } -func (o *Phase) GetName() string { - if o == nil { +func (p *Phase) GetName() string { + if p == nil { return "" } - return o.Name + return p.Name } -func (o *Phase) GetTaxonomies() []string { - if o == nil { +func (p *Phase) GetTaxonomies() []string { + if p == nil { return nil } - return o.Taxonomies + return p.Taxonomies } diff --git a/internal/sdk/models/shared/relativeschedule.go b/internal/sdk/models/shared/relativeschedule.go index 804a1a1..2626011 100644 --- a/internal/sdk/models/shared/relativeschedule.go +++ b/internal/sdk/models/shared/relativeschedule.go @@ -107,32 +107,32 @@ func (r *Reference) UnmarshalJSON(data []byte) error { return nil } -func (o *Reference) GetAttribute() *string { - if o == nil { +func (r *Reference) GetAttribute() *string { + if r == nil { return nil } - return o.Attribute + return r.Attribute } -func (o *Reference) GetID() string { - if o == nil { +func (r *Reference) GetID() string { + if r == nil { return "" } - return o.ID + return r.ID } -func (o *Reference) GetOrigin() RelativeScheduleOrigin { - if o == nil { +func (r *Reference) GetOrigin() RelativeScheduleOrigin { + if r == nil { return RelativeScheduleOrigin("") } - return o.Origin + return r.Origin } -func (o *Reference) GetSchema() *string { - if o == nil { +func (r *Reference) GetSchema() *string { + if r == nil { return nil } - return o.Schema + return r.Schema } type RelativeSchedule struct { @@ -154,37 +154,37 @@ func (r *RelativeSchedule) UnmarshalJSON(data []byte) error { return nil } -func (o *RelativeSchedule) GetDirection() Direction { - if o == nil { +func (r *RelativeSchedule) GetDirection() Direction { + if r == nil { return Direction("") } - return o.Direction + return r.Direction } -func (o *RelativeSchedule) GetDuration() float64 { - if o == nil { +func (r *RelativeSchedule) GetDuration() float64 { + if r == nil { return 0.0 } - return o.Duration + return r.Duration } -func (o *RelativeSchedule) GetMode() RelativeScheduleMode { - if o == nil { +func (r *RelativeSchedule) GetMode() RelativeScheduleMode { + if r == nil { return RelativeScheduleMode("") } - return o.Mode + return r.Mode } -func (o *RelativeSchedule) GetReference() Reference { - if o == nil { +func (r *RelativeSchedule) GetReference() Reference { + if r == nil { return Reference{} } - return o.Reference + return r.Reference } -func (o *RelativeSchedule) GetUnit() TimeUnit { - if o == nil { +func (r *RelativeSchedule) GetUnit() TimeUnit { + if r == nil { return TimeUnit("") } - return o.Unit + return r.Unit } diff --git a/internal/sdk/models/shared/searchflowtemplates.go b/internal/sdk/models/shared/searchflowtemplates.go new file mode 100644 index 0000000..88c29c3 --- /dev/null +++ b/internal/sdk/models/shared/searchflowtemplates.go @@ -0,0 +1,168 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +type SortBy string + +const ( + SortByCreatedAt SortBy = "created_at" + SortByUpdatedAt SortBy = "updated_at" +) + +func (e SortBy) ToPointer() *SortBy { + return &e +} +func (e *SortBy) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "created_at": + fallthrough + case "updated_at": + *e = SortBy(v) + return nil + default: + return fmt.Errorf("invalid value for SortBy: %v", v) + } +} + +type SortOrder string + +const ( + SortOrderAsc SortOrder = "asc" + SortOrderDesc SortOrder = "desc" +) + +func (e SortOrder) ToPointer() *SortOrder { + return &e +} +func (e *SortOrder) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "asc": + fallthrough + case "desc": + *e = SortOrder(v) + return nil + default: + return fmt.Errorf("invalid value for SortOrder: %v", v) + } +} + +type TriggerType string + +const ( + TriggerTypeJourneySubmission TriggerType = "journey_submission" + TriggerTypeManual TriggerType = "manual" + TriggerTypeAutomation TriggerType = "automation" +) + +func (e TriggerType) ToPointer() *TriggerType { + return &e +} +func (e *TriggerType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "journey_submission": + fallthrough + case "manual": + fallthrough + case "automation": + *e = TriggerType(v) + return nil + default: + return fmt.Errorf("invalid value for TriggerType: %v", v) + } +} + +type SearchFlowTemplates struct { + DefinitionID *string `json:"definition_id,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + From *int64 `json:"from,omitempty"` + Name *string `json:"name,omitempty"` + Size *int64 `json:"size,omitempty"` + SortBy *SortBy `default:"updated_at" json:"sort_by"` + SortOrder *SortOrder `default:"desc" json:"sort_order"` + TriggerType *TriggerType `json:"trigger_type,omitempty"` +} + +func (s SearchFlowTemplates) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *SearchFlowTemplates) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { + return err + } + return nil +} + +func (s *SearchFlowTemplates) GetDefinitionID() *string { + if s == nil { + return nil + } + return s.DefinitionID +} + +func (s *SearchFlowTemplates) GetEnabled() *bool { + if s == nil { + return nil + } + return s.Enabled +} + +func (s *SearchFlowTemplates) GetFrom() *int64 { + if s == nil { + return nil + } + return s.From +} + +func (s *SearchFlowTemplates) GetName() *string { + if s == nil { + return nil + } + return s.Name +} + +func (s *SearchFlowTemplates) GetSize() *int64 { + if s == nil { + return nil + } + return s.Size +} + +func (s *SearchFlowTemplates) GetSortBy() *SortBy { + if s == nil { + return nil + } + return s.SortBy +} + +func (s *SearchFlowTemplates) GetSortOrder() *SortOrder { + if s == nil { + return nil + } + return s.SortOrder +} + +func (s *SearchFlowTemplates) GetTriggerType() *TriggerType { + if s == nil { + return nil + } + return s.TriggerType +} diff --git a/internal/sdk/models/shared/section.go b/internal/sdk/models/shared/section.go new file mode 100644 index 0000000..ccd8e42 --- /dev/null +++ b/internal/sdk/models/shared/section.go @@ -0,0 +1,96 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +// Section - A group of Steps that define the progress of the Workflow +type Section struct { + AssignedTo []string `json:"assignedTo,omitempty"` + DueDate *string `json:"dueDate,omitempty"` + // set a Duedate for a step then a specific + DynamicDueDate *DynamicDueDate `json:"dynamicDueDate,omitempty"` + ID *string `json:"id,omitempty"` + Name string `json:"name"` + Order float64 `json:"order"` + Steps []Step `json:"steps"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` + Type ItemType `json:"type"` +} + +func (s Section) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Section) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"name", "order", "steps", "type"}); err != nil { + return err + } + return nil +} + +func (s *Section) GetAssignedTo() []string { + if s == nil { + return nil + } + return s.AssignedTo +} + +func (s *Section) GetDueDate() *string { + if s == nil { + return nil + } + return s.DueDate +} + +func (s *Section) GetDynamicDueDate() *DynamicDueDate { + if s == nil { + return nil + } + return s.DynamicDueDate +} + +func (s *Section) GetID() *string { + if s == nil { + return nil + } + return s.ID +} + +func (s *Section) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *Section) GetOrder() float64 { + if s == nil { + return 0.0 + } + return s.Order +} + +func (s *Section) GetSteps() []Step { + if s == nil { + return []Step{} + } + return s.Steps +} + +func (s *Section) GetTaxonomies() []string { + if s == nil { + return nil + } + return s.Taxonomies +} + +func (s *Section) GetType() ItemType { + if s == nil { + return ItemType("") + } + return s.Type +} diff --git a/internal/sdk/models/shared/security.go b/internal/sdk/models/shared/security.go index 53da636..9ed88ed 100644 --- a/internal/sdk/models/shared/security.go +++ b/internal/sdk/models/shared/security.go @@ -6,9 +6,9 @@ type Security struct { BearerAuth string `security:"scheme,type=http,subtype=bearer,name=Authorization"` } -func (o *Security) GetBearerAuth() string { - if o == nil { +func (s *Security) GetBearerAuth() string { + if s == nil { return "" } - return o.BearerAuth + return s.BearerAuth } diff --git a/internal/sdk/models/shared/statement.go b/internal/sdk/models/shared/statement.go index 715844d..018782f 100644 --- a/internal/sdk/models/shared/statement.go +++ b/internal/sdk/models/shared/statement.go @@ -24,30 +24,30 @@ func (s *Statement) UnmarshalJSON(data []byte) error { return nil } -func (o *Statement) GetID() string { - if o == nil { +func (s *Statement) GetID() string { + if s == nil { return "" } - return o.ID + return s.ID } -func (o *Statement) GetOperator() Operator { - if o == nil { +func (s *Statement) GetOperator() Operator { + if s == nil { return Operator("") } - return o.Operator + return s.Operator } -func (o *Statement) GetSource() EvaluationSource { - if o == nil { +func (s *Statement) GetSource() EvaluationSource { + if s == nil { return EvaluationSource{} } - return o.Source + return s.Source } -func (o *Statement) GetValues() []string { - if o == nil { +func (s *Statement) GetValues() []string { + if s == nil { return []string{} } - return o.Values + return s.Values } diff --git a/internal/sdk/models/shared/step.go b/internal/sdk/models/shared/step.go new file mode 100644 index 0000000..3a7772b --- /dev/null +++ b/internal/sdk/models/shared/step.go @@ -0,0 +1,182 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +type StepAutomationConfig struct { + // Id of the configured automation to run + FlowID string `json:"flowId"` +} + +func (s StepAutomationConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *StepAutomationConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"flowId"}); err != nil { + return err + } + return nil +} + +func (s *StepAutomationConfig) GetFlowID() string { + if s == nil { + return "" + } + return s.FlowID +} + +// Step - Action that needs to be done in a Workflow +type Step struct { + AssignedTo []string `json:"assignedTo,omitempty"` + AutomationConfig *StepAutomationConfig `json:"automationConfig,omitempty"` + // Longer information regarding Task + Description *StepDescription `json:"description,omitempty"` + DueDate *string `json:"dueDate,omitempty"` + // set a Duedate for a step then a specific + DynamicDueDate *DynamicDueDate `json:"dynamicDueDate,omitempty"` + // Details regarding ECP for the workflow step + Ecp *ECPDetails `json:"ecp,omitempty"` + ExecutionType *StepType `json:"executionType,omitempty"` + ID *string `json:"id,omitempty"` + // Details regarding ECP for the workflow step + Installer *ECPDetails `json:"installer,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + Name string `json:"name"` + Order float64 `json:"order"` + // requirements that need to be fulfilled in order to enable the step execution + Requirements []StepRequirement `json:"requirements,omitempty"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` + Type ItemType `json:"type"` + // This field is deprecated. Please use assignedTo + // + // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. + UserIds []float64 `json:"userIds,omitempty"` +} + +func (s Step) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Step) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"name", "order", "type"}); err != nil { + return err + } + return nil +} + +func (s *Step) GetAssignedTo() []string { + if s == nil { + return nil + } + return s.AssignedTo +} + +func (s *Step) GetAutomationConfig() *StepAutomationConfig { + if s == nil { + return nil + } + return s.AutomationConfig +} + +func (s *Step) GetDescription() *StepDescription { + if s == nil { + return nil + } + return s.Description +} + +func (s *Step) GetDueDate() *string { + if s == nil { + return nil + } + return s.DueDate +} + +func (s *Step) GetDynamicDueDate() *DynamicDueDate { + if s == nil { + return nil + } + return s.DynamicDueDate +} + +func (s *Step) GetEcp() *ECPDetails { + if s == nil { + return nil + } + return s.Ecp +} + +func (s *Step) GetExecutionType() *StepType { + if s == nil { + return nil + } + return s.ExecutionType +} + +func (s *Step) GetID() *string { + if s == nil { + return nil + } + return s.ID +} + +func (s *Step) GetInstaller() *ECPDetails { + if s == nil { + return nil + } + return s.Installer +} + +func (s *Step) GetJourney() *StepJourney { + if s == nil { + return nil + } + return s.Journey +} + +func (s *Step) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *Step) GetOrder() float64 { + if s == nil { + return 0.0 + } + return s.Order +} + +func (s *Step) GetRequirements() []StepRequirement { + if s == nil { + return nil + } + return s.Requirements +} + +func (s *Step) GetTaxonomies() []string { + if s == nil { + return nil + } + return s.Taxonomies +} + +func (s *Step) GetType() ItemType { + if s == nil { + return ItemType("") + } + return s.Type +} + +func (s *Step) GetUserIds() []float64 { + if s == nil { + return nil + } + return s.UserIds +} diff --git a/internal/sdk/models/shared/stepdescription.go b/internal/sdk/models/shared/stepdescription.go index e64700d..31453a9 100644 --- a/internal/sdk/models/shared/stepdescription.go +++ b/internal/sdk/models/shared/stepdescription.go @@ -23,16 +23,16 @@ func (s *StepDescription) UnmarshalJSON(data []byte) error { return nil } -func (o *StepDescription) GetEnabled() *bool { - if o == nil { +func (s *StepDescription) GetEnabled() *bool { + if s == nil { return nil } - return o.Enabled + return s.Enabled } -func (o *StepDescription) GetValue() *string { - if o == nil { +func (s *StepDescription) GetValue() *string { + if s == nil { return nil } - return o.Value + return s.Value } diff --git a/internal/sdk/models/shared/stepjourney.go b/internal/sdk/models/shared/stepjourney.go index 0e498b4..9d8b2af 100644 --- a/internal/sdk/models/shared/stepjourney.go +++ b/internal/sdk/models/shared/stepjourney.go @@ -7,9 +7,11 @@ import ( ) type StepJourney struct { - ID *string `json:"id,omitempty"` - JourneyID *string `json:"journeyId,omitempty"` - Name *string `json:"name,omitempty"` + // If true, the task be auto completed when the journey is completed. By default it is true. + CompleteTaskAutomatically *bool `default:"true" json:"complete_task_automatically"` + ID *string `json:"id,omitempty"` + JourneyID *string `json:"journeyId,omitempty"` + Name *string `json:"name,omitempty"` } func (s StepJourney) MarshalJSON() ([]byte, error) { @@ -23,23 +25,30 @@ func (s *StepJourney) UnmarshalJSON(data []byte) error { return nil } -func (o *StepJourney) GetID() *string { - if o == nil { +func (s *StepJourney) GetCompleteTaskAutomatically() *bool { + if s == nil { return nil } - return o.ID + return s.CompleteTaskAutomatically } -func (o *StepJourney) GetJourneyID() *string { - if o == nil { +func (s *StepJourney) GetID() *string { + if s == nil { return nil } - return o.JourneyID + return s.ID } -func (o *StepJourney) GetName() *string { - if o == nil { +func (s *StepJourney) GetJourneyID() *string { + if s == nil { return nil } - return o.Name + return s.JourneyID +} + +func (s *StepJourney) GetName() *string { + if s == nil { + return nil + } + return s.Name } diff --git a/internal/sdk/models/shared/steprequirement.go b/internal/sdk/models/shared/steprequirement.go new file mode 100644 index 0000000..42f9155 --- /dev/null +++ b/internal/sdk/models/shared/steprequirement.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +type StepRequirementCondition string + +const ( + StepRequirementConditionClosed StepRequirementCondition = "CLOSED" +) + +func (e StepRequirementCondition) ToPointer() *StepRequirementCondition { + return &e +} +func (e *StepRequirementCondition) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "CLOSED": + *e = StepRequirementCondition(v) + return nil + default: + return fmt.Errorf("invalid value for StepRequirementCondition: %v", v) + } +} + +// StepRequirement - describe the requirement for step enablement +type StepRequirement struct { + Condition StepRequirementCondition `json:"condition"` + DefinitionID string `json:"definitionId"` + Type ItemType `json:"type"` +} + +func (s StepRequirement) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *StepRequirement) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"condition", "definitionId", "type"}); err != nil { + return err + } + return nil +} + +func (s *StepRequirement) GetCondition() StepRequirementCondition { + if s == nil { + return StepRequirementCondition("") + } + return s.Condition +} + +func (s *StepRequirement) GetDefinitionID() string { + if s == nil { + return "" + } + return s.DefinitionID +} + +func (s *StepRequirement) GetType() ItemType { + if s == nil { + return ItemType("") + } + return s.Type +} diff --git a/internal/sdk/models/shared/steptype.go b/internal/sdk/models/shared/steptype.go new file mode 100644 index 0000000..e76cf9b --- /dev/null +++ b/internal/sdk/models/shared/steptype.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type StepType string + +const ( + StepTypeManual StepType = "MANUAL" + StepTypeAutomation StepType = "AUTOMATION" +) + +func (e StepType) ToPointer() *StepType { + return &e +} +func (e *StepType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "MANUAL": + fallthrough + case "AUTOMATION": + *e = StepType(v) + return nil + default: + return fmt.Errorf("invalid value for StepType: %v", v) + } +} diff --git a/internal/sdk/models/shared/task.go b/internal/sdk/models/shared/task.go index 84396ad..f825fff 100644 --- a/internal/sdk/models/shared/task.go +++ b/internal/sdk/models/shared/task.go @@ -17,9 +17,9 @@ const ( ) type Task struct { - TaskBase *TaskBase `queryParam:"inline"` - AutomationTask *AutomationTask `queryParam:"inline"` - DecisionTask *DecisionTask `queryParam:"inline"` + TaskBase *TaskBase `queryParam:"inline,name=Task"` + AutomationTask *AutomationTask `queryParam:"inline,name=Task"` + DecisionTask *DecisionTask `queryParam:"inline,name=Task"` Type TaskUnionType } @@ -53,24 +53,54 @@ func CreateTaskDecisionTask(decisionTask DecisionTask) Task { func (u *Task) UnmarshalJSON(data []byte) error { - var automationTask AutomationTask = AutomationTask{} - if err := utils.UnmarshalJSON(data, &automationTask, "", true, nil); err == nil { - u.AutomationTask = &automationTask - u.Type = TaskUnionTypeAutomationTask - return nil - } + var candidates []utils.UnionCandidate + // Collect all valid candidates var decisionTask DecisionTask = DecisionTask{} if err := utils.UnmarshalJSON(data, &decisionTask, "", true, nil); err == nil { - u.DecisionTask = &decisionTask - u.Type = TaskUnionTypeDecisionTask - return nil + candidates = append(candidates, utils.UnionCandidate{ + Type: TaskUnionTypeDecisionTask, + Value: &decisionTask, + }) + } + + var automationTask AutomationTask = AutomationTask{} + if err := utils.UnmarshalJSON(data, &automationTask, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: TaskUnionTypeAutomationTask, + Value: &automationTask, + }) } var taskBase TaskBase = TaskBase{} if err := utils.UnmarshalJSON(data, &taskBase, "", true, nil); err == nil { - u.TaskBase = &taskBase - u.Type = TaskUnionTypeTaskBase + candidates = append(candidates, utils.UnionCandidate{ + Type: TaskUnionTypeTaskBase, + Value: &taskBase, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Task", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Task", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(TaskUnionType) + switch best.Type { + case TaskUnionTypeDecisionTask: + u.DecisionTask = best.Value.(*DecisionTask) + return nil + case TaskUnionTypeAutomationTask: + u.AutomationTask = best.Value.(*AutomationTask) + return nil + case TaskUnionTypeTaskBase: + u.TaskBase = best.Value.(*TaskBase) return nil } diff --git a/internal/sdk/models/shared/taskbase.go b/internal/sdk/models/shared/taskbase.go index 1f1d584..8b22cee 100644 --- a/internal/sdk/models/shared/taskbase.go +++ b/internal/sdk/models/shared/taskbase.go @@ -39,93 +39,93 @@ func (t *TaskBase) UnmarshalJSON(data []byte) error { return nil } -func (o *TaskBase) GetAssignedTo() []string { - if o == nil { +func (t *TaskBase) GetAssignedTo() []string { + if t == nil { return nil } - return o.AssignedTo + return t.AssignedTo } -func (o *TaskBase) GetDescription() *StepDescription { - if o == nil { +func (t *TaskBase) GetDescription() *StepDescription { + if t == nil { return nil } - return o.Description + return t.Description } -func (o *TaskBase) GetDueDate() *string { - if o == nil { +func (t *TaskBase) GetDueDate() *string { + if t == nil { return nil } - return o.DueDate + return t.DueDate } -func (o *TaskBase) GetDueDateConfig() *DueDateConfig { - if o == nil { +func (t *TaskBase) GetDueDateConfig() *DueDateConfig { + if t == nil { return nil } - return o.DueDateConfig + return t.DueDateConfig } -func (o *TaskBase) GetEcp() *ECPDetails { - if o == nil { +func (t *TaskBase) GetEcp() *ECPDetails { + if t == nil { return nil } - return o.Ecp + return t.Ecp } -func (o *TaskBase) GetID() string { - if o == nil { +func (t *TaskBase) GetID() string { + if t == nil { return "" } - return o.ID + return t.ID } -func (o *TaskBase) GetInstaller() *ECPDetails { - if o == nil { +func (t *TaskBase) GetInstaller() *ECPDetails { + if t == nil { return nil } - return o.Installer + return t.Installer } -func (o *TaskBase) GetJourney() *StepJourney { - if o == nil { +func (t *TaskBase) GetJourney() *StepJourney { + if t == nil { return nil } - return o.Journey + return t.Journey } -func (o *TaskBase) GetName() string { - if o == nil { +func (t *TaskBase) GetName() string { + if t == nil { return "" } - return o.Name + return t.Name } -func (o *TaskBase) GetPhaseID() *string { - if o == nil { +func (t *TaskBase) GetPhaseID() *string { + if t == nil { return nil } - return o.PhaseID + return t.PhaseID } -func (o *TaskBase) GetRequirements() []EnableRequirement { - if o == nil { +func (t *TaskBase) GetRequirements() []EnableRequirement { + if t == nil { return nil } - return o.Requirements + return t.Requirements } -func (o *TaskBase) GetTaskType() TaskType { - if o == nil { +func (t *TaskBase) GetTaskType() TaskType { + if t == nil { return TaskType("") } - return o.TaskType + return t.TaskType } -func (o *TaskBase) GetTaxonomies() []string { - if o == nil { +func (t *TaskBase) GetTaxonomies() []string { + if t == nil { return nil } - return o.Taxonomies + return t.Taxonomies } diff --git a/internal/sdk/models/shared/trigger.go b/internal/sdk/models/shared/trigger.go index 4886ff8..e4ef6b8 100644 --- a/internal/sdk/models/shared/trigger.go +++ b/internal/sdk/models/shared/trigger.go @@ -8,24 +8,26 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" ) -type TriggerType string +type TriggerUnionType string const ( - TriggerTypeManualTrigger TriggerType = "ManualTrigger" - TriggerTypeAutomationTrigger TriggerType = "AutomationTrigger" - TriggerTypeJourneySubmissionTrigger TriggerType = "JourneySubmissionTrigger" + TriggerUnionTypeManualTrigger TriggerUnionType = "ManualTrigger" + TriggerUnionTypeAutomationTrigger TriggerUnionType = "AutomationTrigger" + TriggerUnionTypeJourneySubmissionTrigger TriggerUnionType = "JourneySubmissionTrigger" + TriggerUnionTypeJourneyAutomationTrigger TriggerUnionType = "JourneyAutomationTrigger" ) type Trigger struct { - ManualTrigger *ManualTrigger `queryParam:"inline"` - AutomationTrigger *AutomationTrigger `queryParam:"inline"` - JourneySubmissionTrigger *JourneySubmissionTrigger `queryParam:"inline"` + ManualTrigger *ManualTrigger `queryParam:"inline,name=Trigger"` + AutomationTrigger *AutomationTrigger `queryParam:"inline,name=Trigger"` + JourneySubmissionTrigger *JourneySubmissionTrigger `queryParam:"inline,name=Trigger"` + JourneyAutomationTrigger *JourneyAutomationTrigger `queryParam:"inline,name=Trigger"` - Type TriggerType + Type TriggerUnionType } func CreateTriggerManualTrigger(manualTrigger ManualTrigger) Trigger { - typ := TriggerTypeManualTrigger + typ := TriggerUnionTypeManualTrigger return Trigger{ ManualTrigger: &manualTrigger, @@ -34,7 +36,7 @@ func CreateTriggerManualTrigger(manualTrigger ManualTrigger) Trigger { } func CreateTriggerAutomationTrigger(automationTrigger AutomationTrigger) Trigger { - typ := TriggerTypeAutomationTrigger + typ := TriggerUnionTypeAutomationTrigger return Trigger{ AutomationTrigger: &automationTrigger, @@ -43,7 +45,7 @@ func CreateTriggerAutomationTrigger(automationTrigger AutomationTrigger) Trigger } func CreateTriggerJourneySubmissionTrigger(journeySubmissionTrigger JourneySubmissionTrigger) Trigger { - typ := TriggerTypeJourneySubmissionTrigger + typ := TriggerUnionTypeJourneySubmissionTrigger return Trigger{ JourneySubmissionTrigger: &journeySubmissionTrigger, @@ -51,26 +53,76 @@ func CreateTriggerJourneySubmissionTrigger(journeySubmissionTrigger JourneySubmi } } +func CreateTriggerJourneyAutomationTrigger(journeyAutomationTrigger JourneyAutomationTrigger) Trigger { + typ := TriggerUnionTypeJourneyAutomationTrigger + + return Trigger{ + JourneyAutomationTrigger: &journeyAutomationTrigger, + Type: typ, + } +} + func (u *Trigger) UnmarshalJSON(data []byte) error { + var candidates []utils.UnionCandidate + + // Collect all valid candidates var automationTrigger AutomationTrigger = AutomationTrigger{} if err := utils.UnmarshalJSON(data, &automationTrigger, "", true, nil); err == nil { - u.AutomationTrigger = &automationTrigger - u.Type = TriggerTypeAutomationTrigger - return nil + candidates = append(candidates, utils.UnionCandidate{ + Type: TriggerUnionTypeAutomationTrigger, + Value: &automationTrigger, + }) } var journeySubmissionTrigger JourneySubmissionTrigger = JourneySubmissionTrigger{} if err := utils.UnmarshalJSON(data, &journeySubmissionTrigger, "", true, nil); err == nil { - u.JourneySubmissionTrigger = &journeySubmissionTrigger - u.Type = TriggerTypeJourneySubmissionTrigger - return nil + candidates = append(candidates, utils.UnionCandidate{ + Type: TriggerUnionTypeJourneySubmissionTrigger, + Value: &journeySubmissionTrigger, + }) } var manualTrigger ManualTrigger = ManualTrigger{} if err := utils.UnmarshalJSON(data, &manualTrigger, "", true, nil); err == nil { - u.ManualTrigger = &manualTrigger - u.Type = TriggerTypeManualTrigger + candidates = append(candidates, utils.UnionCandidate{ + Type: TriggerUnionTypeManualTrigger, + Value: &manualTrigger, + }) + } + + var journeyAutomationTrigger JourneyAutomationTrigger = JourneyAutomationTrigger{} + if err := utils.UnmarshalJSON(data, &journeyAutomationTrigger, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: TriggerUnionTypeJourneyAutomationTrigger, + Value: &journeyAutomationTrigger, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Trigger", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Trigger", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(TriggerUnionType) + switch best.Type { + case TriggerUnionTypeAutomationTrigger: + u.AutomationTrigger = best.Value.(*AutomationTrigger) + return nil + case TriggerUnionTypeJourneySubmissionTrigger: + u.JourneySubmissionTrigger = best.Value.(*JourneySubmissionTrigger) + return nil + case TriggerUnionTypeManualTrigger: + u.ManualTrigger = best.Value.(*ManualTrigger) + return nil + case TriggerUnionTypeJourneyAutomationTrigger: + u.JourneyAutomationTrigger = best.Value.(*JourneyAutomationTrigger) return nil } @@ -90,5 +142,9 @@ func (u Trigger) MarshalJSON() ([]byte, error) { return utils.MarshalJSON(u.JourneySubmissionTrigger, "", true) } + if u.JourneyAutomationTrigger != nil { + return utils.MarshalJSON(u.JourneyAutomationTrigger, "", true) + } + return nil, errors.New("could not marshal union type Trigger: all fields are null") } diff --git a/internal/sdk/models/shared/updateentityattributes.go b/internal/sdk/models/shared/updateentityattributes.go index bd54844..64486aa 100644 --- a/internal/sdk/models/shared/updateentityattributes.go +++ b/internal/sdk/models/shared/updateentityattributes.go @@ -41,18 +41,18 @@ type Target struct { EntitySchema string `json:"entitySchema"` } -func (o *Target) GetEntityAttribute() string { - if o == nil { +func (t *Target) GetEntityAttribute() string { + if t == nil { return "" } - return o.EntityAttribute + return t.EntityAttribute } -func (o *Target) GetEntitySchema() string { - if o == nil { +func (t *Target) GetEntitySchema() string { + if t == nil { return "" } - return o.EntitySchema + return t.EntitySchema } type UpdateEntityAttributes struct { @@ -60,16 +60,16 @@ type UpdateEntityAttributes struct { Target Target `json:"target"` } -func (o *UpdateEntityAttributes) GetSource() Source { - if o == nil { +func (u *UpdateEntityAttributes) GetSource() Source { + if u == nil { return Source("") } - return o.Source + return u.Source } -func (o *UpdateEntityAttributes) GetTarget() Target { - if o == nil { +func (u *UpdateEntityAttributes) GetTarget() Target { + if u == nil { return Target{} } - return o.Target + return u.Target } diff --git a/internal/sdk/models/shared/version.go b/internal/sdk/models/shared/version.go new file mode 100644 index 0000000..0a4ebad --- /dev/null +++ b/internal/sdk/models/shared/version.go @@ -0,0 +1,42 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +// Version of the workflow schema. +// +// - `v1` – *Deprecated*. The initial version of workflows with limited structure and automation capabilities. +// - `v2` – Linear workflows. Supports sequential task execution with basic automation triggers. +// - `v3` – Advanced workflows. Adds support for branching logic (conditions), parallel paths, and enhanced automation features such as dynamic triggers and flow control. +type Version string + +const ( + VersionV1 Version = "v1" + VersionV2 Version = "v2" + VersionV3 Version = "v3" +) + +func (e Version) ToPointer() *Version { + return &e +} +func (e *Version) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "v1": + fallthrough + case "v2": + fallthrough + case "v3": + *e = Version(v) + return nil + default: + return fmt.Errorf("invalid value for Version: %v", v) + } +} diff --git a/internal/sdk/models/shared/workflowdefinition.go b/internal/sdk/models/shared/workflowdefinition.go index fb8af87..0d17e17 100644 --- a/internal/sdk/models/shared/workflowdefinition.go +++ b/internal/sdk/models/shared/workflowdefinition.go @@ -3,9 +3,100 @@ package shared import ( + "errors" + "fmt" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" ) +type FlowType string + +const ( + FlowTypeSection FlowType = "Section" + FlowTypeStep FlowType = "Step" +) + +type Flow struct { + Section *Section `queryParam:"inline,name=flow"` + Step *Step `queryParam:"inline,name=flow"` + + Type FlowType +} + +func CreateFlowSection(section Section) Flow { + typ := FlowTypeSection + + return Flow{ + Section: §ion, + Type: typ, + } +} + +func CreateFlowStep(step Step) Flow { + typ := FlowTypeStep + + return Flow{ + Step: &step, + Type: typ, + } +} + +func (u *Flow) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var section Section = Section{} + if err := utils.UnmarshalJSON(data, §ion, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: FlowTypeSection, + Value: §ion, + }) + } + + var step Step = Step{} + if err := utils.UnmarshalJSON(data, &step, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: FlowTypeStep, + Value: &step, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Flow", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Flow", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(FlowType) + switch best.Type { + case FlowTypeSection: + u.Section = best.Value.(*Section) + return nil + case FlowTypeStep: + u.Step = best.Value.(*Step) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Flow", string(data)) +} + +func (u Flow) MarshalJSON() ([]byte, error) { + if u.Section != nil { + return utils.MarshalJSON(u.Section, "", true) + } + + if u.Step != nil { + return utils.MarshalJSON(u.Step, "", true) + } + + return nil, errors.New("could not marshal union type Flow: all fields are null") +} + type WorkflowDefinition struct { AssignedTo []string `json:"assignedTo,omitempty"` ClosingReasons []ClosingReasonID `json:"closingReasons,omitempty"` @@ -19,7 +110,7 @@ type WorkflowDefinition struct { EnableECPWorkflow *bool `json:"enableECPWorkflow,omitempty"` // Whether the workflow is enabled or not Enabled *bool `default:"true" json:"enabled"` - Flow any `json:"flow"` + Flow []Flow `json:"flow"` ID *string `json:"id,omitempty"` // ISO String Date & Time LastUpdateTime *string `json:"lastUpdateTime,omitempty"` @@ -44,107 +135,107 @@ func (w *WorkflowDefinition) UnmarshalJSON(data []byte) error { return nil } -func (o *WorkflowDefinition) GetAssignedTo() []string { - if o == nil { +func (w *WorkflowDefinition) GetAssignedTo() []string { + if w == nil { return nil } - return o.AssignedTo + return w.AssignedTo } -func (o *WorkflowDefinition) GetClosingReasons() []ClosingReasonID { - if o == nil { +func (w *WorkflowDefinition) GetClosingReasons() []ClosingReasonID { + if w == nil { return nil } - return o.ClosingReasons + return w.ClosingReasons } -func (o *WorkflowDefinition) GetCreationTime() *string { - if o == nil { +func (w *WorkflowDefinition) GetCreationTime() *string { + if w == nil { return nil } - return o.CreationTime + return w.CreationTime } -func (o *WorkflowDefinition) GetDescription() *string { - if o == nil { +func (w *WorkflowDefinition) GetDescription() *string { + if w == nil { return nil } - return o.Description + return w.Description } -func (o *WorkflowDefinition) GetDueDate() *string { - if o == nil { +func (w *WorkflowDefinition) GetDueDate() *string { + if w == nil { return nil } - return o.DueDate + return w.DueDate } -func (o *WorkflowDefinition) GetDynamicDueDate() *DynamicDueDate { - if o == nil { +func (w *WorkflowDefinition) GetDynamicDueDate() *DynamicDueDate { + if w == nil { return nil } - return o.DynamicDueDate + return w.DynamicDueDate } -func (o *WorkflowDefinition) GetEnableECPWorkflow() *bool { - if o == nil { +func (w *WorkflowDefinition) GetEnableECPWorkflow() *bool { + if w == nil { return nil } - return o.EnableECPWorkflow + return w.EnableECPWorkflow } -func (o *WorkflowDefinition) GetEnabled() *bool { - if o == nil { +func (w *WorkflowDefinition) GetEnabled() *bool { + if w == nil { return nil } - return o.Enabled + return w.Enabled } -func (o *WorkflowDefinition) GetFlow() any { - if o == nil { - return nil +func (w *WorkflowDefinition) GetFlow() []Flow { + if w == nil { + return []Flow{} } - return o.Flow + return w.Flow } -func (o *WorkflowDefinition) GetID() *string { - if o == nil { +func (w *WorkflowDefinition) GetID() *string { + if w == nil { return nil } - return o.ID + return w.ID } -func (o *WorkflowDefinition) GetLastUpdateTime() *string { - if o == nil { +func (w *WorkflowDefinition) GetLastUpdateTime() *string { + if w == nil { return nil } - return o.LastUpdateTime + return w.LastUpdateTime } -func (o *WorkflowDefinition) GetName() string { - if o == nil { +func (w *WorkflowDefinition) GetName() string { + if w == nil { return "" } - return o.Name + return w.Name } -func (o *WorkflowDefinition) GetTaxonomies() []string { - if o == nil { +func (w *WorkflowDefinition) GetTaxonomies() []string { + if w == nil { return nil } - return o.Taxonomies + return w.Taxonomies } -func (o *WorkflowDefinition) GetUpdateEntityAttributes() []UpdateEntityAttributes { - if o == nil { +func (w *WorkflowDefinition) GetUpdateEntityAttributes() []UpdateEntityAttributes { + if w == nil { return nil } - return o.UpdateEntityAttributes + return w.UpdateEntityAttributes } -func (o *WorkflowDefinition) GetUserIds() []float64 { - if o == nil { +func (w *WorkflowDefinition) GetUserIds() []float64 { + if w == nil { return nil } - return o.UserIds + return w.UserIds } diff --git a/internal/sdk/optionalnullable/optionalnullable.go b/internal/sdk/optionalnullable/optionalnullable.go new file mode 100644 index 0000000..c6739be --- /dev/null +++ b/internal/sdk/optionalnullable/optionalnullable.go @@ -0,0 +1,233 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package optionalnullable + +import ( + "bytes" + "encoding/json" + "reflect" +) + +// OptionalNullable represents a field that can distinguish between three states: +// 1. Set to a value: field is present with a non-nil value +// 2. Set to nil: field is present but explicitly set to null in JSON +// 3. Unset: field is omitted from JSON entirely +// +// This type is designed to work with JSON marshaling/unmarshaling and supports +// the `omitempty` struct tag to properly omit unset fields from JSON output. +// +// Usage: +// +// type User struct { +// Name OptionalNullable[string] `json:"name,omitempty"` +// Age OptionalNullable[int] `json:"age,omitempty"` +// Tags OptionalNullable[[]string] `json:"tags,omitempty"` +// } +// +// // Set to value +// name := "John" +// user.Name = From(&name) +// +// // Set to nil (will appear as "name": null in JSON) +// user.Name = From[string](nil) +// +// // Leave unset (will be omitted from JSON with omitempty) +// user := User{} +// +// WARNING: Do NOT use *OptionalNullable[T] as a field type. Always use OptionalNullable[T] directly. +// Using *OptionalNullable[T] will break the omitempty behavior and JSON marshaling. +// +// The type is implemented as a map[bool]*T where: +// - nil map represents unset state +// - Map with true key represents set state (value may be nil) +type OptionalNullable[T any] map[bool]*T + +// From creates a new OptionalNullable with the given value. +// Pass nil to create a OptionalNullable that is set to null. +// Pass a pointer to a value to create a OptionalNullable with that value. +// +// Examples: +// +// hello := "hello" +// From(&hello) // set to "hello" +// From[string](nil) // set to null +func From[T any](value *T) OptionalNullable[T] { + return map[bool]*T{ + true: value, + } +} + +// IsNull returns true if the OptionalNullable is explicitly set to nil. +// Returns false if the OptionalNullable is unset or has a value. +// +// Note: This differs from traditional null checks because unset fields +// return false, not true. Use IsSet() to check if a field was provided. +func (n OptionalNullable[T]) IsNull() bool { + v, ok := n[true] + return ok && v == nil +} + +// IsSet returns true if the OptionalNullable has been explicitly set (to either a value or nil). +// Returns false if the OptionalNullable is unset (omitted from JSON). +// +// This is the key method for distinguishing between: +// - Set to nil: IsSet() = true, IsNull() = true +// - Unset: IsSet() = false, IsNull() = false +func (n OptionalNullable[T]) IsSet() bool { + _, ok := n[true] + return ok +} + +// Get returns the internal pointer and whether the field was set. +// +// Return values: +// - (ptr, true): field was set (ptr may be nil if set to null) +// - (nil, false): field was unset/omitted +// +// This method provides direct access to the internal pointer representation. +func (n OptionalNullable[T]) Get() (*T, bool) { + v, ok := n[true] + return v, ok +} + +// GetOrZero returns the value and whether it was set. +// +// Return values: +// - (value, true): field was set to a non-nil value +// - (zero, true): field was explicitly set to nil +// - (zero, false): field was unset/omitted +// +// Examples: +// +// val, ok := nullable.GetOrZero() +// if !ok { +// // Field was unset/omitted +// } else if nullable.IsNull() { +// // Field was explicitly set to null +// } else { +// // Field has a value: val +// } +func (n OptionalNullable[T]) GetOrZero() (T, bool) { + var zero T + + if v, ok := n[true]; ok { + if v == nil { + return zero, true + } + return *v, true + } + return zero, false +} + +// GetUntyped returns the value as interface{} and whether it was set. +// This is useful for reflection-based code that needs to work with the value +// without knowing the specific type T. +// +// Return values: +// - (value, true): field was set to a non-nil value +// - (nil, true): field was explicitly set to nil +// - (nil, false): field was unset/omitted +func (n OptionalNullable[T]) GetUntyped() (interface{}, bool) { + if v, ok := n[true]; ok { + if v == nil { + return nil, true + } + return *v, true + } + return nil, false +} + +// Set sets the OptionalNullable to the given value pointer. +// Pass nil to set the field to null. +// Pass a pointer to a value to set the field to that value. +// +// Examples: +// +// nullable.Set(ptrFrom("hello")) // set to "hello" +// nullable.Set(nil) // set to null +func (n *OptionalNullable[T]) Set(value *T) { + *n = map[bool]*T{ + true: value, + } +} + +// Unset removes the value, making the field unset/omitted. +// After calling Unset(), IsSet() will return false and the field +// will be omitted from JSON output when using omitempty. +func (n *OptionalNullable[T]) Unset() { + *n = map[bool]*T{} +} + +// MarshalJSON implements json.Marshaler. +// +// Behavior: +// - Unset fields: omitted from JSON when struct field has omitempty tag +// - Null fields: serialized as "null" +// - Value fields: serialized as the actual value +// +// The omitempty behavior works because an empty map is considered +// a zero value by Go's JSON package. +func (n OptionalNullable[T]) MarshalJSON() ([]byte, error) { + if n.IsNull() { + return []byte("null"), nil + } + + return json.Marshal(n[true]) +} + +// UnmarshalJSON implements json.Unmarshaler. +// +// Behavior: +// - "null" in JSON: sets the field to null (IsSet=true, IsNull=true) +// - Any other value: sets the field to that value (IsSet=true, IsNull=false) +// - Missing from JSON: field remains unset (IsSet=false, IsNull=false) +func (n *OptionalNullable[T]) UnmarshalJSON(data []byte) error { + if bytes.Equal(data, []byte("null")) { + n.Set(nil) + return nil + } + var v T + if err := json.Unmarshal(data, &v); err != nil { + return err + } + n.Set(&v) + return nil +} + +// NullableInterface defines the interface that all OptionalNullable[T] types implement. +// This interface provides untyped access to optional nullable values for reflection-based code. +type OptionalNullableInterface interface { + GetUntyped() (interface{}, bool) +} + +// AsOptionalNullable attempts to convert a reflect.Value to a OptionalNullableInterface. +// This is a helper function for reflection-based code that needs to check +// if a value implements the optional nullable interface pattern. +// +// Returns: +// - (nullable, true): if the value implements OptionalNullableInterface +// - (nil, false): if the value does not implement OptionalNullableInterface +// +// Example usage: +// +// if nullable, ok := AsOptionalNullable(reflectValue); ok { +// if value, isSet := nullable.GetUntyped(); isSet { +// // Handle the nullable value +// } +// } +func AsOptionalNullable(v reflect.Value) (OptionalNullableInterface, bool) { + // Check if the value can be converted to an interface first + if !v.CanInterface() { + return nil, false + } + + // Check if the underlying value is a nil map (unset nullable) + if v.Kind() == reflect.Map && v.IsNil() { + return nil, false + } + + if nullable, ok := v.Interface().(OptionalNullableInterface); ok { + return nullable, true + } + return nil, false +} diff --git a/internal/sdk/optionalnullable/optionalnullable_test.go b/internal/sdk/optionalnullable/optionalnullable_test.go new file mode 100644 index 0000000..e6e5a01 --- /dev/null +++ b/internal/sdk/optionalnullable/optionalnullable_test.go @@ -0,0 +1,1806 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package optionalnullable + +import ( + "encoding/json" + "reflect" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// Test helper function to create pointers from values +func ptrFrom[T any](value T) *T { + return &value +} + +// Test helper types for comprehensive testing +type TestStruct struct { + Name string `json:"name"` + Age int `json:"age"` +} + +type TestContainer struct { + StringField OptionalNullable[string] `json:"string_field,omitempty"` + IntField OptionalNullable[int] `json:"int_field,omitempty"` + SliceField OptionalNullable[[]string] `json:"slice_field,omitempty"` + StructField OptionalNullable[TestStruct] `json:"struct_field,omitempty"` +} + +// TestNewNullable tests the From constructor +func TestNewNullable(t *testing.T) { + t.Parallel() + t.Run("with string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value for string + }) + + t.Run("with int value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("with slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + }) + + t.Run("with empty slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{})) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("with struct value", func(t *testing.T) { + t.Parallel() + val := TestStruct{Name: "John", Age: 30} + nullable := From(&val) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + v, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, val, v) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, got) + }) +} + +// TestNewNullableUnset tests the NewNullableUnset constructor +func TestNewNullableUnset(t *testing.T) { + t.Parallel() + t.Run("string type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value for string + }) + + t.Run("int type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, 0, got) // zero value for int + }) + + t.Run("slice type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) // zero value for slice is nil + }) +} + +// TestIsNull tests the IsNull method +func TestIsNull(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + assert.False(t, nullable.IsNull()) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + assert.True(t, nullable.IsNull()) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + assert.False(t, nullable.IsNull()) + }) +} + +// TestIsSet tests the IsSet method +func TestIsSet(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + assert.True(t, nullable.IsSet()) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + assert.True(t, nullable.IsSet()) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + assert.False(t, nullable.IsSet()) + }) +} + +// TestGet tests the Get method +func TestGet(t *testing.T) { + t.Parallel() + t.Run("with string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("with slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b"})) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, got) + }) + + t.Run("with nil slice pointer", func(t *testing.T) { + t.Parallel() + nullable := From[[]string](nil) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) // zero value for slice is nil + }) +} + +// TestPointer tests the Pointer method +func TestPointer(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + ptr, ok := nullable.Get() + assert.True(t, ok) + assert.NotNil(t, ptr) + assert.Equal(t, "test", *ptr) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + ptr, ok := nullable.Get() + assert.True(t, ok) + assert.Nil(t, ptr) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + ptr, ok := nullable.Get() + assert.False(t, ok) + assert.Nil(t, ptr) + }) +} + +// TestSet tests the Set method +func TestSet(t *testing.T) { + t.Parallel() + t.Run("set string value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + // Initially unset + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + // Set a value + nullable.Set(ptrFrom("test")) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("set int value", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[int]{} + + nullable.Set(ptrFrom(42)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("set slice value", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[[]string]{} + + slice := []string{"a", "b"} + nullable.Set(ptrFrom(slice)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, got) + }) + + t.Run("set empty slice", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[[]string]{} + + slice := []string{} + nullable.Set(ptrFrom(slice)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("overwrite existing value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("original")) + + // Verify original value + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "original", got) + + // Set new value + nullable.Set(ptrFrom("new")) + + got, ok = nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "new", got) + }) +} + +// TestUnset tests the Unset method +func TestUnset(t *testing.T) { + t.Parallel() + t.Run("unset from value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + // Initially set + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // After unset is not null + // Value is now internal to the map implementation + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unset from nil", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + // Initially set to nil + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) // Set to nil should be null + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // After unset is not null + }) + + t.Run("unset already unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + // Initially unset + assert.False(t, nullable.IsSet()) + + // Unset again + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Empty map is not null + }) +} + +// TestMarshalJSON tests JSON marshaling +func TestMarshalJSON(t *testing.T) { + t.Parallel() + t.Run("marshal string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `"test"`, string(data)) + }) + + t.Run("marshal int value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `42`, string(data)) + }) + + t.Run("marshal nil value", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("marshal slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `["a","b","c"]`, string(data)) + }) + + t.Run("marshal empty slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `[]`, string(data)) + }) + + t.Run("marshal struct value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(TestStruct{Name: "John", Age: 30})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `{"name":"John","age":30}`, string(data)) + }) + + // Note: Unset values are not tested here because the current implementation + // doesn't handle unset fields in marshaling (see TODO in the code) +} + +// TestUnmarshalJSON tests JSON unmarshaling +func TestUnmarshalJSON(t *testing.T) { + t.Parallel() + t.Run("unmarshal string value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`"test"`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("unmarshal int value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(`42`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("unmarshal null value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`null`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unmarshal slice value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(`["a","b","c"]`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + }) + + t.Run("unmarshal empty slice", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(`[]`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("unmarshal struct value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(`{"name":"John","age":30}`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, got) + }) + + t.Run("unmarshal invalid JSON", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`invalid`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) + + t.Run("unmarshal invalid JSON for int", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(`"not_a_number"`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) + + t.Run("unmarshal malformed JSON", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(`{invalid json`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) +} + +// TestJSONRoundTrip tests marshaling and unmarshaling together +func TestJSONRoundTrip(t *testing.T) { + t.Parallel() + t.Run("string value round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From(ptrFrom("test value")) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) + + t.Run("nil value round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From[string](nil) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) + + t.Run("slice round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From(ptrFrom([]string{"a", "b", "c"})) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[[]string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) +} + +// TestJSONToJSONRoundTrip tests starting with JSON and ensuring we can serialize back to the same JSON +func TestJSONToJSONRoundTrip(t *testing.T) { + t.Parallel() + t.Run("string value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `"hello world"` + + // Unmarshal from JSON + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "hello world", got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("null value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `null` + + // Unmarshal from JSON + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("int value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `42` + + // Unmarshal from JSON + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("slice value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `["a","b","c"]` + + // Unmarshal from JSON + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("empty slice JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `[]` + + // Unmarshal from JSON + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("struct value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `{"name":"Alice","age":25}` + + // Unmarshal from JSON + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "Alice", Age: 25}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) +} + +// TestContainerStates tests comprehensive state detection and serialization with TestContainer +func TestContainerStates(t *testing.T) { + t.Parallel() + t.Run("all fields set to values", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From(ptrFrom("hello")), + IntField: From(ptrFrom(42)), + SliceField: From(ptrFrom([]string{"a", "b"})), + StructField: From(ptrFrom(TestStruct{Name: "John", Age: 30})), + } + + // Verify all fields are set and not null + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + assert.True(t, container.IntField.IsSet()) + assert.False(t, container.IntField.IsNull()) + assert.True(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Verify values + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "hello", stringVal) + + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, intVal) + + sliceVal, ok := container.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, sliceVal) + + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, structVal) + + // Test JSON serialization + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Equal(t, "hello", result["string_field"]) + assert.Equal(t, float64(42), result["int_field"]) // JSON numbers are float64 + assert.Equal(t, []interface{}{"a", "b"}, result["slice_field"]) + structResult := result["struct_field"].(map[string]interface{}) + assert.Equal(t, "John", structResult["name"]) + assert.Equal(t, float64(30), structResult["age"]) + }) + + t.Run("all fields set to nil", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From[string](nil), + IntField: From[int](nil), + SliceField: From[[]string](nil), + StructField: From[TestStruct](nil), + } + + // Verify all fields are set but null + assert.True(t, container.StringField.IsSet()) + assert.True(t, container.StringField.IsNull()) + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + assert.True(t, container.SliceField.IsSet()) + assert.True(t, container.SliceField.IsNull()) + assert.True(t, container.StructField.IsSet()) + assert.True(t, container.StructField.IsNull()) + + // Verify GetOrZero() behavior for nil values + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) // set to nil still returns true + assert.Equal(t, "", stringVal) // zero value + + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, intVal) // zero value + + sliceVal, ok := container.SliceField.GetOrZero() + assert.True(t, ok) + assert.Nil(t, sliceVal) // zero value for slice is nil + + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{}, structVal) // zero value + + // Test JSON serialization - all should be null + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Nil(t, result["string_field"]) + assert.Nil(t, result["int_field"]) + assert.Nil(t, result["slice_field"]) + assert.Nil(t, result["struct_field"]) + }) + + t.Run("all fields unset", func(t *testing.T) { + t.Parallel() + container := TestContainer{} + + // Verify all fields are unset + assert.False(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) // unset is not null in new implementation + assert.False(t, container.IntField.IsSet()) + assert.False(t, container.IntField.IsNull()) + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) + assert.False(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Verify GetOrZero() behavior for unset values + stringVal, ok := container.StringField.GetOrZero() + assert.False(t, ok) // unset returns false + assert.Equal(t, "", stringVal) // zero value + + intVal, ok := container.IntField.GetOrZero() + assert.False(t, ok) + assert.Equal(t, 0, intVal) // zero value + + sliceVal, ok := container.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, sliceVal) // zero value + + structVal, ok := container.StructField.GetOrZero() + assert.False(t, ok) + assert.Equal(t, TestStruct{}, structVal) // zero value + + // Test JSON serialization - unset fields should be omitted due to omitempty + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + // With omitempty, unset fields should not appear in JSON + assert.NotContains(t, result, "string_field") + assert.NotContains(t, result, "int_field") + assert.NotContains(t, result, "slice_field") + assert.NotContains(t, result, "struct_field") + }) + + t.Run("slice field states: nil vs unset vs empty vs set", func(t *testing.T) { + t.Parallel() + // Test all possible slice states + nilSlice := TestContainer{ + SliceField: From[[]string](nil), // explicitly set to nil + } + unsetSlice := TestContainer{} // unset + emptySlice := TestContainer{ + SliceField: From(ptrFrom([]string{})), // empty slice + } + setSlice := TestContainer{ + SliceField: From(ptrFrom([]string{"a", "b"})), // slice with values + } + + // Verify nil slice + assert.True(t, nilSlice.SliceField.IsSet()) + assert.True(t, nilSlice.SliceField.IsNull()) + val, ok := nilSlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Nil(t, val) + + // Verify unset slice + assert.False(t, unsetSlice.SliceField.IsSet()) + assert.False(t, unsetSlice.SliceField.IsNull()) // Unset is not null + val, ok = unsetSlice.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, val) + + // Verify empty slice + assert.True(t, emptySlice.SliceField.IsSet()) + assert.False(t, emptySlice.SliceField.IsNull()) + val, ok = emptySlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, val) + + // Verify set slice + assert.True(t, setSlice.SliceField.IsSet()) + assert.False(t, setSlice.SliceField.IsNull()) + val, ok = setSlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, val) + + // Test JSON serialization for each state + nilData, err := json.Marshal(nilSlice) + require.NoError(t, err) + assert.Contains(t, string(nilData), `"slice_field":null`) + + unsetData, err := json.Marshal(unsetSlice) + require.NoError(t, err) + assert.NotContains(t, string(unsetData), "slice_field") // omitted due to omitempty + + emptyData, err := json.Marshal(emptySlice) + require.NoError(t, err) + assert.Contains(t, string(emptyData), `"slice_field":[]`) + + setData, err := json.Marshal(setSlice) + require.NoError(t, err) + assert.Contains(t, string(setData), `"slice_field":["a","b"]`) + }) + + t.Run("mixed states container", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From(ptrFrom("hello")), // set to value + IntField: From[int](nil), // set to nil + StructField: From(ptrFrom(TestStruct{Name: "Alice", Age: 25})), // set to value + } + + // Verify states + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) // Unset is not null + + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Test JSON serialization + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Equal(t, "hello", result["string_field"]) + assert.Nil(t, result["int_field"]) + assert.NotContains(t, result, "slice_field") // unset, so omitted + structResult := result["struct_field"].(map[string]interface{}) + assert.Equal(t, "Alice", structResult["name"]) + assert.Equal(t, float64(25), structResult["age"]) + }) + + t.Run("JSON unmarshaling preserves states", func(t *testing.T) { + t.Parallel() + // JSON with some fields missing, some null, some with values + jsonData := `{ + "string_field": "test", + "int_field": null, + "struct_field": {"name": "Bob", "age": 35} + }` + + var container TestContainer + err := json.Unmarshal([]byte(jsonData), &container) + require.NoError(t, err) + + // string_field: present with value + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", stringVal) + + // int_field: present but null + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, intVal) // zero value + + // slice_field: missing from JSON, should remain unset + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) // Unset is not null + sliceVal, ok := container.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, sliceVal) + + // struct_field: present with value + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "Bob", Age: 35}, structVal) + }) +} + +// TestNilVsUnsetDistinction tests the key feature of distinguishing nil from unset +func TestNilVsUnsetDistinction(t *testing.T) { + t.Parallel() + t.Run("explicit nil vs unset", func(t *testing.T) { + t.Parallel() + // Explicitly set to nil + explicitNil := From[string](nil) + + // Unset + var unset OptionalNullable[string] + + // Both are null, but only one is set + assert.True(t, explicitNil.IsNull()) + assert.True(t, explicitNil.IsSet()) + + assert.False(t, unset.IsNull()) // Unset is not null + assert.False(t, unset.IsSet()) + + // Get behavior differs + got1, ok1 := explicitNil.GetOrZero() + got2, ok2 := unset.GetOrZero() + + assert.True(t, ok1) // explicitly set to nil returns true + assert.False(t, ok2) // unset returns false + assert.Equal(t, "", got1) // both return zero value + assert.Equal(t, "", got2) + + // Get behavior differs + ptr1, ok1 := explicitNil.Get() + ptr2, ok2 := unset.Get() + + assert.True(t, ok1) // explicitly set to nil returns true + assert.False(t, ok2) // unset returns false + assert.Nil(t, ptr1) // both return nil pointer + assert.Nil(t, ptr2) + }) + + t.Run("empty slice vs nil slice vs unset", func(t *testing.T) { + t.Parallel() + // Empty slice + emptyNullable := From(ptrFrom([]string{})) + + // Nil slice + nilNullable := From[[]string](nil) + + // Unset + var unsetNullable OptionalNullable[[]string] + + // All have different characteristics + assert.True(t, emptyNullable.IsSet()) + assert.False(t, emptyNullable.IsNull()) + + assert.True(t, nilNullable.IsSet()) + assert.True(t, nilNullable.IsNull()) + + assert.False(t, unsetNullable.IsSet()) + assert.False(t, unsetNullable.IsNull()) // Unset is not null + + // Get behavior + got1, ok1 := emptyNullable.GetOrZero() + got2, ok2 := nilNullable.GetOrZero() + got3, ok3 := unsetNullable.GetOrZero() + + assert.True(t, ok1) + assert.Equal(t, []string{}, got1) + + assert.True(t, ok2) + assert.Nil(t, got2) + + assert.False(t, ok3) + assert.Nil(t, got3) + }) +} + +// TestJSONOmitEmpty tests behavior with omitempty tag +func TestJSONOmitEmpty(t *testing.T) { + t.Parallel() + t.Run("marshal with omitempty", func(t *testing.T) { + t.Parallel() + // Test container with various nullable states + container := TestContainer{ + StringField: From(ptrFrom("test")), + IntField: From(ptrFrom(42)), + StructField: From[TestStruct](nil), // explicitly nil + } + + data, err := json.Marshal(container) + require.NoError(t, err) + + // Parse back to verify structure + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + // Should contain set fields + assert.Contains(t, result, "string_field") + assert.Contains(t, result, "int_field") + assert.Contains(t, result, "struct_field") + + // Should not contain unset field (due to omitempty) + // Note: This depends on how the marshaling handles unset fields + // The current implementation doesn't handle this case properly (see TODO) + }) + + t.Run("unmarshal missing fields", func(t *testing.T) { + t.Parallel() + // JSON with some fields missing + jsonData := `{"string_field": "test", "int_field": null}` + + var container TestContainer + err := json.Unmarshal([]byte(jsonData), &container) + require.NoError(t, err) + + // Present fields should be set + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + got, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + + // Null field should be set to nil + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + + // Missing fields should remain unset + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.StructField.IsSet()) + }) +} + +// TestEdgeCases tests various edge cases +func TestEdgeCases(t *testing.T) { + t.Parallel() + t.Run("zero values", func(t *testing.T) { + t.Parallel() + // Test with zero values that are not nil + intNullable := From(ptrFrom(0)) + stringNullable := From(ptrFrom("")) + + assert.True(t, intNullable.IsSet()) + assert.False(t, intNullable.IsNull()) + got, ok := intNullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, got) + + assert.True(t, stringNullable.IsSet()) + assert.False(t, stringNullable.IsNull()) + got2, ok2 := stringNullable.GetOrZero() + assert.True(t, ok2) + assert.Equal(t, "", got2) + }) + + t.Run("pointer to pointer", func(t *testing.T) { + t.Parallel() + // Test with pointer to pointer type + inner := "test" + nullable := From(ptrFrom(&inner)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, &inner, got) + assert.Equal(t, "test", *got) + }) + + t.Run("complex struct", func(t *testing.T) { + t.Parallel() + complexStruct := struct { + Name string + Values []int + Metadata map[string]string + }{ + Name: "complex", + Values: []int{1, 2, 3}, + Metadata: map[string]string{ + "key1": "value1", + "key2": "value2", + }, + } + + nullable := From(ptrFrom(complexStruct)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, complexStruct, got) + }) +} + +// TestDoublePointers tests comprehensive double pointer scenarios +func TestDoublePointers(t *testing.T) { + t.Parallel() + + t.Run("string double pointer with value", func(t *testing.T) { + t.Parallel() + inner := "hello world" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, &inner, got) + assert.Equal(t, "hello world", *got) + }) + + t.Run("int double pointer with value", func(t *testing.T) { + t.Parallel() + inner := 42 + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, &inner, got) + assert.Equal(t, 42, *got) + }) + + t.Run("double pointer to nil", func(t *testing.T) { + t.Parallel() + var ptr *string = nil + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Nil(t, got) + }) + + t.Run("nil double pointer", func(t *testing.T) { + t.Parallel() + nullable := From[*string](nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) // zero value for **string is nil + }) + + t.Run("unset double pointer", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) // zero value for **string is nil + }) + + t.Run("double pointer modification", func(t *testing.T) { + t.Parallel() + inner := "original" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + // Verify original value + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "original", *got) + + // Modify through double pointer + *got = "modified" + assert.Equal(t, "modified", inner) + assert.Equal(t, "modified", *got) + }) + + t.Run("double pointer to struct", func(t *testing.T) { + t.Parallel() + inner := TestStruct{Name: "Alice", Age: 30} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, TestStruct{Name: "Alice", Age: 30}, *got) + + // Modify through double pointer + (*got).Name = "Bob" + assert.Equal(t, "Bob", inner.Name) + assert.Equal(t, "Bob", (*got).Name) + }) + + t.Run("double pointer to slice", func(t *testing.T) { + t.Parallel() + inner := []string{"a", "b", "c"} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, []string{"a", "b", "c"}, *got) + + // Modify through double pointer + *got = append(*got, "d") + assert.Equal(t, []string{"a", "b", "c", "d"}, inner) + assert.Equal(t, []string{"a", "b", "c", "d"}, *got) + }) + + t.Run("double pointer to empty slice", func(t *testing.T) { + t.Parallel() + inner := []string{} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, []string{}, *got) + }) + + t.Run("double pointer to nil slice", func(t *testing.T) { + t.Parallel() + var inner []string = nil + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Nil(t, *got) + }) + + t.Run("double pointer JSON marshaling", func(t *testing.T) { + t.Parallel() + inner := "json test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `"json test"`, string(data)) + }) + + t.Run("double pointer JSON unmarshaling", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + err := json.Unmarshal([]byte(`"json test"`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.NotNil(t, got) + assert.Equal(t, "json test", *got) + }) + + t.Run("double pointer JSON null marshaling", func(t *testing.T) { + t.Parallel() + nullable := From[*string](nil) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("double pointer JSON null unmarshaling", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + err := json.Unmarshal([]byte(`null`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) + }) + + t.Run("double pointer round trip", func(t *testing.T) { + t.Parallel() + inner := "round trip test" + ptr := &inner + nullable1 := From(ptrFrom(ptr)) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[*string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare states + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + + // Values should be equal + assert.Equal(t, *got1, *got2) + }) + + t.Run("triple pointer", func(t *testing.T) { + t.Parallel() + inner := "triple" + ptr1 := &inner + ptr2 := &ptr1 + nullable := From(ptrFrom(ptr2)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr2, got) + assert.Equal(t, ptr1, *got) + assert.Equal(t, "triple", **got) + }) + + t.Run("double pointer set and unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + + // Initially unset + assert.False(t, nullable.IsSet()) + + // Set to double pointer + inner := "set test" + ptr := &inner + nullable.Set(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "set test", *got) + + // Set to nil + nullable.Set(nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok = nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok = nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) + }) + + t.Run("double pointer Get method", func(t *testing.T) { + t.Parallel() + inner := "get test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + // Test Get method + gotPtr, ok := nullable.Get() + assert.True(t, ok) + assert.NotNil(t, gotPtr) + assert.Equal(t, ptr, *gotPtr) + assert.Equal(t, "get test", **gotPtr) + + // Test with nil + nilNullable := From[*string](nil) + gotPtr, ok = nilNullable.Get() + assert.True(t, ok) + assert.Nil(t, gotPtr) + + // Test with unset + var unsetNullable OptionalNullable[*string] + gotPtr, ok = unsetNullable.Get() + assert.False(t, ok) + assert.Nil(t, gotPtr) + }) + + t.Run("double pointer zero values", func(t *testing.T) { + t.Parallel() + // Test with zero value string + inner := "" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", *got) + + // Test with zero value int + innerInt := 0 + ptrInt := &innerInt + nullableInt := From(ptrFrom(ptrInt)) + + assert.True(t, nullableInt.IsSet()) + assert.False(t, nullableInt.IsNull()) + + gotInt, okInt := nullableInt.GetOrZero() + assert.True(t, okInt) + assert.Equal(t, 0, *gotInt) + }) +} + +// TestAsOptionalNullable tests the AsOptionalNullable helper function +func TestAsOptionalNullable(t *testing.T) { + t.Parallel() + + t.Run("with nullable string", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) + + t.Run("with nullable int", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, 42, value) + }) + + t.Run("with nullable nil", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Nil(t, value) + }) + + t.Run("with unset nullable", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable string", func(t *testing.T) { + t.Parallel() + regularString := "not nullable" + reflectValue := reflect.ValueOf(regularString) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable int", func(t *testing.T) { + t.Parallel() + regularInt := 42 + reflectValue := reflect.ValueOf(regularInt) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable map", func(t *testing.T) { + t.Parallel() + regularMap := map[string]int{"key": 42} + reflectValue := reflect.ValueOf(regularMap) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable struct", func(t *testing.T) { + t.Parallel() + regularStruct := TestStruct{Name: "test", Age: 30} + reflectValue := reflect.ValueOf(regularStruct) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with nullable double pointer", func(t *testing.T) { + t.Parallel() + inner := "test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, ptr, value) + assert.Equal(t, "test", *value.(*string)) + }) + + t.Run("with nullable slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, []string{"a", "b", "c"}, value) + }) + + t.Run("with nullable struct", func(t *testing.T) { + t.Parallel() + testStruct := TestStruct{Name: "Alice", Age: 25} + nullable := From(ptrFrom(testStruct)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, testStruct, value) + }) + + t.Run("with pointer to nullable", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + ptrToNullable := &nullable + reflectValue := reflect.ValueOf(ptrToNullable) + + // This should work since the pointer to nullable still contains a nullable + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) + + t.Run("with interface containing nullable", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + var iface interface{} = nullable + reflectValue := reflect.ValueOf(iface) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) +} diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 35a3b2d..713ebed 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -2,7 +2,7 @@ package sdk -// Generated from OpenAPI doc version 1.0.0 and generator version 2.687.13 +// Generated from OpenAPI doc version 1.0.0 and generator version 2.735.1 import ( "context" @@ -128,9 +128,9 @@ func WithTimeout(timeout time.Duration) SDKOption { // New creates a new instance of the SDK with the provided options func New(opts ...SDKOption) *SDK { sdk := &SDK{ - SDKVersion: "0.19.0", + SDKVersion: "0.20.0", sdkConfiguration: config.SDKConfiguration{ - UserAgent: "speakeasy-sdk/terraform 0.19.0 2.687.13 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", + UserAgent: "speakeasy-sdk/terraform 0.20.0 2.735.1 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", ServerList: ServerList, }, hooks: hooks.New(), diff --git a/internal/sdk/types/decimal.go b/internal/sdk/types/decimal.go deleted file mode 100644 index d8429bc..0000000 --- a/internal/sdk/types/decimal.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "fmt" - - "github.com/ericlagergren/decimal" -) - -// MustNewDecimalFromString returns an instance of Decimal from a string -// Avoid using this function in production code. -func MustNewDecimalFromString(s string) *decimal.Big { - d, ok := new(decimal.Big).SetString(s) - if !ok { - panic(fmt.Errorf("failed to parse string as decimal.Big")) - } - - return d -} diff --git a/internal/sdk/workflows.go b/internal/sdk/workflows.go index 6a3886e..18c53ba 100644 --- a/internal/sdk/workflows.go +++ b/internal/sdk/workflows.go @@ -12,7 +12,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" "net/http" "net/url" ) @@ -36,7 +35,6 @@ func newWorkflows(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks. func (s *Workflows) CreateDefinition(ctx context.Context, request shared.WorkflowDefinition, opts ...operations.Option) (*operations.CreateDefinitionResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -63,7 +61,7 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo BaseURL: baseURL, Context: ctx, OperationID: "createDefinition", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) @@ -100,100 +98,32 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -286,7 +216,6 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.DeleteDefinitionRequest, opts ...operations.Option) (*operations.DeleteDefinitionResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -313,7 +242,7 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del BaseURL: baseURL, Context: ctx, OperationID: "deleteDefinition", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -343,100 +272,32 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -487,7 +348,6 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDefinitionRequest, opts ...operations.Option) (*operations.GetDefinitionResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -514,7 +374,7 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef BaseURL: baseURL, Context: ctx, OperationID: "getDefinition", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -544,100 +404,32 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -751,7 +543,6 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Option) (*operations.GetDefinitionsResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -778,7 +569,7 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio BaseURL: baseURL, Context: ctx, OperationID: "getDefinitions", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -808,100 +599,32 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -971,7 +694,6 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.Option) (*operations.GetMaxAllowedLimitResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -998,7 +720,7 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O BaseURL: baseURL, Context: ctx, OperationID: "getMaxAllowedLimit", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -1028,100 +750,32 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -1191,7 +845,6 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request operations.GetWorkflowClosingReasonsRequest, opts ...operations.Option) (*operations.GetWorkflowClosingReasonsResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1218,7 +871,7 @@ func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request opera BaseURL: baseURL, Context: ctx, OperationID: "getWorkflowClosingReasons", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } @@ -1248,100 +901,32 @@ func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request opera req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -1390,7 +975,6 @@ func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request opera func (s *Workflows) SetWorkflowClosingReasons(ctx context.Context, request operations.SetWorkflowClosingReasonsRequest, opts ...operations.Option) (*operations.SetWorkflowClosingReasonsResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1417,7 +1001,7 @@ func (s *Workflows) SetWorkflowClosingReasons(ctx context.Context, request opera BaseURL: baseURL, Context: ctx, OperationID: "setWorkflowClosingReasons", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "ClosingReasonsIds", "json", `request:"mediaType=application/json"`) @@ -1454,100 +1038,32 @@ func (s *Workflows) SetWorkflowClosingReasons(ctx context.Context, request opera req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } } @@ -1576,7 +1092,6 @@ func (s *Workflows) SetWorkflowClosingReasons(ctx context.Context, request opera func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.UpdateDefinitionRequest, opts ...operations.Option) (*operations.UpdateDefinitionResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1603,7 +1118,7 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd BaseURL: baseURL, Context: ctx, OperationID: "updateDefinition", - OAuth2Scopes: []string{}, + OAuth2Scopes: nil, SecuritySource: s.sdkConfiguration.Security, } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "WorkflowDefinition", "json", `request:"mediaType=application/json"`) @@ -1640,100 +1155,32 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd req.Header.Set(k, v) } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err + } else if _httpRes != nil { + httpRes = _httpRes } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } } }