From 8d7a72287073c44f7dad2b0703a15b3e451250f6 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Tue, 12 Nov 2024 00:29:33 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.438.1 --- .speakeasy/gen.lock | 227 ++++++---- .speakeasy/workflow.lock | 28 ++ .speakeasy/workflow.yaml | 3 + README.md | 63 ++- RELEASES.md | 12 +- docs/data-sources/closing_reason.md | 32 -- docs/data-sources/workflow_definition.md | 320 ------------- docs/index.md | 2 +- docs/resources/closing_reason.md | 46 -- docs/resources/workflow_definition.md | 410 ----------------- .../data-source.tf | 3 - .../data-source.tf | 3 - examples/provider/provider.tf | 2 +- .../epilot-workflow_closing_reason/import.sh | 1 - .../resource.tf | 8 - .../import.sh | 1 - .../resource.tf | 11 - gen.yaml | 4 +- go.mod | 76 ++-- go.sum | 298 ++++++------- .../boolplanmodifier/suppress_diff.go | 2 +- .../float64planmodifier/suppress_diff.go | 2 +- .../int64planmodifier/suppress_diff.go | 2 +- .../listplanmodifier/suppress_diff.go | 2 +- .../mapplanmodifier/suppress_diff.go | 2 +- .../numberplanmodifier/suppress_diff.go | 2 +- .../objectplanmodifier/suppress_diff.go | 2 +- .../setplanmodifier/suppress_diff.go | 2 +- .../stringplanmodifier/suppress_diff.go | 2 +- internal/planmodifiers/utils/state_check.go | 2 +- .../provider/closingreason_data_source.go | 139 ------ .../provider/closingreason_data_source_sdk.go | 18 - internal/provider/closingreason_resource.go | 266 ----------- .../provider/closingreason_resource_sdk.go | 49 -- internal/provider/provider.go | 29 +- internal/provider/reflect/diags.go | 2 +- internal/provider/reflect/doc.go | 2 +- .../provider/reflect/generic_attr_value.go | 2 +- internal/provider/reflect/helpers.go | 4 +- internal/provider/reflect/interfaces.go | 225 ++++++++-- internal/provider/reflect/into.go | 16 +- internal/provider/reflect/map.go | 105 ++++- internal/provider/reflect/number.go | 316 +++++++------ internal/provider/reflect/options.go | 6 +- internal/provider/reflect/outof.go | 2 +- internal/provider/reflect/pointer.go | 37 +- internal/provider/reflect/primitive.go | 64 ++- internal/provider/reflect/slice.go | 398 +++++++++++++---- internal/provider/reflect/struct.go | 70 ++- internal/provider/types/closing_reason_id.go | 9 - internal/provider/types/dynamic_due_date.go | 12 - internal/provider/types/target.go | 10 - .../types/update_entity_attributes.go | 10 - internal/provider/utils.go | 184 +++++++- .../workflowdefinition_data_source.go | 221 --------- .../workflowdefinition_data_source_sdk.go | 83 ---- .../provider/workflowdefinition_resource.go | 422 ------------------ .../workflowdefinition_resource_sdk.go | 204 --------- internal/sdk/closingreason.go | 197 ++------ internal/sdk/internal/hooks/hooks.go | 2 +- internal/sdk/internal/hooks/registration.go | 17 +- internal/sdk/internal/utils/contenttype.go | 2 +- internal/sdk/internal/utils/form.go | 2 +- internal/sdk/internal/utils/headers.go | 2 +- internal/sdk/internal/utils/json.go | 39 +- internal/sdk/internal/utils/pathparams.go | 2 +- internal/sdk/internal/utils/queryparams.go | 2 +- internal/sdk/internal/utils/requestbody.go | 29 +- internal/sdk/internal/utils/retries.go | 2 +- internal/sdk/internal/utils/security.go | 19 +- internal/sdk/internal/utils/utils.go | 16 +- internal/sdk/models/errors/sdkerror.go | 2 +- .../models/operations/changereasonstatus.go | 2 +- .../models/operations/createclosingreason.go | 2 +- .../sdk/models/operations/createdefinition.go | 2 +- .../sdk/models/operations/deletedefinition.go | 2 +- .../models/operations/getallclosingreasons.go | 2 +- .../sdk/models/operations/getclosingreason.go | 77 ---- .../sdk/models/operations/getdefinition.go | 2 +- .../sdk/models/operations/getdefinitions.go | 2 +- .../models/operations/getmaxallowedlimit.go | 2 +- .../operations/getworkflowclosingreasons.go | 59 +++ internal/sdk/models/operations/options.go | 33 +- .../operations/setworkflowclosingreasons.go | 59 +++ .../sdk/models/operations/updatedefinition.go | 2 +- .../models/shared/changereasonstatusreq.go | 2 +- internal/sdk/models/shared/closingreason.go | 2 +- internal/sdk/models/shared/closingreasonid.go | 2 +- .../shared/closingreasonnotfoundresp.go | 15 - internal/sdk/models/shared/closingreasons.go | 2 +- .../sdk/models/shared/closingreasonsids.go | 14 + .../sdk/models/shared/closingreasonsstatus.go | 2 +- .../models/shared/definitionnotfoundresp.go | 2 +- internal/sdk/models/shared/dynamicduedate.go | 22 +- internal/sdk/models/shared/ecpdetails.go | 39 ++ internal/sdk/models/shared/errorresp.go | 2 +- internal/sdk/models/shared/itemtype.go | 34 ++ internal/sdk/models/shared/maxallowedlimit.go | 2 +- internal/sdk/models/shared/section.go | 47 ++ internal/sdk/models/shared/security.go | 8 +- internal/sdk/models/shared/step.go | 147 ++++++ internal/sdk/models/shared/stepdescription.go | 23 + internal/sdk/models/shared/stepjourney.go | 30 ++ internal/sdk/models/shared/steprequirement.go | 59 +++ internal/sdk/models/shared/steptype.go | 34 ++ .../models/shared/updateentityattributes.go | 2 +- .../sdk/models/shared/workflowdefinition.go | 77 +++- internal/sdk/retry/config.go | 2 +- internal/sdk/sdk.go | 9 +- internal/sdk/types/bigint.go | 2 +- internal/sdk/types/date.go | 2 +- internal/sdk/types/datetime.go | 2 +- internal/sdk/types/decimal.go | 2 +- internal/sdk/types/pointers.go | 3 +- internal/sdk/workflows.go | 401 +++++++++++++++-- internal/validators/DateValidator.go | 2 +- internal/validators/ExactlyOneChild.go | 2 +- internal/validators/JSONParseValidator.go | 2 +- internal/validators/RFC3339Validator.go | 2 +- .../validators/boolvalidators/not_null.go | 2 +- .../validators/float64validators/not_null.go | 2 +- .../validators/int64validators/not_null.go | 2 +- .../validators/listvalidators/not_null.go | 2 +- internal/validators/mapvalidators/not_null.go | 2 +- .../validators/numbervalidators/not_null.go | 2 +- .../validators/objectvalidators/not_null.go | 2 +- internal/validators/setvalidators/not_null.go | 2 +- .../validators/stringvalidators/not_null.go | 2 +- main.go | 2 +- tools/tools.go | 2 +- 130 files changed, 2732 insertions(+), 3342 deletions(-) create mode 100644 .speakeasy/workflow.lock delete mode 100644 docs/data-sources/closing_reason.md delete mode 100644 docs/data-sources/workflow_definition.md delete mode 100644 docs/resources/closing_reason.md delete mode 100644 docs/resources/workflow_definition.md delete mode 100644 examples/data-sources/epilot-workflow_closing_reason/data-source.tf delete mode 100644 examples/data-sources/epilot-workflow_workflow_definition/data-source.tf delete mode 100644 examples/resources/epilot-workflow_closing_reason/import.sh delete mode 100644 examples/resources/epilot-workflow_closing_reason/resource.tf delete mode 100644 examples/resources/epilot-workflow_workflow_definition/import.sh delete mode 100644 examples/resources/epilot-workflow_workflow_definition/resource.tf delete mode 100644 internal/provider/closingreason_data_source.go delete mode 100644 internal/provider/closingreason_data_source_sdk.go delete mode 100644 internal/provider/closingreason_resource.go delete mode 100644 internal/provider/closingreason_resource_sdk.go delete mode 100644 internal/provider/types/closing_reason_id.go delete mode 100644 internal/provider/types/dynamic_due_date.go delete mode 100644 internal/provider/types/target.go delete mode 100644 internal/provider/types/update_entity_attributes.go delete mode 100644 internal/provider/workflowdefinition_data_source.go delete mode 100644 internal/provider/workflowdefinition_data_source_sdk.go delete mode 100644 internal/provider/workflowdefinition_resource.go delete mode 100644 internal/provider/workflowdefinition_resource_sdk.go delete mode 100644 internal/sdk/models/operations/getclosingreason.go create mode 100644 internal/sdk/models/operations/getworkflowclosingreasons.go create mode 100644 internal/sdk/models/operations/setworkflowclosingreasons.go delete mode 100644 internal/sdk/models/shared/closingreasonnotfoundresp.go create mode 100644 internal/sdk/models/shared/closingreasonsids.go create mode 100644 internal/sdk/models/shared/ecpdetails.go create mode 100644 internal/sdk/models/shared/itemtype.go create mode 100644 internal/sdk/models/shared/section.go create mode 100644 internal/sdk/models/shared/step.go create mode 100644 internal/sdk/models/shared/stepdescription.go create mode 100644 internal/sdk/models/shared/stepjourney.go create mode 100644 internal/sdk/models/shared/steprequirement.go create mode 100644 internal/sdk/models/shared/steptype.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 28f83b6..0d4211c 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: 8a2ff4be25db818a35891d602baa4a25 docVersion: 1.0.0 - speakeasyVersion: 1.346.0 - generationVersion: 2.379.3 - releaseVersion: 0.13.0 - configChecksum: b0fe4d200caa906deca84fe07b9ca435 + speakeasyVersion: 1.438.1 + generationVersion: 2.457.2 + releaseVersion: 0.14.0 + configChecksum: 266d8551165a8787299d6a2b6eedacab repoURL: https://github.com/epilot-dev/terraform-provider-epilot-workflow.git repoSubDirectory: . published: true @@ -21,62 +21,18 @@ features: unions: 2.85.0 terraform: additionalDependencies: 0.1.0 - core: 3.24.3 + core: 3.26.2 deprecations: 2.81.1 - globalSecurity: 2.81.6 + envVarSecurityUsage: 0.1.0 + globalSecurity: 2.81.9 globalServerURLs: 2.82.1 - typeOverrides: 2.81.1 + unions: 2.81.17 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/provider/provider.tf - go.mod - go.sum - internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -89,6 +45,7 @@ generatedFiles: - internal/planmodifiers/setplanmodifier/suppress_diff.go - internal/planmodifiers/stringplanmodifier/suppress_diff.go - internal/planmodifiers/utils/state_check.go + - internal/provider/provider.go - internal/provider/reflect/diags.go - internal/provider/reflect/doc.go - internal/provider/reflect/generic_attr_value.go @@ -104,6 +61,63 @@ generatedFiles: - internal/provider/reflect/slice.go - internal/provider/reflect/struct.go - internal/provider/utils.go + - internal/sdk/.gitattributes + - internal/sdk/.gitignore + - internal/sdk/CONTRIBUTING.md + - internal/sdk/closingreason.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/deletedefinition.go + - internal/sdk/models/operations/getallclosingreasons.go + - internal/sdk/models/operations/getdefinition.go + - internal/sdk/models/operations/getdefinitions.go + - internal/sdk/models/operations/getmaxallowedlimit.go + - internal/sdk/models/operations/getworkflowclosingreasons.go + - internal/sdk/models/operations/options.go + - internal/sdk/models/operations/setworkflowclosingreasons.go + - internal/sdk/models/operations/updatedefinition.go + - internal/sdk/models/shared/changereasonstatusreq.go + - internal/sdk/models/shared/closingreason.go + - internal/sdk/models/shared/closingreasonid.go + - internal/sdk/models/shared/closingreasons.go + - internal/sdk/models/shared/closingreasonsids.go + - internal/sdk/models/shared/closingreasonsstatus.go + - internal/sdk/models/shared/definitionnotfoundresp.go + - internal/sdk/models/shared/dynamicduedate.go + - internal/sdk/models/shared/ecpdetails.go + - internal/sdk/models/shared/errorresp.go + - internal/sdk/models/shared/itemtype.go + - internal/sdk/models/shared/maxallowedlimit.go + - internal/sdk/models/shared/section.go + - internal/sdk/models/shared/security.go + - internal/sdk/models/shared/step.go + - internal/sdk/models/shared/stepdescription.go + - internal/sdk/models/shared/stepjourney.go + - internal/sdk/models/shared/steprequirement.go + - internal/sdk/models/shared/steptype.go + - internal/sdk/models/shared/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 +134,79 @@ 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, "steps": [{"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "name": "Call client and confirm address and product", "order": 1, "type": "STEP"}, {"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "name": "Check product availability", "order": 2, "type": "STEP"}, {"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "name": "Send email confirming contact with the client", "order": 3, "type": "STEP"}], "type": "SECTION"}, {"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "name": "Print and send catalog", "order": 2, "type": "STEP"}], "lastUpdateTime": "2021-04-27T12:01:13.000Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + responses: + "200": + application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "description": "Lead Qualification description", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "steps": [{"assignedTo": ["48829"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "2hja82a", "name": "Call client and confirm address and product", "order": 1, "type": "STEP"}, {"assignedTo": ["45390"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "ga92ha2", "name": "Check product availability", "order": 2, "type": "STEP"}, {"assignedTo": ["8230"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "jga92ha", "name": "Send email confirming contact with the client", "order": 3, "type": "STEP"}], "type": "SECTION"}, {"assignedTo": ["8239"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "0a7g22a", "name": "Print and send catalog", "order": 2, "type": "STEP"}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": []} + 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, "steps": [{"assignedTo": ["923432"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "2hja82a", "name": "Call client and confirm address and product", "order": 1, "type": "STEP"}, {"assignedTo": ["45488"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "ga92ha2", "name": "Check product availability", "order": 2, "type": "STEP"}, {"assignedTo": ["45488"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "jga92ha", "name": "Send email confirming contact with the client", "order": 3, "type": "STEP"}], "type": "SECTION"}, {"assignedTo": ["8988"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "0a7g22a", "name": "Print and send catalog", "order": 2, "type": "STEP"}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + getDefinitions: + "": + responses: + "200": + application/json: [{"assignedTo": ["18625", "90252"], "closingReasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "description": "Lead Qualification description", "dueDate": "2021-08-04T21:13:50.373Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "steps": [{"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "2hja82a", "name": "Call client and confirm address and product", "order": 1, "type": "STEP"}, {"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "ga92ha2", "name": "Check product availability", "order": 2, "type": "STEP"}, {"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "jga92ha", "name": "Send email confirming contact with the client", "order": 3, "type": "STEP"}], "type": "SECTION"}, {"assignedTo": ["123482"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "0a7g22a", "name": "Print and send catalog", "order": 2, "type": "STEP"}], "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, "steps": [{"assignedTo": ["8988"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "2hja82a", "name": "Call client and confirm address and product", "order": 1, "type": "STEP"}, {"assignedTo": ["8988"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "ga92ha2", "name": "Check product availability", "order": 2, "type": "STEP"}, {"assignedTo": ["8988"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "jga92ha", "name": "Send email confirming contact with the client", "order": 3, "type": "STEP"}], "type": "SECTION"}, {"assignedTo": ["8988"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "0a7g22a", "name": "Print and send catalog", "order": 2, "type": "STEP"}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": [{"source": "workflow_status", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_step", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}, {"source": "current_section", "target": {"entityAttribute": "my_status", "entitySchema": "opportunity"}}]} + responses: + "200": + application/json: {"assignedTo": ["952802", "80225"], "closingReasons": [{"id": "x739cew"}, {"id": "x739cew"}, {"id": "x739cew"}], "creationTime": "2021-08-04T21:13:50.373Z", "dueDate": "2022-08-04T12:00:00.000Z", "flow": [{"id": "5892na2", "name": "Initial Information Gathering", "order": 1, "steps": [{"assignedTo": ["1"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "2hja82a", "name": "Call client and confirm address and product", "order": 1, "type": "STEP"}, {"assignedTo": ["56645"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "ga92ha2", "name": "Check product availability", "order": 2, "type": "STEP"}, {"assignedTo": ["949923"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "jga92ha", "name": "Send email confirming contact with the client", "order": 3, "type": "STEP"}], "type": "SECTION"}, {"assignedTo": ["156645"], "dueDate": "2021-04-27T12:00:00.000Z", "id": "0a7g22a", "name": "Print and send catalog", "order": 2, "type": "STEP"}], "id": "25n2k52ja", "lastUpdateTime": "2021-08-04T21:13:50.373Z", "name": "Lead Qualification", "updateEntityAttributes": []} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock new file mode 100644 index 0000000..d6962e4 --- /dev/null +++ b/.speakeasy/workflow.lock @@ -0,0 +1,28 @@ +speakeasyVersion: 1.438.1 +sources: + my-source: + sourceNamespace: my-source + sourceRevisionDigest: sha256:e29034ab4368e00402d5ed62745111f950c1fe42234a96cca9ae930a802cfc82 + sourceBlobDigest: sha256:fb129b97949b60ef34fdfef8711aee7df55e9328f16749cdaccac5e5b975d0dd + tags: + - latest + - main +targets: + terraform: + source: my-source + sourceNamespace: my-source + sourceRevisionDigest: sha256:e29034ab4368e00402d5ed62745111f950c1fe42234a96cca9ae930a802cfc82 + sourceBlobDigest: sha256:fb129b97949b60ef34fdfef8711aee7df55e9328f16749cdaccac5e5b975d0dd +workflow: + workflowVersion: 1.0.0 + speakeasyVersion: latest + sources: + my-source: + inputs: + - location: https://docs.api.epilot.io/workflows-definition.yaml + registry: + location: registry.speakeasyapi.dev/epilot/epilot/my-source + targets: + terraform: + target: terraform + source: my-source diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml index 320d33a..2144af3 100644 --- a/.speakeasy/workflow.yaml +++ b/.speakeasy/workflow.yaml @@ -1,8 +1,11 @@ workflowVersion: 1.0.0 +speakeasyVersion: latest sources: my-source: inputs: - location: https://docs.api.epilot.io/workflows-definition.yaml + registry: + location: registry.speakeasyapi.dev/epilot/epilot/my-source targets: terraform: target: terraform diff --git a/README.md b/README.md index 3879765..dae5e20 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.14.0" } } } @@ -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,52 @@ 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 + +### Data Sources + + + +## 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/RELEASES.md b/RELEASES.md index 3a0103b..ea78392 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -22,4 +22,14 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.303.0 (2.339.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [terraform v0.8.2] . \ No newline at end of file +- [terraform v0.8.2] . + +## 2024-11-12 00:28:26 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.438.1 (2.457.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.14.0] . +### Releases +- [Terraform v0.14.0] https://registry.terraform.io/providers/epilot-dev/epilot-workflow/0.14.0 - . \ No newline at end of file diff --git a/docs/data-sources/closing_reason.md b/docs/data-sources/closing_reason.md deleted file mode 100644 index 60e3633..0000000 --- a/docs/data-sources/closing_reason.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_closing_reason Data Source - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - ClosingReason DataSource ---- - -# epilot-workflow_closing_reason (Data Source) - -ClosingReason DataSource - -## Example Usage - -```terraform -data "epilot-workflow_closing_reason" "my_closingreason" { - reason_id = "-poOAPBa-jFZA_AWV3zN0" -} -``` - - -## Schema - -### Read-Only - -- `creation_time` (String) -- `id` (String) The ID of this resource. -- `last_update_time` (String) -- `status` (String) must be one of ["ACTIVE", "INACTIVE"] -- `title` (String) - - diff --git a/docs/data-sources/workflow_definition.md b/docs/data-sources/workflow_definition.md deleted file mode 100644 index d74e206..0000000 --- a/docs/data-sources/workflow_definition.md +++ /dev/null @@ -1,320 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_workflow_definition Data Source - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - WorkflowDefinition DataSource ---- - -# epilot-workflow_workflow_definition (Data Source) - -WorkflowDefinition DataSource - -## Example Usage - -```terraform -data "epilot-workflow_workflow_definition" "my_workflowdefinition" { - definition_id = "7hj28a" -} -``` - - -## Schema - -### Read-Only - -- `assigned_to` (List of String) -- `closing_reasons` (Attributes List) (see [below for nested schema](#nestedatt--closing_reasons)) -- `creation_time` (String) ISO String Date & Time -- `description` (String) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--dynamic_due_date)) -- `enable_ecp_workflow` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `flow` (Attributes List) (see [below for nested schema](#nestedatt--flow)) -- `id` (String) The ID of this resource. -- `last_update_time` (String) ISO String Date & Time -- `name` (String) -- `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 - - -### Nested Schema for `closing_reasons` - -Read-Only: - -- `id` (String) - - - -### Nested Schema for `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` - -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"] - - - - - -### Nested Schema for `update_entity_attributes` - -Read-Only: - -- `source` (String) must be one of ["workflow_status", "current_section", "current_step"] -- `target` (Attributes) (see [below for nested schema](#nestedatt--update_entity_attributes--target)) - - -### Nested Schema for `update_entity_attributes.target` - -Read-Only: - -- `entity_attribute` (String) -- `entity_schema` (String) - - diff --git a/docs/index.md b/docs/index.md index 788ba14..317c426 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.14.0" } } } diff --git a/docs/resources/closing_reason.md b/docs/resources/closing_reason.md deleted file mode 100644 index 3cfabdc..0000000 --- a/docs/resources/closing_reason.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_closing_reason Resource - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - ClosingReason Resource ---- - -# epilot-workflow_closing_reason (Resource) - -ClosingReason Resource - -## Example Usage - -```terraform -resource "epilot-workflow_closing_reason" "my_closingreason" { - creation_time = "...my_creation_time..." - id = "26c83797-1a10-4cbc-add8-4604abbab3cf" - last_update_time = "...my_last_update_time..." - reason_id = "-poOAPBa-jFZA_AWV3zN0" - status = "INACTIVE" - title = "Miss" -} -``` - - -## Schema - -### Required - -- `status` (String) Requires replacement if changed. ; must be one of ["ACTIVE", "INACTIVE"] -- `title` (String) Requires replacement if changed. - -### Optional - -- `creation_time` (String) Requires replacement if changed. -- `id` (String) Requires replacement if changed. -- `last_update_time` (String) Requires replacement if changed. - -## Import - -Import is supported using the following syntax: - -```shell -terraform import epilot-workflow_closing_reason.my_epilot-workflow_closing_reason "" -``` diff --git a/docs/resources/workflow_definition.md b/docs/resources/workflow_definition.md deleted file mode 100644 index 5bc3a39..0000000 --- a/docs/resources/workflow_definition.md +++ /dev/null @@ -1,410 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-workflow_workflow_definition Resource - terraform-provider-epilot-workflow" -subcategory: "" -description: |- - WorkflowDefinition Resource ---- - -# epilot-workflow_workflow_definition (Resource) - -WorkflowDefinition Resource - -## Example Usage - -```terraform -resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - creation_time = "2021-04-27T12:01:13.000Z" - definition_id = "7hj28a" - description = "...my_description..." - due_date = "2021-04-27T12:00:00.000Z" - enable_ecp_workflow = false - flow = [ - { - 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" - } - }, - ] - id = "6301351b-2bbd-41bf-80cf-7a2f75db8f8a" - last_update_time = "2021-04-27T12:01:13.000Z" - name = "Dr. Matthew Cronin" -} -``` - - -## Schema - -### Required - -- `flow` (Attributes List) (see [below for nested schema](#nestedatt--flow)) -- `name` (String) - -### Optional - -- `assigned_to` (List of String) -- `closing_reasons` (Attributes List) (see [below for nested schema](#nestedatt--closing_reasons)) -- `creation_time` (String) ISO String Date & Time -- `description` (String) -- `due_date` (String) -- `dynamic_due_date` (Attributes) set a Duedate for a step then a specific (see [below for nested schema](#nestedatt--dynamic_due_date)) -- `enable_ecp_workflow` (Boolean) Indicates whether this workflow is available for End Customer Portal or not. By default it's not. -- `last_update_time` (String) ISO String Date & Time -- `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 - -### Read-Only - -- `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` - -Optional: - -- `id` (String) Not Null - - - -### Nested Schema for `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 `update_entity_attributes` - -Optional: - -- `source` (String) Not Null; must be one of ["workflow_status", "current_section", "current_step"] -- `target` (Attributes) Not Null (see [below for nested schema](#nestedatt--update_entity_attributes--target)) - - -### Nested Schema for `update_entity_attributes.target` - -Optional: - -- `entity_attribute` (String) Not Null -- `entity_schema` (String) Not Null - -## Import - -Import is supported using the following syntax: - -```shell -terraform import epilot-workflow_workflow_definition.my_epilot-workflow_workflow_definition "" -``` diff --git a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf deleted file mode 100644 index ec4863b..0000000 --- a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index e0b2b3d..0000000 --- a/examples/data-sources/epilot-workflow_workflow_definition/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -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..d2bce54 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.14.0" } } } diff --git a/examples/resources/epilot-workflow_closing_reason/import.sh b/examples/resources/epilot-workflow_closing_reason/import.sh deleted file mode 100644 index fb38494..0000000 --- a/examples/resources/epilot-workflow_closing_reason/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-workflow_closing_reason.my_epilot-workflow_closing_reason "" diff --git a/examples/resources/epilot-workflow_closing_reason/resource.tf b/examples/resources/epilot-workflow_closing_reason/resource.tf deleted file mode 100644 index c0f1076..0000000 --- a/examples/resources/epilot-workflow_closing_reason/resource.tf +++ /dev/null @@ -1,8 +0,0 @@ -resource "epilot-workflow_closing_reason" "my_closingreason" { - creation_time = "...my_creation_time..." - id = "26c83797-1a10-4cbc-add8-4604abbab3cf" - last_update_time = "...my_last_update_time..." - reason_id = "-poOAPBa-jFZA_AWV3zN0" - status = "INACTIVE" - title = "Miss" -} \ No newline at end of file diff --git a/examples/resources/epilot-workflow_workflow_definition/import.sh b/examples/resources/epilot-workflow_workflow_definition/import.sh deleted file mode 100644 index e37820e..0000000 --- a/examples/resources/epilot-workflow_workflow_definition/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-workflow_workflow_definition.my_epilot-workflow_workflow_definition "" diff --git a/examples/resources/epilot-workflow_workflow_definition/resource.tf b/examples/resources/epilot-workflow_workflow_definition/resource.tf deleted file mode 100644 index 49f9dc0..0000000 --- a/examples/resources/epilot-workflow_workflow_definition/resource.tf +++ /dev/null @@ -1,11 +0,0 @@ -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" - enable_ecp_workflow = false - flow = "{ \"see\": \"documentation\" }" - id = "452e3f02-980e-44cf-845d-81d428f0e4f5" - last_update_time = "2021-04-27T12:01:13.000Z" - name = "Luther Greenfelder" -} \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 355adff..6de70d5 100644 --- a/gen.yaml +++ b/gen.yaml @@ -9,6 +9,7 @@ generation: requestResponseComponentNamesFeb2024: false auth: oAuth2ClientCredentialsEnabled: false + oAuth2PasswordEnabled: false telemetryEnabled: false go: version: 0.0.1 @@ -27,12 +28,13 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.13.0 + version: 0.14.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] allowUnknownFieldsInWeakUnions: false author: epilot-dev + defaultErrorName: SDKError environmentVariables: [] imports: option: openapi diff --git a/go.mod b/go.mod index 8004ae1..409218b 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/go-uuid v1.0.3 + 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 + github.com/hashicorp/terraform-plugin-log v0.9.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-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/terraform-plugin-log v0.9.0 // indirect + github.com/hashicorp/go-plugin v1.6.1 // 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-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 deleted file mode 100644 index 0324a9f..0000000 --- a/internal/provider/closingreason_data_source.go +++ /dev/null @@ -1,139 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ datasource.DataSource = &ClosingReasonDataSource{} -var _ datasource.DataSourceWithConfigure = &ClosingReasonDataSource{} - -func NewClosingReasonDataSource() datasource.DataSource { - return &ClosingReasonDataSource{} -} - -// ClosingReasonDataSource is the data source implementation. -type ClosingReasonDataSource struct { - client *sdk.SDK -} - -// ClosingReasonDataSourceModel describes the data model. -type ClosingReasonDataSourceModel struct { - CreationTime types.String `tfsdk:"creation_time"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Status types.String `tfsdk:"status"` - Title types.String `tfsdk:"title"` -} - -// Metadata returns the data source type name. -func (r *ClosingReasonDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_closing_reason" -} - -// Schema defines the schema for the data source. -func (r *ClosingReasonDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "ClosingReason DataSource", - - Attributes: map[string]schema.Attribute{ - "creation_time": schema.StringAttribute{ - Computed: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - }, - "status": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["ACTIVE", "INACTIVE"]`, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - }, - } -} - -func (r *ClosingReasonDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected DataSource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *ClosingReasonDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *ClosingReasonDataSourceModel - var item types.Object - - resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - reasonID := data.ID.ValueString() - request := operations.GetClosingReasonRequest{ - ReasonID: reasonID, - } - res, err := r.client.ClosingReason.GetClosingReason(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedClosingReason(res.ClosingReason) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/closingreason_data_source_sdk.go b/internal/provider/closingreason_data_source_sdk.go deleted file mode 100644 index bb62dec..0000000 --- a/internal/provider/closingreason_data_source_sdk.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *ClosingReasonDataSourceModel) RefreshFromSharedClosingReason(resp *shared.ClosingReason) { - if resp != nil { - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.ID = types.StringPointerValue(resp.ID) - r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) - r.Status = types.StringValue(string(resp.Status)) - r.Title = types.StringValue(resp.Title) - } -} diff --git a/internal/provider/closingreason_resource.go b/internal/provider/closingreason_resource.go deleted file mode 100644 index 8e1eb73..0000000 --- a/internal/provider/closingreason_resource.go +++ /dev/null @@ -1,266 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/planmodifiers/stringplanmodifier" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &ClosingReasonResource{} -var _ resource.ResourceWithImportState = &ClosingReasonResource{} - -func NewClosingReasonResource() resource.Resource { - return &ClosingReasonResource{} -} - -// ClosingReasonResource defines the resource implementation. -type ClosingReasonResource struct { - client *sdk.SDK -} - -// ClosingReasonResourceModel describes the resource data model. -type ClosingReasonResourceModel struct { - CreationTime types.String `tfsdk:"creation_time"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Status types.String `tfsdk:"status"` - Title types.String `tfsdk:"title"` -} - -func (r *ClosingReasonResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_closing_reason" -} - -func (r *ClosingReasonResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "ClosingReason Resource", - Attributes: map[string]schema.Attribute{ - "creation_time": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. `, - }, - "id": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. `, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. `, - }, - "status": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Required: true, - Description: `Requires replacement if changed. ; must be one of ["ACTIVE", "INACTIVE"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "ACTIVE", - "INACTIVE", - ), - }, - }, - "title": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Required: true, - Description: `Requires replacement if changed. `, - }, - }, - } -} - -func (r *ClosingReasonResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *ClosingReasonResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *ClosingReasonResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request := *data.ToSharedClosingReason() - res, err := r.client.ClosingReason.CreateClosingReason(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedClosingReason(res.ClosingReason) - refreshPlan(ctx, plan, &data, resp.Diagnostics) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *ClosingReasonResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *ClosingReasonResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - reasonID := data.ID.ValueString() - request := operations.GetClosingReasonRequest{ - ReasonID: reasonID, - } - res, err := r.client.ClosingReason.GetClosingReason(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.ClosingReason != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedClosingReason(res.ClosingReason) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *ClosingReasonResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *ClosingReasonResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - // Not Implemented; all attributes marked as RequiresReplace - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *ClosingReasonResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *ClosingReasonResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - // Not Implemented; entity does not have a configured DELETE operation -} - -func (r *ClosingReasonResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/closingreason_resource_sdk.go b/internal/provider/closingreason_resource_sdk.go deleted file mode 100644 index 4e40548..0000000 --- a/internal/provider/closingreason_resource_sdk.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *ClosingReasonResourceModel) ToSharedClosingReason() *shared.ClosingReason { - creationTime := new(string) - if !r.CreationTime.IsUnknown() && !r.CreationTime.IsNull() { - *creationTime = r.CreationTime.ValueString() - } else { - creationTime = nil - } - id := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id = r.ID.ValueString() - } else { - id = nil - } - lastUpdateTime := new(string) - if !r.LastUpdateTime.IsUnknown() && !r.LastUpdateTime.IsNull() { - *lastUpdateTime = r.LastUpdateTime.ValueString() - } else { - lastUpdateTime = nil - } - status := shared.ClosingReasonsStatus(r.Status.ValueString()) - title := r.Title.ValueString() - out := shared.ClosingReason{ - CreationTime: creationTime, - ID: id, - LastUpdateTime: lastUpdateTime, - Status: status, - Title: title, - } - return &out -} - -func (r *ClosingReasonResourceModel) RefreshFromSharedClosingReason(resp *shared.ClosingReason) { - if resp != nil { - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.ID = types.StringPointerValue(resp.ID) - r.LastUpdateTime = types.StringPointerValue(resp.LastUpdateTime) - r.Status = types.StringValue(string(resp.Status)) - r.Title = types.StringValue(resp.Title) - } -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 076f8fb..87264ee 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,15 +66,23 @@ 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, } + httpClient := http.DefaultClient + httpClient.Transport = NewLoggingHTTPTransport(http.DefaultTransport) + opts := []sdk.SDKOption{ sdk.WithServerURL(ServerURL), sdk.WithSecurity(security), - sdk.WithClient(http.DefaultClient), + sdk.WithClient(httpClient), } client := sdk.New(opts...) @@ -84,17 +91,11 @@ func (p *EpilotWorkflowProvider) Configure(ctx context.Context, req provider.Con } func (p *EpilotWorkflowProvider) Resources(ctx context.Context) []func() resource.Resource { - return []func() resource.Resource{ - NewClosingReasonResource, - NewWorkflowDefinitionResource, - } + return []func() resource.Resource{} } func (p *EpilotWorkflowProvider) DataSources(ctx context.Context) []func() datasource.DataSource { - return []func() datasource.DataSource{ - NewClosingReasonDataSource, - NewWorkflowDefinitionDataSource, - } + return []func() datasource.DataSource{} } func New(version string) func() provider.Provider { 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..8085789 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 @@ -46,7 +46,7 @@ func commaSeparatedString(in []string) string { // getStructTags returns a map of Terraform field names to their position in // the tags of the struct `in`. `in` must be a struct. -func getStructTags(_ context.Context, in reflect.Value, path path.Path, opts Options) (map[string]int, error) { +func getStructTags(_ context.Context, in reflect.Value, path path.Path, _ Options) (map[string]int, error) { tags := map[string]int{} typ := trueReflectValue(in).Type() if typ.Kind() != reflect.Struct { 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 deleted file mode 100644 index 062c0f6..0000000 --- a/internal/provider/types/closing_reason_id.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type ClosingReasonID struct { - ID types.String `tfsdk:"id"` -} diff --git a/internal/provider/types/dynamic_due_date.go b/internal/provider/types/dynamic_due_date.go deleted file mode 100644 index 9f9fc11..0000000 --- a/internal/provider/types/dynamic_due_date.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type DynamicDueDate struct { - ActionTypeCondition types.String `tfsdk:"action_type_condition"` - NumberOfUnits types.Number `tfsdk:"number_of_units"` - StepID types.String `tfsdk:"step_id"` - TimePeriod types.String `tfsdk:"time_period"` -} diff --git a/internal/provider/types/target.go b/internal/provider/types/target.go deleted file mode 100644 index a4a65fa..0000000 --- a/internal/provider/types/target.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type Target struct { - EntityAttribute types.String `tfsdk:"entity_attribute"` - EntitySchema types.String `tfsdk:"entity_schema"` -} diff --git a/internal/provider/types/update_entity_attributes.go b/internal/provider/types/update_entity_attributes.go deleted file mode 100644 index 89cf9a9..0000000 --- a/internal/provider/types/update_entity_attributes.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type UpdateEntityAttributes struct { - Source types.String `tfsdk:"source"` - Target Target `tfsdk:"target"` -} diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 71fae09..82cc449 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -1,19 +1,27 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package provider import ( + "bufio" + "bytes" "context" "encoding/json" + "errors" "fmt" tfReflect "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/reflect" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "io" "net/http" "net/http/httputil" + "net/textproto" "reflect" + "strings" ) func debugResponse(response *http.Response) string { @@ -91,3 +99,177 @@ func refreshPlan(ctx context.Context, plan types.Object, target interface{}, dia SourceType: tfReflect.SourceTypePlan, }, path.Empty())...) } + +// Note: this is taken as a more minimal/specific version of https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/logging/logging_http_transport.go +func NewLoggingHTTPTransport(t http.RoundTripper) *loggingHttpTransport { + return &loggingHttpTransport{t} +} + +const ( + FieldHttpOperationType = "tf_http_op_type" + OperationHttpRequest = "request" + OperationHttpResponse = "response" + FieldHttpRequestMethod = "tf_http_req_method" + FieldHttpRequestUri = "tf_http_req_uri" + FieldHttpRequestProtoVersion = "tf_http_req_version" + FieldHttpRequestBody = "tf_http_req_body" + FieldHttpResponseProtoVersion = "tf_http_res_version" + FieldHttpResponseStatusCode = "tf_http_res_status_code" + FieldHttpResponseStatusReason = "tf_http_res_status_reason" + FieldHttpResponseBody = "tf_http_res_body" + FieldHttpTransactionId = "tf_http_trans_id" +) + +type loggingHttpTransport struct { + transport http.RoundTripper +} + +func (t *loggingHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { + ctx := req.Context() + ctx = t.addTransactionIdField(ctx) + + // Decompose the request bytes in a message (HTTP body) and fields (HTTP headers), then log it + fields, err := decomposeRequestForLogging(req) + if err != nil { + tflog.Error(ctx, "Failed to parse request bytes for logging", []map[string]interface{}{map[string]interface{}{ + "error": err, + }}...) + } else { + tflog.Debug(ctx, "Sending HTTP Request", []map[string]interface{}{fields}...) + } + + // Invoke the wrapped RoundTrip now + res, err := t.transport.RoundTrip(req) + if err != nil { + return res, err + } + + // Decompose the response bytes in a message (HTTP body) and fields (HTTP headers), then log it + fields, err = decomposeResponseForLogging(res) + if err != nil { + tflog.Error(ctx, "Failed to parse response bytes for logging", []map[string]interface{}{map[string]interface{}{ + "error": err, + }}...) + } else { + tflog.Debug(ctx, "Received HTTP Response", []map[string]interface{}{fields}...) + } + + return res, nil +} + +func (t *loggingHttpTransport) addTransactionIdField(ctx context.Context) context.Context { + tId, err := uuid.GenerateUUID() + + if err != nil { + tId = "Unable to assign Transaction ID: " + err.Error() + } + + return tflog.SetField(ctx, FieldHttpTransactionId, tId) +} + +func decomposeRequestForLogging(req *http.Request) (map[string]interface{}, error) { + fields := make(map[string]interface{}, len(req.Header)+4) + fields[FieldHttpOperationType] = OperationHttpRequest + + fields[FieldHttpRequestMethod] = req.Method + fields[FieldHttpRequestUri] = req.URL.RequestURI() + fields[FieldHttpRequestProtoVersion] = req.Proto + + // Get the full body of the request, including headers appended by http.Transport: + // this is necessary because the http.Request at this stage doesn't contain + // all the headers that will be eventually sent. + // We rely on `httputil.DumpRequestOut` to obtain the actual bytes that will be sent out. + reqBytes, err := httputil.DumpRequestOut(req, true) + if err != nil { + return nil, err + } + + // Create a reader around the request full body + reqReader := textproto.NewReader(bufio.NewReader(bytes.NewReader(reqBytes))) + + err = fieldHeadersFromRequestReader(reqReader, fields) + if err != nil { + return nil, err + } + + // Read the rest of the body content + fields[FieldHttpRequestBody] = bodyFromRestOfRequestReader(reqReader) + return fields, nil +} + +func fieldHeadersFromRequestReader(reader *textproto.Reader, fields map[string]interface{}) error { + // Ignore the first line: it contains non-header content + // that we have already captured. + // Skipping this step, would cause the following call to `ReadMIMEHeader()` + // to fail as it cannot parse the first line. + _, err := reader.ReadLine() + if err != nil { + return err + } + + // Read the MIME-style headers + mimeHeader, err := reader.ReadMIMEHeader() + if err != nil { + return err + } + + // Set the headers as fields to log + for k, v := range mimeHeader { + if len(v) == 1 { + fields[k] = v[0] + } else { + fields[k] = v + } + } + if _, ok := fields["Authorization"]; ok { + fields["Authorization"] = "(sensitive)" + } + + return nil +} + +func bodyFromRestOfRequestReader(reader *textproto.Reader) string { + var builder strings.Builder + for { + line, err := reader.ReadContinuedLine() + if errors.Is(err, io.EOF) { + break + } + builder.WriteString(line) + } + + return builder.String() +} + +func decomposeResponseForLogging(res *http.Response) (map[string]interface{}, error) { + fields := make(map[string]interface{}, len(res.Header)+4) + fields[FieldHttpOperationType] = OperationHttpResponse + + fields[FieldHttpResponseProtoVersion] = res.Proto + fields[FieldHttpResponseStatusCode] = res.StatusCode + fields[FieldHttpResponseStatusReason] = res.Status + + // Set the headers as fields to log + for k, v := range res.Header { + if len(v) == 1 { + fields[k] = v[0] + } else { + fields[k] = v + } + } + + // Read the whole response body + resBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, err + } + + // Wrap the bytes from the response body, back into an io.ReadCloser, + // to respect the interface of http.Response, as expected by users of the + // http.Client + res.Body = io.NopCloser(bytes.NewBuffer(resBody)) + + fields[FieldHttpResponseBody] = string(resBody) + + return fields, nil +} diff --git a/internal/provider/workflowdefinition_data_source.go b/internal/provider/workflowdefinition_data_source.go deleted file mode 100644 index 5ae43d8..0000000 --- a/internal/provider/workflowdefinition_data_source.go +++ /dev/null @@ -1,221 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ datasource.DataSource = &WorkflowDefinitionDataSource{} -var _ datasource.DataSourceWithConfigure = &WorkflowDefinitionDataSource{} - -func NewWorkflowDefinitionDataSource() datasource.DataSource { - return &WorkflowDefinitionDataSource{} -} - -// WorkflowDefinitionDataSource is the data source implementation. -type WorkflowDefinitionDataSource struct { - client *sdk.SDK -} - -// WorkflowDefinitionDataSourceModel describes the data model. -type WorkflowDefinitionDataSourceModel struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - ClosingReasons []tfTypes.ClosingReasonID `tfsdk:"closing_reasons"` - CreationTime types.String `tfsdk:"creation_time"` - Description types.String `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DynamicDueDate *tfTypes.DynamicDueDate `tfsdk:"dynamic_due_date"` - EnableECPWorkflow types.Bool `tfsdk:"enable_ecp_workflow"` - Flow types.String `tfsdk:"flow"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Name types.String `tfsdk:"name"` - UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` - UserIds []types.Number `tfsdk:"user_ids"` -} - -// Metadata returns the data source type name. -func (r *WorkflowDefinitionDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_workflow_definition" -} - -// Schema defines the schema for the data source. -func (r *WorkflowDefinitionDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "WorkflowDefinition DataSource", - - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "closing_reasons": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "creation_time": schema.StringAttribute{ - Computed: true, - Description: `ISO String Date & Time`, - }, - "description": schema.StringAttribute{ - Computed: true, - }, - "due_date": schema.StringAttribute{ - Computed: true, - }, - "dynamic_due_date": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "action_type_condition": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"]`, - }, - "number_of_units": schema.NumberAttribute{ - Computed: true, - }, - "step_id": schema.StringAttribute{ - Computed: true, - }, - "time_period": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["days", "weeks", "months"]`, - }, - }, - Description: `set a Duedate for a step then a specific`, - }, - "enable_ecp_workflow": schema.BoolAttribute{ - Computed: true, - Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, - }, - "flow": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - Description: `ISO String Date & Time`, - }, - "name": schema.StringAttribute{ - Computed: true, - }, - "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"]`, - }, - "target": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "entity_attribute": schema.StringAttribute{ - Computed: true, - }, - "entity_schema": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - }, - "user_ids": schema.ListAttribute{ - Computed: true, - ElementType: types.NumberType, - Description: `This field is deprecated. Please use assignedTo`, - }, - }, - } -} - -func (r *WorkflowDefinitionDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected DataSource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *WorkflowDefinitionDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *WorkflowDefinitionDataSourceModel - var item types.Object - - resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - definitionID := data.ID.ValueString() - request := operations.GetDefinitionRequest{ - DefinitionID: definitionID, - } - res, err := r.client.Workflows.GetDefinition(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedWorkflowDefinition(res.WorkflowDefinition) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/workflowdefinition_data_source_sdk.go b/internal/provider/workflowdefinition_data_source_sdk.go deleted file mode 100644 index 579dace..0000000 --- a/internal/provider/workflowdefinition_data_source_sdk.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "encoding/json" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" - "math/big" -) - -func (r *WorkflowDefinitionDataSourceModel) RefreshFromSharedWorkflowDefinition(resp *shared.WorkflowDefinition) { - if resp != nil { - r.AssignedTo = []types.String{} - for _, v := range resp.AssignedTo { - r.AssignedTo = append(r.AssignedTo, types.StringValue(v)) - } - r.ClosingReasons = []tfTypes.ClosingReasonID{} - if len(r.ClosingReasons) > len(resp.ClosingReasons) { - r.ClosingReasons = r.ClosingReasons[:len(resp.ClosingReasons)] - } - for closingReasonsCount, closingReasonsItem := range resp.ClosingReasons { - var closingReasons1 tfTypes.ClosingReasonID - closingReasons1.ID = types.StringValue(closingReasonsItem.ID) - if closingReasonsCount+1 > len(r.ClosingReasons) { - r.ClosingReasons = append(r.ClosingReasons, closingReasons1) - } else { - r.ClosingReasons[closingReasonsCount].ID = closingReasons1.ID - } - } - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.Description = types.StringPointerValue(resp.Description) - r.DueDate = types.StringPointerValue(resp.DueDate) - if resp.DynamicDueDate == nil { - r.DynamicDueDate = nil - } else { - r.DynamicDueDate = &tfTypes.DynamicDueDate{} - 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.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.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.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} - if len(r.UpdateEntityAttributes) > len(resp.UpdateEntityAttributes) { - r.UpdateEntityAttributes = r.UpdateEntityAttributes[:len(resp.UpdateEntityAttributes)] - } - for updateEntityAttributesCount, updateEntityAttributesItem := range resp.UpdateEntityAttributes { - var updateEntityAttributes1 tfTypes.UpdateEntityAttributes - updateEntityAttributes1.Source = types.StringValue(string(updateEntityAttributesItem.Source)) - updateEntityAttributes1.Target.EntityAttribute = types.StringValue(updateEntityAttributesItem.Target.EntityAttribute) - updateEntityAttributes1.Target.EntitySchema = types.StringValue(updateEntityAttributesItem.Target.EntitySchema) - if updateEntityAttributesCount+1 > len(r.UpdateEntityAttributes) { - r.UpdateEntityAttributes = append(r.UpdateEntityAttributes, updateEntityAttributes1) - } else { - r.UpdateEntityAttributes[updateEntityAttributesCount].Source = updateEntityAttributes1.Source - r.UpdateEntityAttributes[updateEntityAttributesCount].Target = updateEntityAttributes1.Target - } - } - r.UserIds = []types.Number{} - for _, v := range resp.UserIds { - r.UserIds = append(r.UserIds, types.NumberValue(big.NewFloat(float64(v)))) - } - } -} diff --git a/internal/provider/workflowdefinition_resource.go b/internal/provider/workflowdefinition_resource.go deleted file mode 100644 index ea131fb..0000000 --- a/internal/provider/workflowdefinition_resource.go +++ /dev/null @@ -1,422 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/validators" - 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/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &WorkflowDefinitionResource{} -var _ resource.ResourceWithImportState = &WorkflowDefinitionResource{} - -func NewWorkflowDefinitionResource() resource.Resource { - return &WorkflowDefinitionResource{} -} - -// WorkflowDefinitionResource defines the resource implementation. -type WorkflowDefinitionResource struct { - client *sdk.SDK -} - -// WorkflowDefinitionResourceModel describes the resource data model. -type WorkflowDefinitionResourceModel struct { - AssignedTo []types.String `tfsdk:"assigned_to"` - ClosingReasons []tfTypes.ClosingReasonID `tfsdk:"closing_reasons"` - CreationTime types.String `tfsdk:"creation_time"` - Description types.String `tfsdk:"description"` - DueDate types.String `tfsdk:"due_date"` - DynamicDueDate *tfTypes.DynamicDueDate `tfsdk:"dynamic_due_date"` - EnableECPWorkflow types.Bool `tfsdk:"enable_ecp_workflow"` - Flow types.String `tfsdk:"flow"` - ID types.String `tfsdk:"id"` - LastUpdateTime types.String `tfsdk:"last_update_time"` - Name types.String `tfsdk:"name"` - UpdateEntityAttributes []tfTypes.UpdateEntityAttributes `tfsdk:"update_entity_attributes"` - UserIds []types.Number `tfsdk:"user_ids"` -} - -func (r *WorkflowDefinitionResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_workflow_definition" -} - -func (r *WorkflowDefinitionResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "WorkflowDefinition Resource", - Attributes: map[string]schema.Attribute{ - "assigned_to": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "closing_reasons": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - }, - }, - "creation_time": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ISO String Date & Time`, - }, - "description": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "due_date": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "dynamic_due_date": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "action_type_condition": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["WORKFLOW_STARTED", "STEP_CLOSED"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "WORKFLOW_STARTED", - "STEP_CLOSED", - ), - }, - }, - "number_of_units": schema.NumberAttribute{ - Computed: true, - Optional: true, - }, - "step_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "time_period": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["days", "weeks", "months"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "days", - "weeks", - "months", - ), - }, - }, - }, - Description: `set a Duedate for a step then a specific`, - }, - "enable_ecp_workflow": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Indicates whether this workflow is available for End Customer Portal or not. By default it's not.`, - }, - "flow": schema.StringAttribute{ - Required: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "last_update_time": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ISO String Date & Time`, - }, - "name": schema.StringAttribute{ - Required: true, - }, - "update_entity_attributes": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "source": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null; must be one of ["workflow_status", "current_section", "current_step"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "workflow_status", - "current_section", - "current_step", - ), - }, - }, - "target": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "entity_attribute": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "entity_schema": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - }, - }, - }, - }, - "user_ids": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.NumberType, - Description: `This field is deprecated. Please use assignedTo`, - }, - }, - } -} - -func (r *WorkflowDefinitionResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *WorkflowDefinitionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *WorkflowDefinitionResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request := *data.ToSharedWorkflowDefinition() - res, err := r.client.Workflows.CreateDefinition(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedWorkflowDefinition(res.WorkflowDefinition) - refreshPlan(ctx, plan, &data, resp.Diagnostics) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *WorkflowDefinitionResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *WorkflowDefinitionResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - definitionID := data.ID.ValueString() - request := operations.GetDefinitionRequest{ - DefinitionID: definitionID, - } - res, err := r.client.Workflows.GetDefinition(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedWorkflowDefinition(res.WorkflowDefinition) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *WorkflowDefinitionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *WorkflowDefinitionResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - workflowDefinition := *data.ToSharedWorkflowDefinition() - definitionID := data.ID.ValueString() - request := operations.UpdateDefinitionRequest{ - WorkflowDefinition: workflowDefinition, - DefinitionID: definitionID, - } - res, err := r.client.Workflows.UpdateDefinition(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.WorkflowDefinition != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedWorkflowDefinition(res.WorkflowDefinition) - refreshPlan(ctx, plan, &data, resp.Diagnostics) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *WorkflowDefinitionResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *WorkflowDefinitionResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - definitionID := data.ID.ValueString() - request := operations.DeleteDefinitionRequest{ - DefinitionID: definitionID, - } - res, err := r.client.Workflows.DeleteDefinition(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *WorkflowDefinitionResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/workflowdefinition_resource_sdk.go b/internal/provider/workflowdefinition_resource_sdk.go deleted file mode 100644 index 0d0c79c..0000000 --- a/internal/provider/workflowdefinition_resource_sdk.go +++ /dev/null @@ -1,204 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package provider - -import ( - "encoding/json" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" - "math/big" -) - -func (r *WorkflowDefinitionResourceModel) ToSharedWorkflowDefinition() *shared.WorkflowDefinition { - var assignedTo []string = []string{} - for _, assignedToItem := range r.AssignedTo { - assignedTo = append(assignedTo, assignedToItem.ValueString()) - } - var closingReasons []shared.ClosingReasonID = []shared.ClosingReasonID{} - for _, closingReasonsItem := range r.ClosingReasons { - id := closingReasonsItem.ID.ValueString() - closingReasons = append(closingReasons, shared.ClosingReasonID{ - ID: id, - }) - } - creationTime := new(string) - if !r.CreationTime.IsUnknown() && !r.CreationTime.IsNull() { - *creationTime = r.CreationTime.ValueString() - } else { - creationTime = nil - } - description := new(string) - if !r.Description.IsUnknown() && !r.Description.IsNull() { - *description = r.Description.ValueString() - } else { - description = nil - } - dueDate := new(string) - if !r.DueDate.IsUnknown() && !r.DueDate.IsNull() { - *dueDate = r.DueDate.ValueString() - } else { - dueDate = nil - } - var dynamicDueDate *shared.DynamicDueDate - if r.DynamicDueDate != nil { - actionTypeCondition := 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 - } - 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 - } - dynamicDueDate = &shared.DynamicDueDate{ - ActionTypeCondition: actionTypeCondition, - NumberOfUnits: numberOfUnits, - StepID: stepID, - TimePeriod: timePeriod, - } - } - enableECPWorkflow := new(bool) - if !r.EnableECPWorkflow.IsUnknown() && !r.EnableECPWorkflow.IsNull() { - *enableECPWorkflow = r.EnableECPWorkflow.ValueBool() - } else { - enableECPWorkflow = nil - } - var flow interface{} - _ = json.Unmarshal([]byte(r.Flow.ValueString()), &flow) - id1 := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id1 = r.ID.ValueString() - } else { - id1 = nil - } - lastUpdateTime := new(string) - if !r.LastUpdateTime.IsUnknown() && !r.LastUpdateTime.IsNull() { - *lastUpdateTime = r.LastUpdateTime.ValueString() - } else { - lastUpdateTime = nil - } - name := r.Name.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() - target := shared.Target{ - EntityAttribute: entityAttribute, - EntitySchema: entitySchema, - } - updateEntityAttributes = append(updateEntityAttributes, shared.UpdateEntityAttributes{ - Source: source, - Target: target, - }) - } - var userIds []float64 = []float64{} - for _, userIdsItem := range r.UserIds { - userIdsTmp, _ := userIdsItem.ValueBigFloat().Float64() - userIds = append(userIds, userIdsTmp) - } - out := shared.WorkflowDefinition{ - AssignedTo: assignedTo, - ClosingReasons: closingReasons, - CreationTime: creationTime, - Description: description, - DueDate: dueDate, - DynamicDueDate: dynamicDueDate, - EnableECPWorkflow: enableECPWorkflow, - Flow: flow, - ID: id1, - LastUpdateTime: lastUpdateTime, - Name: name, - UpdateEntityAttributes: updateEntityAttributes, - UserIds: userIds, - } - return &out -} - -func (r *WorkflowDefinitionResourceModel) RefreshFromSharedWorkflowDefinition(resp *shared.WorkflowDefinition) { - if resp != nil { - r.AssignedTo = []types.String{} - for _, v := range resp.AssignedTo { - r.AssignedTo = append(r.AssignedTo, types.StringValue(v)) - } - r.ClosingReasons = []tfTypes.ClosingReasonID{} - if len(r.ClosingReasons) > len(resp.ClosingReasons) { - r.ClosingReasons = r.ClosingReasons[:len(resp.ClosingReasons)] - } - for closingReasonsCount, closingReasonsItem := range resp.ClosingReasons { - var closingReasons1 tfTypes.ClosingReasonID - closingReasons1.ID = types.StringValue(closingReasonsItem.ID) - if closingReasonsCount+1 > len(r.ClosingReasons) { - r.ClosingReasons = append(r.ClosingReasons, closingReasons1) - } else { - r.ClosingReasons[closingReasonsCount].ID = closingReasons1.ID - } - } - r.CreationTime = types.StringPointerValue(resp.CreationTime) - r.Description = types.StringPointerValue(resp.Description) - r.DueDate = types.StringPointerValue(resp.DueDate) - if resp.DynamicDueDate == nil { - r.DynamicDueDate = nil - } else { - r.DynamicDueDate = &tfTypes.DynamicDueDate{} - 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.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.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.UpdateEntityAttributes = []tfTypes.UpdateEntityAttributes{} - if len(r.UpdateEntityAttributes) > len(resp.UpdateEntityAttributes) { - r.UpdateEntityAttributes = r.UpdateEntityAttributes[:len(resp.UpdateEntityAttributes)] - } - for updateEntityAttributesCount, updateEntityAttributesItem := range resp.UpdateEntityAttributes { - var updateEntityAttributes1 tfTypes.UpdateEntityAttributes - updateEntityAttributes1.Source = types.StringValue(string(updateEntityAttributesItem.Source)) - updateEntityAttributes1.Target.EntityAttribute = types.StringValue(updateEntityAttributesItem.Target.EntityAttribute) - updateEntityAttributes1.Target.EntitySchema = types.StringValue(updateEntityAttributesItem.Target.EntitySchema) - if updateEntityAttributesCount+1 > len(r.UpdateEntityAttributes) { - r.UpdateEntityAttributes = append(r.UpdateEntityAttributes, updateEntityAttributes1) - } else { - r.UpdateEntityAttributes[updateEntityAttributesCount].Source = updateEntityAttributes1.Source - r.UpdateEntityAttributes[updateEntityAttributesCount].Target = updateEntityAttributes1.Target - } - } - r.UserIds = []types.Number{} - for _, v := range resp.UserIds { - r.UserIds = append(r.UserIds, types.NumberValue(big.NewFloat(float64(v)))) - } - } -} diff --git a/internal/sdk/closingreason.go b/internal/sdk/closingreason.go index 0eeec3c..b55f350 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 @@ -11,7 +11,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "io" "net/http" "net/url" ) @@ -116,13 +115,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 +122,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 +134,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) } @@ -237,17 +242,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 +258,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) } @@ -353,167 +364,33 @@ 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`): - var out shared.ClosingReasons - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ClosingReasons = &out - default: - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetClosingReason - getClosingReason -// Get specific closing reason by id from the organisation. -func (s *ClosingReason) GetClosingReason(ctx context.Context, request operations.GetClosingReasonRequest, opts ...operations.Option) (*operations.GetClosingReasonResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getClosingReason", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/workflows/closing-reasons/{reasonId}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - 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{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - var out shared.ClosingReason - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { return nil, err } - res.ClosingReason = &out - default: - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - var out shared.ErrorResp + var out shared.ClosingReasons if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.ErrorResp = &out + res.ClosingReasons = &out default: - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - var out shared.ClosingReasonNotFoundResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { return nil, err } - - res.ClosingReasonNotFoundResp = &out - default: return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/sdk/internal/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/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/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 deleted file mode 100644 index 0a2e20f..0000000 --- a/internal/sdk/models/operations/getclosingreason.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "net/http" -) - -type GetClosingReasonRequest struct { - // uuid to identify the closing reason. - ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` -} - -func (o *GetClosingReasonRequest) GetReasonID() string { - if o == nil { - return "" - } - return o.ReasonID -} - -type GetClosingReasonResponse struct { - // Returns the closing reason - ClosingReason *shared.ClosingReason - // Closing reason not found - ClosingReasonNotFoundResp *shared.ClosingReasonNotFoundResp - // HTTP response content type for this operation - ContentType string - // Validation Errors - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetClosingReasonResponse) GetClosingReason() *shared.ClosingReason { - if o == nil { - return nil - } - return o.ClosingReason -} - -func (o *GetClosingReasonResponse) GetClosingReasonNotFoundResp() *shared.ClosingReasonNotFoundResp { - if o == nil { - return nil - } - return o.ClosingReasonNotFoundResp -} - -func (o *GetClosingReasonResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetClosingReasonResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetClosingReasonResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetClosingReasonResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} 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/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/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/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 deleted file mode 100644 index 828e59a..0000000 --- a/internal/sdk/models/shared/closingreasonnotfoundresp.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package shared - -// ClosingReasonNotFoundResp - Closing reason could be not found -type ClosingReasonNotFoundResp struct { - Message *string `json:"message,omitempty"` -} - -func (o *ClosingReasonNotFoundResp) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} 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/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/dynamicduedate.go b/internal/sdk/models/shared/dynamicduedate.go index 919b9f1..5c6a7e0 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 @@ -64,22 +64,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 +91,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/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/itemtype.go b/internal/sdk/models/shared/itemtype.go new file mode 100644 index 0000000..a5c671f --- /dev/null +++ b/internal/sdk/models/shared/itemtype.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type ItemType string + +const ( + ItemTypeStep ItemType = "STEP" + ItemTypeSection ItemType = "SECTION" +) + +func (e ItemType) ToPointer() *ItemType { + return &e +} +func (e *ItemType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "STEP": + fallthrough + case "SECTION": + *e = ItemType(v) + return nil + default: + return fmt.Errorf("invalid value for ItemType: %v", v) + } +} diff --git a/internal/sdk/models/shared/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/section.go b/internal/sdk/models/shared/section.go new file mode 100644 index 0000000..2552ad2 --- /dev/null +++ b/internal/sdk/models/shared/section.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// Section - A group of Steps that define the progress of the Workflow +type Section struct { + ID *string `json:"id,omitempty"` + Name string `json:"name"` + Order float64 `json:"order"` + Steps []Step `json:"steps"` + Type ItemType `json:"type"` +} + +func (o *Section) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *Section) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Section) GetOrder() float64 { + if o == nil { + return 0.0 + } + return o.Order +} + +func (o *Section) GetSteps() []Step { + if o == nil { + return []Step{} + } + return o.Steps +} + +func (o *Section) GetType() ItemType { + if o == nil { + return ItemType("") + } + return o.Type +} 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/step.go b/internal/sdk/models/shared/step.go new file mode 100644 index 0000000..f4ec993 --- /dev/null +++ b/internal/sdk/models/shared/step.go @@ -0,0 +1,147 @@ +// 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:"flowId"` +} + +func (o *AutomationConfig) GetFlowID() string { + if o == nil { + return "" + } + return o.FlowID +} + +// Step - Action that needs to be done in a Workflow +type Step struct { + AssignedTo []string `json:"assignedTo,omitempty"` + AutomationConfig *AutomationConfig `json:"automationConfig,omitempty"` + // Longer information regarding Task + Description *StepDescription `json:"description,omitempty"` + DueDate *string `json:"dueDate,omitempty"` + // set a Duedate for a step then a specific + DynamicDueDate *DynamicDueDate `json:"dynamicDueDate,omitempty"` + // Details regarding ECP for the workflow step + Ecp *ECPDetails `json:"ecp,omitempty"` + ExecutionType *StepType `json:"executionType,omitempty"` + ID *string `json:"id,omitempty"` + // Details regarding ECP for the workflow step + Installer *ECPDetails `json:"installer,omitempty"` + Journey *StepJourney `json:"journey,omitempty"` + Name string `json:"name"` + Order float64 `json:"order"` + // requirements that need to be fulfilled in order to enable the step execution + Requirements []StepRequirement `json:"requirements,omitempty"` + Type ItemType `json:"type"` + // This field is deprecated. Please use assignedTo + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + UserIds []float64 `json:"userIds,omitempty"` +} + +func (o *Step) GetAssignedTo() []string { + if o == nil { + return nil + } + return o.AssignedTo +} + +func (o *Step) GetAutomationConfig() *AutomationConfig { + if o == nil { + return nil + } + return o.AutomationConfig +} + +func (o *Step) GetDescription() *StepDescription { + if o == nil { + return nil + } + return o.Description +} + +func (o *Step) GetDueDate() *string { + if o == nil { + return nil + } + return o.DueDate +} + +func (o *Step) GetDynamicDueDate() *DynamicDueDate { + if o == nil { + return nil + } + return o.DynamicDueDate +} + +func (o *Step) GetEcp() *ECPDetails { + if o == nil { + return nil + } + return o.Ecp +} + +func (o *Step) GetExecutionType() *StepType { + if o == nil { + return nil + } + return o.ExecutionType +} + +func (o *Step) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *Step) GetInstaller() *ECPDetails { + if o == nil { + return nil + } + return o.Installer +} + +func (o *Step) GetJourney() *StepJourney { + if o == nil { + return nil + } + return o.Journey +} + +func (o *Step) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Step) GetOrder() float64 { + if o == nil { + return 0.0 + } + return o.Order +} + +func (o *Step) GetRequirements() []StepRequirement { + if o == nil { + return nil + } + return o.Requirements +} + +func (o *Step) GetType() ItemType { + if o == nil { + return ItemType("") + } + return o.Type +} + +func (o *Step) GetUserIds() []float64 { + if o == nil { + return nil + } + return o.UserIds +} 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/steprequirement.go b/internal/sdk/models/shared/steprequirement.go new file mode 100644 index 0000000..1d58fd4 --- /dev/null +++ b/internal/sdk/models/shared/steprequirement.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type Condition string + +const ( + ConditionClosed Condition = "CLOSED" +) + +func (e Condition) ToPointer() *Condition { + return &e +} +func (e *Condition) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "CLOSED": + *e = Condition(v) + return nil + default: + return fmt.Errorf("invalid value for Condition: %v", v) + } +} + +// StepRequirement - describe the requirement for step enablement +type StepRequirement struct { + Condition Condition `json:"condition"` + DefinitionID string `json:"definitionId"` + Type ItemType `json:"type"` +} + +func (o *StepRequirement) GetCondition() Condition { + if o == nil { + return Condition("") + } + return o.Condition +} + +func (o *StepRequirement) GetDefinitionID() string { + if o == nil { + return "" + } + return o.DefinitionID +} + +func (o *StepRequirement) GetType() ItemType { + if o == nil { + return ItemType("") + } + return o.Type +} diff --git a/internal/sdk/models/shared/steptype.go b/internal/sdk/models/shared/steptype.go new file mode 100644 index 0000000..e76cf9b --- /dev/null +++ b/internal/sdk/models/shared/steptype.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type StepType string + +const ( + StepTypeManual StepType = "MANUAL" + StepTypeAutomation StepType = "AUTOMATION" +) + +func (e StepType) ToPointer() *StepType { + return &e +} +func (e *StepType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "MANUAL": + fallthrough + case "AUTOMATION": + *e = StepType(v) + return nil + default: + return fmt.Errorf("invalid value for StepType: %v", v) + } +} diff --git a/internal/sdk/models/shared/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..1207c29 100644 --- a/internal/sdk/models/shared/workflowdefinition.go +++ b/internal/sdk/models/shared/workflowdefinition.go @@ -1,7 +1,76 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// 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 FlowType string + +const ( + FlowTypeSection FlowType = "Section" + FlowTypeStep FlowType = "Step" +) + +type Flow struct { + Section *Section + Step *Step + + Type FlowType +} + +func CreateFlowSection(section Section) Flow { + typ := FlowTypeSection + + return Flow{ + Section: §ion, + Type: typ, + } +} + +func CreateFlowStep(step Step) Flow { + typ := FlowTypeStep + + return Flow{ + Step: &step, + Type: typ, + } +} + +func (u *Flow) UnmarshalJSON(data []byte) error { + + var section Section = Section{} + if err := utils.UnmarshalJSON(data, §ion, "", true, true); err == nil { + u.Section = §ion + u.Type = FlowTypeSection + return nil + } + + var step Step = Step{} + if err := utils.UnmarshalJSON(data, &step, "", true, true); err == nil { + u.Step = &step + u.Type = FlowTypeStep + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Flow", string(data)) +} + +func (u Flow) MarshalJSON() ([]byte, error) { + if u.Section != nil { + return utils.MarshalJSON(u.Section, "", true) + } + + if u.Step != nil { + return utils.MarshalJSON(u.Step, "", true) + } + + return nil, errors.New("could not marshal union type Flow: all fields are null") +} + type WorkflowDefinition struct { AssignedTo []string `json:"assignedTo,omitempty"` ClosingReasons []ClosingReasonID `json:"closingReasons,omitempty"` @@ -13,7 +82,7 @@ type WorkflowDefinition struct { 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"` + Flow []Flow `json:"flow"` ID *string `json:"id,omitempty"` // ISO String Date & Time LastUpdateTime *string `json:"lastUpdateTime,omitempty"` @@ -74,9 +143,9 @@ func (o *WorkflowDefinition) GetEnableECPWorkflow() *bool { return o.EnableECPWorkflow } -func (o *WorkflowDefinition) GetFlow() any { +func (o *WorkflowDefinition) GetFlow() []Flow { if o == nil { - return nil + return []Flow{} } return o.Flow } 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..0d17084 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) @@ -146,8 +149,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.457.2", + UserAgent: "speakeasy-sdk/go 0.0.1 2.457.2 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", Hooks: hooks.New(), }, } 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..913ccab 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 @@ -11,7 +11,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" - "io" "net/http" "net/url" ) @@ -116,17 +115,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: + 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 @@ -134,6 +131,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 +144,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 +156,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) } @@ -244,13 +258,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 +265,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 +277,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) } @@ -359,17 +379,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 +395,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 +408,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 +420,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 +441,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) } @@ -499,17 +543,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 +559,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 +580,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) } @@ -623,17 +682,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 +698,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 +719,239 @@ 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.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 + } + + 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.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 + } + + 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) } @@ -753,17 +1049,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 +1065,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 +1078,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 +1090,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/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