diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index c9aa25a..6ca39b4 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: ae471e39d05055eb1d09ad61715bb339 + docChecksum: 8cca425d43827206f136d897f6b6d971 docVersion: 1.0.0 - speakeasyVersion: 1.422.1 - generationVersion: 2.438.15 - releaseVersion: 0.15.2 - configChecksum: 51df825a76e7f72ef6717314a9f0d4b4 + speakeasyVersion: 1.366.0 + generationVersion: 2.396.0 + releaseVersion: 0.16.0 + configChecksum: 074bf36ec11af180d6bf31a5857355fd repoURL: https://github.com/epilot-dev/terraform-provider-epilot-workflow.git repoSubDirectory: . published: true @@ -22,72 +22,27 @@ features: terraform: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.4 - core: 3.25.0 + core: 3.24.6 deprecations: 2.81.1 envVarSecurityUsage: 0.1.0 - globalSecurity: 2.81.9 + globalSecurity: 2.81.8 globalServerURLs: 2.82.1 + inputOutputModels: 2.83.0 retries: 2.81.1 typeOverrides: 2.81.1 unions: 2.81.16 generatedFiles: - - .gitattributes - - CONTRIBUTING.md - - USAGE.md - - examples/README.md - - examples/data-sources/epilot-workflow_closing_reason/data-source.tf - - examples/data-sources/epilot-workflow_workflow_definition/data-source.tf - - examples/provider/provider.tf - - examples/resources/epilot-workflow_closing_reason/import.sh - - examples/resources/epilot-workflow_closing_reason/resource.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 - - internal/planmodifiers/float64planmodifier/suppress_diff.go - - internal/planmodifiers/int64planmodifier/suppress_diff.go - - internal/planmodifiers/listplanmodifier/suppress_diff.go - - internal/planmodifiers/mapplanmodifier/suppress_diff.go - - internal/planmodifiers/numberplanmodifier/suppress_diff.go - - internal/planmodifiers/objectplanmodifier/suppress_diff.go - - 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/provider.go - - internal/provider/reflect/diags.go - - internal/provider/reflect/doc.go - - internal/provider/reflect/generic_attr_value.go - - internal/provider/reflect/helpers.go - - internal/provider/reflect/interfaces.go - - internal/provider/reflect/into.go - - internal/provider/reflect/map.go - - internal/provider/reflect/number.go - - internal/provider/reflect/options.go - - internal/provider/reflect/outof.go - - internal/provider/reflect/pointer.go - - internal/provider/reflect/primitive.go - - internal/provider/reflect/slice.go - - internal/provider/reflect/struct.go - - internal/provider/types/closing_reason_id.go - - internal/provider/types/dynamic_due_date.go - - internal/provider/types/target.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/.gitignore - - internal/sdk/CONTRIBUTING.md - internal/sdk/closingreason.go + - internal/sdk/workflows.go - internal/sdk/flowsv2.go - - internal/sdk/internal/hooks/hooks.go + - internal/sdk/sdk.go + - internal/sdk/models/errors/sdkerror.go + - internal/sdk/retry/config.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/internal/utils/contenttype.go - internal/sdk/internal/utils/form.go - internal/sdk/internal/utils/headers.go @@ -98,65 +53,92 @@ generatedFiles: - internal/sdk/internal/utils/retries.go - internal/sdk/internal/utils/security.go - internal/sdk/internal/utils/utils.go - - internal/sdk/models/errors/sdkerror.go - internal/sdk/models/operations/changereasonstatus.go - internal/sdk/models/operations/createclosingreason.go - - internal/sdk/models/operations/createdefinition.go - - internal/sdk/models/operations/createflowtemplate.go - - internal/sdk/models/operations/deletedefinition.go - - internal/sdk/models/operations/deleteflowtemplate.go + - internal/sdk/models/operations/deleteclosingreason.go - internal/sdk/models/operations/getallclosingreasons.go - internal/sdk/models/operations/getclosingreason.go + - internal/sdk/models/operations/getclosingreasonv1.go + - internal/sdk/models/operations/updateclosingreason.go + - internal/sdk/models/operations/createdefinition.go + - internal/sdk/models/operations/deletedefinition.go - internal/sdk/models/operations/getdefinition.go - internal/sdk/models/operations/getdefinitions.go - - internal/sdk/models/operations/getflowtemplate.go - internal/sdk/models/operations/getmaxallowedlimit.go - internal/sdk/models/operations/getworkflowclosingreasons.go - - internal/sdk/models/operations/listflowtemplates.go - - internal/sdk/models/operations/options.go - internal/sdk/models/operations/setworkflowclosingreasons.go - internal/sdk/models/operations/updatedefinition.go + - internal/sdk/models/operations/createflowtemplate.go + - internal/sdk/models/operations/deleteflowtemplate.go + - internal/sdk/models/operations/getflowtemplate.go + - internal/sdk/models/operations/listflowtemplates.go - internal/sdk/models/operations/updateflowtemplate.go - - internal/sdk/models/shared/automationtask.go + - internal/sdk/models/shared/errorresp.go - internal/sdk/models/shared/changereasonstatusreq.go + - internal/sdk/models/shared/closingreasonsstatus.go - internal/sdk/models/shared/closingreason.go - - internal/sdk/models/shared/closingreasonid.go + - internal/sdk/models/shared/closingreasoninput.go - internal/sdk/models/shared/closingreasonnotfoundresp.go - internal/sdk/models/shared/closingreasons.go - - internal/sdk/models/shared/closingreasonsids.go - - internal/sdk/models/shared/closingreasonsstatus.go - - internal/sdk/models/shared/condition.go - - internal/sdk/models/shared/decisiontask.go - - internal/sdk/models/shared/definitionnotfoundresp.go - - internal/sdk/models/shared/duedateconfig.go + - internal/sdk/models/shared/workflowdefinition.go + - internal/sdk/models/shared/updateentityattributes.go - internal/sdk/models/shared/dynamicduedate.go - - internal/sdk/models/shared/ecpdetails.go - - internal/sdk/models/shared/edge.go + - internal/sdk/models/shared/closingreasonid.go + - internal/sdk/models/shared/definitionnotfoundresp.go + - internal/sdk/models/shared/maxallowedlimit.go + - internal/sdk/models/shared/closingreasonsids.go + - internal/sdk/models/shared/flowtemplate.go + - internal/sdk/models/shared/task.go + - internal/sdk/models/shared/taskbase.go + - internal/sdk/models/shared/tasktype.go - internal/sdk/models/shared/enablerequirement.go - - internal/sdk/models/shared/errorresp.go + - internal/sdk/models/shared/stepjourney.go + - internal/sdk/models/shared/ecpdetails.go + - internal/sdk/models/shared/duedateconfig.go + - internal/sdk/models/shared/stepdescription.go + - internal/sdk/models/shared/automationtask.go + - internal/sdk/models/shared/decisiontask.go + - internal/sdk/models/shared/condition.go + - internal/sdk/models/shared/statement.go - internal/sdk/models/shared/evaluationsource.go - - internal/sdk/models/shared/flowtemplate.go - - internal/sdk/models/shared/flowtemplateslist.go - - internal/sdk/models/shared/maxallowedlimit.go - internal/sdk/models/shared/operator.go - internal/sdk/models/shared/phase.go + - internal/sdk/models/shared/edge.go + - internal/sdk/models/shared/flowtemplateslist.go - internal/sdk/models/shared/security.go - - internal/sdk/models/shared/statement.go - - internal/sdk/models/shared/stepdescription.go - - internal/sdk/models/shared/stepjourney.go - - internal/sdk/models/shared/task.go - - internal/sdk/models/shared/taskbase.go - - internal/sdk/models/shared/tasktype.go - - internal/sdk/models/shared/updateentityattributes.go - - internal/sdk/models/shared/workflowdefinition.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/sdk/.gitignore + - internal/sdk/models/operations/options.go + - internal/sdk/.gitattributes + - internal/sdk/internal/hooks/hooks.go + - internal/sdk/CONTRIBUTING.md + - examples/README.md + - go.mod + - go.sum + - internal/planmodifiers/boolplanmodifier/suppress_diff.go + - internal/planmodifiers/float64planmodifier/suppress_diff.go + - internal/planmodifiers/int64planmodifier/suppress_diff.go + - internal/planmodifiers/listplanmodifier/suppress_diff.go + - internal/planmodifiers/mapplanmodifier/suppress_diff.go + - internal/planmodifiers/numberplanmodifier/suppress_diff.go + - internal/planmodifiers/objectplanmodifier/suppress_diff.go + - internal/planmodifiers/setplanmodifier/suppress_diff.go + - internal/planmodifiers/stringplanmodifier/suppress_diff.go + - internal/planmodifiers/utils/state_check.go + - internal/provider/reflect/diags.go + - internal/provider/reflect/doc.go + - internal/provider/reflect/generic_attr_value.go + - internal/provider/reflect/helpers.go + - internal/provider/reflect/interfaces.go + - internal/provider/reflect/into.go + - internal/provider/reflect/map.go + - internal/provider/reflect/number.go + - internal/provider/reflect/options.go + - internal/provider/reflect/outof.go + - internal/provider/reflect/pointer.go + - internal/provider/reflect/primitive.go + - internal/provider/reflect/slice.go + - internal/provider/reflect/struct.go + - internal/provider/utils.go - internal/validators/DateValidator.go - internal/validators/ExactlyOneChild.go - internal/validators/JSONParseValidator.go @@ -173,129 +155,723 @@ generatedFiles: - main.go - terraform-registry-manifest.json - tools/tools.go + - internal/provider/types/closing_reason_id.go + - internal/provider/types/dynamic_due_date.go + - internal/provider/types/target.go + - internal/provider/types/update_entity_attributes.go + - USAGE.md + - internal/provider/provider.go + - examples/provider/provider.tf + - examples/resources/epilot-workflow_closing_reason/import.sh + - internal/provider/closingreason_resource.go + - internal/provider/closingreason_resource_sdk.go + - examples/resources/epilot-workflow_closing_reason/resource.tf + - examples/resources/epilot-workflow_workflow_definition/import.sh + - internal/provider/workflowdefinition_resource.go + - internal/provider/workflowdefinition_resource_sdk.go + - examples/resources/epilot-workflow_workflow_definition/resource.tf + - internal/provider/closingreason_data_source.go + - internal/provider/closingreason_data_source_sdk.go + - examples/data-sources/epilot-workflow_closing_reason/data-source.tf + - internal/provider/workflowdefinition_data_source.go + - internal/provider/workflowdefinition_data_source_sdk.go + - examples/data-sources/epilot-workflow_workflow_definition/data-source.tf + - .gitattributes + - CONTRIBUTING.md examples: changeReasonStatus: speakeasy-default-change-reason-status: parameters: path: - reasonId: "" + reasonId: createClosingReason: "": requestBody: - application/json: {"status": "ACTIVE", "title": "better offer"} + application/json: + status: ACTIVE + title: better offer responses: "201": - application/json: {"status": "INACTIVE", "title": ""} - getAllClosingReasons: - "": - parameters: - query: - includeInactive: true - responses: - "200": - application/json: {"reasons": [{"status": "ACTIVE", "title": ""}]} + application/json: + status: INACTIVE + title: createDefinition: "": requestBody: - application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}], "creationTime": "2021-04-27T12:01:13.000Z", "description": "Lead Qualification description", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["123482"]}, {"name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["123482"]}, {"name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["123482"]}]}, {"name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["123482"]}], "lastUpdateTime": "2021-04-27T12:01:13.000Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + application/json: + assignedTo: + - "952802" + - "80225" + closingReasons: + - id: x739cew + creationTime: "2021-04-27T12:01:13.000Z" + description: Lead Qualification description + dueDate: "2022-08-04T12:00:00.000Z" + flow: + - name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "123482" + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "123482" + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "123482" + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "123482" + name: Print and send catalog + order: 2 + type: STEP + lastUpdateTime: "2021-04-27T12:01:13.000Z" + name: Lead Qualification + updateEntityAttributes: + - source: workflow_status + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity responses: "200": - application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "description": "Lead Qualification description", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"id": "2hja82a", "name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["48829"]}, {"id": "ga92ha2", "name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["45390"]}, {"id": "jga92ha", "name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["8230"]}]}, {"id": "0a7g22a", "name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["8239"]}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": []} + application/json: + assignedTo: + - "952802" + - "80225" + closingReasons: + - id: x739cew + - id: x739cew + - id: x739cew + creationTime: "2021-08-04T21:13:50.373Z" + description: Lead Qualification description + dueDate: "2022-08-04T12:00:00.000Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "48829" + id: 2hja82a + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "45390" + id: ga92ha2 + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "8230" + id: jga92ha + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "8239" + id: 0a7g22a + name: Print and send catalog + order: 2 + type: STEP + id: 25n2k52ja + lastUpdateTime: "2021-08-04T21:13:50.373Z" + name: Lead Qualification + updateEntityAttributes: [] "201": - application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "description": "Lead Qualification description", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"id": "2hja82a", "name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["48829"]}, {"id": "ga92ha2", "name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["45390"]}, {"id": "jga92ha", "name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["8230"]}]}, {"id": "0a7g22a", "name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["8239"]}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + application/json: + assignedTo: + - "952802" + - "80225" + closingReasons: + - id: x739cew + creationTime: "2021-08-04T21:13:50.373Z" + description: Lead Qualification description + dueDate: "2022-08-04T12:00:00.000Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "48829" + id: 2hja82a + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "45390" + id: ga92ha2 + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "8230" + id: jga92ha + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "8239" + id: 0a7g22a + name: Print and send catalog + order: 2 + type: STEP + id: 25n2k52ja + lastUpdateTime: "2021-08-04T21:13:50.373Z" + name: Lead Qualification + updateEntityAttributes: + - source: workflow_status + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity + createFlowTemplate: + speakeasy-default-create-flow-template: + requestBody: + application/json: + closing_reasons: + - id: x739cew + - id: x739cew + - id: x739cew + created_at: "2021-04-27T12:01:13.000Z" + due_date: "2021-04-27T12:00:00.000Z" + edges: + - from_id: + id: + to_id: + - from_id: + id: + to_id: + name: + phases: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + tasks: + - conditions: + - id: + logical_operator: OR + statements: [] + - id: + logical_operator: AND + statements: + - id: + operator: less_than + values: + - + - + - + - id: + operator: greater_than_or_equals + values: + - + - + - + - id: + logical_operator: AND + statements: [] + due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: AUTOMATION + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: MANUAL + - automation_config: + flow_id: + due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: MANUAL + update_entity_attributes: + - source: current_section + target: + entityAttribute: my_status + entitySchema: opportunity + updated_at: "2021-04-27T12:01:13.000Z" + responses: + "201": + application/json: + closing_reasons: + - id: x739cew + created_at: "2021-04-27T12:01:13.000Z" + due_date: "2021-04-27T12:00:00.000Z" + edges: + - from_id: + id: + to_id: + name: + phases: [] + tasks: [] + update_entity_attributes: + - source: current_section + target: + entityAttribute: my_status + entitySchema: opportunity + updated_at: "2021-04-27T12:01:13.000Z" + "400": {} deleteDefinition: "": parameters: path: - definitionId: "CustomerRequest" + definitionId: CustomerRequest + deleteFlowTemplate: + speakeasy-default-delete-flow-template: + parameters: + path: + flowId: 7hj28akg + getAllClosingReasons: + "": + parameters: + query: + includeInactive: true + responses: + "200": + application/json: + reasons: + - status: ACTIVE + title: + getClosingReason: + "": + parameters: + path: + reasonId: -poOAPBa-jFZA_AWV3zN0 + responses: + "200": + application/json: + creationTime: "2021-08-04T21:13:50.373Z" + id: -poOAPBa-jFZA_AWV3zN0 + lastUpdateTime: "2021-08-04T21:13:50.373Z" + status: ACTIVE + title: Closing due to example reason getDefinition: "": parameters: path: - definitionId: "7hj28a" + definitionId: 7hj28a responses: "200": - application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "ffoowef"}, {"id": "hebwoeu"}, {"id": "mbnoenq"}], "creationTime": "2021-08-04T21:13:50.373Z", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"id": "2hja82a", "name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["923432"]}, {"id": "ga92ha2", "name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["45488"]}, {"id": "jga92ha", "name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["45488"]}]}, {"id": "0a7g22a", "name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["8988"]}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + application/json: + assignedTo: + - "952802" + - "80225" + closingReasons: + - id: ffoowef + - id: hebwoeu + - id: mbnoenq + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2022-08-04T12:00:00.000Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "923432" + id: 2hja82a + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "45488" + id: ga92ha2 + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "45488" + id: jga92ha + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "8988" + id: 0a7g22a + name: Print and send catalog + order: 2 + type: STEP + id: 25n2k52ja + lastUpdateTime: "2021-08-04T21:13:50.373Z" + name: Lead Qualification + updateEntityAttributes: + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_section + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_section + target: + entityAttribute: my_status + entitySchema: opportunity getDefinitions: "": responses: "200": - application/json: [{"assignedTo": ["18625", "90252"], "closingReasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "description": "Lead Qualification description", "dueDate": "2021-08-04T21:13:50.373Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"id": "2hja82a", "name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["123482"]}, {"id": "ga92ha2", "name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["123482"]}, {"id": "jga92ha", "name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["123482"]}]}, {"id": "0a7g22a", "name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["123482"]}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": []}] + application/json: + - assignedTo: + - "18625" + - "90252" + closingReasons: + - id: x739cew + - id: x739cew + - id: x739cew + creationTime: "2021-08-04T21:13:50.373Z" + description: Lead Qualification description + dueDate: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "123482" + id: 2hja82a + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "123482" + id: ga92ha2 + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "123482" + id: jga92ha + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "123482" + id: 0a7g22a + name: Print and send catalog + order: 2 + type: STEP + id: 25n2k52ja + lastUpdateTime: "2021-08-04T21:13:50.373Z" + name: Lead Qualification + updateEntityAttributes: [] + getFlowTemplate: + speakeasy-default-get-flow-template: + parameters: + path: + flowId: 7hj28akg + responses: + "200": + application/json: + closing_reasons: + - id: x739cew + - id: x739cew + - id: x739cew + created_at: "2021-04-27T12:01:13.000Z" + due_date: "2021-04-27T12:00:00.000Z" + edges: [] + name: + phases: [] + tasks: [] + update_entity_attributes: [] + updated_at: "2021-04-27T12:01:13.000Z" + "400": {} + "404": {} getMaxAllowedLimit: "": responses: "200": - application/json: {"currentNoOfWorkflows": 5, "maxAllowed": 7} + application/json: + currentNoOfWorkflows: 5 + maxAllowed: 7 getWorkflowClosingReasons: "": parameters: path: - definitionId: "fxcwfw" + definitionId: fxcwfw + responses: + "200": + application/json: + reasons: + - id: x739cew + - id: x739cew + - id: x739cew + listFlowTemplates: + speakeasy-default-list-flow-templates: responses: "200": - application/json: {"reasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}]} + application/json: + results: + - closing_reasons: + - id: x739cew + - id: x739cew + created_at: "2021-04-27T12:01:13.000Z" + due_date: "2021-04-27T12:00:00.000Z" + edges: + - from_id: + id: + to_id: + - from_id: + id: + to_id: + - from_id: + id: + to_id: + name: + phases: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + tasks: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: DECISION + - automation_config: + flow_id: + due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: AUTOMATION + - conditions: [] + due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: AUTOMATION + update_entity_attributes: + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_section + target: + entityAttribute: my_status + entitySchema: opportunity + - source: workflow_status + target: + entityAttribute: my_status + entitySchema: opportunity + updated_at: "2021-04-27T12:01:13.000Z" + "500": {} setWorkflowClosingReasons: "": parameters: path: definitionId: "7889" requestBody: - application/json: {"reasons": [{"id": "x739cew"}]} + application/json: + reasons: + - id: x739cew updateDefinition: "": parameters: path: - definitionId: "7hj28a" - requestBody: - application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"id": "2hja82a", "name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["8988"]}, {"id": "ga92ha2", "name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["8988"]}, {"id": "jga92ha", "name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["8988"]}]}, {"id": "0a7g22a", "name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["8988"]}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} - responses: - "200": - application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "type": "SECTION", "steps": [{"id": "2hja82a", "name": "Call client and confirm address and product", "type": "STEP", "order": 1, "assignedTo": ["1"]}, {"id": "ga92ha2", "name": "Check product availability", "type": "STEP", "order": 2, "assignedTo": ["56645"]}, {"id": "jga92ha", "name": "Send email confirming contact with the client", "type": "STEP", "order": 3, "assignedTo": ["949923"]}]}, {"id": "0a7g22a", "name": "Print and send catalog", "type": "STEP", "order": 2, "assignedTo": ["156645"]}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": []} - getClosingReason: - "": - parameters: - path: - reasonId: "-poOAPBa-jFZA_AWV3zN0" - responses: - "200": - application/json: {"creationTime": "2021-08-04T21:13:50.373Z", "id": "-poOAPBa-jFZA_AWV3zN0", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "status": "ACTIVE", "title": "Closing due to example reason"} - createFlowTemplate: - speakeasy-default-create-flow-template: + definitionId: 7hj28a requestBody: - application/json: {"closing_reasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}, {"from_id": "", "id": "", "to_id": ""}], "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"conditions": [{"id": "", "logical_operator": "OR", "statements": []}, {"id": "", "logical_operator": "AND", "statements": [{"id": "", "operator": "less_than", "values": ["", "", ""]}, {"id": "", "operator": "greater_than_or_equals", "values": ["", "", ""]}]}, {"id": "", "logical_operator": "AND", "statements": []}], "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "AUTOMATION"}, {"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}, {"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "MANUAL"}], "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} - responses: - "201": - application/json: {"closing_reasons": [{"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "name": "", "phases": [], "tasks": [], "update_entity_attributes": [{"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} - "400": {} - deleteFlowTemplate: - speakeasy-default-delete-flow-template: - parameters: - path: - flowId: "7hj28akg" - getFlowTemplate: - speakeasy-default-get-flow-template: - parameters: - path: - flowId: "7hj28akg" - responses: - "200": - application/json: {"closing_reasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [], "name": "", "phases": [], "tasks": [], "update_entity_attributes": [], "updated_at": "2021-04-27T12:01:13.000Z"} - "400": {} - "404": {} - listFlowTemplates: - speakeasy-default-list-flow-templates: + application/json: + assignedTo: + - "952802" + - "80225" + closingReasons: + - id: x739cew + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2022-08-04T12:00:00.000Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "8988" + id: 2hja82a + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "8988" + id: ga92ha2 + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "8988" + id: jga92ha + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "8988" + id: 0a7g22a + name: Print and send catalog + order: 2 + type: STEP + id: 25n2k52ja + lastUpdateTime: "2021-08-04T21:13:50.373Z" + name: Lead Qualification + updateEntityAttributes: + - source: workflow_status + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_section + target: + entityAttribute: my_status + entitySchema: opportunity responses: "200": - application/json: {"results": [{"closing_reasons": [{"id": "x739cew"}, {"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}, {"from_id": "", "id": "", "to_id": ""}, {"from_id": "", "id": "", "to_id": ""}], "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}, {"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "DECISION"}, {"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "AUTOMATION"}, {"conditions": [], "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "AUTOMATION"}], "update_entity_attributes": [{"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"}]} - "500": {} + application/json: + assignedTo: + - "952802" + - "80225" + closingReasons: + - id: x739cew + - id: x739cew + - id: x739cew + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2022-08-04T12:00:00.000Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + steps: + - assignedTo: + - "1" + id: 2hja82a + name: Call client and confirm address and product + order: 1 + type: STEP + - assignedTo: + - "56645" + id: ga92ha2 + name: Check product availability + order: 2 + type: STEP + - assignedTo: + - "949923" + id: jga92ha + name: Send email confirming contact with the client + order: 3 + type: STEP + type: SECTION + - assignedTo: + - "156645" + id: 0a7g22a + name: Print and send catalog + order: 2 + type: STEP + id: 25n2k52ja + lastUpdateTime: "2021-08-04T21:13:50.373Z" + name: Lead Qualification + updateEntityAttributes: [] updateFlowTemplate: speakeasy-default-update-flow-template: parameters: path: - flowId: "7hj28akg" + flowId: 7hj28akg requestBody: - application/json: {"closing_reasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "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"}], "update_entity_attributes": [{"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: + closing_reasons: + - id: x739cew + - id: x739cew + - id: x739cew + created_at: "2021-04-27T12:01:13.000Z" + due_date: "2021-04-27T12:00:00.000Z" + edges: + - from_id: + id: + to_id: + 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 + update_entity_attributes: + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity + updated_at: "2021-04-27T12:01:13.000Z" responses: "200": - application/json: {"closing_reasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "created_at": "2021-04-27T12:01:13.000Z", "due_date": "2021-04-27T12:00:00.000Z", "edges": [{"from_id": "", "id": "", "to_id": ""}], "name": "", "phases": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}, {"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}, {"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": ""}], "tasks": [{"due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "DECISION"}, {"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "AUTOMATION"}, {"automation_config": {"flow_id": ""}, "due_date": "2021-04-27T12:00:00.000Z", "id": "", "name": "", "task_type": "AUTOMATION"}], "update_entity_attributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}], "updated_at": "2021-04-27T12:01:13.000Z"} + application/json: + closing_reasons: + - id: x739cew + - id: x739cew + - id: x739cew + created_at: "2021-04-27T12:01:13.000Z" + due_date: "2021-04-27T12:00:00.000Z" + edges: + - from_id: + id: + to_id: + name: + phases: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + tasks: + - due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: DECISION + - automation_config: + flow_id: + due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: AUTOMATION + - automation_config: + flow_id: + due_date: "2021-04-27T12:00:00.000Z" + id: + name: + task_type: AUTOMATION + update_entity_attributes: + - source: workflow_status + target: + entityAttribute: my_status + entitySchema: opportunity + - source: current_step + target: + entityAttribute: my_status + entitySchema: opportunity + updated_at: "2021-04-27T12:01:13.000Z" "400": {} diff --git a/README.md b/README.md index f076bdd..690288c 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ TF_REATTACH_PROVIDERS=... terraform apply - -## Installation + +## SDK Installation To install this provider, copy and paste this code into your Terraform configuration. Then, run `terraform init`. @@ -61,7 +61,7 @@ terraform { required_providers { epilot-workflow = { source = "epilot-dev/epilot-workflow" - version = "0.15.2" + version = "0.16.0" } } } @@ -70,17 +70,19 @@ provider "epilot-workflow" { # Configuration options } ``` - + - -## Testing the provider locally + +## SDK Example Usage -#### Local Provider +### Testing the provider locally Should you want to validate a change locally, the `--debug` flag allows you to execute the provider against a terraform instance locally. This also allows for debuggers (e.g. delve) to be attached to the provider. +### Example + ```sh go run main.go --debug # Copy the TF_REATTACH_PROVIDERS env var @@ -89,43 +91,13 @@ cd examples/your-example TF_REATTACH_PROVIDERS=... terraform init TF_REATTACH_PROVIDERS=... terraform apply ``` + -#### Compiled Provider - -Terraform allows you to use local provider builds by setting a `dev_overrides` block in a configuration file called `.terraformrc`. This block overrides all other configured installation methods. - -1. Execute `go build` to construct a binary called `terraform-provider-epilot-workflow` -2. Ensure that the `.terraformrc` file is configured with a `dev_overrides` section such that your local copy of terraform can see the provider binary - -Terraform searches for the `.terraformrc` file in your home directory and applies any configuration settings you set. - -``` -provider_installation { - - dev_overrides { - "registry.terraform.io/epilot-dev/epilot-workflow" = "" - } - - # For all other providers, install them directly from their origin provider - # registries as normal. If you omit this, Terraform will _only_ use - # the dev_overrides block, and so no other providers will be available. - direct {} -} -``` - - - -## Available Resources and Data Sources - -### Resources + +## Available Resources and Operations -* [epilot-workflow_closing_reason](docs/resources/closing_reason.md) -* [epilot-workflow_workflow_definition](docs/resources/workflow_definition.md) -### Data Sources -* [epilot-workflow_closing_reason](docs/data-sources/closing_reason.md) -* [epilot-workflow_workflow_definition](docs/data-sources/workflow_definition.md) - + ## Summary diff --git a/docs/data-sources/closing_reason.md b/docs/data-sources/closing_reason.md index 40e29df..c87510a 100644 --- a/docs/data-sources/closing_reason.md +++ b/docs/data-sources/closing_reason.md @@ -14,6 +14,7 @@ ClosingReason DataSource ```terraform data "epilot-workflow_closing_reason" "my_closingreason" { + reason_id = "x739cew" } ``` @@ -25,5 +26,5 @@ data "epilot-workflow_closing_reason" "my_closingreason" { - `creation_time` (String) - `id` (String) The ID of this resource. - `last_update_time` (String) -- `status` (String) +- `status` (String) must be one of ["ACTIVE", "INACTIVE"] - `title` (String) diff --git a/docs/data-sources/workflow_definition.md b/docs/data-sources/workflow_definition.md index f37c0bc..6e50617 100644 --- a/docs/data-sources/workflow_definition.md +++ b/docs/data-sources/workflow_definition.md @@ -14,6 +14,7 @@ WorkflowDefinition DataSource ```terraform data "epilot-workflow_workflow_definition" "my_workflowdefinition" { + definition_id = "7hj28a" } ``` @@ -51,10 +52,10 @@ Read-Only: Read-Only: -- `action_type_condition` (String) +- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] - `number_of_units` (Number) - `step_id` (String) -- `time_period` (String) +- `time_period` (String) must be one of ["minutes", "hours", "days", "weeks", "months"] @@ -62,7 +63,7 @@ Read-Only: Read-Only: -- `source` (String) +- `source` (String) must be one of ["workflow_status", "current_section", "current_step"] - `target` (Attributes) (see [below for nested schema](#nestedatt--update_entity_attributes--target)) diff --git a/docs/index.md b/docs/index.md index 3e527c2..025bdcc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { epilot-workflow = { source = "epilot-dev/epilot-workflow" - version = "0.15.2" + version = "0.16.0" } } } diff --git a/docs/resources/closing_reason.md b/docs/resources/closing_reason.md index 55f90d2..7b812f1 100644 --- a/docs/resources/closing_reason.md +++ b/docs/resources/closing_reason.md @@ -14,11 +14,9 @@ ClosingReason Resource ```terraform resource "epilot-workflow_closing_reason" "my_closingreason" { - creation_time = "...my_creation_time..." - id = "...my_id..." - last_update_time = "...my_last_update_time..." - status = "INACTIVE" - title = "...my_title..." + reason_id = "x739cew" + status = "ACTIVE" + title = "Miss" } ``` @@ -27,14 +25,14 @@ resource "epilot-workflow_closing_reason" "my_closingreason" { ### Required -- `status` (String) must be one of ["ACTIVE", "INACTIVE"]; Requires replacement if changed. -- `title` (String) Requires replacement if changed. +- `status` (String) must be one of ["ACTIVE", "INACTIVE"] +- `title` (String) -### Optional +### Read-Only -- `creation_time` (String) Requires replacement if changed. -- `id` (String) Requires replacement if changed. -- `last_update_time` (String) Requires replacement if changed. +- `creation_time` (String) +- `id` (String) The ID of this resource. +- `last_update_time` (String) ## Import diff --git a/docs/resources/workflow_definition.md b/docs/resources/workflow_definition.md index 36f10fc..8e47448 100644 --- a/docs/resources/workflow_definition.md +++ b/docs/resources/workflow_definition.md @@ -14,44 +14,16 @@ WorkflowDefinition Resource ```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 = "STEP_CLOSED" - number_of_units = 0.36 - step_id = "...my_step_id..." - time_period = "days" - } - enable_ecp_workflow = false - enabled = false + creation_time = "2021-04-27T12:01:13.000Z" + definition_id = "7hj28a" + description = "...my_description..." + due_date = "2021-04-27T12:00:00.000Z" + enabled = true + enable_ecp_workflow = true flow = "{ \"see\": \"documentation\" }" - id = "...my_id..." + id = "1a10cbc6-dd84-4604-abba-b3cfdce452e3" 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 - ] + name = "Tammy Moore PhD" } ``` diff --git a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf index 2d40804..a97897a 100644 --- a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf +++ b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf @@ -1,2 +1,3 @@ data "epilot-workflow_closing_reason" "my_closingreason" { + reason_id = "x739cew" } \ 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 index 3592e48..e0b2b3d 100644 --- a/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf +++ b/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf @@ -1,2 +1,3 @@ data "epilot-workflow_workflow_definition" "my_workflowdefinition" { + definition_id = "7hj28a" } \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 4407b05..e48bf9c 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.15.2" + version = "0.16.0" } } } diff --git a/examples/resources/epilot-workflow_closing_reason/resource.tf b/examples/resources/epilot-workflow_closing_reason/resource.tf index 3a46938..f1bc9cb 100644 --- a/examples/resources/epilot-workflow_closing_reason/resource.tf +++ b/examples/resources/epilot-workflow_closing_reason/resource.tf @@ -1,7 +1,5 @@ resource "epilot-workflow_closing_reason" "my_closingreason" { - creation_time = "...my_creation_time..." - id = "...my_id..." - last_update_time = "...my_last_update_time..." - status = "INACTIVE" - title = "...my_title..." + reason_id = "x739cew" + status = "ACTIVE" + title = "Miss" } \ No newline at end of file diff --git a/examples/resources/epilot-workflow_workflow_definition/resource.tf b/examples/resources/epilot-workflow_workflow_definition/resource.tf index 09c31a6..99e4a5e 100644 --- a/examples/resources/epilot-workflow_workflow_definition/resource.tf +++ b/examples/resources/epilot-workflow_workflow_definition/resource.tf @@ -1,40 +1,12 @@ 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 = "STEP_CLOSED" - number_of_units = 0.36 - step_id = "...my_step_id..." - time_period = "days" - } - enable_ecp_workflow = false - enabled = false + creation_time = "2021-04-27T12:01:13.000Z" + definition_id = "7hj28a" + description = "...my_description..." + due_date = "2021-04-27T12:00:00.000Z" + enabled = true + enable_ecp_workflow = true flow = "{ \"see\": \"documentation\" }" - id = "...my_id..." + id = "1a10cbc6-dd84-4604-abba-b3cfdce452e3" 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 - ] + name = "Tammy Moore PhD" } \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 3f3771f..487c587 100644 --- a/gen.yaml +++ b/gen.yaml @@ -27,7 +27,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.15.2 + version: 0.16.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/go.mod b/go.mod index 4c453d7..6e8af53 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/epilot-dev/terraform-provider-epilot-workflow -go 1.22.0 +go 1.21 require ( github.com/cenkalti/backoff/v4 v4.2.0 github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 github.com/hashicorp/terraform-plugin-docs v0.19.4 - github.com/hashicorp/terraform-plugin-framework v1.12.0 + github.com/hashicorp/terraform-plugin-framework v1.10.0 github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 - github.com/hashicorp/terraform-plugin-go v0.24.0 + github.com/hashicorp/terraform-plugin-go v0.23.0 ) require ( @@ -32,7 +32,7 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.1 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/hc-install v0.7.0 // indirect @@ -60,15 +60,15 @@ require ( github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.14.4 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect - google.golang.org/grpc v1.66.2 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/net v0.23.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/text v0.15.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/grpc v1.63.2 // indirect + google.golang.org/protobuf v1.34.0 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f9e8505..2d68f29 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= -github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -87,12 +87,12 @@ github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7 github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= -github.com/hashicorp/terraform-plugin-framework v1.12.0 h1:7HKaueHPaikX5/7cbC1r9d1m12iYHY+FlNZEGxQ42CQ= -github.com/hashicorp/terraform-plugin-framework v1.12.0/go.mod h1:N/IOQ2uYjW60Jp39Cp3mw7I/OpC/GfZ0385R0YibmkE= +github.com/hashicorp/terraform-plugin-framework v1.10.0 h1:xXhICE2Fns1RYZxEQebwkB2+kXouLC932Li9qelozrc= +github.com/hashicorp/terraform-plugin-framework v1.10.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E= github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo= -github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U= -github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg= +github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= +github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= @@ -180,8 +180,8 @@ go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -191,12 +191,10 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -210,8 +208,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -219,20 +217,20 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= -google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= +google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/internal/provider/closingreason_data_source.go b/internal/provider/closingreason_data_source.go index 2848b52..76d699c 100644 --- a/internal/provider/closingreason_data_source.go +++ b/internal/provider/closingreason_data_source.go @@ -56,7 +56,8 @@ func (r *ClosingReasonDataSource) Schema(ctx context.Context, req datasource.Sch Computed: true, }, "status": schema.StringAttribute{ - Computed: true, + Computed: true, + Description: `must be one of ["ACTIVE", "INACTIVE"]`, }, "title": schema.StringAttribute{ Computed: true, diff --git a/internal/provider/closingreason_resource.go b/internal/provider/closingreason_resource.go index 5414771..482561a 100644 --- a/internal/provider/closingreason_resource.go +++ b/internal/provider/closingreason_resource.go @@ -5,15 +5,12 @@ package provider import ( "context" "fmt" - speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/planmodifiers/stringplanmodifier" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "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/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" @@ -51,38 +48,16 @@ func (r *ClosingReasonResource) Schema(ctx context.Context, req resource.SchemaR Attributes: map[string]schema.Attribute{ "creation_time": schema.StringAttribute{ Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Requires replacement if changed.`, }, "id": schema.StringAttribute{ Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Requires replacement if changed.`, }, "last_update_time": schema.StringAttribute{ Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Requires replacement if changed.`, }, "status": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `must be one of ["ACTIVE", "INACTIVE"]; Requires replacement if changed.`, + Required: true, + Description: `must be one of ["ACTIVE", "INACTIVE"]`, Validators: []validator.String{ stringvalidator.OneOf( "ACTIVE", @@ -92,11 +67,6 @@ func (r *ClosingReasonResource) Schema(ctx context.Context, req resource.SchemaR }, "title": schema.StringAttribute{ Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Requires replacement if changed.`, }, }, } @@ -140,7 +110,7 @@ func (r *ClosingReasonResource) Create(ctx context.Context, req resource.CreateR return } - request := *data.ToSharedClosingReason() + request := *data.ToSharedClosingReasonInput() res, err := r.client.ClosingReason.CreateClosingReason(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -236,7 +206,36 @@ func (r *ClosingReasonResource) Update(ctx context.Context, req resource.UpdateR return } - // Not Implemented; all attributes marked as RequiresReplace + closingReason := *data.ToSharedClosingReasonInput() + var reasonID string + reasonID = data.ID.ValueString() + + request := operations.UpdateClosingReasonRequest{ + ClosingReason: closingReason, + ReasonID: reasonID, + } + 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 + } + data.RefreshFromSharedClosingReason(res.ClosingReason) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -260,7 +259,29 @@ func (r *ClosingReasonResource) Delete(ctx context.Context, req resource.DeleteR return } - // Not Implemented; entity does not have a configured DELETE operation + var reasonID string + reasonID = data.ID.ValueString() + + request := operations.DeleteClosingReasonRequest{ + ReasonID: reasonID, + } + 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) { diff --git a/internal/provider/closingreason_resource_sdk.go b/internal/provider/closingreason_resource_sdk.go index 7695555..b91515f 100644 --- a/internal/provider/closingreason_resource_sdk.go +++ b/internal/provider/closingreason_resource_sdk.go @@ -7,35 +7,14 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *ClosingReasonResourceModel) ToSharedClosingReason() *shared.ClosingReason { - creationTime := new(string) - if !r.CreationTime.IsUnknown() && !r.CreationTime.IsNull() { - *creationTime = r.CreationTime.ValueString() - } else { - creationTime = nil - } - id := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id = r.ID.ValueString() - } else { - id = nil - } - lastUpdateTime := new(string) - if !r.LastUpdateTime.IsUnknown() && !r.LastUpdateTime.IsNull() { - *lastUpdateTime = r.LastUpdateTime.ValueString() - } else { - lastUpdateTime = nil - } +func (r *ClosingReasonResourceModel) ToSharedClosingReasonInput() *shared.ClosingReasonInput { status := shared.ClosingReasonsStatus(r.Status.ValueString()) var title string title = r.Title.ValueString() - out := shared.ClosingReason{ - CreationTime: creationTime, - ID: id, - LastUpdateTime: lastUpdateTime, - Status: status, - Title: title, + out := shared.ClosingReasonInput{ + Status: status, + Title: title, } return &out } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b968962..cb2cee2 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -36,7 +36,8 @@ func (p *EpilotWorkflowProvider) Metadata(ctx context.Context, req provider.Meta func (p *EpilotWorkflowProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ - Description: `Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization`, + MarkdownDescription: `Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization` + "\n" + + ``, Attributes: map[string]schema.Attribute{ "server_url": schema.StringAttribute{ MarkdownDescription: "Server URL (defaults to https://workflows-definition.sls.epilot.io)", diff --git a/internal/provider/workflowdefinition_data_source.go b/internal/provider/workflowdefinition_data_source.go index 6ac8b05..0757050 100644 --- a/internal/provider/workflowdefinition_data_source.go +++ b/internal/provider/workflowdefinition_data_source.go @@ -85,7 +85,8 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc Computed: true, Attributes: map[string]schema.Attribute{ "action_type_condition": schema.StringAttribute{ - Computed: true, + Computed: true, + Description: `must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"]`, }, "number_of_units": schema.NumberAttribute{ Computed: true, @@ -94,7 +95,8 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc Computed: true, }, "time_period": schema.StringAttribute{ - Computed: true, + Computed: true, + Description: `must be one of ["minutes", "hours", "days", "weeks", "months"]`, }, }, Description: `set a Duedate for a step then a specific`, @@ -131,7 +133,8 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "source": schema.StringAttribute{ - Computed: true, + Computed: true, + Description: `must be one of ["workflow_status", "current_section", "current_step"]`, }, "target": schema.SingleNestedAttribute{ Computed: true, diff --git a/internal/provider/workflowdefinition_resource.go b/internal/provider/workflowdefinition_resource.go index c4748a9..5199f58 100644 --- a/internal/provider/workflowdefinition_resource.go +++ b/internal/provider/workflowdefinition_resource.go @@ -71,9 +71,6 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, @@ -185,9 +182,6 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, Attributes: map[string]schema.Attribute{ "source": schema.StringAttribute{ Computed: true, diff --git a/internal/sdk/closingreason.go b/internal/sdk/closingreason.go index dbcb656..0d589e4 100644 --- a/internal/sdk/closingreason.go +++ b/internal/sdk/closingreason.go @@ -13,6 +13,7 @@ import ( "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" + "io" "net/http" "net/url" ) @@ -180,6 +181,13 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + switch { case httpRes.StatusCode == 202: case httpRes.StatusCode == 400: @@ -187,11 +195,6 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -199,17 +202,9 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio 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) } @@ -219,7 +214,7 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio // CreateClosingReason - createClosingReason // A created Closing Reason is stored for the organization and will be displayed in the library of reasons. -func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared.ClosingReason, opts ...operations.Option) (*operations.CreateClosingReasonResponse, error) { +func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared.ClosingReasonInput, opts ...operations.Option) (*operations.CreateClosingReasonResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "createClosingReason", @@ -370,15 +365,17 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.ClosingReason if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -386,17 +383,197 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. res.ClosingReason = &out default: - rawBody, err := utils.ConsumeRawBody(httpRes) + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// DeleteClosingReason - deleteClosingReason +// Permanently delete a closing reason (Using INACTIVE status is recommended instead) +func (s *ClosingReason) DeleteClosingReason(ctx context.Context, request operations.DeleteClosingReasonRequest, opts ...operations.Option) (*operations.DeleteClosingReasonResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "deleteClosingReason", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/workflows/closing-reasons/{reasonId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", 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, "DELETE", 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 + } + + 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, + } + } + } + + 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 { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.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.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, 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) + } else { + req, err = s.sdkConfiguration.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.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteClosingReasonResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode == 403: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ErrorResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReasonNotFoundResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReasonNotFoundResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -555,15 +732,17 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.ClosingReasons if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -571,17 +750,9 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat res.ClosingReasons = &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) } @@ -612,7 +783,7 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/workflows/closing-reasons/{reasonId}", request, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/workflows/closing-reasons/{reasonId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -736,15 +907,17 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.ClosingReason if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -752,24 +925,425 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations res.ClosingReason = &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) } case httpRes.StatusCode == 400: fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 500: + case httpRes.StatusCode == 403: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ErrorResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReasonNotFoundResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReasonNotFoundResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetClosingReasonV1 - getClosingReasonV1 +// Get specific closing reason by id from the organisation. +// +// Deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. +func (s *ClosingReason) GetClosingReasonV1(ctx context.Context, request operations.GetClosingReasonV1Request, opts ...operations.Option) (*operations.GetClosingReasonV1Response, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getClosingReasonV1", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/workflows/closing-reasons/{reasonId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", 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, "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 + } + + 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, + } + } + } + + 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 { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.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.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.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.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetClosingReasonV1Response{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReason + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReason = &out + default: + 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: + fallthrough + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ErrorResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReasonNotFoundResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReasonNotFoundResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// UpdateClosingReason - updateClosingReason +// Update an existing closing reason +func (s *ClosingReason) UpdateClosingReason(ctx context.Context, request operations.UpdateClosingReasonRequest, opts ...operations.Option) (*operations.UpdateClosingReasonResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "updateClosingReason", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/workflows/closing-reasons/{reasonId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "ClosingReason", "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, "PATCH", 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) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + 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, + } + } + } + + 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 { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.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.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.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.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdateClosingReasonResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReason + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReason = &out + default: + 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 == 403: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -777,20 +1351,11 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations 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) } case httpRes.StatusCode == 404: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - var out shared.ClosingReasonNotFoundResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -798,17 +1363,9 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations res.ClosingReasonNotFoundResp = &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) } diff --git a/internal/sdk/flowsv2.go b/internal/sdk/flowsv2.go index 4233b59..33b0979 100644 --- a/internal/sdk/flowsv2.go +++ b/internal/sdk/flowsv2.go @@ -13,6 +13,7 @@ import ( "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" + "io" "net/http" "net/url" ) @@ -180,15 +181,17 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.FlowTem RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.FlowTemplate if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -196,10 +199,6 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.FlowTem res.FlowTemplate = &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) } case httpRes.StatusCode == 400: @@ -209,11 +208,6 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.FlowTem 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -221,17 +215,9 @@ func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.FlowTem 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) } @@ -386,6 +372,13 @@ func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.Del RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + switch { case httpRes.StatusCode == 204: fallthrough @@ -393,11 +386,6 @@ func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.Del 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -405,17 +393,9 @@ func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.Del 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) } @@ -570,15 +550,17 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.FlowTemplate if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -586,10 +568,6 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo res.FlowTemplate = &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) } case httpRes.StatusCode == 400: @@ -599,11 +577,6 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -611,20 +584,11 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo 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) } case httpRes.StatusCode == 404: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - var out shared.DefinitionNotFoundResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -632,17 +596,9 @@ func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlo res.DefinitionNotFoundResp = &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) } @@ -797,15 +753,17 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.FlowTemplatesList if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -813,20 +771,11 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti res.FlowTemplatesList = &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) } 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -834,17 +783,9 @@ func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Opti 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) } @@ -1005,15 +946,17 @@ func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.Upd RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.FlowTemplate if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1021,10 +964,6 @@ func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.Upd res.FlowTemplate = &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) } case httpRes.StatusCode == 400: @@ -1034,11 +973,6 @@ func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.Upd 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1046,17 +980,9 @@ func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.Upd 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) } diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index bd307e1..986393e 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -487,29 +487,30 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa v.Set(m) return nil case reflect.Slice, reflect.Array: - var unmarshaled []json.RawMessage + if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + var unmarhsaled []json.RawMessage - if err := json.Unmarshal(value, &unmarshaled); err != nil { + if err := json.Unmarshal(value, &unmarhsaled); err != nil { return err } - arrVal := reflect.MakeSlice(typ, len(unmarshaled), len(unmarshaled)) + arrVal := v - for index, value := range unmarshaled { + for _, value := range unmarhsaled { itemVal := reflect.New(typ.Elem()) if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { return err } - arrVal.Index(index).Set(itemVal.Elem()) - } - - if v.Kind() == reflect.Pointer { - if v.IsNil() { - v.Set(reflect.New(typ)) - } - v = v.Elem() + arrVal = reflect.Append(arrVal, itemVal.Elem()) } v.Set(arrVal) diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index 000226e..0fd33cf 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -66,16 +66,15 @@ func serializeRequestBody(request interface{}, nullable, optional bool, requestF if tag != nil { // request object (non-flattened) requestVal := requestValType.FieldByName(requestFieldName) - val := reflect.ValueOf(requestVal.Interface()) if isNil(requestField.Type, requestVal) { if !nullable && optional { return nil, "", nil } - return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) + return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) } - return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) + return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) } } @@ -83,7 +82,7 @@ func serializeRequestBody(request interface{}, nullable, optional bool, requestF return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], reflect.ValueOf(request), tag) } -func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (io.Reader, string, error) { +func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (*bytes.Buffer, string, error) { buf := &bytes.Buffer{} if isNil(val.Type(), val) { @@ -117,8 +116,6 @@ func serializeContentType(fieldName string, mediaType string, val reflect.Value, if err := encodeFormData(fieldName, buf, val.Interface()); err != nil { return nil, "", err } - case val.Type().Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()): - return val.Interface().(io.Reader), mediaType, nil default: val = reflect.Indirect(val) @@ -127,8 +124,8 @@ func serializeContentType(fieldName string, mediaType string, val reflect.Value, if _, err := buf.WriteString(valToString(val.Interface())); err != nil { return nil, "", err } - case reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)): - if _, err := buf.Write(val.Interface().([]byte)); err != nil { + case val.Type() == reflect.TypeOf([]byte(nil)): + if _, err := buf.Write(val.Bytes()); err != nil { return nil, "", err } default: @@ -218,7 +215,7 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va var fieldName string var fileName string - var reader io.Reader + var content []byte for i := 0; i < fieldType.NumField(); i++ { field := fieldType.Field(i) @@ -229,19 +226,15 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va continue } - if tag.Content && val.CanInterface() { - if reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)) { - reader = bytes.NewReader(val.Interface().([]byte)) - } else if reflect.TypeOf(val.Interface()).Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()) { - reader = val.Interface().(io.Reader) - } + if tag.Content { + content = val.Bytes() } else { fieldName = tag.Name fileName = val.String() } } - if fieldName == "" || fileName == "" || reader == nil { + if fieldName == "" || fileName == "" || content == nil { return fmt.Errorf("invalid multipart/form-data file") } @@ -249,7 +242,7 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va if err != nil { return err } - if _, err := io.Copy(fw, reader); err != nil { + if _, err := fw.Write(content); err != nil { return err } diff --git a/internal/sdk/internal/utils/security.go b/internal/sdk/internal/utils/security.go index 19dfa6f..c8503f9 100644 --- a/internal/sdk/internal/utils/security.go +++ b/internal/sdk/internal/utils/security.go @@ -119,14 +119,9 @@ func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *secu } if schemeType.Kind() == reflect.Struct { - if schemeTag.Type == "http" { - switch schemeTag.SubType { - case "basic": - handleBasicAuthScheme(headers, schemeVal.Interface()) - return - case "custom": - return - } + if schemeTag.Type == "http" && schemeTag.SubType == "basic" { + handleBasicAuthScheme(headers, schemeVal.Interface()) + return } for i := 0; i < schemeType.NumField(); i++ { @@ -176,7 +171,6 @@ func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag switch schemeTag.SubType { case "bearer": headers[secTag.Name] = prefixBearer(valToString(val)) - case "custom": default: panic("not supported") } diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index f1ff9e0..adb2f70 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -3,12 +3,10 @@ package utils import ( - "bytes" "context" "fmt" "io" "math/big" - "net/http" "reflect" "regexp" "strconv" @@ -230,15 +228,3 @@ func contains(arr []string, str string) bool { } return false } - -func ConsumeRawBody(res *http.Response) ([]byte, error) { - rawBody, err := io.ReadAll(res.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - - res.Body.Close() - res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - - return rawBody, nil -} diff --git a/internal/sdk/models/operations/deleteclosingreason.go b/internal/sdk/models/operations/deleteclosingreason.go new file mode 100644 index 0000000..5fdfff7 --- /dev/null +++ b/internal/sdk/models/operations/deleteclosingreason.go @@ -0,0 +1,68 @@ +// 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 DeleteClosingReasonRequest struct { + // unique id to identify the closing reason. + ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` +} + +func (o *DeleteClosingReasonRequest) GetReasonID() string { + if o == nil { + return "" + } + return o.ReasonID +} + +type DeleteClosingReasonResponse struct { + // Closing reason not found + ClosingReasonNotFoundResp *shared.ClosingReasonNotFoundResp + // HTTP response content type for this operation + ContentType string + // Forbidden + ErrorResp *shared.ErrorResp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *DeleteClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if o == nil { + return nil + } + return o.ClosingReasonNotFoundResp +} + +func (o *DeleteClosingReasonResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *DeleteClosingReasonResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *DeleteClosingReasonResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *DeleteClosingReasonResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/getclosingreason.go b/internal/sdk/models/operations/getclosingreason.go index a1faf13..39ba554 100644 --- a/internal/sdk/models/operations/getclosingreason.go +++ b/internal/sdk/models/operations/getclosingreason.go @@ -8,7 +8,7 @@ import ( ) type GetClosingReasonRequest struct { - // uuid to identify the closing reason. + // unique id to identify the closing reason. ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` } diff --git a/internal/sdk/models/operations/getclosingreasonv1.go b/internal/sdk/models/operations/getclosingreasonv1.go new file mode 100644 index 0000000..2ff49e1 --- /dev/null +++ b/internal/sdk/models/operations/getclosingreasonv1.go @@ -0,0 +1,77 @@ +// 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 GetClosingReasonV1Request struct { + // uuid to identify the closing reason. + ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` +} + +func (o *GetClosingReasonV1Request) GetReasonID() string { + if o == nil { + return "" + } + return o.ReasonID +} + +type GetClosingReasonV1Response struct { + // Returns the closing reason + ClosingReason *shared.ClosingReason + // Closing reason not found + ClosingReasonNotFoundResp *shared.ClosingReasonNotFoundResp + // HTTP response content type for this operation + ContentType string + // Validation Errors + ErrorResp *shared.ErrorResp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *GetClosingReasonV1Response) GetClosingReason() *shared.ClosingReason { + if o == nil { + return nil + } + return o.ClosingReason +} + +func (o *GetClosingReasonV1Response) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if o == nil { + return nil + } + return o.ClosingReasonNotFoundResp +} + +func (o *GetClosingReasonV1Response) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetClosingReasonV1Response) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *GetClosingReasonV1Response) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetClosingReasonV1Response) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/updateclosingreason.go b/internal/sdk/models/operations/updateclosingreason.go new file mode 100644 index 0000000..b5cfd90 --- /dev/null +++ b/internal/sdk/models/operations/updateclosingreason.go @@ -0,0 +1,86 @@ +// 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 UpdateClosingReasonRequest struct { + // Updated closing reason fields + ClosingReason shared.ClosingReasonInput `request:"mediaType=application/json"` + // unique id to identify the closing reason. + ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` +} + +func (o *UpdateClosingReasonRequest) GetClosingReason() shared.ClosingReasonInput { + if o == nil { + return shared.ClosingReasonInput{} + } + return o.ClosingReason +} + +func (o *UpdateClosingReasonRequest) GetReasonID() string { + if o == nil { + return "" + } + return o.ReasonID +} + +type UpdateClosingReasonResponse struct { + // Closing reason updated successfully + ClosingReason *shared.ClosingReason + // Closing reason not found + ClosingReasonNotFoundResp *shared.ClosingReasonNotFoundResp + // HTTP response content type for this operation + ContentType string + // Validation Errors + ErrorResp *shared.ErrorResp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *UpdateClosingReasonResponse) GetClosingReason() *shared.ClosingReason { + if o == nil { + return nil + } + return o.ClosingReason +} + +func (o *UpdateClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { + if o == nil { + return nil + } + return o.ClosingReasonNotFoundResp +} + +func (o *UpdateClosingReasonResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *UpdateClosingReasonResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *UpdateClosingReasonResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *UpdateClosingReasonResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/shared/automationtask.go b/internal/sdk/models/shared/automationtask.go index c44f2b3..9737948 100644 --- a/internal/sdk/models/shared/automationtask.go +++ b/internal/sdk/models/shared/automationtask.go @@ -21,7 +21,7 @@ type AutomationTask struct { Description *StepDescription `json:"description,omitempty"` DueDate *string `json:"due_date,omitempty"` // Set due date for the task based on a dynamic condition - DynamicDueDate *DueDateConfig `json:"dynamic_due_date,omitempty"` + DueDateConfig *DueDateConfig `json:"due_date_config,omitempty"` // Details regarding ECP for the workflow step Ecp *ECPDetails `json:"ecp,omitempty"` ID string `json:"id"` @@ -65,11 +65,11 @@ func (o *AutomationTask) GetDueDate() *string { return o.DueDate } -func (o *AutomationTask) GetDynamicDueDate() *DueDateConfig { +func (o *AutomationTask) GetDueDateConfig() *DueDateConfig { if o == nil { return nil } - return o.DynamicDueDate + return o.DueDateConfig } func (o *AutomationTask) GetEcp() *ECPDetails { diff --git a/internal/sdk/models/shared/closingreasoninput.go b/internal/sdk/models/shared/closingreasoninput.go new file mode 100644 index 0000000..47eadf7 --- /dev/null +++ b/internal/sdk/models/shared/closingreasoninput.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ClosingReasonInput - One Closing reason for a workflow +type ClosingReasonInput struct { + Status ClosingReasonsStatus `json:"status"` + Title string `json:"title"` +} + +func (o *ClosingReasonInput) GetStatus() ClosingReasonsStatus { + if o == nil { + return ClosingReasonsStatus("") + } + return o.Status +} + +func (o *ClosingReasonInput) GetTitle() string { + if o == nil { + return "" + } + return o.Title +} diff --git a/internal/sdk/models/shared/decisiontask.go b/internal/sdk/models/shared/decisiontask.go index 1300f97..25ecc71 100644 --- a/internal/sdk/models/shared/decisiontask.go +++ b/internal/sdk/models/shared/decisiontask.go @@ -9,7 +9,7 @@ type DecisionTask struct { Description *StepDescription `json:"description,omitempty"` DueDate *string `json:"due_date,omitempty"` // Set due date for the task based on a dynamic condition - DynamicDueDate *DueDateConfig `json:"dynamic_due_date,omitempty"` + DueDateConfig *DueDateConfig `json:"due_date_config,omitempty"` // Details regarding ECP for the workflow step Ecp *ECPDetails `json:"ecp,omitempty"` ID string `json:"id"` @@ -53,11 +53,11 @@ func (o *DecisionTask) GetDueDate() *string { return o.DueDate } -func (o *DecisionTask) GetDynamicDueDate() *DueDateConfig { +func (o *DecisionTask) GetDueDateConfig() *DueDateConfig { if o == nil { return nil } - return o.DynamicDueDate + return o.DueDateConfig } func (o *DecisionTask) GetEcp() *ECPDetails { diff --git a/internal/sdk/models/shared/flowtemplate.go b/internal/sdk/models/shared/flowtemplate.go index 118ae1f..1cb5a48 100644 --- a/internal/sdk/models/shared/flowtemplate.go +++ b/internal/sdk/models/shared/flowtemplate.go @@ -16,8 +16,8 @@ type FlowTemplate struct { Description *string `json:"description,omitempty"` DueDate *string `json:"due_date,omitempty"` // Set due date for the task based on a dynamic condition - DynamicDueDate *DueDateConfig `json:"dynamic_due_date,omitempty"` - Edges []Edge `json:"edges"` + DueDateConfig *DueDateConfig `json:"due_date_config,omitempty"` + Edges []Edge `json:"edges"` // Whether the workflow is enabled or not Enabled *bool `default:"true" json:"enabled"` ID *string `json:"id,omitempty"` @@ -84,11 +84,11 @@ func (o *FlowTemplate) GetDueDate() *string { return o.DueDate } -func (o *FlowTemplate) GetDynamicDueDate() *DueDateConfig { +func (o *FlowTemplate) GetDueDateConfig() *DueDateConfig { if o == nil { return nil } - return o.DynamicDueDate + return o.DueDateConfig } func (o *FlowTemplate) GetEdges() []Edge { diff --git a/internal/sdk/models/shared/phase.go b/internal/sdk/models/shared/phase.go index fcd1c41..7c954b5 100644 --- a/internal/sdk/models/shared/phase.go +++ b/internal/sdk/models/shared/phase.go @@ -6,9 +6,9 @@ type Phase struct { AssignedTo []string `json:"assigned_to,omitempty"` DueDate *string `json:"due_date,omitempty"` // Set due date for the task based on a dynamic condition - DynamicDueDate *DueDateConfig `json:"dynamic_due_date,omitempty"` - ID string `json:"id"` - Name string `json:"name"` + DueDateConfig *DueDateConfig `json:"due_date_config,omitempty"` + ID string `json:"id"` + Name string `json:"name"` // Taxonomy ids that are associated with this workflow and used for filtering Taxonomies []string `json:"taxonomies,omitempty"` } @@ -27,11 +27,11 @@ func (o *Phase) GetDueDate() *string { return o.DueDate } -func (o *Phase) GetDynamicDueDate() *DueDateConfig { +func (o *Phase) GetDueDateConfig() *DueDateConfig { if o == nil { return nil } - return o.DynamicDueDate + return o.DueDateConfig } func (o *Phase) GetID() string { diff --git a/internal/sdk/models/shared/taskbase.go b/internal/sdk/models/shared/taskbase.go index 68756e0..800728b 100644 --- a/internal/sdk/models/shared/taskbase.go +++ b/internal/sdk/models/shared/taskbase.go @@ -8,7 +8,7 @@ type TaskBase struct { Description *StepDescription `json:"description,omitempty"` DueDate *string `json:"due_date,omitempty"` // Set due date for the task based on a dynamic condition - DynamicDueDate *DueDateConfig `json:"dynamic_due_date,omitempty"` + DueDateConfig *DueDateConfig `json:"due_date_config,omitempty"` // Details regarding ECP for the workflow step Ecp *ECPDetails `json:"ecp,omitempty"` ID string `json:"id"` @@ -45,11 +45,11 @@ func (o *TaskBase) GetDueDate() *string { return o.DueDate } -func (o *TaskBase) GetDynamicDueDate() *DueDateConfig { +func (o *TaskBase) GetDueDateConfig() *DueDateConfig { if o == nil { return nil } - return o.DynamicDueDate + return o.DueDateConfig } func (o *TaskBase) GetEcp() *ECPDetails { diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index e4e4c9b..3f7a605 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -41,9 +41,6 @@ func Float32(f float32) *float32 { return &f } // Float64 provides a helper function to return a pointer to a float64 func Float64(f float64) *float64 { return &f } -// Pointer provides a helper function to return a pointer to a type -func Pointer[T any](v T) *T { return &v } - type sdkConfiguration struct { Client HTTPClient Security func(context.Context) (interface{}, error) @@ -150,8 +147,8 @@ func New(opts ...SDKOption) *SDK { Language: "go", OpenAPIDocVersion: "1.0.0", SDKVersion: "0.0.1", - GenVersion: "2.438.15", - UserAgent: "speakeasy-sdk/go 0.0.1 2.438.15 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", + GenVersion: "2.396.0", + UserAgent: "speakeasy-sdk/go 0.0.1 2.396.0 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", Hooks: hooks.New(), }, } diff --git a/internal/sdk/types/pointers.go b/internal/sdk/types/pointers.go index 35c439d..950d6a3 100644 --- a/internal/sdk/types/pointers.go +++ b/internal/sdk/types/pointers.go @@ -8,4 +8,3 @@ func Int(i int) *int { return &i } func Int64(i int64) *int64 { return &i } func Float32(f float32) *float32 { return &f } func Float64(f float64) *float64 { return &f } -func Pointer[T any](v T) *T { return &v } diff --git a/internal/sdk/workflows.go b/internal/sdk/workflows.go index 58aab7a..968b937 100644 --- a/internal/sdk/workflows.go +++ b/internal/sdk/workflows.go @@ -13,6 +13,7 @@ import ( "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" + "io" "net/http" "net/url" ) @@ -180,15 +181,17 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.WorkflowDefinition if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -196,10 +199,6 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo res.WorkflowDefinition = &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) } case httpRes.StatusCode == 400: @@ -209,11 +208,6 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -221,17 +215,9 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo 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) } @@ -386,6 +372,13 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + switch { case httpRes.StatusCode == 204: fallthrough @@ -393,11 +386,6 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -405,17 +393,9 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del 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) } @@ -570,15 +550,17 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.WorkflowDefinition if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -586,10 +568,6 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef res.WorkflowDefinition = &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) } case httpRes.StatusCode == 400: @@ -599,11 +577,6 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -611,20 +584,11 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef 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) } case httpRes.StatusCode == 404: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - var out shared.DefinitionNotFoundResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -632,17 +596,9 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef res.DefinitionNotFoundResp = &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) } @@ -797,15 +753,17 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out []shared.WorkflowDefinition if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -813,20 +771,11 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio res.Classes = 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) } 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -834,17 +783,9 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio 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) } @@ -999,15 +940,17 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.MaxAllowedLimit if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1015,20 +958,11 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O res.MaxAllowedLimit = &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) } 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1036,17 +970,9 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O 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) } @@ -1201,15 +1127,17 @@ func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request opera RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.ClosingReasonsIds if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1217,17 +1145,9 @@ func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request opera res.ClosingReasonsIds = &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) } @@ -1388,13 +1308,16 @@ func (s *Workflows) SetWorkflowClosingReasons(ctx context.Context, request opera RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + switch { case httpRes.StatusCode == 201: 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) } @@ -1555,15 +1478,17 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd RawResponse: httpRes, } + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + 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 - } - var out shared.WorkflowDefinition if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1571,10 +1496,6 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd res.WorkflowDefinition = &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) } case httpRes.StatusCode == 400: @@ -1584,11 +1505,6 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd 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 - } - var out shared.ErrorResp if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1596,17 +1512,9 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd 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) } diff --git a/original.yaml b/original.yaml index e69de29..bc7099a 100644 --- a/original.yaml +++ b/original.yaml @@ -0,0 +1,1635 @@ +openapi: 3.0.0 + +info: + title: Workflows Definitions + version: 1.0.0 + description: | + Service for Workflow Definitions for different processes inside of an Organization + +servers: + - url: https://workflows-definition.sls.epilot.io + +security: + - BearerAuth: [] + +paths: + /v1/workflows/limits/max-allowed: + get: + operationId: getMaxAllowedLimit + summary: getMaxAllowedLimit + description: Get limits and number of created executions for an Organization. + tags: + - Workflows + responses: + 200: + description: A combo of current number of workflows, and the max allowed number of workflows. + content: + application/json: + schema: + $ref: "#/components/schemas/MaxAllowedLimit" + example: + currentNoOfWorkflows: 5 + maxAllowed: 7 + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + + /v1/workflows/definitions: + get: + operationId: getDefinitions + summary: getDefinitions + description: Retrieve all Workflow Definitions from an Organization + tags: + - Workflows + responses: + 200: + description: Success - definitions loaded with success. Empty array if org has no definitions. + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/WorkflowDefinition" + example: + - id: 25n2k52ja + name: Lead Qualification + assignedTo: + - "18625" + - "90252" + description: Lead Qualification description + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["123482"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["123482"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["123482"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["123482"] + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + post: + operationId: createDefinition + summary: createDefinition + description: Create a Workflow Definition. + tags: + - Workflows + requestBody: + description: Workflow Definition payload + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + name: Lead Qualification + description: Lead Qualification description + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + flow: + - name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["123482"] + - name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["123482"] + - name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["123482"] + - name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["123482"] + responses: + 201: + description: Success - if the definition is created successfully + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + description: Lead Qualification description + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["48829"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["45390"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["8230"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["8239"] + 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: + get: + operationId: listFlowTemplates + summary: listFlowTemplates + description: List all Flow Templates for a customer + tags: + - Flows V2 + 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/FlowTemplate" + 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/{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 + + /v1/workflows/definitions/{definitionId}: + get: + operationId: getDefinition + summary: getDefinition + description: Get specific Definition by id from the Organization. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: Short uuid (length 8) to identify the Workflow Definition. + example: 7hj28a + responses: + 200: + description: Returns the Workflow definition + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["923432"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["45488"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["45488"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["8988"] + closingReasons: + [ + { id: ffoowef, title: test }, + { id: "hebwoeu", title: Closing because all }, + { id: "mbnoenq", title: Better offer }, + ] + 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: updateDefinition + summary: updateDefinition + description: Update Workflow Definition. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: Short uuid (length 8) to identify the Workflow Definition. + example: 7hj28a + requestBody: + description: Workflow Definition payload + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["8988"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["8988"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["8988"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["8988"] + responses: + 200: + description: Success - if the definition is updated successfully + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["1"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["56645"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["949923"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["156645"] + 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: deleteDefinition + summary: deleteDefinition + description: Delete Workflow Definition. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: Id of the definition to de deleted. + example: CustomerRequest + responses: + 204: + description: Success - if the definition is deleted successfully + 401: + description: Failed to authenticate + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: No definition found + + /v1/workflows/closing-reasons: + get: + operationId: getAllClosingReasons + summary: getAllClosingReasons + description: Get all Closing Reasons defined in the organization by default all Active. + parameters: + - in: query + name: includeInactive + schema: + type: boolean + required: false + description: Filter Closing Reasons by status like active inactiv + example: true + tags: + - Closing Reason + responses: + 200: + description: Returns the entire catalog of closing reasons per organization + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasons" + post: + operationId: createClosingReason + summary: createClosingReason + description: A created Closing Reason is stored for the organization and will be displayed in the library of reasons. + tags: + - Closing Reason + requestBody: + description: closing reason to store + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + example: + title: better offer + description: A customer closes the process because he found something better + responses: + 201: + description: closing reason is stored successfully in the repository + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + + /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 + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + responses: + 200: + description: Returns the closing reason + 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" + + patch: + operationId: updateClosingReason + summary: updateClosingReason + description: Update an existing closing reason + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + requestBody: + description: Updated closing reason fields + required: true + content: + application/json: + schema: + $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 + +components: + securitySchemes: + BearerAuth: + type: http + scheme: bearer + bearerFormat: JWT + + schemas: + # ------------------------- # + # V2 data structures + # ------------------------- # + FlowTemplate: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + created_at: + 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 + 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" + closing_reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReasonId" + 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 + required: + - name + - tasks + - edges + + 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: + allOf: + - $ref: "#/components/schemas/TaskBase" + - type: object + required: + - automation_config + properties: + automation_config: + type: object + properties: + flow_id: + type: string + description: Id of the configured automation to run + required: + - flow_id + + DecisionTask: + allOf: + - $ref: "#/components/schemas/TaskBase" + - type: object + required: + - conditions + properties: + conditions: + type: array + items: + $ref: "#/components/schemas/Condition" + + 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 + required: + - id + - from_id + - to_id + + Condition: + type: object + properties: + id: + type: string + logical_operator: + type: string + enum: + - AND + - OR + statements: + type: array + items: + $ref: "#/components/schemas/Statement" + required: + - id + - 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: + type: string + enum: + - minutes + - hours + - days + - weeks + - months + type: + type: string + enum: + - WORKFLOW_STARTED + - TASK_FINISHED + task_id: + type: string + required: + - duration + - unit + - type + + EnableRequirement: + description: describe the requirement for a task to be enabled + type: object + properties: + task_id: + type: string + phase_id: + type: string + when: + type: string + enum: + - TASK_FINISHED + - PHASE_FINISHED + required: + - when + + # ------------------------- # + # V1 data structures + # ------------------------- # + + WorkflowDefinition: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + creationTime: + 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 + example: "2021-04-27T12:01:13.000Z" + dueDate: + type: string + example: "2021-04-27T12:00:00.000Z" + dynamicDueDate: + $ref: "#/components/schemas/DynamicDueDate" + userIds: + type: array + items: + type: number + deprecated: true + description: This field is deprecated. Please use assignedTo + assignedTo: + type: array + items: + type: string + enableECPWorkflow: + type: boolean + description: Indicates whether this workflow is available for End Customer Portal or not. By default it's not. + flow: + type: array + items: + anyOf: + - $ref: "#/components/schemas/Section" + - $ref: "#/components/schemas/Step" + closingReasons: + type: array + items: + $ref: "#/components/schemas/ClosingReasonId" + updateEntityAttributes: + 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 + + Step: + type: object + description: Action that needs to be done in a Workflow + properties: + id: + type: string + name: + type: string + description: + $ref: '#/components/schemas/StepDescription' + executionType: + $ref: '#/components/schemas/StepType' + automationConfig: + type: object + properties: + flowId: + type: string + description: Id of the configured automation to run + required: + - flowId + journey: + $ref: '#/components/schemas/StepJourney' + order: + type: number + dueDate: + type: string + example: "2021-04-27T12:00:00.000Z" + dynamicDueDate: + $ref: "#/components/schemas/DynamicDueDate" + userIds: + type: array + items: + type: number + deprecated: true + description: This field is deprecated. Please use assignedTo + requirements: + type: array + description: requirements that need to be fulfilled in order to enable the step execution + items: + $ref: "#/components/schemas/StepRequirement" + assignedTo: + type: array + items: + type: string + type: + $ref: "#/components/schemas/ItemType" + 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 + required: + - name + - order + - type + + Section: + type: object + description: A group of Steps that define the progress of the Workflow + properties: + id: + type: string + name: + type: string + order: + 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 + + ItemType: + type: string + enum: + - STEP + - SECTION + + StepType: + type: string + enum: + - MANUAL + - AUTOMATION + + StepJourney: + type: object + properties: + id: + type: string + journeyId: + type: string + name: + type: string + + ECPDetails: + type: object + description: Details regarding ECP for the workflow step + properties: + enabled: + type: boolean + label: + type: string + description: + type: string + journey: + $ref: '#/components/schemas/StepJourney' + + StepDescription: + type: object + description: Longer information regarding Task + properties: + enabled: + type: boolean + value: + type: string + + MaxAllowedLimit: + type: object + properties: + currentNoOfWorkflows: + type: number + maxAllowed: + type: number + + DefinitionNotFoundResp: + description: Definition could be not found + properties: + message: + type: string + + ClosingReasonNotFoundResp: + description: Closing reason could be not found + properties: + message: + type: string + + ChangeReasonStatusReq: + type: object + properties: + status: + $ref: "#/components/schemas/ClosingReasonsStatus" + required: + - status + + ClosingReasons: + type: object + properties: + reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReason" + required: + - reasons + + ClosingReason: + type: object + description: One Closing reason for a workflow + required: + - title + - status + 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 + enum: + - ACTIVE + - INACTIVE + + ClosingReasonsIds: + type: object + properties: + reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReasonId" + required: + - reasons + + ClosingReasonId: + type: object + properties: + id: + type: string + example: "x739cew" + required: + - id + + ErrorResp: + type: object + properties: + message: + type: string + + UpdateEntityAttributes: + type: object + properties: + source: + type: string + enum: + - "workflow_status" + - "current_section" + - "current_step" + target: + type: object + properties: + # Field "slug" will be used from the entity + entitySchema: + type: string + example: "opportunity" + # Field "name" will be used from the entity attribute + entityAttribute: + type: string + example: "my_status" + required: + - entitySchema + - entityAttribute + required: + - source + - target + + DynamicDueDate: + description: set a Duedate for a step then a specific + type: object + properties: + numberOfUnits: + type: number + timePeriod: + type: string + enum: + - minutes + - hours + - days + - weeks + - months + actionTypeCondition: + type: string + enum: + - WORKFLOW_STARTED + - STEP_CLOSED + stepId: + type: string + required: + - numberOfUnits + - timePeriod + - actionTypeCondition + + StepRequirement: + description: describe the requirement for step enablement + type: object + properties: + definitionId: + type: string + type: + $ref: "#/components/schemas/ItemType" + condition: + type: string + enum: + - CLOSED + required: + - definitionId + - type + - condition diff --git a/original_modified.yaml b/original_modified.yaml new file mode 100644 index 0000000..afa63e0 --- /dev/null +++ b/original_modified.yaml @@ -0,0 +1,1604 @@ +openapi: 3.0.0 +info: + title: Workflows Definitions + version: 1.0.0 + description: | + Service for Workflow Definitions for different processes inside of an Organization +servers: + - url: https://workflows-definition.sls.epilot.io +security: + - BearerAuth: [] +paths: + /v1/workflows/limits/max-allowed: + get: + operationId: getMaxAllowedLimit + summary: getMaxAllowedLimit + description: Get limits and number of created executions for an Organization. + tags: + - Workflows + responses: + 200: + description: A combo of current number of workflows, and the max allowed number of workflows. + content: + application/json: + schema: + $ref: "#/components/schemas/MaxAllowedLimit" + example: + currentNoOfWorkflows: 5 + maxAllowed: 7 + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + /v1/workflows/definitions: + get: + operationId: getDefinitions + summary: getDefinitions + description: Retrieve all Workflow Definitions from an Organization + tags: + - Workflows + responses: + 200: + description: Success - definitions loaded with success. Empty array if org has no definitions. + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/WorkflowDefinition" + example: + - id: 25n2k52ja + name: Lead Qualification + assignedTo: + - "18625" + - "90252" + description: Lead Qualification description + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["123482"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["123482"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["123482"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["123482"] + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + post: + operationId: createDefinition + summary: createDefinition + description: Create a Workflow Definition. + tags: + - Workflows + requestBody: + description: Workflow Definition payload + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + name: Lead Qualification + description: Lead Qualification description + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + flow: + - name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["123482"] + - name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["123482"] + - name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["123482"] + - name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["123482"] + responses: + 201: + description: Success - if the definition is created successfully + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + description: Lead Qualification description + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["48829"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["45390"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["8230"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["8239"] + 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" + x-speakeasy-entity-operation: WorkflowDefinition#create + /v2/flows/templates: + get: + operationId: listFlowTemplates + summary: listFlowTemplates + description: List all Flow Templates for a customer + tags: + - Flows V2 + 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/FlowTemplate" + 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/{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 + /v1/workflows/definitions/{definitionId}: + get: + operationId: getDefinition + summary: getDefinition + description: Get specific Definition by id from the Organization. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: Short uuid (length 8) to identify the Workflow Definition. + example: 7hj28a + x-speakeasy-match: id + responses: + 200: + description: Returns the Workflow definition + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["923432"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["45488"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["45488"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["8988"] + closingReasons: [{id: ffoowef, title: test}, {id: "hebwoeu", title: Closing because all}, {id: "mbnoenq", title: Better offer}] + 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" + x-speakeasy-entity-operation: WorkflowDefinition#get + put: + operationId: updateDefinition + summary: updateDefinition + description: Update Workflow Definition. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: Short uuid (length 8) to identify the Workflow Definition. + example: 7hj28a + x-speakeasy-match: id + requestBody: + description: Workflow Definition payload + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["8988"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["8988"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["8988"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["8988"] + responses: + 200: + description: Success - if the definition is updated successfully + content: + application/json: + schema: + $ref: "#/components/schemas/WorkflowDefinition" + example: + id: 25n2k52ja + name: Lead Qualification + dueDate: "2022-08-04T12:00:00.000Z" + assignedTo: + - "952802" + - "80225" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + flow: + - id: 5892na2 + name: Initial Information Gathering + order: 1 + type: SECTION + steps: + - id: 2hja82a + name: "Call client and confirm address and product" + type: STEP + order: 1 + assignedTo: ["1"] + - id: ga92ha2 + name: "Check product availability" + type: STEP + order: 2 + assignedTo: ["56645"] + - id: jga92ha + name: "Send email confirming contact with the client" + type: STEP + order: 3 + assignedTo: ["949923"] + - id: 0a7g22a + name: Print and send catalog + type: STEP + order: 2 + assignedTo: ["156645"] + 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" + x-speakeasy-entity-operation: WorkflowDefinition#update + delete: + operationId: deleteDefinition + summary: deleteDefinition + description: Delete Workflow Definition. + tags: + - Workflows + parameters: + - in: path + name: definitionId + schema: + type: string + required: true + description: Id of the definition to de deleted. + example: CustomerRequest + x-speakeasy-match: id + # jsonencode workflows definiton flows due to type incompatibilities + responses: + 204: + description: Success - if the definition is deleted successfully + 401: + description: Failed to authenticate + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: No definition found + x-speakeasy-entity-operation: WorkflowDefinition#delete + /v1/workflows/closing-reasons: + get: + operationId: getAllClosingReasons + summary: getAllClosingReasons + description: Get all Closing Reasons defined in the organization by default all Active. + parameters: + - in: query + name: includeInactive + schema: + type: boolean + required: false + description: Filter Closing Reasons by status like active inactiv + example: true + tags: + - Closing Reason + responses: + 200: + description: Returns the entire catalog of closing reasons per organization + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasons" + post: + operationId: createClosingReason + summary: createClosingReason + description: A created Closing Reason is stored for the organization and will be displayed in the library of reasons. + tags: + - Closing Reason + requestBody: + description: closing reason to store + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + example: + title: better offer + description: A customer closes the process because he found something better + responses: + 201: + description: closing reason is stored successfully in the repository + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + x-speakeasy-entity-operation: ClosingReason#create + /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 + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + x-speakeasy-match: id + responses: + 200: + description: Returns the closing reason + 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" + x-speakeasy-entity-operation: ClosingReason#get + patch: + operationId: updateClosingReason + summary: updateClosingReason + description: Update an existing closing reason + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + x-speakeasy-match: id + requestBody: + description: Updated closing reason fields + required: true + content: + application/json: + schema: + $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" + x-speakeasy-entity-operation: ClosingReason#update + 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. + x-speakeasy-match: id + 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" + x-speakeasy-entity-operation: ClosingReason#delete + /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 +components: + securitySchemes: + BearerAuth: + type: http + scheme: bearer + bearerFormat: JWT + schemas: + # ------------------------- # + # V2 data structures + # ------------------------- # + FlowTemplate: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + created_at: + 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 + 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" + closing_reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReasonId" + 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 + required: + - name + - tasks + - edges + 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: + allOf: + - $ref: "#/components/schemas/TaskBase" + - type: object + required: + - automation_config + properties: + automation_config: + type: object + properties: + flow_id: + type: string + description: Id of the configured automation to run + required: + - flow_id + DecisionTask: + allOf: + - $ref: "#/components/schemas/TaskBase" + - type: object + required: + - conditions + properties: + conditions: + type: array + items: + $ref: "#/components/schemas/Condition" + 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 + required: + - id + - from_id + - to_id + Condition: + type: object + properties: + id: + type: string + logical_operator: + type: string + enum: + - AND + - OR + statements: + type: array + items: + $ref: "#/components/schemas/Statement" + required: + - id + - 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: + type: string + enum: + - minutes + - hours + - days + - weeks + - months + type: + type: string + enum: + - WORKFLOW_STARTED + - TASK_FINISHED + task_id: + type: string + required: + - duration + - unit + - type + EnableRequirement: + description: describe the requirement for a task to be enabled + type: object + properties: + task_id: + type: string + phase_id: + type: string + when: + type: string + enum: + - TASK_FINISHED + - PHASE_FINISHED + required: + - when + # ------------------------- # + # V1 data structures + # ------------------------- # + WorkflowDefinition: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + creationTime: + 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 + example: "2021-04-27T12:01:13.000Z" + dueDate: + type: string + example: "2021-04-27T12:00:00.000Z" + dynamicDueDate: + $ref: "#/components/schemas/DynamicDueDate" + userIds: + type: array + items: + type: number + deprecated: true + description: This field is deprecated. Please use assignedTo + assignedTo: + type: array + items: + type: string + enableECPWorkflow: + type: boolean + description: Indicates whether this workflow is available for End Customer Portal or not. By default it's not. + flow: + type: array + items: + anyOf: + - $ref: "#/components/schemas/Section" + - $ref: "#/components/schemas/Step" + x-speakeasy-type-override: any + closingReasons: + type: array + items: + $ref: "#/components/schemas/ClosingReasonId" + updateEntityAttributes: + 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 + x-speakeasy-entity: WorkflowDefinition + Step: + type: object + description: Action that needs to be done in a Workflow + properties: + id: + type: string + name: + type: string + description: + $ref: '#/components/schemas/StepDescription' + executionType: + $ref: '#/components/schemas/StepType' + automationConfig: + type: object + properties: + flowId: + type: string + description: Id of the configured automation to run + required: + - flowId + journey: + $ref: '#/components/schemas/StepJourney' + order: + type: number + dueDate: + type: string + example: "2021-04-27T12:00:00.000Z" + dynamicDueDate: + $ref: "#/components/schemas/DynamicDueDate" + userIds: + type: array + items: + type: number + deprecated: true + description: This field is deprecated. Please use assignedTo + requirements: + type: array + description: requirements that need to be fulfilled in order to enable the step execution + items: + $ref: "#/components/schemas/StepRequirement" + assignedTo: + type: array + items: + type: string + type: + $ref: "#/components/schemas/ItemType" + 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 + required: + - name + - order + - type + Section: + type: object + description: A group of Steps that define the progress of the Workflow + properties: + id: + type: string + name: + type: string + order: + 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 + ItemType: + type: string + enum: + - STEP + - SECTION + StepType: + type: string + enum: + - MANUAL + - AUTOMATION + StepJourney: + type: object + properties: + id: + type: string + journeyId: + type: string + name: + type: string + ECPDetails: + type: object + description: Details regarding ECP for the workflow step + properties: + enabled: + type: boolean + label: + type: string + description: + type: string + journey: + $ref: '#/components/schemas/StepJourney' + StepDescription: + type: object + description: Longer information regarding Task + properties: + enabled: + type: boolean + value: + type: string + MaxAllowedLimit: + type: object + properties: + currentNoOfWorkflows: + type: number + maxAllowed: + type: number + DefinitionNotFoundResp: + description: Definition could be not found + properties: + message: + type: string + ClosingReasonNotFoundResp: + description: Closing reason could be not found + properties: + message: + type: string + ChangeReasonStatusReq: + type: object + properties: + status: + $ref: "#/components/schemas/ClosingReasonsStatus" + required: + - status + ClosingReasons: + type: object + properties: + reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReason" + required: + - reasons + ClosingReason: + type: object + description: One Closing reason for a workflow + required: + - title + - status + properties: + id: + type: string + readOnly: true + title: + type: string + status: + $ref: "#/components/schemas/ClosingReasonsStatus" + lastUpdateTime: + type: string + readOnly: true + creationTime: + type: string + readOnly: true + x-speakeasy-entity: ClosingReason + ClosingReasonsStatus: + type: string + enum: + - ACTIVE + - INACTIVE + ClosingReasonsIds: + type: object + properties: + reasons: + type: array + items: + $ref: "#/components/schemas/ClosingReasonId" + required: + - reasons + ClosingReasonId: + type: object + properties: + id: + type: string + example: "x739cew" + required: + - id + ErrorResp: + type: object + properties: + message: + type: string + UpdateEntityAttributes: + type: object + properties: + source: + type: string + enum: + - "workflow_status" + - "current_section" + - "current_step" + target: + type: object + properties: + # Field "slug" will be used from the entity + entitySchema: + type: string + example: "opportunity" + # Field "name" will be used from the entity attribute + entityAttribute: + type: string + example: "my_status" + required: + - entitySchema + - entityAttribute + required: + - source + - target + DynamicDueDate: + description: set a Duedate for a step then a specific + type: object + properties: + numberOfUnits: + type: number + timePeriod: + type: string + enum: + - minutes + - hours + - days + - weeks + - months + actionTypeCondition: + type: string + enum: + - WORKFLOW_STARTED + - STEP_CLOSED + stepId: + type: string + required: + - numberOfUnits + - timePeriod + - actionTypeCondition + StepRequirement: + description: describe the requirement for step enablement + type: object + properties: + definitionId: + type: string + type: + $ref: "#/components/schemas/ItemType" + condition: + type: string + enum: + - CLOSED + required: + - definitionId + - type + - condition +x-speakeasy-retries: + strategy: backoff + backoff: + initialInterval: 5000 # 5 seconds + maxInterval: 60000 # 60 seconds + maxElapsedTime: 3600000 # 5 minutes + exponent: 1.5 + statusCodes: + - 5XX + retryConnectionErrors: true diff --git a/overlay.yaml b/overlay.yaml index ad292de..b63a189 100644 --- a/overlay.yaml +++ b/overlay.yaml @@ -48,16 +48,28 @@ actions: x-speakeasy-type-override: any -# Closing reasons - - target: $["paths"]["/v1/workflows/closing-reasons/{reasonId}"]["get"] - update: - x-speakeasy-entity-operation: ClosingReason#get + # Closing reasons - target: $["paths"]["/v1/workflows/closing-reasons"]["post"] update: x-speakeasy-entity-operation: ClosingReason#create - - target: $["paths"]["/v1/workflows/closing-reasons/{reasonId}"]["get"]["parameters"][0] + - target: $["paths"]["/v2/workflows/closing-reasons/{reasonId}"]["get"] + update: + x-speakeasy-entity-operation: ClosingReason#get + - target: $["paths"]["/v2/workflows/closing-reasons/{reasonId}"]["get"]["parameters"][0] + update: + x-speakeasy-match: id + - target: $["paths"]["/v2/workflows/closing-reasons/{reasonId}"]["patch"] + update: + x-speakeasy-entity-operation: ClosingReason#update + - target: $["paths"]["/v2/workflows/closing-reasons/{reasonId}"]["patch"]["parameters"][0] + update: + x-speakeasy-match: id + - target: $["paths"]["/v2/workflows/closing-reasons/{reasonId}"]["delete"] + update: + x-speakeasy-entity-operation: ClosingReason#delete + - target: $["paths"]["/v2/workflows/closing-reasons/{reasonId}"]["delete"]["parameters"][0] update: x-speakeasy-match: id - target: $["components"]["schemas"]["ClosingReason"] update: - x-speakeasy-entity: ClosingReason \ No newline at end of file + x-speakeasy-entity: ClosingReason diff --git a/workflow.yaml b/workflow.yaml index 92a7534..bc7099a 100644 --- a/workflow.yaml +++ b/workflow.yaml @@ -645,11 +645,130 @@ paths: schema: $ref: "#/components/schemas/ClosingReason" - /v1/workflows/closing-reasons/{reasonId}: + /v2/workflows/closing-reasons/{reasonId}: get: - operationId: getClosingReason + operationId: getClosingReason summary: getClosingReason description: Get specific closing reason by id from the organisation. + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + responses: + 200: + description: Returns the closing reason + 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" + + patch: + operationId: updateClosingReason + summary: updateClosingReason + description: Update an existing closing reason + tags: + - Closing Reason + parameters: + - in: path + name: reasonId + schema: + type: string + example: "x739cew" + required: true + description: unique id to identify the closing reason. + requestBody: + description: Updated closing reason fields + required: true + content: + application/json: + schema: + $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: @@ -814,7 +933,7 @@ components: due_date: type: string example: "2021-04-27T12:00:00.000Z" - dynamic_due_date: + due_date_config: $ref: "#/components/schemas/DueDateConfig" assigned_to: type: array @@ -921,7 +1040,7 @@ components: due_date: type: string example: "2021-04-27T12:00:00.000Z" - dynamic_due_date: + due_date_config: $ref: "#/components/schemas/DueDateConfig" requirements: type: array @@ -961,7 +1080,7 @@ components: due_date: type: string example: "2021-04-27T12:00:00.000Z" - dynamic_due_date: + due_date_config: $ref: "#/components/schemas/DueDateConfig" assigned_to: type: array @@ -1402,14 +1521,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