diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 28f83b6..c9aa25a 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: cbe462f4a20d4b2a1273895979390e09 + docChecksum: ae471e39d05055eb1d09ad61715bb339 docVersion: 1.0.0 - speakeasyVersion: 1.346.0 - generationVersion: 2.379.3 - releaseVersion: 0.13.0 - configChecksum: b0fe4d200caa906deca84fe07b9ca435 + speakeasyVersion: 1.422.1 + generationVersion: 2.438.15 + releaseVersion: 0.15.2 + configChecksum: 51df825a76e7f72ef6717314a9f0d4b4 repoURL: https://github.com/epilot-dev/terraform-provider-epilot-workflow.git repoSubDirectory: . published: true @@ -21,62 +21,27 @@ features: unions: 2.85.0 terraform: additionalDependencies: 0.1.0 - core: 3.24.3 + constsAndDefaults: 0.1.4 + core: 3.25.0 deprecations: 2.81.1 - globalSecurity: 2.81.6 + envVarSecurityUsage: 0.1.0 + globalSecurity: 2.81.9 globalServerURLs: 2.82.1 + retries: 2.81.1 typeOverrides: 2.81.1 + unions: 2.81.16 generatedFiles: - - internal/sdk/closingreason.go - - internal/sdk/workflows.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 - - internal/sdk/internal/utils/json.go - - internal/sdk/internal/utils/pathparams.go - - internal/sdk/internal/utils/queryparams.go - - internal/sdk/internal/utils/requestbody.go - - internal/sdk/internal/utils/retries.go - - internal/sdk/internal/utils/security.go - - internal/sdk/internal/utils/utils.go - - internal/sdk/models/operations/changereasonstatus.go - - internal/sdk/models/operations/createclosingreason.go - - internal/sdk/models/operations/getallclosingreasons.go - - internal/sdk/models/operations/getclosingreason.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/getmaxallowedlimit.go - - internal/sdk/models/operations/updatedefinition.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/closingreasons.go - - internal/sdk/models/shared/closingreasonnotfoundresp.go - - internal/sdk/models/shared/workflowdefinition.go - - internal/sdk/models/shared/updateentityattributes.go - - internal/sdk/models/shared/dynamicduedate.go - - internal/sdk/models/shared/closingreasonid.go - - internal/sdk/models/shared/definitionnotfoundresp.go - - internal/sdk/models/shared/maxallowedlimit.go - - internal/sdk/models/shared/security.go - - internal/sdk/.gitignore - - internal/sdk/models/operations/options.go - - internal/sdk/.gitattributes - - internal/sdk/internal/hooks/registration.go - - internal/sdk/internal/hooks/hooks.go - - internal/sdk/CONTRIBUTING.md + - .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 @@ -89,6 +54,11 @@ generatedFiles: - internal/planmodifiers/setplanmodifier/suppress_diff.go - internal/planmodifiers/stringplanmodifier/suppress_diff.go - internal/planmodifiers/utils/state_check.go + - internal/provider/closingreason_data_source.go + - internal/provider/closingreason_data_source_sdk.go + - internal/provider/closingreason_resource.go + - internal/provider/closingreason_resource_sdk.go + - internal/provider/provider.go - internal/provider/reflect/diags.go - internal/provider/reflect/doc.go - internal/provider/reflect/generic_attr_value.go @@ -103,7 +73,90 @@ generatedFiles: - 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/flowsv2.go + - internal/sdk/internal/hooks/hooks.go + - internal/sdk/internal/utils/contenttype.go + - internal/sdk/internal/utils/form.go + - internal/sdk/internal/utils/headers.go + - internal/sdk/internal/utils/json.go + - internal/sdk/internal/utils/pathparams.go + - internal/sdk/internal/utils/queryparams.go + - internal/sdk/internal/utils/requestbody.go + - 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/getallclosingreasons.go + - internal/sdk/models/operations/getclosingreason.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/updateflowtemplate.go + - internal/sdk/models/shared/automationtask.go + - internal/sdk/models/shared/changereasonstatusreq.go + - internal/sdk/models/shared/closingreason.go + - internal/sdk/models/shared/closingreasonid.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/dynamicduedate.go + - internal/sdk/models/shared/ecpdetails.go + - internal/sdk/models/shared/edge.go + - internal/sdk/models/shared/enablerequirement.go + - internal/sdk/models/shared/errorresp.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/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/validators/DateValidator.go - internal/validators/ExactlyOneChild.go - internal/validators/JSONParseValidator.go @@ -120,26 +173,129 @@ 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: "" + createClosingReason: + "": + requestBody: + 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": ""}]} + 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"}}]} + 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": []} + "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"}}]} + deleteDefinition: + "": + parameters: + path: + definitionId: "CustomerRequest" + getDefinition: + "": + parameters: + path: + 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"}}]} + 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": []}] + getMaxAllowedLimit: + "": + responses: + "200": + application/json: {"currentNoOfWorkflows": 5, "maxAllowed": 7} + getWorkflowClosingReasons: + "": + parameters: + path: + definitionId: "fxcwfw" + responses: + "200": + application/json: {"reasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}]} + setWorkflowClosingReasons: + "": + parameters: + path: + definitionId: "7889" + requestBody: + 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: + 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: + 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": {} + updateFlowTemplate: + speakeasy-default-update-flow-template: + parameters: + path: + 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"} + 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"} + "400": {} diff --git a/Makefile b/Makefile index 76d8636..240559b 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,21 @@ .PHONY: all docs -all: docs speakeasy +all: speakeasy docs + +original.yaml: + cp workflow.yaml original.yaml + +original_modified.yaml: original.yaml overlay.yaml + speakeasy overlay apply -s original.yaml -o overlay.yaml > original_modified.yaml + +overlay.yaml: + speakeasy overlay compare -s original.yaml -s original_modified.yaml > overlay.yaml speakeasy: - speakeasy generate sdk --lang terraform -o . -s workflow.yaml + $(eval TMP := $(shell mktemp -d)) +# curl https://docs.api.epilot.io/workflows-definition.yaml > $(TMP)/openapi.yaml + cp workflow.yaml $(TMP)/openapi.yaml + speakeasy overlay apply -s $(TMP)/openapi.yaml -o overlay.yaml > $(TMP)/final.yaml + speakeasy generate sdk --lang terraform -o . -s $(TMP)/final.yaml docs: go generate ./... diff --git a/README.md b/README.md index 3879765..f076bdd 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ TF_REATTACH_PROVIDERS=... terraform apply - -## SDK Installation + +## 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.13.0" + version = "0.15.2" } } } @@ -70,19 +70,17 @@ provider "epilot-workflow" { # Configuration options } ``` - + - -## SDK Example Usage + +## Testing the provider locally -### Testing the provider locally +#### Local Provider 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 @@ -91,13 +89,57 @@ cd examples/your-example TF_REATTACH_PROVIDERS=... terraform init TF_REATTACH_PROVIDERS=... terraform apply ``` - - -## Available Resources and Operations +#### 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 + +* [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 + +Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization + + +## Table of Contents - +* [Installation](#installation) +* [Available Resources and Data Sources](#available-resources-and-data-sources) +* [Testing the provider locally](#testing-the-provider-locally) + diff --git a/docs/data-sources/closing_reason.md b/docs/data-sources/closing_reason.md index 60e3633..40e29df 100644 --- a/docs/data-sources/closing_reason.md +++ b/docs/data-sources/closing_reason.md @@ -14,7 +14,6 @@ ClosingReason DataSource ```terraform data "epilot-workflow_closing_reason" "my_closingreason" { - reason_id = "-poOAPBa-jFZA_AWV3zN0" } ``` @@ -26,7 +25,5 @@ data "epilot-workflow_closing_reason" "my_closingreason" { - `creation_time` (String) - `id` (String) The ID of this resource. - `last_update_time` (String) -- `status` (String) must be one of ["ACTIVE", "INACTIVE"] +- `status` (String) - `title` (String) - - diff --git a/docs/data-sources/workflow_definition.md b/docs/data-sources/workflow_definition.md index d74e206..f37c0bc 100644 --- a/docs/data-sources/workflow_definition.md +++ b/docs/data-sources/workflow_definition.md @@ -14,7 +14,6 @@ WorkflowDefinition DataSource ```terraform data "epilot-workflow_workflow_definition" "my_workflowdefinition" { - definition_id = "7hj28a" } ``` @@ -30,10 +29,12 @@ data "epilot-workflow_workflow_definition" "my_workflowdefinition" { - `due_date` (String) - `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--dynamic_due_date)) - `enable_ecp_workflow` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `flow` (Attributes List) (see [below for nested schema](#nestedatt--flow)) +- `enabled` (Boolean) Whether the workflow is enabled or not +- `flow` (String) Parsed as JSON. - `id` (String) The ID of this resource. - `last_update_time` (String) ISO String Date & Time - `name` (String) +- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - `update_entity_attributes` (Attributes List) (see [below for nested schema](#nestedatt--update_entity_attributes)) - `user_ids` (List of Number) This field is deprecated. Please use assignedTo @@ -50,255 +51,10 @@ Read-Only: Read-Only: -- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] +- `action_type_condition` (String) - `number_of_units` (Number) - `step_id` (String) -- `time_period` (String) must be one of ["days", "weeks", "months"] - - - -### Nested Schema for `flow` - -Read-Only: - -- `section` (Attributes) A group of Steps that define the progress of the Workflow (see [below for nested schema](#nestedatt--flow--section)) -- `step` (Attributes) Action that needs to be done in a Workflow (see [below for nested schema](#nestedatt--flow--step)) - - -### Nested Schema for `flow.section` - -Read-Only: - -- `id` (String) -- `name` (String) -- `order` (Number) -- `steps` (Attributes List) (see [below for nested schema](#nestedatt--flow--section--steps)) -- `type` (String) must be one of ["STEP", "SECTION"] - - -### Nested Schema for `flow.section.steps` - -Read-Only: - -- `assigned_to` (List of String) -- `automation_config` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--automation_config)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--flow--section--steps--description)) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--flow--section--steps--dynamic_due_date)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--section--steps--ecp)) -- `execution_type` (String) must be one of ["MANUAL", "AUTOMATION"] -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--section--steps--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--journey)) -- `name` (String) -- `order` (Number) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the step execution (see [below for nested schema](#nestedatt--flow--section--steps--requirements)) -- `type` (String) must be one of ["STEP", "SECTION"] -- `user_ids` (List of Number) This field is deprecated. Please use assignedTo - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `flow_id` (String) Id of the configured automation to run - - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] -- `number_of_units` (Number) -- `step_id` (String) -- `time_period` (String) must be one of ["days", "weeks", "months"] - - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--user_ids--journey)) -- `label` (String) - - -### Nested Schema for `flow.section.steps.user_ids.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--user_ids--journey)) -- `label` (String) - - -### Nested Schema for `flow.section.steps.user_ids.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `flow.section.steps.user_ids` - -Read-Only: - -- `condition` (String) must be one of ["CLOSED"] -- `definition_id` (String) -- `type` (String) must be one of ["STEP", "SECTION"] - - - - - -### Nested Schema for `flow.step` - -Read-Only: - -- `assigned_to` (List of String) -- `automation_config` (Attributes) (see [below for nested schema](#nestedatt--flow--step--automation_config)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--flow--step--description)) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--flow--step--dynamic_due_date)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--step--ecp)) -- `execution_type` (String) must be one of ["MANUAL", "AUTOMATION"] -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--step--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--step--journey)) -- `name` (String) -- `order` (Number) -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the step execution (see [below for nested schema](#nestedatt--flow--step--requirements)) -- `type` (String) must be one of ["STEP", "SECTION"] -- `user_ids` (List of Number) This field is deprecated. Please use assignedTo - - -### Nested Schema for `flow.step.automation_config` - -Read-Only: - -- `flow_id` (String) Id of the configured automation to run - - - -### Nested Schema for `flow.step.description` - -Read-Only: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `flow.step.dynamic_due_date` - -Read-Only: - -- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] -- `number_of_units` (Number) -- `step_id` (String) -- `time_period` (String) must be one of ["days", "weeks", "months"] - - - -### Nested Schema for `flow.step.ecp` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--step--ecp--journey)) -- `label` (String) - - -### Nested Schema for `flow.step.ecp.label` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.step.installer` - -Read-Only: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--step--installer--journey)) -- `label` (String) - - -### Nested Schema for `flow.step.installer.label` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.step.journey` - -Read-Only: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `flow.step.requirements` - -Read-Only: - -- `condition` (String) must be one of ["CLOSED"] -- `definition_id` (String) -- `type` (String) must be one of ["STEP", "SECTION"] - - +- `time_period` (String) @@ -306,7 +62,7 @@ Read-Only: Read-Only: -- `source` (String) must be one of ["workflow_status", "current_section", "current_step"] +- `source` (String) - `target` (Attributes) (see [below for nested schema](#nestedatt--update_entity_attributes--target)) @@ -316,5 +72,3 @@ Read-Only: - `entity_attribute` (String) - `entity_schema` (String) - - diff --git a/docs/index.md b/docs/index.md index 788ba14..3e527c2 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.12.0" + version = "0.15.2" } } } diff --git a/docs/resources/closing_reason.md b/docs/resources/closing_reason.md index 3cfabdc..55f90d2 100644 --- a/docs/resources/closing_reason.md +++ b/docs/resources/closing_reason.md @@ -15,11 +15,10 @@ ClosingReason Resource ```terraform resource "epilot-workflow_closing_reason" "my_closingreason" { creation_time = "...my_creation_time..." - id = "26c83797-1a10-4cbc-add8-4604abbab3cf" + id = "...my_id..." last_update_time = "...my_last_update_time..." - reason_id = "-poOAPBa-jFZA_AWV3zN0" status = "INACTIVE" - title = "Miss" + title = "...my_title..." } ``` @@ -28,7 +27,7 @@ resource "epilot-workflow_closing_reason" "my_closingreason" { ### Required -- `status` (String) Requires replacement if changed. ; must be one of ["ACTIVE", "INACTIVE"] +- `status` (String) must be one of ["ACTIVE", "INACTIVE"]; Requires replacement if changed. - `title` (String) Requires replacement if changed. ### Optional diff --git a/docs/resources/workflow_definition.md b/docs/resources/workflow_definition.md index 5bc3a39..36f10fc 100644 --- a/docs/resources/workflow_definition.md +++ b/docs/resources/workflow_definition.md @@ -14,85 +14,44 @@ WorkflowDefinition Resource ```terraform resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - creation_time = "2021-04-27T12:01:13.000Z" - definition_id = "7hj28a" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" + 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 - flow = [ + enabled = false + flow = "{ \"see\": \"documentation\" }" + id = "...my_id..." + last_update_time = "2021-04-27T12:01:13.000Z" + name = "...my_name..." + taxonomies = [ + "..." + ] + update_entity_attributes = [ { - section = { - id = "452e3f02-980e-44cf-845d-81d428f0e4f5" - name = "Luther Greenfelder" - order = 12.7 - steps = [ - { - assigned_to = [ - "...", - ] - automation_config = { - flow_id = "...my_flow_id..." - } - description = { - enabled = false - value = "...my_value..." - } - due_date = "2021-04-27T12:00:00.000Z" - dynamic_due_date = { - action_type_condition = "WORKFLOW_STARTED" - number_of_units = 95.2 - step_id = "...my_step_id..." - time_period = "weeks" - } - ecp = { - description = "...my_description..." - enabled = true - journey = { - id = "56e082d1-2997-4428-b0e6-c4cc2bdf6697" - journey_id = "...my_journey_id..." - name = "Floyd Pacocha" - } - label = "...my_label..." - } - execution_type = "MANUAL" - id = "7a2ecac9-f13d-48a1-a6b9-dc969f95f0ea" - installer = { - description = "...my_description..." - enabled = true - journey = { - id = "4100e0ec-f324-443f-89bc-c4a7284764a3" - journey_id = "...my_journey_id..." - name = "Kara Hoppe" - } - label = "...my_label..." - } - journey = { - id = "eff3a06c-e7de-4f51-84a6-068ca5b78833" - journey_id = "...my_journey_id..." - name = "Brandy Senger" - } - name = "Sammy Gislason" - order = 14.54 - requirements = [ - { - condition = "CLOSED" - definition_id = "...my_definition_id..." - type = "STEP" - }, - ] - type = "STEP" - user_ids = [ - 94.55, - ] - }, - ] - type = "SECTION" + source = "current_step" + target = { + entity_attribute = "my_status" + entity_schema = "opportunity" } - }, + } + ] + user_ids = [ + 5.93 ] - id = "6301351b-2bbd-41bf-80cf-7a2f75db8f8a" - last_update_time = "2021-04-27T12:01:13.000Z" - name = "Dr. Matthew Cronin" } ``` @@ -101,7 +60,7 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { ### Required -- `flow` (Attributes List) (see [below for nested schema](#nestedatt--flow)) +- `flow` (String) Parsed as JSON. - `name` (String) ### Optional @@ -113,7 +72,9 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - `due_date` (String) - `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--dynamic_due_date)) - `enable_ecp_workflow` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. +- `enabled` (Boolean) Whether the workflow is enabled or not. Default: true - `last_update_time` (String) ISO String Date & Time +- `taxonomies` (List of String) Taxonomy ids that are associated with this workflow and used for filtering - `update_entity_attributes` (Attributes List) (see [below for nested schema](#nestedatt--update_entity_attributes)) - `user_ids` (List of Number) This field is deprecated. Please use assignedTo @@ -121,251 +82,6 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - `id` (String) The ID of this resource. - -### Nested Schema for `flow` - -Optional: - -- `section` (Attributes) A group of Steps that define the progress of the Workflow (see [below for nested schema](#nestedatt--flow--section)) -- `step` (Attributes) Action that needs to be done in a Workflow (see [below for nested schema](#nestedatt--flow--step)) - - -### Nested Schema for `flow.section` - -Optional: - -- `id` (String) -- `name` (String) Not Null -- `order` (Number) Not Null -- `steps` (Attributes List) Not Null (see [below for nested schema](#nestedatt--flow--section--steps)) -- `type` (String) Not Null; must be one of ["STEP", "SECTION"] - - -### Nested Schema for `flow.section.steps` - -Optional: - -- `assigned_to` (List of String) -- `automation_config` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--automation_config)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--flow--section--steps--description)) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--flow--section--steps--dynamic_due_date)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--section--steps--ecp)) -- `execution_type` (String) must be one of ["MANUAL", "AUTOMATION"] -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--section--steps--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--journey)) -- `name` (String) Not Null -- `order` (Number) Not Null -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the step execution (see [below for nested schema](#nestedatt--flow--section--steps--requirements)) -- `type` (String) Not Null; must be one of ["STEP", "SECTION"] -- `user_ids` (List of Number) This field is deprecated. Please use assignedTo - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `flow_id` (String) Id of the configured automation to run. Not Null - - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] -- `number_of_units` (Number) -- `step_id` (String) -- `time_period` (String) must be one of ["days", "weeks", "months"] - - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--user_ids--journey)) -- `label` (String) - - -### Nested Schema for `flow.section.steps.user_ids.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--section--steps--user_ids--journey)) -- `label` (String) - - -### Nested Schema for `flow.section.steps.user_ids.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `flow.section.steps.user_ids` - -Optional: - -- `condition` (String) Not Null; must be one of ["CLOSED"] -- `definition_id` (String) Not Null -- `type` (String) Not Null; must be one of ["STEP", "SECTION"] - - - - - -### Nested Schema for `flow.step` - -Optional: - -- `assigned_to` (List of String) -- `automation_config` (Attributes) (see [below for nested schema](#nestedatt--flow--step--automation_config)) -- `description` (Attributes) Longer information regarding Task (see [below for nested schema](#nestedatt--flow--step--description)) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--flow--step--dynamic_due_date)) -- `ecp` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--step--ecp)) -- `execution_type` (String) must be one of ["MANUAL", "AUTOMATION"] -- `id` (String) -- `installer` (Attributes) Details regarding ECP for the workflow step (see [below for nested schema](#nestedatt--flow--step--installer)) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--step--journey)) -- `name` (String) Not Null -- `order` (Number) Not Null -- `requirements` (Attributes List) requirements that need to be fulfilled in order to enable the step execution (see [below for nested schema](#nestedatt--flow--step--requirements)) -- `type` (String) Not Null; must be one of ["STEP", "SECTION"] -- `user_ids` (List of Number) This field is deprecated. Please use assignedTo - - -### Nested Schema for `flow.step.automation_config` - -Optional: - -- `flow_id` (String) Id of the configured automation to run. Not Null - - - -### Nested Schema for `flow.step.description` - -Optional: - -- `enabled` (Boolean) -- `value` (String) - - - -### Nested Schema for `flow.step.dynamic_due_date` - -Optional: - -- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] -- `number_of_units` (Number) -- `step_id` (String) -- `time_period` (String) must be one of ["days", "weeks", "months"] - - - -### Nested Schema for `flow.step.ecp` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--step--ecp--journey)) -- `label` (String) - - -### Nested Schema for `flow.step.ecp.label` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.step.installer` - -Optional: - -- `description` (String) -- `enabled` (Boolean) -- `journey` (Attributes) (see [below for nested schema](#nestedatt--flow--step--installer--journey)) -- `label` (String) - - -### Nested Schema for `flow.step.installer.label` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - - -### Nested Schema for `flow.step.journey` - -Optional: - -- `id` (String) -- `journey_id` (String) -- `name` (String) - - - -### Nested Schema for `flow.step.requirements` - -Optional: - -- `condition` (String) Not Null; must be one of ["CLOSED"] -- `definition_id` (String) Not Null -- `type` (String) Not Null; must be one of ["STEP", "SECTION"] - - - - ### Nested Schema for `closing_reasons` @@ -379,10 +95,10 @@ Optional: Optional: -- `action_type_condition` (String) must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] -- `number_of_units` (Number) +- `action_type_condition` (String) Not Null; must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"] +- `number_of_units` (Number) Not Null - `step_id` (String) -- `time_period` (String) must be one of ["days", "weeks", "months"] +- `time_period` (String) Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"] 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 ec4863b..2d40804 100644 --- a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf +++ b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf @@ -1,3 +1,2 @@ data "epilot-workflow_closing_reason" "my_closingreason" { - reason_id = "-poOAPBa-jFZA_AWV3zN0" } \ 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 e0b2b3d..3592e48 100644 --- a/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf +++ b/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf @@ -1,3 +1,2 @@ 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 6ad6a46..4407b05 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.13.0" + version = "0.15.2" } } } diff --git a/examples/resources/epilot-workflow_closing_reason/resource.tf b/examples/resources/epilot-workflow_closing_reason/resource.tf index c0f1076..3a46938 100644 --- a/examples/resources/epilot-workflow_closing_reason/resource.tf +++ b/examples/resources/epilot-workflow_closing_reason/resource.tf @@ -1,8 +1,7 @@ resource "epilot-workflow_closing_reason" "my_closingreason" { creation_time = "...my_creation_time..." - id = "26c83797-1a10-4cbc-add8-4604abbab3cf" + id = "...my_id..." last_update_time = "...my_last_update_time..." - reason_id = "-poOAPBa-jFZA_AWV3zN0" status = "INACTIVE" - title = "Miss" + title = "...my_title..." } \ 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 49f9dc0..09c31a6 100644 --- a/examples/resources/epilot-workflow_workflow_definition/resource.tf +++ b/examples/resources/epilot-workflow_workflow_definition/resource.tf @@ -1,11 +1,40 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - creation_time = "2021-04-27T12:01:13.000Z" - definition_id = "7hj28a" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" + 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 flow = "{ \"see\": \"documentation\" }" - id = "452e3f02-980e-44cf-845d-81d428f0e4f5" + id = "...my_id..." last_update_time = "2021-04-27T12:01:13.000Z" - name = "Luther Greenfelder" + name = "...my_name..." + taxonomies = [ + "..." + ] + update_entity_attributes = [ + { + source = "current_step" + target = { + entity_attribute = "my_status" + entity_schema = "opportunity" + } + } + ] + user_ids = [ + 5.93 + ] } \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 355adff..3f3771f 100644 --- a/gen.yaml +++ b/gen.yaml @@ -27,7 +27,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.13.0 + version: 0.15.2 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/go.mod b/go.mod index 8004ae1..4c453d7 100644 --- a/go.mod +++ b/go.mod @@ -1,64 +1,74 @@ module github.com/epilot-dev/terraform-provider-epilot-workflow -go 1.21 - -toolchain go1.21.6 +go 1.22.0 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.13.0 - github.com/hashicorp/terraform-plugin-framework v1.7.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 - github.com/hashicorp/terraform-plugin-go v0.22.1 + github.com/hashicorp/terraform-plugin-docs v0.19.4 + github.com/hashicorp/terraform-plugin-framework v1.12.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 + github.com/hashicorp/terraform-plugin-go v0.24.0 ) require ( + github.com/BurntSushi/toml v1.2.1 // indirect + github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Masterminds/sprig/v3 v3.2.2 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/Masterminds/semver/v3 v3.2.0 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/fatih/color v1.13.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect + github.com/cloudflare/circl v1.3.7 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/cli v1.1.6 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect 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.0 // indirect + github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/terraform-exec v0.17.2 // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/hc-install v0.7.0 // indirect + github.com/hashicorp/terraform-exec v0.21.0 // indirect + github.com/hashicorp/terraform-json v0.22.1 // indirect github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect - github.com/huandu/xstrings v1.3.2 // indirect - github.com/imdario/mergo v0.3.13 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mitchellh/cli v1.1.4 // indirect + github.com/huandu/xstrings v1.3.3 // indirect + github.com/imdario/mergo v0.3.15 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect - github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.13.1 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/grpc v1.62.1 // indirect - google.golang.org/protobuf v1.33.0 // indirect + github.com/yuin/goldmark v1.7.1 // indirect + 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/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 + 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 417aa41..f9e8505 100644 --- a/go.sum +++ b/go.sum @@ -1,71 +1,64 @@ -github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0= +github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI= -github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= -github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= -github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= +github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= -github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= -github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8= +github.com/hashicorp/cli v1.1.6/go.mod h1:MPon5QYlgjjo0BSoAiN0ESeT5fRzDjVRp+uioJ0piz4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -79,28 +72,27 @@ 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.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= -github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +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-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= -github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= -github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= -github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go= -github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8= -github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= -github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= -github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= -github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= -github.com/hashicorp/terraform-plugin-framework v1.7.0 h1:wOULbVmfONnJo9iq7/q+iBOBJul5vRovaYJIu2cY/Pw= -github.com/hashicorp/terraform-plugin-framework v1.7.0/go.mod h1:jY9Id+3KbZ17OMpulgnWLSfwxNVYSoYBQFTgsx044CI= -github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8esP6OcvocVymw52lY0HyQ5OxB7VNl7k4bS0= -github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE= -github.com/hashicorp/terraform-plugin-go v0.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w= -github.com/hashicorp/terraform-plugin-go v0.22.1/go.mod h1:qrjnqRghvQ6KnDbB12XeZ4FluclYwptntoWCr9QaXTI= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= +github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= +github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= +github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= +github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= +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-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-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= @@ -109,166 +101,144 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= +github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA= -github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= -github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= -github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= -github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc= -github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= +github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= +go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +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/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= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +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/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/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= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +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/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= +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/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/planmodifiers/boolplanmodifier/suppress_diff.go b/internal/planmodifiers/boolplanmodifier/suppress_diff.go index ab17812..22f8c32 100644 --- a/internal/planmodifiers/boolplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package boolplanmodifier diff --git a/internal/planmodifiers/float64planmodifier/suppress_diff.go b/internal/planmodifiers/float64planmodifier/suppress_diff.go index 1c99fab..f049e10 100644 --- a/internal/planmodifiers/float64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/float64planmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package float64planmodifier diff --git a/internal/planmodifiers/int64planmodifier/suppress_diff.go b/internal/planmodifiers/int64planmodifier/suppress_diff.go index bf5c5b6..19b0793 100644 --- a/internal/planmodifiers/int64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/int64planmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package int64planmodifier diff --git a/internal/planmodifiers/listplanmodifier/suppress_diff.go b/internal/planmodifiers/listplanmodifier/suppress_diff.go index d16d6c3..b556b87 100644 --- a/internal/planmodifiers/listplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/listplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package listplanmodifier diff --git a/internal/planmodifiers/mapplanmodifier/suppress_diff.go b/internal/planmodifiers/mapplanmodifier/suppress_diff.go index 28d40f7..983b45f 100644 --- a/internal/planmodifiers/mapplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/mapplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package mapplanmodifier diff --git a/internal/planmodifiers/numberplanmodifier/suppress_diff.go b/internal/planmodifiers/numberplanmodifier/suppress_diff.go index 108e998..8c9933e 100644 --- a/internal/planmodifiers/numberplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/numberplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package numberplanmodifier diff --git a/internal/planmodifiers/objectplanmodifier/suppress_diff.go b/internal/planmodifiers/objectplanmodifier/suppress_diff.go index 88e16e6..7f0dc4d 100644 --- a/internal/planmodifiers/objectplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/objectplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package objectplanmodifier diff --git a/internal/planmodifiers/setplanmodifier/suppress_diff.go b/internal/planmodifiers/setplanmodifier/suppress_diff.go index 10a391a..3a6e9ca 100644 --- a/internal/planmodifiers/setplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/setplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package setplanmodifier diff --git a/internal/planmodifiers/stringplanmodifier/suppress_diff.go b/internal/planmodifiers/stringplanmodifier/suppress_diff.go index 94ab6a7..e43cb43 100644 --- a/internal/planmodifiers/stringplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/stringplanmodifier/suppress_diff.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package stringplanmodifier diff --git a/internal/planmodifiers/utils/state_check.go b/internal/planmodifiers/utils/state_check.go index 6b126bf..51d5362 100644 --- a/internal/planmodifiers/utils/state_check.go +++ b/internal/planmodifiers/utils/state_check.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/provider/closingreason_data_source.go b/internal/provider/closingreason_data_source.go index 0324a9f..2848b52 100644 --- a/internal/provider/closingreason_data_source.go +++ b/internal/provider/closingreason_data_source.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -56,8 +56,7 @@ func (r *ClosingReasonDataSource) Schema(ctx context.Context, req datasource.Sch Computed: true, }, "status": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["ACTIVE", "INACTIVE"]`, + Computed: true, }, "title": schema.StringAttribute{ Computed: true, @@ -104,7 +103,9 @@ func (r *ClosingReasonDataSource) Read(ctx context.Context, req datasource.ReadR return } - reasonID := data.ID.ValueString() + var reasonID string + reasonID = data.ID.ValueString() + request := operations.GetClosingReasonRequest{ ReasonID: reasonID, } diff --git a/internal/provider/closingreason_data_source_sdk.go b/internal/provider/closingreason_data_source_sdk.go index bb62dec..500ba02 100644 --- a/internal/provider/closingreason_data_source_sdk.go +++ b/internal/provider/closingreason_data_source_sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider diff --git a/internal/provider/closingreason_resource.go b/internal/provider/closingreason_resource.go index 8e1eb73..5414771 100644 --- a/internal/provider/closingreason_resource.go +++ b/internal/provider/closingreason_resource.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -51,38 +51,38 @@ 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), }, - Optional: true, - Description: `Requires replacement if changed. `, + Description: `Requires replacement if changed.`, }, "id": schema.StringAttribute{ Computed: true, + Optional: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplaceIfConfigured(), speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Optional: true, - Description: `Requires replacement if changed. `, + 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), }, - Optional: true, - Description: `Requires replacement if changed. `, + Description: `Requires replacement if changed.`, }, "status": schema.StringAttribute{ + Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplaceIfConfigured(), speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, - Description: `Requires replacement if changed. ; must be one of ["ACTIVE", "INACTIVE"]`, + Description: `must be one of ["ACTIVE", "INACTIVE"]; Requires replacement if changed.`, Validators: []validator.String{ stringvalidator.OneOf( "ACTIVE", @@ -91,12 +91,12 @@ 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), }, - Required: true, - Description: `Requires replacement if changed. `, + Description: `Requires replacement if changed.`, }, }, } @@ -186,7 +186,9 @@ func (r *ClosingReasonResource) Read(ctx context.Context, req resource.ReadReque return } - reasonID := data.ID.ValueString() + var reasonID string + reasonID = data.ID.ValueString() + request := operations.GetClosingReasonRequest{ ReasonID: reasonID, } diff --git a/internal/provider/closingreason_resource_sdk.go b/internal/provider/closingreason_resource_sdk.go index 4e40548..7695555 100644 --- a/internal/provider/closingreason_resource_sdk.go +++ b/internal/provider/closingreason_resource_sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -27,7 +27,9 @@ func (r *ClosingReasonResourceModel) ToSharedClosingReason() *shared.ClosingReas lastUpdateTime = nil } status := shared.ClosingReasonsStatus(r.Status.ValueString()) - title := r.Title.ValueString() + var title string + title = r.Title.ValueString() + out := shared.ClosingReason{ CreationTime: creationTime, ID: id, diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 076f8fb..b968962 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -36,8 +36,7 @@ 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{ - MarkdownDescription: `Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization` + "\n" + - ``, + Description: `Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization`, Attributes: map[string]schema.Attribute{ "server_url": schema.StringAttribute{ MarkdownDescription: "Server URL (defaults to https://workflows-definition.sls.epilot.io)", @@ -45,8 +44,8 @@ func (p *EpilotWorkflowProvider) Schema(ctx context.Context, req provider.Schema Required: false, }, "bearer_auth": schema.StringAttribute{ - Optional: true, Sensitive: true, + Optional: true, }, }, } @@ -67,7 +66,12 @@ func (p *EpilotWorkflowProvider) Configure(ctx context.Context, req provider.Con ServerURL = "https://workflows-definition.sls.epilot.io" } - bearerAuth := data.BearerAuth.ValueString() + bearerAuth := new(string) + if !data.BearerAuth.IsUnknown() && !data.BearerAuth.IsNull() { + *bearerAuth = data.BearerAuth.ValueString() + } else { + bearerAuth = nil + } security := shared.Security{ BearerAuth: bearerAuth, } diff --git a/internal/provider/reflect/diags.go b/internal/provider/reflect/diags.go index ce8aa51..50c50c8 100644 --- a/internal/provider/reflect/diags.go +++ b/internal/provider/reflect/diags.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/doc.go b/internal/provider/reflect/doc.go index 2978edc..e384126 100644 --- a/internal/provider/reflect/doc.go +++ b/internal/provider/reflect/doc.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. // Package reflect is a forked version of https://github.com/hashicorp/terraform-plugin-framework/tree/main/internal/reflect // that has been modified to support speakeasy's terraform generator. diff --git a/internal/provider/reflect/generic_attr_value.go b/internal/provider/reflect/generic_attr_value.go index 39454f5..48824d5 100644 --- a/internal/provider/reflect/generic_attr_value.go +++ b/internal/provider/reflect/generic_attr_value.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/helpers.go b/internal/provider/reflect/helpers.go index 398049d..b17719d 100644 --- a/internal/provider/reflect/helpers.go +++ b/internal/provider/reflect/helpers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/interfaces.go b/internal/provider/reflect/interfaces.go index f5bd513..ff4416e 100644 --- a/internal/provider/reflect/interfaces.go +++ b/internal/provider/reflect/interfaces.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -73,18 +73,38 @@ func FromUnknownable(ctx context.Context, typ attr.Type, val Unknownable, path p if val.GetUnknown(ctx) { tfVal := tftypes.NewValue(typ.TerraformType(ctx), tftypes.UnknownValue) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + res, err := typ.ValueFromTerraform(ctx, tfVal) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := res.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - res, err := typ.ValueFromTerraform(ctx, tfVal) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } + return res, nil } err := tftypes.ValidateValue(typ.TerraformType(ctx), val.GetValue(ctx)) @@ -94,18 +114,38 @@ func FromUnknownable(ctx context.Context, typ attr.Type, val Unknownable, path p tfVal := tftypes.NewValue(typ.TerraformType(ctx), val.GetValue(ctx)) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + res, err := typ.ValueFromTerraform(ctx, tfVal) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := res.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - res, err := typ.ValueFromTerraform(ctx, tfVal) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } + return res, nil } @@ -167,18 +207,38 @@ func FromNullable(ctx context.Context, typ attr.Type, val Nullable, path path.Pa if val.GetNull(ctx) { tfVal := tftypes.NewValue(typ.TerraformType(ctx), nil) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + res, err := typ.ValueFromTerraform(ctx, tfVal) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := res.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - res, err := typ.ValueFromTerraform(ctx, tfVal) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } + return res, nil } err := tftypes.ValidateValue(typ.TerraformType(ctx), val.GetValue(ctx)) @@ -188,18 +248,38 @@ func FromNullable(ctx context.Context, typ attr.Type, val Nullable, path path.Pa tfVal := tftypes.NewValue(typ.TerraformType(ctx), val.GetValue(ctx)) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + res, err := typ.ValueFromTerraform(ctx, tfVal) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := res.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - res, err := typ.ValueFromTerraform(ctx, tfVal) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } + return res, diags } @@ -259,18 +339,38 @@ func FromValueCreator(ctx context.Context, typ attr.Type, val tftypes.ValueCreat } tfVal := tftypes.NewValue(typ.TerraformType(ctx), raw) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + res, err := typ.ValueFromTerraform(ctx, tfVal) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := res.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - res, err := typ.ValueFromTerraform(ctx, tfVal) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } + return res, diags } @@ -282,18 +382,38 @@ func FromValueCreator(ctx context.Context, typ attr.Type, val tftypes.ValueCreat func NewAttributeValue(ctx context.Context, typ attr.Type, val tftypes.Value, target reflect.Value, opts Options, path path.Path) (reflect.Value, diag.Diagnostics) { var diags diag.Diagnostics - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, val, path)...) + res, err := typ.ValueFromTerraform(ctx, val) + if err != nil { + return target, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := res.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return target, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, val, path)...) - res, err := typ.ValueFromTerraform(ctx, val) - if err != nil { - return target, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return target, diags + } + } } + if reflect.TypeOf(res) != target.Type() { diags.Append(diag.WithPath(path, DiagNewAttributeValueIntoWrongType{ ValType: reflect.TypeOf(res), @@ -336,17 +456,36 @@ func FromAttributeValue(ctx context.Context, typ attr.Type, val attr.Value, path return nil, diags } - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - tfVal, err := val.ToTerraformValue(ctx) - if err != nil { - return val, append(diags, toTerraformValueErrorDiag(err, path)) - } + switch t := val.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return val, diags } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + tfVal, err := val.ToTerraformValue(ctx) + if err != nil { + return val, append(diags, toTerraformValueErrorDiag(err, path)) + } + + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + + if diags.HasError() { + return val, diags + } + } } return val, diags diff --git a/internal/provider/reflect/into.go b/internal/provider/reflect/into.go index 45b15ef..29a437f 100644 --- a/internal/provider/reflect/into.go +++ b/internal/provider/reflect/into.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -166,6 +166,20 @@ func BuildValue(ctx context.Context, typ attr.Type, val tftypes.Value, target re return target, diags } + + // Dynamic reflection is currently only supported using an `attr.Value`, which should have happened in logic above. + if typ.TerraformType(ctx).Is(tftypes.DynamicPseudoType) { + diags.AddAttributeError( + path, + "Value Conversion Error", + "An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+ + "Reflection for dynamic types is currently not supported. Use the corresponding `types` package type or a custom type that handles dynamic values.\n\n"+ + fmt.Sprintf("Path: %s\nTarget Type: %s\nSuggested `types` Type: %s", path.String(), target.Type(), reflect.TypeOf(typ.ValueType(ctx))), + ) + + return target, diags + } + // *big.Float and *big.Int are technically pointers, but we want them // handled as numbers if target.Type() == reflect.TypeOf(big.NewFloat(0)) || target.Type() == reflect.TypeOf(big.NewInt(0)) { diff --git a/internal/provider/reflect/map.go b/internal/provider/reflect/map.go index affbabe..91e27a6 100644 --- a/internal/provider/reflect/map.go +++ b/internal/provider/reflect/map.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -102,14 +102,6 @@ func FromMap(ctx context.Context, typ attr.TypeWithElementType, val reflect.Valu if val.IsNil() { tfVal := tftypes.NewValue(tfType, nil) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - - if diags.HasError() { - return nil, diags - } - } - attrVal, err := typ.ValueFromTerraform(ctx, tfVal) if err != nil { @@ -121,6 +113,33 @@ func FromMap(ctx context.Context, typ attr.TypeWithElementType, val reflect.Valu return nil, diags } + switch t := attrVal.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + + if diags.HasError() { + return nil, diags + } + } + } + return attrVal, diags } @@ -136,23 +155,50 @@ func FromMap(ctx context.Context, typ attr.TypeWithElementType, val reflect.Valu ) return nil, diags } - val, valDiags := FromValue(ctx, elemType, val.MapIndex(key).Interface(), path.AtMapKey(key.String())) + + mapKeyPath := path.AtMapKey(key.String()) + + // If the element implements xattr.ValidateableAttribute, or xattr.TypeWithValidate, + // and the element does not validate then diagnostics will be added here and returned + // before reaching the switch statement below. + val, valDiags := FromValue(ctx, elemType, val.MapIndex(key).Interface(), mapKeyPath) + diags.Append(valDiags...) if diags.HasError() { return nil, diags } + tfVal, err := val.ToTerraformValue(ctx) if err != nil { return nil, append(diags, toTerraformValueErrorDiag(err, path)) } - if typeWithValidate, ok := elemType.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path.AtMapKey(key.String()))...) + switch t := val.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: mapKeyPath, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := elemType.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, mapKeyPath)...) + + if diags.HasError() { + return nil, diags + } + } } tfElems[key.String()] = tfVal @@ -165,14 +211,6 @@ func FromMap(ctx context.Context, typ attr.TypeWithElementType, val reflect.Valu tfVal := tftypes.NewValue(tfType, tfElems) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - - if diags.HasError() { - return nil, diags - } - } - attrVal, err := typ.ValueFromTerraform(ctx, tfVal) if err != nil { @@ -184,5 +222,32 @@ func FromMap(ctx context.Context, typ attr.TypeWithElementType, val reflect.Valu return nil, diags } + switch t := attrVal.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + + if diags.HasError() { + return nil, diags + } + } + } + return attrVal, diags } diff --git a/internal/provider/reflect/number.go b/internal/provider/reflect/number.go index e0021c3..53673b8 100644 --- a/internal/provider/reflect/number.go +++ b/internal/provider/reflect/number.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -23,9 +23,7 @@ import ( // *big.Int). // // Number will loudly fail when a number cannot be losslessly represented using -// the requested type, unless opts.AllowRoundingNumbers is set to true. This -// setting is mildly dangerous, because Terraform does not like when you round -// things, as a general rule of thumb. +// the requested type. // // It is meant to be called through Into, not directly. func Number(ctx context.Context, typ attr.Type, val tftypes.Value, target reflect.Value, opts Options, path path.Path) (reflect.Value, diag.Diagnostics) { @@ -52,7 +50,7 @@ func Number(ctx context.Context, typ attr.Type, val tftypes.Value, target reflec return reflect.ValueOf(result), diags case reflect.TypeOf(big.NewInt(0)): intResult, acc := result.Int(nil) - if acc != big.Exact && !opts.AllowRoundingNumbers { + if acc != big.Exact { return reflect.ValueOf(result), append(diags, roundingErrorDiag) } return reflect.ValueOf(intResult), diags @@ -61,64 +59,40 @@ func Number(ctx context.Context, typ attr.Type, val tftypes.Value, target reflec case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: intResult, acc := result.Int64() - if acc != big.Exact && !opts.AllowRoundingNumbers { + if acc != big.Exact { return target, append(diags, roundingErrorDiag) } switch target.Kind() { case reflect.Int: if strconv.IntSize == 32 && intResult > math.MaxInt32 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MaxInt32 + return target, append(diags, roundingErrorDiag) } if strconv.IntSize == 32 && intResult < math.MinInt32 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MinInt32 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(int(intResult)), diags case reflect.Int8: if intResult > math.MaxInt8 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MaxInt8 + return target, append(diags, roundingErrorDiag) } if intResult < math.MinInt8 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MinInt8 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(int8(intResult)), diags case reflect.Int16: if intResult > math.MaxInt16 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MaxInt16 + return target, append(diags, roundingErrorDiag) } if intResult < math.MinInt16 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MinInt16 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(int16(intResult)), diags case reflect.Int32: if intResult > math.MaxInt32 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MaxInt32 + return target, append(diags, roundingErrorDiag) } if intResult < math.MinInt32 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - intResult = math.MinInt32 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(int32(intResult)), diags case reflect.Int64: @@ -127,105 +101,74 @@ func Number(ctx context.Context, typ attr.Type, val tftypes.Value, target reflec case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: uintResult, acc := result.Uint64() - if acc != big.Exact && !opts.AllowRoundingNumbers { + if acc != big.Exact { return target, append(diags, roundingErrorDiag) } switch target.Kind() { case reflect.Uint: if strconv.IntSize == 32 && uintResult > math.MaxUint32 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - uintResult = math.MaxUint32 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(uint(uintResult)), diags case reflect.Uint8: if uintResult > math.MaxUint8 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - uintResult = math.MaxUint8 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(uint8(uintResult)), diags case reflect.Uint16: if uintResult > math.MaxUint16 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - uintResult = math.MaxUint16 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(uint16(uintResult)), diags case reflect.Uint32: if uintResult > math.MaxUint32 { - if !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } - uintResult = math.MaxUint32 + return target, append(diags, roundingErrorDiag) } return reflect.ValueOf(uint32(uintResult)), diags case reflect.Uint64: return reflect.ValueOf(uintResult), diags } case reflect.Float32: - floatResult, acc := result.Float32() - if acc != big.Exact && !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) - } else if acc == big.Above { - floatResult = math.MaxFloat32 - } else if acc == big.Below { - floatResult = math.SmallestNonzeroFloat32 - } else if acc != big.Exact { - err := fmt.Errorf("unsure how to round %s and %f", acc, floatResult) - diags.AddAttributeError( - path, - "Value Conversion Error", - "An unexpected error was encountered trying to convert to number. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), - ) + float64Result, _ := result.Float64() + + bf := big.NewFloat(float64Result) + + if result.Text('f', -1) != bf.Text('f', -1) { + diags.Append(roundingErrorDiag) + return target, diags } - return reflect.ValueOf(floatResult), diags - case reflect.Float64: - floatResult, acc := result.Float64() - if acc != big.Exact && !opts.AllowRoundingNumbers { - return target, append(diags, roundingErrorDiag) + + float32Result, accuracy := result.Float32() + + // Underflow + // Reference: https://pkg.go.dev/math/big#Float.Float32 + if float32Result == 0 && accuracy != big.Exact { + diags.Append(roundingErrorDiag) + + return target, diags } - if acc == big.Above { - if floatResult == math.Inf(1) || floatResult == math.MaxFloat64 { - floatResult = math.MaxFloat64 - } else if floatResult == 0.0 || floatResult == math.SmallestNonzeroFloat64 { - floatResult = -math.SmallestNonzeroFloat64 - } else { - err := fmt.Errorf("not sure how to round %s and %f", acc, floatResult) - diags.AddAttributeError( - path, - "Value Conversion Error", - "An unexpected error was encountered trying to convert to number. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), - ) - return target, diags - } - } else if acc == big.Below { - if floatResult == math.Inf(-1) || floatResult == -math.MaxFloat64 { - floatResult = -math.MaxFloat64 - } else if floatResult == 0.0 || floatResult == -math.SmallestNonzeroFloat64 { - floatResult = math.SmallestNonzeroFloat64 - } else { - err := fmt.Errorf("not sure how to round %s and %f", acc, floatResult) - diags.AddAttributeError( - path, - "Value Conversion Error", - "An unexpected error was encountered trying to convert to number. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), - ) - return target, diags - } - } else if acc != big.Exact { - err := fmt.Errorf("not sure how to round %s and %f", acc, floatResult) - diags.AddAttributeError( - path, - "Value Conversion Error", - "An unexpected error was encountered trying to convert to number. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), - ) + + // Overflow + // Reference: https://pkg.go.dev/math/big#Float.Float32 + if math.IsInf(float64(float32Result), 0) { + diags.Append(roundingErrorDiag) + + return target, diags + } + + return reflect.ValueOf(float32Result), diags + case reflect.Float64: + floatResult, _ := result.Float64() + + bf := big.NewFloat(floatResult) + + if result.Text('f', -1) != bf.Text('f', -1) { + diags.Append(roundingErrorDiag) + return target, diags } + return reflect.ValueOf(floatResult), diags } err = fmt.Errorf("cannot convert number to %s", target.Type()) @@ -248,17 +191,36 @@ func FromInt(ctx context.Context, typ attr.Type, val int64, path path.Path) (att } tfNum := tftypes.NewValue(tftypes.Number, val) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) + num, err := typ.ValueFromTerraform(ctx, tfNum) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := num.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) - num, err := typ.ValueFromTerraform(ctx, tfNum) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return num, diags @@ -275,17 +237,36 @@ func FromUint(ctx context.Context, typ attr.Type, val uint64, path path.Path) (a } tfNum := tftypes.NewValue(tftypes.Number, val) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) + num, err := typ.ValueFromTerraform(ctx, tfNum) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := num.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) - num, err := typ.ValueFromTerraform(ctx, tfNum) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return num, diags @@ -302,17 +283,36 @@ func FromFloat(ctx context.Context, typ attr.Type, val float64, path path.Path) } tfNum := tftypes.NewValue(tftypes.Number, val) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) + num, err := typ.ValueFromTerraform(ctx, tfNum) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := num.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) - num, err := typ.ValueFromTerraform(ctx, tfNum) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return num, diags @@ -329,17 +329,36 @@ func FromBigFloat(ctx context.Context, typ attr.Type, val *big.Float, path path. } tfNum := tftypes.NewValue(tftypes.Number, val) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) + num, err := typ.ValueFromTerraform(ctx, tfNum) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := num.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) - num, err := typ.ValueFromTerraform(ctx, tfNum) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return num, diags @@ -357,17 +376,36 @@ func FromBigInt(ctx context.Context, typ attr.Type, val *big.Int, path path.Path } tfNum := tftypes.NewValue(tftypes.Number, fl) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) + num, err := typ.ValueFromTerraform(ctx, tfNum) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := num.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfNum, path)...) - num, err := typ.ValueFromTerraform(ctx, tfNum) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return num, diags diff --git a/internal/provider/reflect/options.go b/internal/provider/reflect/options.go index c6d7b44..063353f 100644 --- a/internal/provider/reflect/options.go +++ b/internal/provider/reflect/options.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -20,10 +20,6 @@ type Options struct { // they must be explicitly handled. UnhandledUnknownAsEmpty bool - // AllowRoundingNumbers silently rounds numbers that don't fit - // perfectly in the types they're being stored in, rather than - // returning errors. Numbers will always be rounded towards 0. - AllowRoundingNumbers bool // SourceType informs the reflection system what the source is // such that it can make decisions based on the tfPlanOnly annotation // The default is SourceTypeState diff --git a/internal/provider/reflect/outof.go b/internal/provider/reflect/outof.go index 4fc5d24..215406a 100644 --- a/internal/provider/reflect/outof.go +++ b/internal/provider/reflect/outof.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/pointer.go b/internal/provider/reflect/pointer.go index 0ac5ebb..215653e 100644 --- a/internal/provider/reflect/pointer.go +++ b/internal/provider/reflect/pointer.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -97,14 +97,6 @@ func FromPointer(ctx context.Context, typ attr.Type, value reflect.Value, path p if value.IsNil() { tfVal := tftypes.NewValue(typ.TerraformType(ctx), nil) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - - if diags.HasError() { - return nil, diags - } - } - attrVal, err := typ.ValueFromTerraform(ctx, tfVal) if err != nil { @@ -116,6 +108,33 @@ func FromPointer(ctx context.Context, typ attr.Type, value reflect.Value, path p return nil, diags } + switch t := attrVal.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + + if diags.HasError() { + return nil, diags + } + } + } + return attrVal, diags } diff --git a/internal/provider/reflect/primitive.go b/internal/provider/reflect/primitive.go index fc6b0e6..adf648e 100644 --- a/internal/provider/reflect/primitive.go +++ b/internal/provider/reflect/primitive.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -67,17 +67,36 @@ func FromString(ctx context.Context, typ attr.Type, val string, path path.Path) } tfStr := tftypes.NewValue(tftypes.String, val) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfStr, path)...) + str, err := typ.ValueFromTerraform(ctx, tfStr) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := str.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfStr, path)...) - str, err := typ.ValueFromTerraform(ctx, tfStr) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return str, diags @@ -94,17 +113,36 @@ func FromBool(ctx context.Context, typ attr.Type, val bool, path path.Path) (att } tfBool := tftypes.NewValue(tftypes.Bool, val) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfBool, path)...) + b, err := typ.ValueFromTerraform(ctx, tfBool) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := b.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfBool, path)...) - b, err := typ.ValueFromTerraform(ctx, tfBool) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return b, diags diff --git a/internal/provider/reflect/slice.go b/internal/provider/reflect/slice.go index 7eea860..79ad6b8 100644 --- a/internal/provider/reflect/slice.go +++ b/internal/provider/reflect/slice.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -28,16 +28,6 @@ func reflectSlice(ctx context.Context, typ attr.Type, val tftypes.Value, target })) return target, diags } - // TODO: check that the val is a list or set or tuple - elemTyper, ok := typ.(attr.TypeWithElementType) - if !ok { - diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ - Val: val, - TargetType: target.Type(), - Err: fmt.Errorf("cannot reflect %s using type information provided by %T, %T must be an attr.TypeWithElementType", val.Type(), typ, typ), - })) - return target, diags - } // we need our value to become a list of values so we can iterate over // them and handle them individually @@ -52,50 +42,130 @@ func reflectSlice(ctx context.Context, typ attr.Type, val tftypes.Value, target return target, diags } - // we need to know the type the slice is wrapping - elemType := target.Type().Elem() - elemAttrType := elemTyper.ElementType() + switch t := typ.(type) { + // List or Set + case attr.TypeWithElementType: + // we need to know the type the slice is wrapping + elemType := target.Type().Elem() + elemAttrType := t.ElementType() + + // we want an empty version of the slice + slice := reflect.MakeSlice(target.Type(), 0, len(values)) + + // go over each of the values passed in, create a Go value of the right + // type for them, and add it to our new slice + for pos, value := range values { + // create a new Go value of the type that can go in the slice + targetValue := reflect.Zero(elemType) + + // update our path so we can have nice errors + valPath := path.AtListIndex(pos) + + if typ.TerraformType(ctx).Is(tftypes.Set{}) { + attrVal, err := elemAttrType.ValueFromTerraform(ctx, value) + + if err != nil { + diags.AddAttributeError( + path, + "Value Conversion Error", + "An unexpected error was encountered trying to convert to slice value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), + ) + return target, diags + } + + valPath = path.AtSetValue(attrVal) + } - // we want an empty version of the slice - slice := reflect.MakeSlice(target.Type(), 0, len(values)) + // reflect the value into our new target + val, valDiags := BuildValue(ctx, elemAttrType, value, targetValue, opts, valPath) + diags.Append(valDiags...) - // go over each of the values passed in, create a Go value of the right - // type for them, and add it to our new slice - for pos, value := range values { - // create a new Go value of the type that can go in the slice - targetValue := reflect.Zero(elemType) + if diags.HasError() { + return target, diags + } - // update our path so we can have nice errors - valPath := path.AtListIndex(pos) + // add the new target to our slice + slice = reflect.Append(slice, val) + } - if typ.TerraformType(ctx).Is(tftypes.Set{}) { - attrVal, err := elemAttrType.ValueFromTerraform(ctx, value) + return slice, diags - if err != nil { - diags.AddAttributeError( - path, - "Value Conversion Error", - "An unexpected error was encountered trying to convert to slice value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), - ) - return target, diags + // Tuple reflection into slices is currently limited to use-cases where all tuple element types are the same. + // + // Overall, Tuple support is limited in the framework, but the main path that executes tuple reflection is the provider-defined function variadic + // parameter. All tuple elements in this variadic parameter will have the same element type. For use-cases where the variadic parameter is a dynamic type, + // all elements will have the same type of `DynamicType` and value of `DynamicValue`, with an underlying value that may be different. + case attr.TypeWithElementTypes: + // we need to know the type the slice is wrapping + elemType := target.Type().Elem() + + // we want an empty version of the slice + slice := reflect.MakeSlice(target.Type(), 0, len(values)) + + if len(t.ElementTypes()) <= 0 { + // If the tuple values are empty as well, we can just pass back an empty slice of the type we received. + if len(values) == 0 { + return slice, diags } - valPath = path.AtSetValue(attrVal) + diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ + Val: val, + TargetType: target.Type(), + Err: fmt.Errorf("cannot reflect %s using type information provided by %T, tuple type contained no element types but received values", val.Type(), t), + })) + return target, diags } - // reflect the value into our new target - val, valDiags := BuildValue(ctx, elemAttrType, value, targetValue, opts, valPath) - diags.Append(valDiags...) + // Ensure that all tuple element types are the same by comparing each element type to the first + multipleTypes := false + allElemTypes := t.ElementTypes() + elemAttrType := allElemTypes[0] + for _, elemType := range allElemTypes[1:] { + if !elemAttrType.Equal(elemType) { + multipleTypes = true + break + } + } - if diags.HasError() { + if multipleTypes { + diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ + Val: val, + TargetType: target.Type(), + Err: fmt.Errorf("cannot reflect %s using type information provided by %T, reflection support for tuples is limited to multiple elements of the same element type. Expected all element types to be %T", val.Type(), t, elemAttrType), + })) return target, diags } - // add the new target to our slice - slice = reflect.Append(slice, val) - } + // go over each of the values passed in, create a Go value of the right + // type for them, and add it to our new slice + for pos, value := range values { + // create a new Go value of the type that can go in the slice + targetValue := reflect.Zero(elemType) + + // update our path so we can have nice errors + valPath := path.AtTupleIndex(pos) - return slice, diags + // reflect the value into our new target + val, valDiags := BuildValue(ctx, elemAttrType, value, targetValue, opts, valPath) + diags.Append(valDiags...) + + if diags.HasError() { + return target, diags + } + + // add the new target to our slice + slice = reflect.Append(slice, val) + } + + return slice, diags + default: + diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ + Val: val, + TargetType: target.Type(), + Err: fmt.Errorf("cannot reflect %s using type information provided by %T, %T must be an attr.TypeWithElementType or attr.TypeWithElementTypes", val.Type(), typ, typ), + })) + return target, diags + } } // FromSlice returns an attr.Value as produced by `typ` using the data in @@ -115,14 +185,6 @@ func FromSlice(ctx context.Context, typ attr.Type, val reflect.Value, path path. if val.IsNil() { tfVal := tftypes.NewValue(tfType, nil) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - - if diags.HasError() { - return nil, diags - } - } - attrVal, err := typ.ValueFromTerraform(ctx, tfVal) if err != nil { @@ -134,54 +196,195 @@ func FromSlice(ctx context.Context, typ attr.Type, val reflect.Value, path path. return nil, diags } - return attrVal, diags - } + switch t := attrVal.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} - t, ok := typ.(attr.TypeWithElementType) - if !ok { - err := fmt.Errorf("cannot use type %T as schema type %T; %T must be an attr.TypeWithElementType to hold %T", val, typ, typ, val) - diags.AddAttributeError( - path, - "Value Conversion Error", - "An unexpected error was encountered trying to convert from slice value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), - ) - return nil, diags + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + + if diags.HasError() { + return nil, diags + } + } + } + + return attrVal, diags } - elemType := t.ElementType() tfElems := make([]tftypes.Value, 0, val.Len()) - for i := 0; i < val.Len(); i++ { - // The underlying reflect.Slice is fetched by Index(). For set types, - // the path is value-based instead of index-based. Since there is only - // the index until the value is retrieved, this will pass the - // technically incorrect index-based path at first for framework - // debugging purposes, then correct the path afterwards. - valPath := path.AtListIndex(i) + switch t := typ.(type) { + // List or Set + case attr.TypeWithElementType: + elemType := t.ElementType() + for i := 0; i < val.Len(); i++ { + // The underlying reflect.Slice is fetched by Index(). For set types, + // the path is value-based instead of index-based. Since there is only + // the index until the value is retrieved, this will pass the + // technically incorrect index-based path at first for framework + // debugging purposes, then correct the path afterwards. + valPath := path.AtListIndex(i) + + // If the element implements xattr.ValidateableAttribute, or xattr.TypeWithValidate, + // and the element does not validate then diagnostics will be added here and returned + // before reaching the switch statement below. + val, valDiags := FromValue(ctx, elemType, val.Index(i).Interface(), valPath) + diags.Append(valDiags...) + + if diags.HasError() { + return nil, diags + } - val, valDiags := FromValue(ctx, elemType, val.Index(i).Interface(), valPath) - diags.Append(valDiags...) + tfVal, err := val.ToTerraformValue(ctx) + if err != nil { + return nil, append(diags, toTerraformValueErrorDiag(err, path)) + } - if diags.HasError() { + if tfType.Is(tftypes.Set{}) { + valPath = path.AtSetValue(val) + } + + switch t := val.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: valPath, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := elemType.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, valPath)...) + + if diags.HasError() { + return nil, diags + } + } + } + + tfElems = append(tfElems, tfVal) + } + + // Tuple reflection from slices is currently limited to use-cases where all tuple element types are the same. + // + // Overall, Tuple support is limited in the framework, but the main path that executes tuple reflection is the provider-defined function variadic + // parameter. All tuple elements in this variadic parameter will have the same element type. For use-cases where the variadic parameter is a dynamic type, + // all elements will have the same type of `DynamicType` and value of `DynamicValue`, with an underlying value that may be different. + case attr.TypeWithElementTypes: + if len(t.ElementTypes()) <= 0 { + // If the tuple values are empty as well, we can just pass back an empty slice of the type we received. + if val.Len() == 0 { + break + } + + err := fmt.Errorf("cannot use type %s as schema type %T; tuple type contained no element types but received values", val.Type(), t) + diags.AddAttributeError( + path, + "Value Conversion Error", + "An unexpected error was encountered trying to convert from slice value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), + ) return nil, diags } - tfVal, err := val.ToTerraformValue(ctx) - if err != nil { - return nil, append(diags, toTerraformValueErrorDiag(err, path)) + // Ensure that all tuple element types are the same by comparing each element type to the first + multipleTypes := false + allElemTypes := t.ElementTypes() + elemAttrType := allElemTypes[0] + for _, elemType := range allElemTypes[1:] { + if !elemAttrType.Equal(elemType) { + multipleTypes = true + break + } } - if tfType.Is(tftypes.Set{}) { - valPath = path.AtSetValue(val) + if multipleTypes { + err := fmt.Errorf("cannot use type %s as schema type %T; reflection support for tuples is limited to multiple elements of the same element type. Expected all element types to be %T", val.Type(), t, elemAttrType) + diags.AddAttributeError( + path, + "Value Conversion Error", + "An unexpected error was encountered trying to convert from slice value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), + ) + return nil, diags } - if typeWithValidate, ok := elemType.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, valPath)...) + for i := 0; i < val.Len(); i++ { + valPath := path.AtTupleIndex(i) + + // If the element implements xattr.ValidateableAttribute, or xattr.TypeWithValidate, + // and the element does not validate then diagnostics will be added here and returned + // before reaching the switch statement below. + val, valDiags := FromValue(ctx, elemAttrType, val.Index(i).Interface(), valPath) + diags.Append(valDiags...) + if diags.HasError() { return nil, diags } - } - tfElems = append(tfElems, tfVal) + tfVal, err := val.ToTerraformValue(ctx) + if err != nil { + return nil, append(diags, toTerraformValueErrorDiag(err, path)) + } + + switch t := val.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: valPath, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := elemAttrType.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, valPath)...) + + if diags.HasError() { + return nil, diags + } + } + } + + tfElems = append(tfElems, tfVal) + } + default: + err := fmt.Errorf("cannot use type %s as schema type %T; %T must be an attr.TypeWithElementType or attr.TypeWithElementTypes", val.Type(), t, t) + diags.AddAttributeError( + path, + "Value Conversion Error", + "An unexpected error was encountered trying to convert from slice value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), + ) + return nil, diags } err := tftypes.ValidateValue(tfType, tfElems) @@ -191,14 +394,6 @@ func FromSlice(ctx context.Context, typ attr.Type, val reflect.Value, path path. tfVal := tftypes.NewValue(tfType, tfElems) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - - if diags.HasError() { - return nil, diags - } - } - attrVal, err := typ.ValueFromTerraform(ctx, tfVal) if err != nil { @@ -210,5 +405,32 @@ func FromSlice(ctx context.Context, typ attr.Type, val reflect.Value, path path. return nil, diags } + switch t := attrVal.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) + + if diags.HasError() { + return nil, diags + } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + + if diags.HasError() { + return nil, diags + } + } + } + return attrVal, diags } diff --git a/internal/provider/reflect/struct.go b/internal/provider/reflect/struct.go index 01ceb7b..68ea994 100644 --- a/internal/provider/reflect/struct.go +++ b/internal/provider/reflect/struct.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package reflect @@ -229,6 +229,9 @@ func FromStruct(ctx context.Context, typ attr.TypeWithAttributeTypes, val reflec path := path.AtName(name) fieldValue := val.Field(fieldNo) + // If the attr implements xattr.ValidateableAttribute, or xattr.TypeWithValidate, + // and the attr does not validate then diagnostics will be added here and returned + // before reaching the switch statement below. attrVal, attrValDiags := FromValue(ctx, attrTypes[name], fieldValue.Interface(), path) diags.Append(attrValDiags...) @@ -241,33 +244,80 @@ func FromStruct(ctx context.Context, typ attr.TypeWithAttributeTypes, val reflec return nil, append(diags, toTerraformValueErrorDiag(err, path)) } - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfObjVal, path)...) + switch t := attrVal.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := attrTypes[name].(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfObjVal, path)...) + + if diags.HasError() { + return nil, diags + } + } + } + + tfObjTyp := tfObjVal.Type() + + // If the original attribute type is tftypes.DynamicPseudoType, the value could end up being + // a concrete type (like tftypes.String, tftypes.List, etc.). In this scenario, the type used + // to build the final tftypes.Object must stay as tftypes.DynamicPseudoType + if attrTypes[name].TerraformType(ctx).Is(tftypes.DynamicPseudoType) { + tfObjTyp = tftypes.DynamicPseudoType } objValues[name] = tfObjVal - objTypes[name] = tfObjVal.Type() + objTypes[name] = tfObjTyp } tfVal := tftypes.NewValue(tftypes.Object{ AttributeTypes: objTypes, }, objValues) - if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { - diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) + ret, err := typ.ValueFromTerraform(ctx, tfVal) + if err != nil { + return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + } + + switch t := ret.(type) { + case xattr.ValidateableAttribute: + resp := xattr.ValidateAttributeResponse{} + + t.ValidateAttribute(ctx, + xattr.ValidateAttributeRequest{ + Path: path, + }, + &resp, + ) + + diags.Append(resp.Diagnostics...) if diags.HasError() { return nil, diags } - } + default: + //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. + if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { + diags.Append(typeWithValidate.Validate(ctx, tfVal, path)...) - ret, err := typ.ValueFromTerraform(ctx, tfVal) - if err != nil { - return nil, append(diags, valueFromTerraformErrorDiag(err, path)) + if diags.HasError() { + return nil, diags + } + } } return ret, diags diff --git a/internal/provider/types/closing_reason_id.go b/internal/provider/types/closing_reason_id.go index 062c0f6..7206d40 100644 --- a/internal/provider/types/closing_reason_id.go +++ b/internal/provider/types/closing_reason_id.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/provider/types/dynamic_due_date.go b/internal/provider/types/dynamic_due_date.go index 9f9fc11..3527805 100644 --- a/internal/provider/types/dynamic_due_date.go +++ b/internal/provider/types/dynamic_due_date.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/provider/types/target.go b/internal/provider/types/target.go index a4a65fa..37b5b1d 100644 --- a/internal/provider/types/target.go +++ b/internal/provider/types/target.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/provider/types/update_entity_attributes.go b/internal/provider/types/update_entity_attributes.go index 89cf9a9..ce1cd99 100644 --- a/internal/provider/types/update_entity_attributes.go +++ b/internal/provider/types/update_entity_attributes.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 71fae09..e827fab 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider diff --git a/internal/provider/workflowdefinition_data_source.go b/internal/provider/workflowdefinition_data_source.go index 5ae43d8..6ac8b05 100644 --- a/internal/provider/workflowdefinition_data_source.go +++ b/internal/provider/workflowdefinition_data_source.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -36,10 +36,12 @@ type WorkflowDefinitionDataSourceModel struct { DueDate types.String `tfsdk:"due_date"` DynamicDueDate *tfTypes.DynamicDueDate `tfsdk:"dynamic_due_date"` EnableECPWorkflow types.Bool `tfsdk:"enable_ecp_workflow"` + Enabled types.Bool `tfsdk:"enabled"` Flow types.String `tfsdk:"flow"` ID types.String `tfsdk:"id"` LastUpdateTime types.String `tfsdk:"last_update_time"` Name types.String `tfsdk:"name"` + Taxonomies []types.String `tfsdk:"taxonomies"` UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` UserIds []types.Number `tfsdk:"user_ids"` } @@ -83,8 +85,7 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc Computed: true, Attributes: map[string]schema.Attribute{ "action_type_condition": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"]`, + Computed: true, }, "number_of_units": schema.NumberAttribute{ Computed: true, @@ -93,8 +94,7 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc Computed: true, }, "time_period": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["days", "weeks", "months"]`, + Computed: true, }, }, Description: `set a Duedate for a step then a specific`, @@ -103,6 +103,10 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc Computed: true, Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, }, + "enabled": schema.BoolAttribute{ + Computed: true, + Description: `Whether the workflow is enabled or not`, + }, "flow": schema.StringAttribute{ Computed: true, Description: `Parsed as JSON.`, @@ -117,13 +121,17 @@ func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasourc "name": schema.StringAttribute{ Computed: true, }, + "taxonomies": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + Description: `Taxonomy ids that are associated with this workflow and used for filtering`, + }, "update_entity_attributes": schema.ListNestedAttribute{ Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "source": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["workflow_status", "current_section", "current_step"]`, + Computed: true, }, "target": schema.SingleNestedAttribute{ Computed: true, @@ -186,7 +194,9 @@ func (r *WorkflowDefinitionDataSource) Read(ctx context.Context, req datasource. return } - definitionID := data.ID.ValueString() + var definitionID string + definitionID = data.ID.ValueString() + request := operations.GetDefinitionRequest{ DefinitionID: definitionID, } diff --git a/internal/provider/workflowdefinition_data_source_sdk.go b/internal/provider/workflowdefinition_data_source_sdk.go index 579dace..f709c47 100644 --- a/internal/provider/workflowdefinition_data_source_sdk.go +++ b/internal/provider/workflowdefinition_data_source_sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -36,29 +36,22 @@ func (r *WorkflowDefinitionDataSourceModel) RefreshFromSharedWorkflowDefinition( r.DynamicDueDate = nil } else { r.DynamicDueDate = &tfTypes.DynamicDueDate{} - if resp.DynamicDueDate.ActionTypeCondition != nil { - r.DynamicDueDate.ActionTypeCondition = types.StringValue(string(*resp.DynamicDueDate.ActionTypeCondition)) - } else { - r.DynamicDueDate.ActionTypeCondition = types.StringNull() - } - if resp.DynamicDueDate.NumberOfUnits != nil { - r.DynamicDueDate.NumberOfUnits = types.NumberValue(big.NewFloat(float64(*resp.DynamicDueDate.NumberOfUnits))) - } else { - r.DynamicDueDate.NumberOfUnits = types.NumberNull() - } + r.DynamicDueDate.ActionTypeCondition = types.StringValue(string(resp.DynamicDueDate.ActionTypeCondition)) + r.DynamicDueDate.NumberOfUnits = types.NumberValue(big.NewFloat(float64(resp.DynamicDueDate.NumberOfUnits))) r.DynamicDueDate.StepID = types.StringPointerValue(resp.DynamicDueDate.StepID) - if resp.DynamicDueDate.TimePeriod != nil { - r.DynamicDueDate.TimePeriod = types.StringValue(string(*resp.DynamicDueDate.TimePeriod)) - } else { - r.DynamicDueDate.TimePeriod = types.StringNull() - } + r.DynamicDueDate.TimePeriod = types.StringValue(string(resp.DynamicDueDate.TimePeriod)) } + r.Enabled = types.BoolPointerValue(resp.Enabled) r.EnableECPWorkflow = types.BoolPointerValue(resp.EnableECPWorkflow) flowResult, _ := json.Marshal(resp.Flow) r.Flow = types.StringValue(string(flowResult)) r.ID = types.StringPointerValue(resp.ID) r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) r.Name = types.StringValue(resp.Name) + r.Taxonomies = []types.String{} + for _, v := range resp.Taxonomies { + r.Taxonomies = append(r.Taxonomies, types.StringValue(v)) + } r.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} if len(r.UpdateEntityAttributes) > len(resp.UpdateEntityAttributes) { r.UpdateEntityAttributes = r.UpdateEntityAttributes[:len(resp.UpdateEntityAttributes)] diff --git a/internal/provider/workflowdefinition_resource.go b/internal/provider/workflowdefinition_resource.go index ea131fb..c4748a9 100644 --- a/internal/provider/workflowdefinition_resource.go +++ b/internal/provider/workflowdefinition_resource.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -9,12 +9,14 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators" + speakeasy_numbervalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/numbervalidators" speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/objectvalidators" speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators/stringvalidators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" @@ -42,10 +44,12 @@ type WorkflowDefinitionResourceModel struct { DueDate types.String `tfsdk:"due_date"` DynamicDueDate *tfTypes.DynamicDueDate `tfsdk:"dynamic_due_date"` EnableECPWorkflow types.Bool `tfsdk:"enable_ecp_workflow"` + Enabled types.Bool `tfsdk:"enabled"` Flow types.String `tfsdk:"flow"` ID types.String `tfsdk:"id"` LastUpdateTime types.String `tfsdk:"last_update_time"` Name types.String `tfsdk:"name"` + Taxonomies []types.String `tfsdk:"taxonomies"` UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` UserIds []types.Number `tfsdk:"user_ids"` } @@ -67,6 +71,9 @@ 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, @@ -99,8 +106,9 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc "action_type_condition": schema.StringAttribute{ Computed: true, Optional: true, - Description: `must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"]`, + Description: `Not Null; must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( "WORKFLOW_STARTED", "STEP_CLOSED", @@ -108,8 +116,12 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc }, }, "number_of_units": schema.NumberAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.Number{ + speakeasy_numbervalidators.NotNull(), + }, }, "step_id": schema.StringAttribute{ Computed: true, @@ -118,9 +130,12 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc "time_period": schema.StringAttribute{ Computed: true, Optional: true, - Description: `must be one of ["days", "weeks", "months"]`, + Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( + "minutes", + "hours", "days", "weeks", "months", @@ -135,6 +150,12 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc Optional: true, Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, }, + "enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + Default: booldefault.StaticBool(true), + Description: `Whether the workflow is enabled or not. Default: true`, + }, "flow": schema.StringAttribute{ Required: true, Description: `Parsed as JSON.`, @@ -154,10 +175,19 @@ func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.Sc "name": schema.StringAttribute{ Required: true, }, + "taxonomies": schema.ListAttribute{ + Computed: true, + Optional: true, + ElementType: types.StringType, + Description: `Taxonomy ids that are associated with this workflow and used for filtering`, + }, "update_entity_attributes": schema.ListNestedAttribute{ Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ + Validators: []validator.Object{ + speakeasy_objectvalidators.NotNull(), + }, Attributes: map[string]schema.Attribute{ "source": schema.StringAttribute{ Computed: true, @@ -295,7 +325,9 @@ func (r *WorkflowDefinitionResource) Read(ctx context.Context, req resource.Read return } - definitionID := data.ID.ValueString() + var definitionID string + definitionID = data.ID.ValueString() + request := operations.GetDefinitionRequest{ DefinitionID: definitionID, } @@ -344,7 +376,9 @@ func (r *WorkflowDefinitionResource) Update(ctx context.Context, req resource.Up } workflowDefinition := *data.ToSharedWorkflowDefinition() - definitionID := data.ID.ValueString() + var definitionID string + definitionID = data.ID.ValueString() + request := operations.UpdateDefinitionRequest{ WorkflowDefinition: workflowDefinition, DefinitionID: definitionID, @@ -394,7 +428,9 @@ func (r *WorkflowDefinitionResource) Delete(ctx context.Context, req resource.De return } - definitionID := data.ID.ValueString() + var definitionID string + definitionID = data.ID.ValueString() + request := operations.DeleteDefinitionRequest{ DefinitionID: definitionID, } diff --git a/internal/provider/workflowdefinition_resource_sdk.go b/internal/provider/workflowdefinition_resource_sdk.go index 0d0c79c..319f632 100644 --- a/internal/provider/workflowdefinition_resource_sdk.go +++ b/internal/provider/workflowdefinition_resource_sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider @@ -17,7 +17,9 @@ func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition() *shared.W } var closingReasons []shared.ClosingReasonID = []shared.ClosingReasonID{} for _, closingReasonsItem := range r.ClosingReasons { - id := closingReasonsItem.ID.ValueString() + var id string + id = closingReasonsItem.ID.ValueString() + closingReasons = append(closingReasons, shared.ClosingReasonID{ ID: id, }) @@ -42,30 +44,17 @@ func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition() *shared.W } var dynamicDueDate *shared.DynamicDueDate if r.DynamicDueDate != nil { - actionTypeCondition := new(shared.ActionTypeCondition) - if !r.DynamicDueDate.ActionTypeCondition.IsUnknown() && !r.DynamicDueDate.ActionTypeCondition.IsNull() { - *actionTypeCondition = shared.ActionTypeCondition(r.DynamicDueDate.ActionTypeCondition.ValueString()) - } else { - actionTypeCondition = nil - } - numberOfUnits := new(float64) - if !r.DynamicDueDate.NumberOfUnits.IsUnknown() && !r.DynamicDueDate.NumberOfUnits.IsNull() { - *numberOfUnits, _ = r.DynamicDueDate.NumberOfUnits.ValueBigFloat().Float64() - } else { - numberOfUnits = nil - } + actionTypeCondition := shared.ActionTypeCondition(r.DynamicDueDate.ActionTypeCondition.ValueString()) + var numberOfUnits float64 + numberOfUnits, _ = r.DynamicDueDate.NumberOfUnits.ValueBigFloat().Float64() + stepID := new(string) if !r.DynamicDueDate.StepID.IsUnknown() && !r.DynamicDueDate.StepID.IsNull() { *stepID = r.DynamicDueDate.StepID.ValueString() } else { stepID = nil } - timePeriod := new(shared.TimePeriod) - if !r.DynamicDueDate.TimePeriod.IsUnknown() && !r.DynamicDueDate.TimePeriod.IsNull() { - *timePeriod = shared.TimePeriod(r.DynamicDueDate.TimePeriod.ValueString()) - } else { - timePeriod = nil - } + timePeriod := shared.TimePeriod(r.DynamicDueDate.TimePeriod.ValueString()) dynamicDueDate = &shared.DynamicDueDate{ ActionTypeCondition: actionTypeCondition, NumberOfUnits: numberOfUnits, @@ -79,6 +68,12 @@ func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition() *shared.W } else { enableECPWorkflow = nil } + enabled := new(bool) + if !r.Enabled.IsUnknown() && !r.Enabled.IsNull() { + *enabled = r.Enabled.ValueBool() + } else { + enabled = nil + } var flow interface{} _ = json.Unmarshal([]byte(r.Flow.ValueString()), &flow) id1 := new(string) @@ -93,12 +88,22 @@ func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition() *shared.W } else { lastUpdateTime = nil } - name := r.Name.ValueString() + var name string + name = r.Name.ValueString() + + var taxonomies []string = []string{} + for _, taxonomiesItem := range r.Taxonomies { + taxonomies = append(taxonomies, taxonomiesItem.ValueString()) + } var updateEntityAttributes []shared.UpdateEntityAttributes = []shared.UpdateEntityAttributes{} for _, updateEntityAttributesItem := range r.UpdateEntityAttributes { source := shared.Source(updateEntityAttributesItem.Source.ValueString()) - entityAttribute := updateEntityAttributesItem.Target.EntityAttribute.ValueString() - entitySchema := updateEntityAttributesItem.Target.EntitySchema.ValueString() + var entityAttribute string + entityAttribute = updateEntityAttributesItem.Target.EntityAttribute.ValueString() + + var entitySchema string + entitySchema = updateEntityAttributesItem.Target.EntitySchema.ValueString() + target := shared.Target{ EntityAttribute: entityAttribute, EntitySchema: entitySchema, @@ -121,10 +126,12 @@ func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition() *shared.W DueDate: dueDate, DynamicDueDate: dynamicDueDate, EnableECPWorkflow: enableECPWorkflow, + Enabled: enabled, Flow: flow, ID: id1, LastUpdateTime: lastUpdateTime, Name: name, + Taxonomies: taxonomies, UpdateEntityAttributes: updateEntityAttributes, UserIds: userIds, } @@ -157,29 +164,22 @@ func (r *WorkflowDefinitionResourceModel) RefreshFromSharedWorkflowDefinition(re r.DynamicDueDate = nil } else { r.DynamicDueDate = &tfTypes.DynamicDueDate{} - if resp.DynamicDueDate.ActionTypeCondition != nil { - r.DynamicDueDate.ActionTypeCondition = types.StringValue(string(*resp.DynamicDueDate.ActionTypeCondition)) - } else { - r.DynamicDueDate.ActionTypeCondition = types.StringNull() - } - if resp.DynamicDueDate.NumberOfUnits != nil { - r.DynamicDueDate.NumberOfUnits = types.NumberValue(big.NewFloat(float64(*resp.DynamicDueDate.NumberOfUnits))) - } else { - r.DynamicDueDate.NumberOfUnits = types.NumberNull() - } + r.DynamicDueDate.ActionTypeCondition = types.StringValue(string(resp.DynamicDueDate.ActionTypeCondition)) + r.DynamicDueDate.NumberOfUnits = types.NumberValue(big.NewFloat(float64(resp.DynamicDueDate.NumberOfUnits))) r.DynamicDueDate.StepID = types.StringPointerValue(resp.DynamicDueDate.StepID) - if resp.DynamicDueDate.TimePeriod != nil { - r.DynamicDueDate.TimePeriod = types.StringValue(string(*resp.DynamicDueDate.TimePeriod)) - } else { - r.DynamicDueDate.TimePeriod = types.StringNull() - } + r.DynamicDueDate.TimePeriod = types.StringValue(string(resp.DynamicDueDate.TimePeriod)) } + r.Enabled = types.BoolPointerValue(resp.Enabled) r.EnableECPWorkflow = types.BoolPointerValue(resp.EnableECPWorkflow) flowResult, _ := json.Marshal(resp.Flow) r.Flow = types.StringValue(string(flowResult)) r.ID = types.StringPointerValue(resp.ID) r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) r.Name = types.StringValue(resp.Name) + r.Taxonomies = []types.String{} + for _, v := range resp.Taxonomies { + r.Taxonomies = append(r.Taxonomies, types.StringValue(v)) + } r.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} if len(r.UpdateEntityAttributes) > len(resp.UpdateEntityAttributes) { r.UpdateEntityAttributes = r.UpdateEntityAttributes[:len(resp.UpdateEntityAttributes)] diff --git a/internal/sdk/closingreason.go b/internal/sdk/closingreason.go index 0eeec3c..dbcb656 100644 --- a/internal/sdk/closingreason.go +++ b/internal/sdk/closingreason.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package sdk @@ -6,12 +6,13 @@ import ( "bytes" "context" "fmt" + "github.com/cenkalti/backoff/v4" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "io" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" "net/http" "net/url" ) @@ -38,6 +39,7 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -81,33 +83,95 @@ func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operatio return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.ChangeReasonStatusResponse{ @@ -116,13 +180,6 @@ 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: @@ -130,6 +187,11 @@ 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 @@ -137,9 +199,17 @@ 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) } @@ -159,6 +229,7 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -202,33 +273,95 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.CreateClosingReasonResponse{ @@ -237,17 +370,15 @@ 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 @@ -255,9 +386,17 @@ func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared. 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) } 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) } @@ -277,6 +416,7 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -318,33 +458,95 @@ func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operat return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.GetAllClosingReasonsResponse{ @@ -353,17 +555,15 @@ 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 @@ -371,9 +571,17 @@ 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) } @@ -393,6 +601,7 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -430,33 +639,95 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.GetClosingReasonResponse{ @@ -465,17 +736,15 @@ 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 @@ -483,6 +752,10 @@ 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: @@ -492,6 +765,11 @@ func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations 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 @@ -499,11 +777,20 @@ 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 @@ -511,9 +798,17 @@ 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 new file mode 100644 index 0000000..4233b59 --- /dev/null +++ b/internal/sdk/flowsv2.go @@ -0,0 +1,1065 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdk + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/hooks" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" + "net/http" + "net/url" +) + +type FlowsV2 struct { + sdkConfiguration sdkConfiguration +} + +func newFlowsV2(sdkConfig sdkConfiguration) *FlowsV2 { + return &FlowsV2{ + sdkConfiguration: sdkConfig, + } +} + +// CreateFlowTemplate - createFlowTemplate +// Create a new Flow Template. +func (s *FlowsV2) CreateFlowTemplate(ctx context.Context, request shared.FlowTemplate, opts ...operations.Option) (*operations.CreateFlowTemplateResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "createFlowTemplate", + 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 := url.JoinPath(baseURL, "/v2/flows/templates") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + 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.CreateFlowTemplateResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 + } + + 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: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + 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 + } + + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// DeleteFlowTemplate - deleteFlowTemplate +// Delete Flow Template. +func (s *FlowsV2) DeleteFlowTemplate(ctx context.Context, request operations.DeleteFlowTemplateRequest, opts ...operations.Option) (*operations.DeleteFlowTemplateResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "deleteFlowTemplate", + 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/flows/templates/{flowId}", 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 + } + } + } 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.DeleteFlowTemplateResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 204: + fallthrough + case httpRes.StatusCode == 404: + 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 + } + + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetFlowTemplate - getFlowTemplate +// Get specific FLow template for a customer +func (s *FlowsV2) GetFlowTemplate(ctx context.Context, request operations.GetFlowTemplateRequest, opts ...operations.Option) (*operations.GetFlowTemplateResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getFlowTemplate", + 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/flows/templates/{flowId}", 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.GetFlowTemplateResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 + } + + 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: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + 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 + } + + 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 + } + + 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) + } + + return res, nil + +} + +// ListFlowTemplates - listFlowTemplates +// List all Flow Templates for a customer +func (s *FlowsV2) ListFlowTemplates(ctx context.Context, opts ...operations.Option) (*operations.ListFlowTemplatesResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "listFlowTemplates", + 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 := url.JoinPath(baseURL, "/v2/flows/templates") + 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.ListFlowTemplatesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 + } + + 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 + } + + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// UpdateFlowTemplate - updateFlowTemplate +// Update Flow Template. +func (s *FlowsV2) UpdateFlowTemplate(ctx context.Context, request operations.UpdateFlowTemplateRequest, opts ...operations.Option) (*operations.UpdateFlowTemplateResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "updateFlowTemplate", + 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/flows/templates/{flowId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "FlowTemplate", "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, "PUT", 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.UpdateFlowTemplateResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 + } + + 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: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + 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 + } + + res.ErrorResp = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/internal/sdk/internal/hooks/hooks.go b/internal/sdk/internal/hooks/hooks.go index b978f6b..8ea491a 100644 --- a/internal/sdk/internal/hooks/hooks.go +++ b/internal/sdk/internal/hooks/hooks.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package hooks diff --git a/internal/sdk/internal/hooks/registration.go b/internal/sdk/internal/hooks/registration.go index 99a3606..fa131be 100644 --- a/internal/sdk/internal/hooks/registration.go +++ b/internal/sdk/internal/hooks/registration.go @@ -1,15 +1,18 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - package hooks /* * This file is only ever generated once on the first generation and then is free to be modified. - * Any hooks you wish to add should be registered in the InitHooks function. Feel free to define them - * in this file or in separate files in the hooks package. + * Any hooks you wish to add should be registered in the initHooks function. Feel free to define + * your hooks in this file or in separate files in the hooks package. + * + * Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance. */ func initHooks(h *Hooks) { - // Add hooks by calling h.register{SDKInit/BeforeRequest/AfterSuccess/AfterError}Hook - // with an instance of a hook that implements that specific Hook interface - // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance + // exampleHook := &ExampleHook{} + + // h.registerSDKInitHook(exampleHook) + // h.registerBeforeRequestHook(exampleHook) + // h.registerAfterErrorHook(exampleHook) + // h.registerAfterSuccessHook(exampleHook) } diff --git a/internal/sdk/internal/utils/contenttype.go b/internal/sdk/internal/utils/contenttype.go index 81e669d..f6487e0 100644 --- a/internal/sdk/internal/utils/contenttype.go +++ b/internal/sdk/internal/utils/contenttype.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/form.go b/internal/sdk/internal/utils/form.go index c6f0eb3..dc1fd3b 100644 --- a/internal/sdk/internal/utils/form.go +++ b/internal/sdk/internal/utils/form.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/headers.go b/internal/sdk/internal/utils/headers.go index 7af15f9..a07608b 100644 --- a/internal/sdk/internal/utils/headers.go +++ b/internal/sdk/internal/utils/headers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index 9f5e7ef..bd307e1 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils @@ -165,11 +165,17 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool if field.Tag.Get("const") != "" { if r, ok := unmarhsaled[fieldName]; ok { val := string(r) + if strings.HasPrefix(val, `"`) && strings.HasSuffix(val, `"`) { - val = val[1 : len(val)-1] + var err error + val, err = strconv.Unquote(val) + if err != nil { + return fmt.Errorf("failed to unquote const field `%s` value `%s`: %w", fieldName, val, err) + } } - if val != field.Tag.Get("const") { - return fmt.Errorf("const field %s does not match expected value %s", fieldName, field.Tag.Get("const")) + constValue := field.Tag.Get("const") + if val != constValue { + return fmt.Errorf("const field `%s` does not match expected value `%s` got `%s`", fieldName, constValue, val) } delete(unmarhsaled, fieldName) @@ -481,30 +487,29 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa v.Set(m) return nil case reflect.Slice, reflect.Array: - 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 + var unmarshaled []json.RawMessage - if err := json.Unmarshal(value, &unmarhsaled); err != nil { + if err := json.Unmarshal(value, &unmarshaled); err != nil { return err } - arrVal := v + arrVal := reflect.MakeSlice(typ, len(unmarshaled), len(unmarshaled)) - for _, value := range unmarhsaled { + for index, value := range unmarshaled { itemVal := reflect.New(typ.Elem()) if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { return err } - arrVal = reflect.Append(arrVal, itemVal.Elem()) + arrVal.Index(index).Set(itemVal.Elem()) + } + + if v.Kind() == reflect.Pointer { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() } v.Set(arrVal) diff --git a/internal/sdk/internal/utils/pathparams.go b/internal/sdk/internal/utils/pathparams.go index 17fd796..440bb9d 100644 --- a/internal/sdk/internal/utils/pathparams.go +++ b/internal/sdk/internal/utils/pathparams.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/queryparams.go b/internal/sdk/internal/utils/queryparams.go index 6369a61..ad359eb 100644 --- a/internal/sdk/internal/utils/queryparams.go +++ b/internal/sdk/internal/utils/queryparams.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index b4e2b8b..000226e 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils @@ -66,15 +66,16 @@ 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, requestVal, string(requestField.Tag)) + 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)) } } @@ -82,7 +83,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) (*bytes.Buffer, string, error) { +func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (io.Reader, string, error) { buf := &bytes.Buffer{} if isNil(val.Type(), val) { @@ -116,6 +117,8 @@ 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) @@ -124,8 +127,8 @@ func serializeContentType(fieldName string, mediaType string, val reflect.Value, if _, err := buf.WriteString(valToString(val.Interface())); err != nil { return nil, "", err } - case val.Type() == reflect.TypeOf([]byte(nil)): - if _, err := buf.Write(val.Bytes()); err != nil { + case reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)): + if _, err := buf.Write(val.Interface().([]byte)); err != nil { return nil, "", err } default: @@ -215,7 +218,7 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va var fieldName string var fileName string - var content []byte + var reader io.Reader for i := 0; i < fieldType.NumField(); i++ { field := fieldType.Field(i) @@ -226,15 +229,19 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va continue } - if tag.Content { - content = val.Bytes() + 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) + } } else { fieldName = tag.Name fileName = val.String() } } - if fieldName == "" || fileName == "" || content == nil { + if fieldName == "" || fileName == "" || reader == nil { return fmt.Errorf("invalid multipart/form-data file") } @@ -242,7 +249,7 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va if err != nil { return err } - if _, err := fw.Write(content); err != nil { + if _, err := io.Copy(fw, reader); err != nil { return err } diff --git a/internal/sdk/internal/utils/retries.go b/internal/sdk/internal/utils/retries.go index 8839a0b..182ec60 100644 --- a/internal/sdk/internal/utils/retries.go +++ b/internal/sdk/internal/utils/retries.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/security.go b/internal/sdk/internal/utils/security.go index ace81f7..19dfa6f 100644 --- a/internal/sdk/internal/utils/security.go +++ b/internal/sdk/internal/utils/security.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils @@ -21,6 +21,7 @@ type securityTag struct { Name string Type string SubType string + Env string } func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error { @@ -118,9 +119,14 @@ func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *secu } if schemeType.Kind() == reflect.Struct { - if schemeTag.Type == "http" && schemeTag.SubType == "basic" { - handleBasicAuthScheme(headers, schemeVal.Interface()) - return + if schemeTag.Type == "http" { + switch schemeTag.SubType { + case "basic": + handleBasicAuthScheme(headers, schemeVal.Interface()) + return + case "custom": + return + } } for i := 0; i < schemeType.NumField(); i++ { @@ -170,6 +176,7 @@ 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") } @@ -227,6 +234,7 @@ func parseSecurityTag(field reflect.StructField) *securityTag { name := "" securityType := "" securitySubType := "" + env := "" options := strings.Split(tag, ",") for _, optionConf := range options { @@ -246,6 +254,8 @@ func parseSecurityTag(field reflect.StructField) *securityTag { option = true case "scheme": scheme = true + case "env": + env = parts[1] } } @@ -257,6 +267,7 @@ func parseSecurityTag(field reflect.StructField) *securityTag { Name: name, Type: securityType, SubType: securitySubType, + Env: env, } } diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index 50482f2..f1ff9e0 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -1,12 +1,14 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils import ( + "bytes" "context" "fmt" "io" "math/big" + "net/http" "reflect" "regexp" "strconv" @@ -228,3 +230,15 @@ 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/errors/sdkerror.go b/internal/sdk/models/errors/sdkerror.go index ff3fad6..c633d56 100644 --- a/internal/sdk/models/errors/sdkerror.go +++ b/internal/sdk/models/errors/sdkerror.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package errors diff --git a/internal/sdk/models/operations/changereasonstatus.go b/internal/sdk/models/operations/changereasonstatus.go index d245881..72e457e 100644 --- a/internal/sdk/models/operations/changereasonstatus.go +++ b/internal/sdk/models/operations/changereasonstatus.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/createclosingreason.go b/internal/sdk/models/operations/createclosingreason.go index f413124..abbfad6 100644 --- a/internal/sdk/models/operations/createclosingreason.go +++ b/internal/sdk/models/operations/createclosingreason.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/createdefinition.go b/internal/sdk/models/operations/createdefinition.go index 181616f..c435e88 100644 --- a/internal/sdk/models/operations/createdefinition.go +++ b/internal/sdk/models/operations/createdefinition.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/createflowtemplate.go b/internal/sdk/models/operations/createflowtemplate.go new file mode 100644 index 0000000..f88ddf5 --- /dev/null +++ b/internal/sdk/models/operations/createflowtemplate.go @@ -0,0 +1,56 @@ +// 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 CreateFlowTemplateResponse struct { + // HTTP response content type for this operation + ContentType string + // Validation Errors + ErrorResp *shared.ErrorResp + // Success - if the flow template is created successfully + FlowTemplate *shared.FlowTemplate + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *CreateFlowTemplateResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *CreateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *CreateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if o == nil { + return nil + } + return o.FlowTemplate +} + +func (o *CreateFlowTemplateResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *CreateFlowTemplateResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/deletedefinition.go b/internal/sdk/models/operations/deletedefinition.go index cd269b4..d553a6b 100644 --- a/internal/sdk/models/operations/deletedefinition.go +++ b/internal/sdk/models/operations/deletedefinition.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/deleteflowtemplate.go b/internal/sdk/models/operations/deleteflowtemplate.go new file mode 100644 index 0000000..e146494 --- /dev/null +++ b/internal/sdk/models/operations/deleteflowtemplate.go @@ -0,0 +1,59 @@ +// 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 DeleteFlowTemplateRequest struct { + // Id of the flow template to de deleted. + FlowID string `pathParam:"style=simple,explode=false,name=flowId"` +} + +func (o *DeleteFlowTemplateRequest) GetFlowID() string { + if o == nil { + return "" + } + return o.FlowID +} + +type DeleteFlowTemplateResponse struct { + // HTTP response content type for this operation + ContentType string + // Failed to authenticate + 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 *DeleteFlowTemplateResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *DeleteFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *DeleteFlowTemplateResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *DeleteFlowTemplateResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/getallclosingreasons.go b/internal/sdk/models/operations/getallclosingreasons.go index f9221ea..10f6b8c 100644 --- a/internal/sdk/models/operations/getallclosingreasons.go +++ b/internal/sdk/models/operations/getallclosingreasons.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getclosingreason.go b/internal/sdk/models/operations/getclosingreason.go index 0a2e20f..a1faf13 100644 --- a/internal/sdk/models/operations/getclosingreason.go +++ b/internal/sdk/models/operations/getclosingreason.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getdefinition.go b/internal/sdk/models/operations/getdefinition.go index edf5f75..94a3f32 100644 --- a/internal/sdk/models/operations/getdefinition.go +++ b/internal/sdk/models/operations/getdefinition.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getdefinitions.go b/internal/sdk/models/operations/getdefinitions.go index f4e1512..e479278 100644 --- a/internal/sdk/models/operations/getdefinitions.go +++ b/internal/sdk/models/operations/getdefinitions.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getflowtemplate.go b/internal/sdk/models/operations/getflowtemplate.go new file mode 100644 index 0000000..f956ebe --- /dev/null +++ b/internal/sdk/models/operations/getflowtemplate.go @@ -0,0 +1,76 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" + "net/http" +) + +type GetFlowTemplateRequest struct { + FlowID string `pathParam:"style=simple,explode=false,name=flowId"` +} + +func (o *GetFlowTemplateRequest) GetFlowID() string { + if o == nil { + return "" + } + return o.FlowID +} + +type GetFlowTemplateResponse struct { + // HTTP response content type for this operation + ContentType string + // Definition Not found + DefinitionNotFoundResp *shared.DefinitionNotFoundResp + // Validation Errors + ErrorResp *shared.ErrorResp + // Returns the Flow Template + FlowTemplate *shared.FlowTemplate + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *GetFlowTemplateResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetFlowTemplateResponse) GetDefinitionNotFoundResp() *shared.DefinitionNotFoundResp { + if o == nil { + return nil + } + return o.DefinitionNotFoundResp +} + +func (o *GetFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *GetFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if o == nil { + return nil + } + return o.FlowTemplate +} + +func (o *GetFlowTemplateResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetFlowTemplateResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/getmaxallowedlimit.go b/internal/sdk/models/operations/getmaxallowedlimit.go index b64ff93..d9703ef 100644 --- a/internal/sdk/models/operations/getmaxallowedlimit.go +++ b/internal/sdk/models/operations/getmaxallowedlimit.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getworkflowclosingreasons.go b/internal/sdk/models/operations/getworkflowclosingreasons.go new file mode 100644 index 0000000..e9c6d00 --- /dev/null +++ b/internal/sdk/models/operations/getworkflowclosingreasons.go @@ -0,0 +1,59 @@ +// 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 GetWorkflowClosingReasonsRequest struct { + // ID of a workflow definition + DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` +} + +func (o *GetWorkflowClosingReasonsRequest) GetDefinitionID() string { + if o == nil { + return "" + } + return o.DefinitionID +} + +type GetWorkflowClosingReasonsResponse struct { + // Returns the entire catalog of closing reasons for a specific workflow + ClosingReasonsIds *shared.ClosingReasonsIds + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *GetWorkflowClosingReasonsResponse) GetClosingReasonsIds() *shared.ClosingReasonsIds { + if o == nil { + return nil + } + return o.ClosingReasonsIds +} + +func (o *GetWorkflowClosingReasonsResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetWorkflowClosingReasonsResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetWorkflowClosingReasonsResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/listflowtemplates.go b/internal/sdk/models/operations/listflowtemplates.go new file mode 100644 index 0000000..4570a13 --- /dev/null +++ b/internal/sdk/models/operations/listflowtemplates.go @@ -0,0 +1,56 @@ +// 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 ListFlowTemplatesResponse struct { + // HTTP response content type for this operation + ContentType string + // Other errors + ErrorResp *shared.ErrorResp + // Success - flow templates loaded with success. Empty array if customer has no flows defined. + FlowTemplatesList *shared.FlowTemplatesList + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *ListFlowTemplatesResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ListFlowTemplatesResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *ListFlowTemplatesResponse) GetFlowTemplatesList() *shared.FlowTemplatesList { + if o == nil { + return nil + } + return o.FlowTemplatesList +} + +func (o *ListFlowTemplatesResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ListFlowTemplatesResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/options.go b/internal/sdk/models/operations/options.go index 6cf35c9..4d0008e 100644 --- a/internal/sdk/models/operations/options.go +++ b/internal/sdk/models/operations/options.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations @@ -19,11 +19,23 @@ const ( SupportedOptionURLOverride = "urlOverride" ) +type AcceptHeaderEnum string + +const ( + AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" + AcceptHeaderEnumWildcardWildcard AcceptHeaderEnum = "*/*" +) + +func (e AcceptHeaderEnum) ToPointer() *AcceptHeaderEnum { + return &e +} + type Options struct { - ServerURL *string - Retries *retry.Config - Timeout *time.Duration - URLOverride *string + ServerURL *string + Retries *retry.Config + Timeout *time.Duration + AcceptHeaderOverride *AcceptHeaderEnum + URLOverride *string } type Option func(*Options, ...string) error @@ -80,6 +92,17 @@ func WithOperationTimeout(timeout time.Duration) Option { } } +func WithAcceptHeaderOverride(acceptHeaderOverride AcceptHeaderEnum) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionAcceptHeaderOverride) { + return ErrUnsupportedOption + } + + opts.AcceptHeaderOverride = &acceptHeaderOverride + return nil + } +} + // WithURLOverride allows overriding the URL. func WithURLOverride(urlOverride string) Option { return func(opts *Options, supportedOptions ...string) error { diff --git a/internal/sdk/models/operations/setworkflowclosingreasons.go b/internal/sdk/models/operations/setworkflowclosingreasons.go new file mode 100644 index 0000000..e676d5d --- /dev/null +++ b/internal/sdk/models/operations/setworkflowclosingreasons.go @@ -0,0 +1,59 @@ +// 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 SetWorkflowClosingReasonsRequest struct { + // set all closing reasons for a specific definition + ClosingReasonsIds shared.ClosingReasonsIds `request:"mediaType=application/json"` + // ID of a workflow definition + DefinitionID string `pathParam:"style=simple,explode=false,name=definitionId"` +} + +func (o *SetWorkflowClosingReasonsRequest) GetClosingReasonsIds() shared.ClosingReasonsIds { + if o == nil { + return shared.ClosingReasonsIds{} + } + return o.ClosingReasonsIds +} + +func (o *SetWorkflowClosingReasonsRequest) GetDefinitionID() string { + if o == nil { + return "" + } + return o.DefinitionID +} + +type SetWorkflowClosingReasonsResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *SetWorkflowClosingReasonsResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *SetWorkflowClosingReasonsResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *SetWorkflowClosingReasonsResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/updatedefinition.go b/internal/sdk/models/operations/updatedefinition.go index c056fbc..8a087da 100644 --- a/internal/sdk/models/operations/updatedefinition.go +++ b/internal/sdk/models/operations/updatedefinition.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/updateflowtemplate.go b/internal/sdk/models/operations/updateflowtemplate.go new file mode 100644 index 0000000..c2d23b5 --- /dev/null +++ b/internal/sdk/models/operations/updateflowtemplate.go @@ -0,0 +1,76 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" + "net/http" +) + +type UpdateFlowTemplateRequest struct { + // Flow Template payload + FlowTemplate shared.FlowTemplate `request:"mediaType=application/json"` + FlowID string `pathParam:"style=simple,explode=false,name=flowId"` +} + +func (o *UpdateFlowTemplateRequest) GetFlowTemplate() shared.FlowTemplate { + if o == nil { + return shared.FlowTemplate{} + } + return o.FlowTemplate +} + +func (o *UpdateFlowTemplateRequest) GetFlowID() string { + if o == nil { + return "" + } + return o.FlowID +} + +type UpdateFlowTemplateResponse struct { + // HTTP response content type for this operation + ContentType string + // Validation Errors + ErrorResp *shared.ErrorResp + // Flow template has been updated successfully + FlowTemplate *shared.FlowTemplate + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *UpdateFlowTemplateResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *UpdateFlowTemplateResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *UpdateFlowTemplateResponse) GetFlowTemplate() *shared.FlowTemplate { + if o == nil { + return nil + } + return o.FlowTemplate +} + +func (o *UpdateFlowTemplateResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *UpdateFlowTemplateResponse) 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 new file mode 100644 index 0000000..c44f2b3 --- /dev/null +++ b/internal/sdk/models/shared/automationtask.go @@ -0,0 +1,136 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type AutomationConfig struct { + // Id of the configured automation to run + FlowID string `json:"flow_id"` +} + +func (o *AutomationConfig) GetFlowID() string { + if o == nil { + return "" + } + return o.FlowID +} + +type AutomationTask struct { + AssignedTo []string `json:"assigned_to,omitempty"` + AutomationConfig AutomationConfig `json:"automation_config"` + // Longer information regarding Task + 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"` + // Details regarding ECP for the workflow step + Ecp *ECPDetails `json:"ecp,omitempty"` + ID string `json:"id"` + // Details regarding ECP for the workflow step + Installer *ECPDetails `json:"installer,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + Name string `json:"name"` + PhaseID *string `json:"phase_id,omitempty"` + // requirements that need to be fulfilled in order to enable the task while flow instances are running + Requirements []EnableRequirement `json:"requirements,omitempty"` + TaskType TaskType `json:"task_type"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` +} + +func (o *AutomationTask) GetAssignedTo() []string { + if o == nil { + return nil + } + return o.AssignedTo +} + +func (o *AutomationTask) GetAutomationConfig() AutomationConfig { + if o == nil { + return AutomationConfig{} + } + return o.AutomationConfig +} + +func (o *AutomationTask) GetDescription() *StepDescription { + if o == nil { + return nil + } + return o.Description +} + +func (o *AutomationTask) GetDueDate() *string { + if o == nil { + return nil + } + return o.DueDate +} + +func (o *AutomationTask) GetDynamicDueDate() *DueDateConfig { + if o == nil { + return nil + } + return o.DynamicDueDate +} + +func (o *AutomationTask) GetEcp() *ECPDetails { + if o == nil { + return nil + } + return o.Ecp +} + +func (o *AutomationTask) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *AutomationTask) GetInstaller() *ECPDetails { + if o == nil { + return nil + } + return o.Installer +} + +func (o *AutomationTask) GetJourney() *StepJourney { + if o == nil { + return nil + } + return o.Journey +} + +func (o *AutomationTask) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *AutomationTask) GetPhaseID() *string { + if o == nil { + return nil + } + return o.PhaseID +} + +func (o *AutomationTask) GetRequirements() []EnableRequirement { + if o == nil { + return nil + } + return o.Requirements +} + +func (o *AutomationTask) GetTaskType() TaskType { + if o == nil { + return TaskType("") + } + return o.TaskType +} + +func (o *AutomationTask) GetTaxonomies() []string { + if o == nil { + return nil + } + return o.Taxonomies +} diff --git a/internal/sdk/models/shared/changereasonstatusreq.go b/internal/sdk/models/shared/changereasonstatusreq.go index 98a057a..938e8f2 100644 --- a/internal/sdk/models/shared/changereasonstatusreq.go +++ b/internal/sdk/models/shared/changereasonstatusreq.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/closingreason.go b/internal/sdk/models/shared/closingreason.go index 6a62f45..098a3e4 100644 --- a/internal/sdk/models/shared/closingreason.go +++ b/internal/sdk/models/shared/closingreason.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/closingreasonid.go b/internal/sdk/models/shared/closingreasonid.go index bb88b11..ab5a29c 100644 --- a/internal/sdk/models/shared/closingreasonid.go +++ b/internal/sdk/models/shared/closingreasonid.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/closingreasonnotfoundresp.go b/internal/sdk/models/shared/closingreasonnotfoundresp.go index 828e59a..2bbfab4 100644 --- a/internal/sdk/models/shared/closingreasonnotfoundresp.go +++ b/internal/sdk/models/shared/closingreasonnotfoundresp.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/closingreasons.go b/internal/sdk/models/shared/closingreasons.go index d24ee4e..7c0d9b4 100644 --- a/internal/sdk/models/shared/closingreasons.go +++ b/internal/sdk/models/shared/closingreasons.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/closingreasonsids.go b/internal/sdk/models/shared/closingreasonsids.go new file mode 100644 index 0000000..05dd280 --- /dev/null +++ b/internal/sdk/models/shared/closingreasonsids.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type ClosingReasonsIds struct { + Reasons []ClosingReasonID `json:"reasons"` +} + +func (o *ClosingReasonsIds) GetReasons() []ClosingReasonID { + if o == nil { + return []ClosingReasonID{} + } + return o.Reasons +} diff --git a/internal/sdk/models/shared/closingreasonsstatus.go b/internal/sdk/models/shared/closingreasonsstatus.go index 4818dac..1e61607 100644 --- a/internal/sdk/models/shared/closingreasonsstatus.go +++ b/internal/sdk/models/shared/closingreasonsstatus.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/condition.go b/internal/sdk/models/shared/condition.go new file mode 100644 index 0000000..2b6c9b0 --- /dev/null +++ b/internal/sdk/models/shared/condition.go @@ -0,0 +1,61 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type LogicalOperator string + +const ( + LogicalOperatorAnd LogicalOperator = "AND" + LogicalOperatorOr LogicalOperator = "OR" +) + +func (e LogicalOperator) ToPointer() *LogicalOperator { + return &e +} +func (e *LogicalOperator) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "AND": + fallthrough + case "OR": + *e = LogicalOperator(v) + return nil + default: + return fmt.Errorf("invalid value for LogicalOperator: %v", v) + } +} + +type Condition struct { + ID string `json:"id"` + LogicalOperator LogicalOperator `json:"logical_operator"` + Statements []Statement `json:"statements"` +} + +func (o *Condition) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *Condition) GetLogicalOperator() LogicalOperator { + if o == nil { + return LogicalOperator("") + } + return o.LogicalOperator +} + +func (o *Condition) GetStatements() []Statement { + if o == nil { + return []Statement{} + } + return o.Statements +} diff --git a/internal/sdk/models/shared/decisiontask.go b/internal/sdk/models/shared/decisiontask.go new file mode 100644 index 0000000..1300f97 --- /dev/null +++ b/internal/sdk/models/shared/decisiontask.go @@ -0,0 +1,124 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type DecisionTask struct { + AssignedTo []string `json:"assigned_to,omitempty"` + Conditions []Condition `json:"conditions"` + // Longer information regarding Task + 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"` + // Details regarding ECP for the workflow step + Ecp *ECPDetails `json:"ecp,omitempty"` + ID string `json:"id"` + // Details regarding ECP for the workflow step + Installer *ECPDetails `json:"installer,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + Name string `json:"name"` + PhaseID *string `json:"phase_id,omitempty"` + // requirements that need to be fulfilled in order to enable the task while flow instances are running + Requirements []EnableRequirement `json:"requirements,omitempty"` + TaskType TaskType `json:"task_type"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` +} + +func (o *DecisionTask) GetAssignedTo() []string { + if o == nil { + return nil + } + return o.AssignedTo +} + +func (o *DecisionTask) GetConditions() []Condition { + if o == nil { + return []Condition{} + } + return o.Conditions +} + +func (o *DecisionTask) GetDescription() *StepDescription { + if o == nil { + return nil + } + return o.Description +} + +func (o *DecisionTask) GetDueDate() *string { + if o == nil { + return nil + } + return o.DueDate +} + +func (o *DecisionTask) GetDynamicDueDate() *DueDateConfig { + if o == nil { + return nil + } + return o.DynamicDueDate +} + +func (o *DecisionTask) GetEcp() *ECPDetails { + if o == nil { + return nil + } + return o.Ecp +} + +func (o *DecisionTask) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *DecisionTask) GetInstaller() *ECPDetails { + if o == nil { + return nil + } + return o.Installer +} + +func (o *DecisionTask) GetJourney() *StepJourney { + if o == nil { + return nil + } + return o.Journey +} + +func (o *DecisionTask) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *DecisionTask) GetPhaseID() *string { + if o == nil { + return nil + } + return o.PhaseID +} + +func (o *DecisionTask) GetRequirements() []EnableRequirement { + if o == nil { + return nil + } + return o.Requirements +} + +func (o *DecisionTask) GetTaskType() TaskType { + if o == nil { + return TaskType("") + } + return o.TaskType +} + +func (o *DecisionTask) GetTaxonomies() []string { + if o == nil { + return nil + } + return o.Taxonomies +} diff --git a/internal/sdk/models/shared/definitionnotfoundresp.go b/internal/sdk/models/shared/definitionnotfoundresp.go index f7765f0..a7235aa 100644 --- a/internal/sdk/models/shared/definitionnotfoundresp.go +++ b/internal/sdk/models/shared/definitionnotfoundresp.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/duedateconfig.go b/internal/sdk/models/shared/duedateconfig.go new file mode 100644 index 0000000..e01cfaf --- /dev/null +++ b/internal/sdk/models/shared/duedateconfig.go @@ -0,0 +1,105 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type Type string + +const ( + TypeWorkflowStarted Type = "WORKFLOW_STARTED" + TypeTaskFinished Type = "TASK_FINISHED" +) + +func (e Type) ToPointer() *Type { + return &e +} +func (e *Type) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "WORKFLOW_STARTED": + fallthrough + case "TASK_FINISHED": + *e = Type(v) + return nil + default: + return fmt.Errorf("invalid value for Type: %v", v) + } +} + +type Unit string + +const ( + UnitMinutes Unit = "minutes" + UnitHours Unit = "hours" + UnitDays Unit = "days" + UnitWeeks Unit = "weeks" + UnitMonths Unit = "months" +) + +func (e Unit) ToPointer() *Unit { + return &e +} +func (e *Unit) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "minutes": + fallthrough + case "hours": + fallthrough + case "days": + fallthrough + case "weeks": + fallthrough + case "months": + *e = Unit(v) + return nil + default: + return fmt.Errorf("invalid value for Unit: %v", v) + } +} + +// DueDateConfig - Set due date for the task based on a dynamic condition +type DueDateConfig struct { + Duration float64 `json:"duration"` + TaskID *string `json:"task_id,omitempty"` + Type Type `json:"type"` + Unit Unit `json:"unit"` +} + +func (o *DueDateConfig) GetDuration() float64 { + if o == nil { + return 0.0 + } + return o.Duration +} + +func (o *DueDateConfig) GetTaskID() *string { + if o == nil { + return nil + } + return o.TaskID +} + +func (o *DueDateConfig) GetType() Type { + if o == nil { + return Type("") + } + return o.Type +} + +func (o *DueDateConfig) GetUnit() Unit { + if o == nil { + return Unit("") + } + return o.Unit +} diff --git a/internal/sdk/models/shared/dynamicduedate.go b/internal/sdk/models/shared/dynamicduedate.go index 919b9f1..2bc585b 100644 --- a/internal/sdk/models/shared/dynamicduedate.go +++ b/internal/sdk/models/shared/dynamicduedate.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared @@ -36,9 +36,11 @@ func (e *ActionTypeCondition) UnmarshalJSON(data []byte) error { type TimePeriod string const ( - TimePeriodDays TimePeriod = "days" - TimePeriodWeeks TimePeriod = "weeks" - TimePeriodMonths TimePeriod = "months" + TimePeriodMinutes TimePeriod = "minutes" + TimePeriodHours TimePeriod = "hours" + TimePeriodDays TimePeriod = "days" + TimePeriodWeeks TimePeriod = "weeks" + TimePeriodMonths TimePeriod = "months" ) func (e TimePeriod) ToPointer() *TimePeriod { @@ -50,6 +52,10 @@ func (e *TimePeriod) UnmarshalJSON(data []byte) error { return err } switch v { + case "minutes": + fallthrough + case "hours": + fallthrough case "days": fallthrough case "weeks": @@ -64,22 +70,22 @@ func (e *TimePeriod) UnmarshalJSON(data []byte) error { // DynamicDueDate - set a Duedate for a step then a specific type DynamicDueDate struct { - ActionTypeCondition *ActionTypeCondition `json:"actionTypeCondition,omitempty"` - NumberOfUnits *float64 `json:"numberOfUnits,omitempty"` - StepID *string `json:"stepId,omitempty"` - TimePeriod *TimePeriod `json:"timePeriod,omitempty"` + ActionTypeCondition ActionTypeCondition `json:"actionTypeCondition"` + NumberOfUnits float64 `json:"numberOfUnits"` + StepID *string `json:"stepId,omitempty"` + TimePeriod TimePeriod `json:"timePeriod"` } -func (o *DynamicDueDate) GetActionTypeCondition() *ActionTypeCondition { +func (o *DynamicDueDate) GetActionTypeCondition() ActionTypeCondition { if o == nil { - return nil + return ActionTypeCondition("") } return o.ActionTypeCondition } -func (o *DynamicDueDate) GetNumberOfUnits() *float64 { +func (o *DynamicDueDate) GetNumberOfUnits() float64 { if o == nil { - return nil + return 0.0 } return o.NumberOfUnits } @@ -91,9 +97,9 @@ func (o *DynamicDueDate) GetStepID() *string { return o.StepID } -func (o *DynamicDueDate) GetTimePeriod() *TimePeriod { +func (o *DynamicDueDate) GetTimePeriod() TimePeriod { if o == nil { - return nil + return TimePeriod("") } return o.TimePeriod } diff --git a/internal/sdk/models/shared/ecpdetails.go b/internal/sdk/models/shared/ecpdetails.go new file mode 100644 index 0000000..8f32be9 --- /dev/null +++ b/internal/sdk/models/shared/ecpdetails.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ECPDetails - Details regarding ECP for the workflow step +type ECPDetails struct { + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + Label *string `json:"label,omitempty"` +} + +func (o *ECPDetails) GetDescription() *string { + if o == nil { + return nil + } + return o.Description +} + +func (o *ECPDetails) GetEnabled() *bool { + if o == nil { + return nil + } + return o.Enabled +} + +func (o *ECPDetails) GetJourney() *StepJourney { + if o == nil { + return nil + } + return o.Journey +} + +func (o *ECPDetails) GetLabel() *string { + if o == nil { + return nil + } + return o.Label +} diff --git a/internal/sdk/models/shared/edge.go b/internal/sdk/models/shared/edge.go new file mode 100644 index 0000000..7766ee8 --- /dev/null +++ b/internal/sdk/models/shared/edge.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Edge struct { + ConditionID *string `json:"condition_id,omitempty"` + FromID string `json:"from_id"` + ID string `json:"id"` + ToID string `json:"to_id"` +} + +func (o *Edge) GetConditionID() *string { + if o == nil { + return nil + } + return o.ConditionID +} + +func (o *Edge) GetFromID() string { + if o == nil { + return "" + } + return o.FromID +} + +func (o *Edge) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *Edge) GetToID() string { + if o == nil { + return "" + } + return o.ToID +} diff --git a/internal/sdk/models/shared/enablerequirement.go b/internal/sdk/models/shared/enablerequirement.go new file mode 100644 index 0000000..5285e5a --- /dev/null +++ b/internal/sdk/models/shared/enablerequirement.go @@ -0,0 +1,62 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type When string + +const ( + WhenTaskFinished When = "TASK_FINISHED" + WhenPhaseFinished When = "PHASE_FINISHED" +) + +func (e When) ToPointer() *When { + return &e +} +func (e *When) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "TASK_FINISHED": + fallthrough + case "PHASE_FINISHED": + *e = When(v) + return nil + default: + return fmt.Errorf("invalid value for When: %v", v) + } +} + +// EnableRequirement - describe the requirement for a task to be enabled +type EnableRequirement struct { + PhaseID *string `json:"phase_id,omitempty"` + TaskID *string `json:"task_id,omitempty"` + When When `json:"when"` +} + +func (o *EnableRequirement) GetPhaseID() *string { + if o == nil { + return nil + } + return o.PhaseID +} + +func (o *EnableRequirement) GetTaskID() *string { + if o == nil { + return nil + } + return o.TaskID +} + +func (o *EnableRequirement) GetWhen() When { + if o == nil { + return When("") + } + return o.When +} diff --git a/internal/sdk/models/shared/errorresp.go b/internal/sdk/models/shared/errorresp.go index 499c86a..4f53535 100644 --- a/internal/sdk/models/shared/errorresp.go +++ b/internal/sdk/models/shared/errorresp.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/evaluationsource.go b/internal/sdk/models/shared/evaluationsource.go new file mode 100644 index 0000000..bbdfa9a --- /dev/null +++ b/internal/sdk/models/shared/evaluationsource.go @@ -0,0 +1,243 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type AttributeOperation string + +const ( + AttributeOperationAll AttributeOperation = "all" + AttributeOperationUpdated AttributeOperation = "updated" + AttributeOperationAdded AttributeOperation = "added" + AttributeOperationDeleted AttributeOperation = "deleted" +) + +func (e AttributeOperation) ToPointer() *AttributeOperation { + return &e +} +func (e *AttributeOperation) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "all": + fallthrough + case "updated": + fallthrough + case "added": + fallthrough + case "deleted": + *e = AttributeOperation(v) + return nil + default: + return fmt.Errorf("invalid value for AttributeOperation: %v", v) + } +} + +type AttributeType string + +const ( + AttributeTypeString AttributeType = "string" + AttributeTypeText AttributeType = "text" + AttributeTypeNumber AttributeType = "number" + AttributeTypeBoolean AttributeType = "boolean" + AttributeTypeDate AttributeType = "date" + AttributeTypeDatetime AttributeType = "datetime" + AttributeTypeTags AttributeType = "tags" + AttributeTypeCountry AttributeType = "country" + AttributeTypeEmail AttributeType = "email" + AttributeTypePhone AttributeType = "phone" + AttributeTypeProduct AttributeType = "product" + AttributeTypePrice AttributeType = "price" + AttributeTypeStatus AttributeType = "status" + AttributeTypeRelation AttributeType = "relation" + AttributeTypeMultiselect AttributeType = "multiselect" + AttributeTypeSelect AttributeType = "select" + AttributeTypeRadio AttributeType = "radio" + AttributeTypeRelationUser AttributeType = "relation_user" + AttributeTypePurpose AttributeType = "purpose" + AttributeTypeLabel AttributeType = "label" +) + +func (e AttributeType) ToPointer() *AttributeType { + return &e +} +func (e *AttributeType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "string": + fallthrough + case "text": + fallthrough + case "number": + fallthrough + case "boolean": + fallthrough + case "date": + fallthrough + case "datetime": + fallthrough + case "tags": + fallthrough + case "country": + fallthrough + case "email": + fallthrough + case "phone": + fallthrough + case "product": + fallthrough + case "price": + fallthrough + case "status": + fallthrough + case "relation": + fallthrough + case "multiselect": + fallthrough + case "select": + fallthrough + case "radio": + fallthrough + case "relation_user": + fallthrough + case "purpose": + fallthrough + case "label": + *e = AttributeType(v) + return nil + default: + return fmt.Errorf("invalid value for AttributeType: %v", v) + } +} + +type Origin string + +const ( + OriginTrigger Origin = "trigger" + OriginAction Origin = "action" +) + +func (e Origin) ToPointer() *Origin { + return &e +} +func (e *Origin) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "trigger": + fallthrough + case "action": + *e = Origin(v) + return nil + default: + return fmt.Errorf("invalid value for Origin: %v", v) + } +} + +type OriginType string + +const ( + OriginTypeEntity OriginType = "entity" + OriginTypeWorkflow OriginType = "workflow" + OriginTypeJourneyBlock OriginType = "journey_block" +) + +func (e OriginType) ToPointer() *OriginType { + return &e +} +func (e *OriginType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "entity": + fallthrough + case "workflow": + fallthrough + case "journey_block": + *e = OriginType(v) + return nil + default: + return fmt.Errorf("invalid value for OriginType: %v", v) + } +} + +type EvaluationSource struct { + Attribute *string `json:"attribute,omitempty"` + AttributeOperation *AttributeOperation `json:"attribute_operation,omitempty"` + AttributeRepeatable *bool `json:"attribute_repeatable,omitempty"` + AttributeType *AttributeType `json:"attribute_type,omitempty"` + // The id of the action or trigger + ID *string `json:"id,omitempty"` + Origin *Origin `json:"origin,omitempty"` + OriginType *OriginType `json:"origin_type,omitempty"` + Schema *string `json:"schema,omitempty"` +} + +func (o *EvaluationSource) GetAttribute() *string { + if o == nil { + return nil + } + return o.Attribute +} + +func (o *EvaluationSource) GetAttributeOperation() *AttributeOperation { + if o == nil { + return nil + } + return o.AttributeOperation +} + +func (o *EvaluationSource) GetAttributeRepeatable() *bool { + if o == nil { + return nil + } + return o.AttributeRepeatable +} + +func (o *EvaluationSource) GetAttributeType() *AttributeType { + if o == nil { + return nil + } + return o.AttributeType +} + +func (o *EvaluationSource) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *EvaluationSource) GetOrigin() *Origin { + if o == nil { + return nil + } + return o.Origin +} + +func (o *EvaluationSource) GetOriginType() *OriginType { + if o == nil { + return nil + } + return o.OriginType +} + +func (o *EvaluationSource) GetSchema() *string { + if o == nil { + return nil + } + return o.Schema +} diff --git a/internal/sdk/models/shared/flowtemplate.go b/internal/sdk/models/shared/flowtemplate.go new file mode 100644 index 0000000..118ae1f --- /dev/null +++ b/internal/sdk/models/shared/flowtemplate.go @@ -0,0 +1,155 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +type FlowTemplate struct { + AssignedTo []string `json:"assigned_to,omitempty"` + // Indicates whether this workflow is available for End Customer Portal or not. By default it's not. + AvailableInEcp *bool `json:"available_in_ecp,omitempty"` + ClosingReasons []ClosingReasonID `json:"closing_reasons,omitempty"` + // ISO String Date & Time + CreatedAt *string `json:"created_at,omitempty"` + 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"` + // Whether the workflow is enabled or not + Enabled *bool `default:"true" json:"enabled"` + ID *string `json:"id,omitempty"` + Name string `json:"name"` + Phases []Phase `json:"phases,omitempty"` + Tasks []Task `json:"tasks"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` + UpdateEntityAttributes []UpdateEntityAttributes `json:"update_entity_attributes,omitempty"` + // ISO String Date & Time + UpdatedAt *string `json:"updated_at,omitempty"` +} + +func (f FlowTemplate) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(f, "", false) +} + +func (f *FlowTemplate) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &f, "", false, false); err != nil { + return err + } + return nil +} + +func (o *FlowTemplate) GetAssignedTo() []string { + if o == nil { + return nil + } + return o.AssignedTo +} + +func (o *FlowTemplate) GetAvailableInEcp() *bool { + if o == nil { + return nil + } + return o.AvailableInEcp +} + +func (o *FlowTemplate) GetClosingReasons() []ClosingReasonID { + if o == nil { + return nil + } + return o.ClosingReasons +} + +func (o *FlowTemplate) GetCreatedAt() *string { + if o == nil { + return nil + } + return o.CreatedAt +} + +func (o *FlowTemplate) GetDescription() *string { + if o == nil { + return nil + } + return o.Description +} + +func (o *FlowTemplate) GetDueDate() *string { + if o == nil { + return nil + } + return o.DueDate +} + +func (o *FlowTemplate) GetDynamicDueDate() *DueDateConfig { + if o == nil { + return nil + } + return o.DynamicDueDate +} + +func (o *FlowTemplate) GetEdges() []Edge { + if o == nil { + return []Edge{} + } + return o.Edges +} + +func (o *FlowTemplate) GetEnabled() *bool { + if o == nil { + return nil + } + return o.Enabled +} + +func (o *FlowTemplate) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *FlowTemplate) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *FlowTemplate) GetPhases() []Phase { + if o == nil { + return nil + } + return o.Phases +} + +func (o *FlowTemplate) GetTasks() []Task { + if o == nil { + return []Task{} + } + return o.Tasks +} + +func (o *FlowTemplate) GetTaxonomies() []string { + if o == nil { + return nil + } + return o.Taxonomies +} + +func (o *FlowTemplate) GetUpdateEntityAttributes() []UpdateEntityAttributes { + if o == nil { + return nil + } + return o.UpdateEntityAttributes +} + +func (o *FlowTemplate) GetUpdatedAt() *string { + if o == nil { + return nil + } + return o.UpdatedAt +} diff --git a/internal/sdk/models/shared/flowtemplateslist.go b/internal/sdk/models/shared/flowtemplateslist.go new file mode 100644 index 0000000..bebfa65 --- /dev/null +++ b/internal/sdk/models/shared/flowtemplateslist.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type FlowTemplatesList struct { + Results []FlowTemplate `json:"results"` +} + +func (o *FlowTemplatesList) GetResults() []FlowTemplate { + if o == nil { + return []FlowTemplate{} + } + return o.Results +} diff --git a/internal/sdk/models/shared/maxallowedlimit.go b/internal/sdk/models/shared/maxallowedlimit.go index 440935d..40dc1fa 100644 --- a/internal/sdk/models/shared/maxallowedlimit.go +++ b/internal/sdk/models/shared/maxallowedlimit.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/operator.go b/internal/sdk/models/shared/operator.go new file mode 100644 index 0000000..bdbbab4 --- /dev/null +++ b/internal/sdk/models/shared/operator.go @@ -0,0 +1,70 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type Operator string + +const ( + OperatorEquals Operator = "equals" + OperatorNotEquals Operator = "not_equals" + OperatorAnyOf Operator = "any_of" + OperatorNoneOf Operator = "none_of" + OperatorContains Operator = "contains" + OperatorNotContains Operator = "not_contains" + OperatorStartsWith Operator = "starts_with" + OperatorEndsWith Operator = "ends_with" + OperatorGreaterThan Operator = "greater_than" + OperatorLessThan Operator = "less_than" + OperatorGreaterThanOrEquals Operator = "greater_than_or_equals" + OperatorLessThanOrEquals Operator = "less_than_or_equals" + OperatorIsEmpty Operator = "is_empty" + OperatorIsNotEmpty Operator = "is_not_empty" +) + +func (e Operator) ToPointer() *Operator { + return &e +} +func (e *Operator) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "equals": + fallthrough + case "not_equals": + fallthrough + case "any_of": + fallthrough + case "none_of": + fallthrough + case "contains": + fallthrough + case "not_contains": + fallthrough + case "starts_with": + fallthrough + case "ends_with": + fallthrough + case "greater_than": + fallthrough + case "less_than": + fallthrough + case "greater_than_or_equals": + fallthrough + case "less_than_or_equals": + fallthrough + case "is_empty": + fallthrough + case "is_not_empty": + *e = Operator(v) + return nil + default: + return fmt.Errorf("invalid value for Operator: %v", v) + } +} diff --git a/internal/sdk/models/shared/phase.go b/internal/sdk/models/shared/phase.go new file mode 100644 index 0000000..fcd1c41 --- /dev/null +++ b/internal/sdk/models/shared/phase.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +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"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` +} + +func (o *Phase) GetAssignedTo() []string { + if o == nil { + return nil + } + return o.AssignedTo +} + +func (o *Phase) GetDueDate() *string { + if o == nil { + return nil + } + return o.DueDate +} + +func (o *Phase) GetDynamicDueDate() *DueDateConfig { + if o == nil { + return nil + } + return o.DynamicDueDate +} + +func (o *Phase) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *Phase) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Phase) GetTaxonomies() []string { + if o == nil { + return nil + } + return o.Taxonomies +} diff --git a/internal/sdk/models/shared/security.go b/internal/sdk/models/shared/security.go index 194e081..d0fe761 100644 --- a/internal/sdk/models/shared/security.go +++ b/internal/sdk/models/shared/security.go @@ -1,14 +1,14 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared type Security struct { - BearerAuth string `security:"scheme,type=http,subtype=bearer,name=Authorization"` + BearerAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` } -func (o *Security) GetBearerAuth() string { +func (o *Security) GetBearerAuth() *string { if o == nil { - return "" + return nil } return o.BearerAuth } diff --git a/internal/sdk/models/shared/statement.go b/internal/sdk/models/shared/statement.go new file mode 100644 index 0000000..46e0b5b --- /dev/null +++ b/internal/sdk/models/shared/statement.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type Statement struct { + ID string `json:"id"` + Operator Operator `json:"operator"` + Source EvaluationSource `json:"source"` + Values []string `json:"values"` +} + +func (o *Statement) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *Statement) GetOperator() Operator { + if o == nil { + return Operator("") + } + return o.Operator +} + +func (o *Statement) GetSource() EvaluationSource { + if o == nil { + return EvaluationSource{} + } + return o.Source +} + +func (o *Statement) GetValues() []string { + if o == nil { + return []string{} + } + return o.Values +} diff --git a/internal/sdk/models/shared/stepdescription.go b/internal/sdk/models/shared/stepdescription.go new file mode 100644 index 0000000..14576d5 --- /dev/null +++ b/internal/sdk/models/shared/stepdescription.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// StepDescription - Longer information regarding Task +type StepDescription struct { + Enabled *bool `json:"enabled,omitempty"` + Value *string `json:"value,omitempty"` +} + +func (o *StepDescription) GetEnabled() *bool { + if o == nil { + return nil + } + return o.Enabled +} + +func (o *StepDescription) GetValue() *string { + if o == nil { + return nil + } + return o.Value +} diff --git a/internal/sdk/models/shared/stepjourney.go b/internal/sdk/models/shared/stepjourney.go new file mode 100644 index 0000000..0b384d2 --- /dev/null +++ b/internal/sdk/models/shared/stepjourney.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type StepJourney struct { + ID *string `json:"id,omitempty"` + JourneyID *string `json:"journeyId,omitempty"` + Name *string `json:"name,omitempty"` +} + +func (o *StepJourney) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *StepJourney) GetJourneyID() *string { + if o == nil { + return nil + } + return o.JourneyID +} + +func (o *StepJourney) GetName() *string { + if o == nil { + return nil + } + return o.Name +} diff --git a/internal/sdk/models/shared/task.go b/internal/sdk/models/shared/task.go new file mode 100644 index 0000000..5516ce2 --- /dev/null +++ b/internal/sdk/models/shared/task.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + +type TaskUnionType string + +const ( + TaskUnionTypeTaskBase TaskUnionType = "TaskBase" + TaskUnionTypeAutomationTask TaskUnionType = "AutomationTask" + TaskUnionTypeDecisionTask TaskUnionType = "DecisionTask" +) + +type Task struct { + TaskBase *TaskBase + AutomationTask *AutomationTask + DecisionTask *DecisionTask + + Type TaskUnionType +} + +func CreateTaskTaskBase(taskBase TaskBase) Task { + typ := TaskUnionTypeTaskBase + + return Task{ + TaskBase: &taskBase, + Type: typ, + } +} + +func CreateTaskAutomationTask(automationTask AutomationTask) Task { + typ := TaskUnionTypeAutomationTask + + return Task{ + AutomationTask: &automationTask, + Type: typ, + } +} + +func CreateTaskDecisionTask(decisionTask DecisionTask) Task { + typ := TaskUnionTypeDecisionTask + + return Task{ + DecisionTask: &decisionTask, + Type: typ, + } +} + +func (u *Task) UnmarshalJSON(data []byte) error { + + var taskBase TaskBase = TaskBase{} + if err := utils.UnmarshalJSON(data, &taskBase, "", true, true); err == nil { + u.TaskBase = &taskBase + u.Type = TaskUnionTypeTaskBase + return nil + } + + var automationTask AutomationTask = AutomationTask{} + if err := utils.UnmarshalJSON(data, &automationTask, "", true, true); err == nil { + u.AutomationTask = &automationTask + u.Type = TaskUnionTypeAutomationTask + return nil + } + + var decisionTask DecisionTask = DecisionTask{} + if err := utils.UnmarshalJSON(data, &decisionTask, "", true, true); err == nil { + u.DecisionTask = &decisionTask + u.Type = TaskUnionTypeDecisionTask + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Task", string(data)) +} + +func (u Task) MarshalJSON() ([]byte, error) { + if u.TaskBase != nil { + return utils.MarshalJSON(u.TaskBase, "", true) + } + + if u.AutomationTask != nil { + return utils.MarshalJSON(u.AutomationTask, "", true) + } + + if u.DecisionTask != nil { + return utils.MarshalJSON(u.DecisionTask, "", true) + } + + return nil, errors.New("could not marshal union type Task: all fields are null") +} diff --git a/internal/sdk/models/shared/taskbase.go b/internal/sdk/models/shared/taskbase.go new file mode 100644 index 0000000..68756e0 --- /dev/null +++ b/internal/sdk/models/shared/taskbase.go @@ -0,0 +1,116 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type TaskBase struct { + AssignedTo []string `json:"assigned_to,omitempty"` + // Longer information regarding Task + 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"` + // Details regarding ECP for the workflow step + Ecp *ECPDetails `json:"ecp,omitempty"` + ID string `json:"id"` + // Details regarding ECP for the workflow step + Installer *ECPDetails `json:"installer,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + Name string `json:"name"` + PhaseID *string `json:"phase_id,omitempty"` + // requirements that need to be fulfilled in order to enable the task while flow instances are running + Requirements []EnableRequirement `json:"requirements,omitempty"` + TaskType TaskType `json:"task_type"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` +} + +func (o *TaskBase) GetAssignedTo() []string { + if o == nil { + return nil + } + return o.AssignedTo +} + +func (o *TaskBase) GetDescription() *StepDescription { + if o == nil { + return nil + } + return o.Description +} + +func (o *TaskBase) GetDueDate() *string { + if o == nil { + return nil + } + return o.DueDate +} + +func (o *TaskBase) GetDynamicDueDate() *DueDateConfig { + if o == nil { + return nil + } + return o.DynamicDueDate +} + +func (o *TaskBase) GetEcp() *ECPDetails { + if o == nil { + return nil + } + return o.Ecp +} + +func (o *TaskBase) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *TaskBase) GetInstaller() *ECPDetails { + if o == nil { + return nil + } + return o.Installer +} + +func (o *TaskBase) GetJourney() *StepJourney { + if o == nil { + return nil + } + return o.Journey +} + +func (o *TaskBase) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *TaskBase) GetPhaseID() *string { + if o == nil { + return nil + } + return o.PhaseID +} + +func (o *TaskBase) GetRequirements() []EnableRequirement { + if o == nil { + return nil + } + return o.Requirements +} + +func (o *TaskBase) GetTaskType() TaskType { + if o == nil { + return TaskType("") + } + return o.TaskType +} + +func (o *TaskBase) GetTaxonomies() []string { + if o == nil { + return nil + } + return o.Taxonomies +} diff --git a/internal/sdk/models/shared/tasktype.go b/internal/sdk/models/shared/tasktype.go new file mode 100644 index 0000000..e5d94ba --- /dev/null +++ b/internal/sdk/models/shared/tasktype.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type TaskType string + +const ( + TaskTypeManual TaskType = "MANUAL" + TaskTypeAutomation TaskType = "AUTOMATION" + TaskTypeDecision TaskType = "DECISION" +) + +func (e TaskType) ToPointer() *TaskType { + return &e +} +func (e *TaskType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "MANUAL": + fallthrough + case "AUTOMATION": + fallthrough + case "DECISION": + *e = TaskType(v) + return nil + default: + return fmt.Errorf("invalid value for TaskType: %v", v) + } +} diff --git a/internal/sdk/models/shared/updateentityattributes.go b/internal/sdk/models/shared/updateentityattributes.go index 4b1a63e..bd54844 100644 --- a/internal/sdk/models/shared/updateentityattributes.go +++ b/internal/sdk/models/shared/updateentityattributes.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/workflowdefinition.go b/internal/sdk/models/shared/workflowdefinition.go index 63f792b..fe1090f 100644 --- a/internal/sdk/models/shared/workflowdefinition.go +++ b/internal/sdk/models/shared/workflowdefinition.go @@ -1,7 +1,11 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package shared +import ( + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" +) + type WorkflowDefinition struct { AssignedTo []string `json:"assignedTo,omitempty"` ClosingReasons []ClosingReasonID `json:"closingReasons,omitempty"` @@ -12,12 +16,16 @@ type WorkflowDefinition struct { // set a Duedate for a step then a specific DynamicDueDate *DynamicDueDate `json:"dynamicDueDate,omitempty"` // Indicates whether this workflow is available for End Customer Portal or not. By default it's not. - EnableECPWorkflow *bool `json:"enableECPWorkflow,omitempty"` - Flow any `json:"flow"` - ID *string `json:"id,omitempty"` + EnableECPWorkflow *bool `json:"enableECPWorkflow,omitempty"` + // Whether the workflow is enabled or not + Enabled *bool `default:"true" json:"enabled"` + Flow any `json:"flow"` + ID *string `json:"id,omitempty"` // ISO String Date & Time - LastUpdateTime *string `json:"lastUpdateTime,omitempty"` - Name string `json:"name"` + LastUpdateTime *string `json:"lastUpdateTime,omitempty"` + Name string `json:"name"` + // Taxonomy ids that are associated with this workflow and used for filtering + Taxonomies []string `json:"taxonomies,omitempty"` UpdateEntityAttributes []UpdateEntityAttributes `json:"updateEntityAttributes,omitempty"` // This field is deprecated. Please use assignedTo // @@ -25,6 +33,17 @@ type WorkflowDefinition struct { UserIds []float64 `json:"userIds,omitempty"` } +func (w WorkflowDefinition) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(w, "", false) +} + +func (w *WorkflowDefinition) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &w, "", false, false); err != nil { + return err + } + return nil +} + func (o *WorkflowDefinition) GetAssignedTo() []string { if o == nil { return nil @@ -74,6 +93,13 @@ func (o *WorkflowDefinition) GetEnableECPWorkflow() *bool { return o.EnableECPWorkflow } +func (o *WorkflowDefinition) GetEnabled() *bool { + if o == nil { + return nil + } + return o.Enabled +} + func (o *WorkflowDefinition) GetFlow() any { if o == nil { return nil @@ -102,6 +128,13 @@ func (o *WorkflowDefinition) GetName() string { return o.Name } +func (o *WorkflowDefinition) GetTaxonomies() []string { + if o == nil { + return nil + } + return o.Taxonomies +} + func (o *WorkflowDefinition) GetUpdateEntityAttributes() []UpdateEntityAttributes { if o == nil { return nil diff --git a/internal/sdk/retry/config.go b/internal/sdk/retry/config.go index a9b559b..c051b0a 100644 --- a/internal/sdk/retry/config.go +++ b/internal/sdk/retry/config.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package retry diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 29192d3..e4e4c9b 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package sdk @@ -41,6 +41,9 @@ 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) @@ -68,6 +71,7 @@ func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { type SDK struct { ClosingReason *ClosingReason Workflows *Workflows + FlowsV2 *FlowsV2 sdkConfiguration sdkConfiguration } @@ -146,8 +150,8 @@ func New(opts ...SDKOption) *SDK { Language: "go", OpenAPIDocVersion: "1.0.0", SDKVersion: "0.0.1", - GenVersion: "2.379.3", - UserAgent: "speakeasy-sdk/go 0.0.1 2.379.3 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", + 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", Hooks: hooks.New(), }, } @@ -171,5 +175,7 @@ func New(opts ...SDKOption) *SDK { sdk.Workflows = newWorkflows(sdk.sdkConfiguration) + sdk.FlowsV2 = newFlowsV2(sdk.sdkConfiguration) + return sdk } diff --git a/internal/sdk/types/bigint.go b/internal/sdk/types/bigint.go index 4765ef2..9c6a086 100644 --- a/internal/sdk/types/bigint.go +++ b/internal/sdk/types/bigint.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/date.go b/internal/sdk/types/date.go index 131f364..5b2782f 100644 --- a/internal/sdk/types/date.go +++ b/internal/sdk/types/date.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/datetime.go b/internal/sdk/types/datetime.go index c07ddcd..3eff332 100644 --- a/internal/sdk/types/datetime.go +++ b/internal/sdk/types/datetime.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/decimal.go b/internal/sdk/types/decimal.go index f7def72..d8429bc 100644 --- a/internal/sdk/types/decimal.go +++ b/internal/sdk/types/decimal.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/pointers.go b/internal/sdk/types/pointers.go index 1ed80cf..35c439d 100644 --- a/internal/sdk/types/pointers.go +++ b/internal/sdk/types/pointers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types @@ -8,3 +8,4 @@ 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 e5bb013..58aab7a 100644 --- a/internal/sdk/workflows.go +++ b/internal/sdk/workflows.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package sdk @@ -6,12 +6,13 @@ import ( "bytes" "context" "fmt" + "github.com/cenkalti/backoff/v4" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "io" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" "net/http" "net/url" ) @@ -38,6 +39,7 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -81,33 +83,95 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.CreateDefinitionResponse{ @@ -116,17 +180,15 @@ 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 @@ -134,6 +196,10 @@ 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: @@ -143,6 +209,11 @@ 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 @@ -150,9 +221,17 @@ 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) } @@ -172,6 +251,7 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -209,33 +289,95 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.DeleteDefinitionResponse{ @@ -244,13 +386,6 @@ 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 @@ -258,6 +393,11 @@ 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 @@ -265,9 +405,17 @@ 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) } @@ -287,6 +435,7 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -324,33 +473,95 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.GetDefinitionResponse{ @@ -359,17 +570,15 @@ 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 @@ -377,6 +586,10 @@ 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: @@ -386,6 +599,11 @@ 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 @@ -393,11 +611,20 @@ 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 @@ -405,9 +632,17 @@ 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) } @@ -427,6 +662,7 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -464,33 +700,95 @@ func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Optio return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.GetDefinitionsResponse{ @@ -499,17 +797,15 @@ 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 @@ -517,11 +813,20 @@ 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 @@ -529,9 +834,17 @@ 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) } @@ -551,6 +864,7 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -588,33 +902,95 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.O return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.GetMaxAllowedLimitResponse{ @@ -623,17 +999,15 @@ 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 @@ -641,11 +1015,20 @@ 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 @@ -653,9 +1036,365 @@ 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) + } + + return res, nil + +} + +// GetWorkflowClosingReasons - getWorkflowClosingReasons +// Returns all closing reasons defined for the workflow. +func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request operations.GetWorkflowClosingReasonsRequest, opts ...operations.Option) (*operations.GetWorkflowClosingReasonsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getWorkflowClosingReasons", + 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/definitions/{definitionId}/closing-reasons", 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.GetWorkflowClosingReasonsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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 + } + + 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) + } + + return res, nil + +} + +// SetWorkflowClosingReasons - setWorkflowClosingReasons +// Sets which closing reasons are defined for this workflow, based on the entire closing reasons catalog. +func (s *Workflows) SetWorkflowClosingReasons(ctx context.Context, request operations.SetWorkflowClosingReasonsRequest, opts ...operations.Option) (*operations.SetWorkflowClosingReasonsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "setWorkflowClosingReasons", + 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/definitions/{definitionId}/closing-reasons", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "ClosingReasonsIds", "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", "*/*") + 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.SetWorkflowClosingReasonsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + 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) } @@ -675,6 +1414,7 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd o := operations.Options{} supportedOptions := []string{ + operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -718,33 +1458,95 @@ func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.Upd return nil, err } - 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) + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig } else { - err = fmt.Errorf("error sending request: no response") + 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 + }) - _, 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 + } } } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + 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.UpdateDefinitionResponse{ @@ -753,17 +1555,15 @@ 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 @@ -771,6 +1571,10 @@ 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: @@ -780,6 +1584,11 @@ 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 @@ -787,9 +1596,17 @@ 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/internal/validators/DateValidator.go b/internal/validators/DateValidator.go index 1bd2815..ab0e8cd 100644 --- a/internal/validators/DateValidator.go +++ b/internal/validators/DateValidator.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package validators diff --git a/internal/validators/ExactlyOneChild.go b/internal/validators/ExactlyOneChild.go index dc9cd6a..1765a3a 100644 --- a/internal/validators/ExactlyOneChild.go +++ b/internal/validators/ExactlyOneChild.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package validators diff --git a/internal/validators/JSONParseValidator.go b/internal/validators/JSONParseValidator.go index cb680b9..b8bb96b 100644 --- a/internal/validators/JSONParseValidator.go +++ b/internal/validators/JSONParseValidator.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package validators diff --git a/internal/validators/RFC3339Validator.go b/internal/validators/RFC3339Validator.go index 888f85c..f5e6146 100644 --- a/internal/validators/RFC3339Validator.go +++ b/internal/validators/RFC3339Validator.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package validators diff --git a/internal/validators/boolvalidators/not_null.go b/internal/validators/boolvalidators/not_null.go index de7f756..6eca17e 100644 --- a/internal/validators/boolvalidators/not_null.go +++ b/internal/validators/boolvalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package boolvalidators diff --git a/internal/validators/float64validators/not_null.go b/internal/validators/float64validators/not_null.go index fed2c05..8f786d2 100644 --- a/internal/validators/float64validators/not_null.go +++ b/internal/validators/float64validators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package float64validators diff --git a/internal/validators/int64validators/not_null.go b/internal/validators/int64validators/not_null.go index c07e1de..707ff95 100644 --- a/internal/validators/int64validators/not_null.go +++ b/internal/validators/int64validators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package int64validators diff --git a/internal/validators/listvalidators/not_null.go b/internal/validators/listvalidators/not_null.go index f39d6fa..9b88e52 100644 --- a/internal/validators/listvalidators/not_null.go +++ b/internal/validators/listvalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package listvalidators diff --git a/internal/validators/mapvalidators/not_null.go b/internal/validators/mapvalidators/not_null.go index 9cdf99e..dc6959e 100644 --- a/internal/validators/mapvalidators/not_null.go +++ b/internal/validators/mapvalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package mapvalidators diff --git a/internal/validators/numbervalidators/not_null.go b/internal/validators/numbervalidators/not_null.go index e2baffe..57d4da0 100644 --- a/internal/validators/numbervalidators/not_null.go +++ b/internal/validators/numbervalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package numbervalidators diff --git a/internal/validators/objectvalidators/not_null.go b/internal/validators/objectvalidators/not_null.go index 480ec23..bf01894 100644 --- a/internal/validators/objectvalidators/not_null.go +++ b/internal/validators/objectvalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package objectvalidators diff --git a/internal/validators/setvalidators/not_null.go b/internal/validators/setvalidators/not_null.go index 45369e3..f859d64 100644 --- a/internal/validators/setvalidators/not_null.go +++ b/internal/validators/setvalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package setvalidators diff --git a/internal/validators/stringvalidators/not_null.go b/internal/validators/stringvalidators/not_null.go index ce5f808..1e40ac1 100644 --- a/internal/validators/stringvalidators/not_null.go +++ b/internal/validators/stringvalidators/not_null.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package stringvalidators diff --git a/main.go b/main.go index 515bdb0..ed51759 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package main diff --git a/original.yaml b/original.yaml new file mode 100644 index 0000000..e69de29 diff --git a/overlay.yaml b/overlay.yaml new file mode 100644 index 0000000..ad292de --- /dev/null +++ b/overlay.yaml @@ -0,0 +1,63 @@ +overlay: 1.0.0 +info: + title: Overlay epilot schema to make a schema resource + version: 0.0.1 +actions: + - target: $ + update: + 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 + # Workflow Definitions + - target: $["paths"]["/v1/workflows/definitions/{definitionId}"]["get"] + update: + x-speakeasy-entity-operation: WorkflowDefinition#get + - target: $["paths"]["/v1/workflows/definitions"]["post"] + update: + x-speakeasy-entity-operation: WorkflowDefinition#create + - target: $["paths"]["/v1/workflows/definitions/{definitionId}"]["put"] + update: + x-speakeasy-entity-operation: WorkflowDefinition#update + - target: $["paths"]["/v1/workflows/definitions/{definitionId}"]["delete"] + update: + x-speakeasy-entity-operation: WorkflowDefinition#delete + + - target: $["components"]["schemas"]["WorkflowDefinition"] + update: + x-speakeasy-entity: WorkflowDefinition + - target: $["paths"]["/v1/workflows/definitions/{definitionId}"]["get"]["parameters"][0] + update: + x-speakeasy-match: id + - target: $["paths"]["/v1/workflows/definitions/{definitionId}"]["put"]["parameters"][0] + update: + x-speakeasy-match: id + - target: $["paths"]["/v1/workflows/definitions/{definitionId}"]["delete"]["parameters"][0] + update: + x-speakeasy-match: id + + # jsonencode workflows definiton flows due to type incompatibilities + - target: $["components"]["schemas"]["WorkflowDefinition"]["properties"]["flow"] + update: + x-speakeasy-type-override: any + + +# Closing reasons + - target: $["paths"]["/v1/workflows/closing-reasons/{reasonId}"]["get"] + update: + x-speakeasy-entity-operation: ClosingReason#get + - target: $["paths"]["/v1/workflows/closing-reasons"]["post"] + update: + x-speakeasy-entity-operation: ClosingReason#create + - target: $["paths"]["/v1/workflows/closing-reasons/{reasonId}"]["get"]["parameters"][0] + update: + x-speakeasy-match: id + - target: $["components"]["schemas"]["ClosingReason"] + update: + x-speakeasy-entity: ClosingReason \ No newline at end of file diff --git a/tools/tools.go b/tools/tools.go index 08da0fd..36b2580 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. //go:build tools diff --git a/workflow.yaml b/workflow.yaml index 0ba5354..92a7534 100644 --- a/workflow.yaml +++ b/workflow.yaml @@ -97,7 +97,6 @@ paths: $ref: "#/components/schemas/ErrorResp" post: operationId: createDefinition - x-speakeasy-entity-operation: WorkflowDefinition#create summary: createDefinition description: Create a Workflow Definition. tags: @@ -199,10 +198,181 @@ paths: 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 - x-speakeasy-entity-operation: WorkflowDefinition#get summary: getDefinition description: Get specific Definition by id from the Organization. tags: @@ -210,7 +380,6 @@ paths: parameters: - in: path name: definitionId - x-speakeasy-match: id schema: type: string required: true @@ -290,7 +459,6 @@ paths: $ref: "#/components/schemas/ErrorResp" put: operationId: updateDefinition - x-speakeasy-entity-operation: WorkflowDefinition#update summary: updateDefinition description: Update Workflow Definition. tags: @@ -298,7 +466,6 @@ paths: parameters: - in: path name: definitionId - x-speakeasy-match: id schema: type: string required: true @@ -408,7 +575,6 @@ paths: $ref: "#/components/schemas/ErrorResp" delete: operationId: deleteDefinition - x-speakeasy-entity-operation: WorkflowDefinition#delete summary: deleteDefinition description: Delete Workflow Definition. tags: @@ -416,7 +582,6 @@ paths: parameters: - in: path name: definitionId - x-speakeasy-match: id schema: type: string required: true @@ -458,7 +623,6 @@ paths: $ref: "#/components/schemas/ClosingReasons" post: operationId: createClosingReason - x-speakeasy-entity-operation: ClosingReason#create summary: createClosingReason description: A created Closing Reason is stored for the organization and will be displayed in the library of reasons. tags: @@ -484,7 +648,6 @@ paths: /v1/workflows/closing-reasons/{reasonId}: get: operationId: getClosingReason - x-speakeasy-entity-operation: ClosingReason#get summary: getClosingReason description: Get specific closing reason by id from the organisation. tags: @@ -492,7 +655,6 @@ paths: parameters: - in: path name: reasonId - x-speakeasy-match: id schema: type: string required: true @@ -570,6 +732,53 @@ paths: 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: @@ -578,9 +787,374 @@ components: 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" + dynamic_due_date: + $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" + dynamic_due_date: + $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" + dynamic_due_date: + $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 - x-speakeasy-entity: WorkflowDefinition properties: id: type: string @@ -592,6 +1166,10 @@ components: type: string description: ISO String Date & Time example: "2021-04-27T12:01:13.000Z" + enabled: + type: boolean + description: Whether the workflow is enabled or not + default: true lastUpdateTime: type: string description: ISO String Date & Time @@ -615,7 +1193,6 @@ components: type: boolean description: Indicates whether this workflow is available for End Customer Portal or not. By default it's not. flow: - x-speakeasy-type-override: any type: array items: anyOf: @@ -629,6 +1206,11 @@ components: type: array items: $ref: "#/components/schemas/UpdateEntityAttributes" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering required: - name - flow @@ -683,6 +1265,11 @@ components: $ref: "#/components/schemas/ECPDetails" installer: $ref: "#/components/schemas/ECPDetails" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering required: - name - order @@ -700,10 +1287,24 @@ components: type: number type: $ref: "#/components/schemas/ItemType" + dueDate: + type: string + example: "2021-04-27T12:00:00.000Z" + dynamicDueDate: + $ref: "#/components/schemas/DynamicDueDate" + assignedTo: + type: array + items: + type: string steps: type: array items: $ref: "#/components/schemas/Step" + taxonomies: + type: array + items: + type: string + description: Taxonomy ids that are associated with this workflow and used for filtering required: - name - order @@ -715,7 +1316,7 @@ components: enum: - STEP - SECTION - + StepType: type: string enum: @@ -768,6 +1369,12 @@ components: message: type: string + ClosingReasonNotFoundResp: + description: Closing reason could be not found + properties: + message: + type: string + ChangeReasonStatusReq: type: object properties: @@ -871,6 +1478,8 @@ components: timePeriod: type: string enum: + - minutes + - hours - days - weeks - months @@ -881,6 +1490,10 @@ components: - STEP_CLOSED stepId: type: string + required: + - numberOfUnits + - timePeriod + - actionTypeCondition StepRequirement: description: describe the requirement for step enablement @@ -898,9 +1511,3 @@ components: - definitionId - type - condition - - ClosingReasonNotFoundResp: - description: Closing reason could be not found - properties: - message: - type: string