From b2f08046c817de080e3669f679340e7e2e5925fd Mon Sep 17 00:00:00 2001 From: Nishu Goel Date: Mon, 5 Aug 2024 16:31:43 +0200 Subject: [PATCH] Add resource for closing reasons in workflow provider --- .speakeasy/gen.lock | 37 +- CONTRIBUTING.md | 26 + README.md | 2 +- docs/data-sources/workflow_definition.md | 39 +- docs/index.md | 2 +- docs/resources/workflow_definition.md | 79 ++- .../data-source.tf | 3 + examples/provider/provider.tf | 2 +- .../epilot-workflow_closing_reason/import.sh | 1 + .../resource.tf | 8 + .../resource.tf | 44 +- gen.yaml | 2 +- .../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 | 4 +- internal/provider/reflect/diags.go | 2 +- internal/provider/reflect/doc.go | 2 +- .../provider/reflect/generic_attr_value.go | 2 +- internal/provider/reflect/helpers.go | 2 +- internal/provider/reflect/interfaces.go | 2 +- internal/provider/reflect/into.go | 2 +- internal/provider/reflect/map.go | 2 +- internal/provider/reflect/number.go | 2 +- internal/provider/reflect/options.go | 2 +- internal/provider/reflect/outof.go | 2 +- internal/provider/reflect/pointer.go | 2 +- internal/provider/reflect/primitive.go | 2 +- internal/provider/reflect/slice.go | 2 +- internal/provider/reflect/struct.go | 2 +- internal/provider/types/automation_config.go | 2 +- internal/provider/types/closing_reason_id.go | 2 +- internal/provider/types/dynamic_due_date.go | 2 +- internal/provider/types/ecp_details.go | 2 +- internal/provider/types/flow.go | 2 +- internal/provider/types/section.go | 2 +- internal/provider/types/step.go | 2 +- internal/provider/types/step_description.go | 2 +- internal/provider/types/step_journey.go | 2 +- internal/provider/types/step_requirement.go | 2 +- internal/provider/types/target.go | 2 +- .../types/update_entity_attributes.go | 2 +- internal/provider/utils.go | 2 +- .../workflowdefinition_data_source.go | 2 +- .../workflowdefinition_data_source_sdk.go | 2 +- .../provider/workflowdefinition_resource.go | 2 +- .../workflowdefinition_resource_sdk.go | 2 +- internal/sdk/CONTRIBUTING.md | 26 + internal/sdk/closingreason.go | 522 ++++++++++++++++++ internal/sdk/internal/hooks/hooks.go | 2 +- internal/sdk/internal/hooks/registration.go | 2 +- 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 | 2 +- internal/sdk/internal/utils/pathparams.go | 2 +- internal/sdk/internal/utils/queryparams.go | 128 +++-- internal/sdk/internal/utils/requestbody.go | 2 +- internal/sdk/internal/utils/retries.go | 2 +- internal/sdk/internal/utils/security.go | 2 +- internal/sdk/internal/utils/utils.go | 2 +- internal/sdk/models/errors/sdkerror.go | 2 +- .../models/operations/changereasonstatus.go | 67 +++ .../models/operations/createclosingreason.go | 47 ++ .../sdk/models/operations/createdefinition.go | 2 +- .../sdk/models/operations/deletedefinition.go | 2 +- .../models/operations/getallclosingreasons.go | 59 ++ .../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 | 93 ++++ .../operations/setworkflowclosingreasons.go | 59 -- .../sdk/models/operations/updatedefinition.go | 2 +- .../models/shared/changereasonstatusreq.go | 14 + internal/sdk/models/shared/closingreason.go | 47 ++ internal/sdk/models/shared/closingreasonid.go | 2 +- .../shared/closingreasonnotfoundresp.go | 15 + internal/sdk/models/shared/closingreasons.go | 14 + .../sdk/models/shared/closingreasonsids.go | 14 - .../sdk/models/shared/closingreasonsstatus.go | 34 ++ .../models/shared/definitionnotfoundresp.go | 2 +- internal/sdk/models/shared/dynamicduedate.go | 2 +- internal/sdk/models/shared/ecpdetails.go | 2 +- internal/sdk/models/shared/errorresp.go | 2 +- internal/sdk/models/shared/itemtype.go | 2 +- internal/sdk/models/shared/maxallowedlimit.go | 2 +- internal/sdk/models/shared/section.go | 2 +- internal/sdk/models/shared/security.go | 2 +- internal/sdk/models/shared/step.go | 2 +- internal/sdk/models/shared/stepdescription.go | 2 +- internal/sdk/models/shared/stepjourney.go | 2 +- internal/sdk/models/shared/steprequirement.go | 2 +- internal/sdk/models/shared/steptype.go | 2 +- .../models/shared/updateentityattributes.go | 2 +- .../sdk/models/shared/workflowdefinition.go | 2 +- internal/sdk/retry/config.go | 2 +- internal/sdk/sdk.go | 19 +- 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 | 2 +- internal/sdk/workflows.go | 313 +++++------ 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 +- workflow.yaml | 143 ++++- 132 files changed, 2131 insertions(+), 532 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 examples/data-sources/epilot-workflow_closing_reason/data-source.tf create mode 100644 examples/resources/epilot-workflow_closing_reason/import.sh create mode 100644 examples/resources/epilot-workflow_closing_reason/resource.tf create mode 100644 internal/provider/closingreason_data_source.go create mode 100644 internal/provider/closingreason_data_source_sdk.go create mode 100644 internal/provider/closingreason_resource.go create mode 100644 internal/provider/closingreason_resource_sdk.go create mode 100644 internal/sdk/CONTRIBUTING.md create mode 100644 internal/sdk/closingreason.go create mode 100644 internal/sdk/models/operations/changereasonstatus.go create mode 100644 internal/sdk/models/operations/createclosingreason.go create mode 100644 internal/sdk/models/operations/getallclosingreasons.go create mode 100644 internal/sdk/models/operations/getclosingreason.go delete mode 100644 internal/sdk/models/operations/getworkflowclosingreasons.go create mode 100644 internal/sdk/models/operations/options.go delete mode 100644 internal/sdk/models/operations/setworkflowclosingreasons.go create mode 100644 internal/sdk/models/shared/changereasonstatusreq.go create mode 100644 internal/sdk/models/shared/closingreason.go create mode 100644 internal/sdk/models/shared/closingreasonnotfoundresp.go create mode 100644 internal/sdk/models/shared/closingreasons.go delete mode 100644 internal/sdk/models/shared/closingreasonsids.go create mode 100644 internal/sdk/models/shared/closingreasonsstatus.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index dc20bbf..89db698 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: cdc191ce1bf61d7565b6f4caa1ea7ff9 + docChecksum: 088d1c5acb62ad859574f77a4fa9cfe7 docVersion: 1.0.0 - speakeasyVersion: 1.330.0 - generationVersion: 2.361.10 - releaseVersion: 0.11.0 - configChecksum: fe1f4f47e217555f3049bc6b86f7300b + speakeasyVersion: 1.346.0 + generationVersion: 2.379.3 + releaseVersion: 0.12.0 + configChecksum: c0d92b66a873af7e8a44f04f3d7ceed7 repoURL: https://github.com/epilot-dev/terraform-provider-epilot-workflow.git repoSubDirectory: . published: true @@ -21,12 +21,13 @@ features: unions: 2.85.0 terraform: additionalDependencies: 0.1.0 - core: 3.23.3 + core: 3.24.3 deprecations: 2.81.1 globalSecurity: 2.81.6 globalServerURLs: 2.82.1 unions: 2.81.15 generatedFiles: + - internal/sdk/closingreason.go - internal/sdk/workflows.go - internal/sdk/sdk.go - internal/sdk/models/errors/sdkerror.go @@ -46,14 +47,22 @@ generatedFiles: - 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/getworkflowclosingreasons.go - - internal/sdk/models/operations/setworkflowclosingreasons.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/section.go @@ -66,15 +75,15 @@ generatedFiles: - internal/sdk/models/shared/dynamicduedate.go - internal/sdk/models/shared/stepdescription.go - internal/sdk/models/shared/closingreasonid.go - - internal/sdk/models/shared/errorresp.go - internal/sdk/models/shared/definitionnotfoundresp.go - internal/sdk/models/shared/maxallowedlimit.go - - internal/sdk/models/shared/closingreasonsids.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 - examples/README.md - go.mod - go.sum @@ -134,11 +143,19 @@ generatedFiles: - 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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d585717 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/README.md b/README.md index 074e14c..756090a 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ terraform { required_providers { epilot-workflow = { source = "epilot-dev/epilot-workflow" - version = "0.11.0" + version = "0.12.0" } } } diff --git a/docs/data-sources/workflow_definition.md b/docs/data-sources/workflow_definition.md index e8205f4..d74e206 100644 --- a/docs/data-sources/workflow_definition.md +++ b/docs/data-sources/workflow_definition.md @@ -28,7 +28,7 @@ data "epilot-workflow_workflow_definition" "my_workflowdefinition" { - `creation_time` (String) ISO String Date & Time - `description` (String) - `due_date` (String) -- `dynamic_due_date` (String) set a Duedate for a step then a specific. Parsed as JSON. +- `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. @@ -45,6 +45,17 @@ 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` @@ -73,7 +84,7 @@ Read-Only: - `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` (String) set a Duedate for a step then a specific. Parsed as JSON. +- `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) @@ -102,6 +113,17 @@ Read-Only: - `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` @@ -175,7 +197,7 @@ Read-Only: - `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` (String) set a Duedate for a step then a specific. Parsed as JSON. +- `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) @@ -204,6 +226,17 @@ Read-Only: - `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` diff --git a/docs/index.md b/docs/index.md index cba4e83..0369ebd 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.10.0" + version = "0.11.0" } } } diff --git a/docs/resources/workflow_definition.md b/docs/resources/workflow_definition.md index 8ad6709..a03698e 100644 --- a/docs/resources/workflow_definition.md +++ b/docs/resources/workflow_definition.md @@ -18,7 +18,6 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { definition_id = "7hj28a" description = "...my_description..." due_date = "2021-04-27T12:00:00.000Z" - dynamic_due_date = "{ \"see\": \"documentation\" }" enable_ecp_workflow = false flow = [ { @@ -38,57 +37,62 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { enabled = true value = "...my_value..." } - due_date = "2021-04-27T12:00:00.000Z" - dynamic_due_date = "{ \"see\": \"documentation\" }" + due_date = "2021-04-27T12:00:00.000Z" + dynamic_due_date = { + action_type_condition = "STEP_CLOSED" + number_of_units = 73.8 + step_id = "...my_step_id..." + time_period = "weeks" + } ecp = { description = "...my_description..." enabled = false journey = { - id = "b9364361-b277-46d7-98c7-5f3e120ea0dc" + id = "64361b27-76d7-498c-b5f3-e120ea0dc9e1" journey_id = "...my_journey_id..." - name = "Mrs. Grady Bins" + name = "Lorraine Witting" } label = "...my_label..." } execution_type = "AUTOMATION" - id = "f93f96aa-0e34-4085-b7db-1176521d792f" + id = "3f96aa0e-3408-45f7-9b11-76521d792fea" installer = { description = "...my_description..." enabled = true journey = { - id = "a4830af3-5ac0-4f05-96d8-6c6d56674fb2" + id = "830af35a-c0f0-4516-986c-6d56674fb26d" journey_id = "...my_journey_id..." - name = "Elena Kuhic" + name = "Paulette O'Hara" } label = "...my_label..." } journey = { - id = "9f9b2b84-e882-493d-9869-3f16fc9936c9" + id = "9b2b84e8-8293-4d18-a93f-16fc9936c940" journey_id = "...my_journey_id..." - name = "Kimberly Marvin" + name = "Dr. Joel Hermann" } - name = "Dr. Eloise Nader" - order = 66.72 + name = "Lorene Denesik" + order = 4.83 requirements = [ { condition = "CLOSED" definition_id = "...my_definition_id..." - type = "SECTION" + type = "STEP" }, ] - type = "STEP" + type = "SECTION" user_ids = [ - 31.44, + 9.27, ] }, ] - type = "SECTION" + type = "STEP" } }, ] - id = "1470408a-193e-4721-a537-6b6381b5dd26" + id = "70408a19-3e72-4165-b76b-6381b5dd263e" last_update_time = "2021-04-27T12:01:13.000Z" - name = "Eloise Kreiger DVM" + name = "Nina Bednar" } ``` @@ -107,7 +111,7 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { - `creation_time` (String) ISO String Date & Time - `description` (String) - `due_date` (String) -- `dynamic_due_date` (String) set a Duedate for a step then a specific. Parsed as JSON. +- `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)) @@ -145,7 +149,7 @@ Optional: - `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` (String) set a Duedate for a step then a specific. Parsed as JSON. +- `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) @@ -174,6 +178,17 @@ Optional: - `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` @@ -247,7 +262,7 @@ Optional: - `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` (String) set a Duedate for a step then a specific. Parsed as JSON. +- `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) @@ -276,6 +291,17 @@ Optional: - `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` @@ -348,6 +374,17 @@ 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` diff --git a/examples/data-sources/epilot-workflow_closing_reason/data-source.tf b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf new file mode 100644 index 0000000..ec4863b --- /dev/null +++ b/examples/data-sources/epilot-workflow_closing_reason/data-source.tf @@ -0,0 +1,3 @@ +data "epilot-workflow_closing_reason" "my_closingreason" { + reason_id = "-poOAPBa-jFZA_AWV3zN0" +} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index e89a00a..2de1503 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.11.0" + version = "0.12.0" } } } diff --git a/examples/resources/epilot-workflow_closing_reason/import.sh b/examples/resources/epilot-workflow_closing_reason/import.sh new file mode 100644 index 0000000..fb38494 --- /dev/null +++ b/examples/resources/epilot-workflow_closing_reason/import.sh @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..c0f1076 --- /dev/null +++ b/examples/resources/epilot-workflow_closing_reason/resource.tf @@ -0,0 +1,8 @@ +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/resource.tf b/examples/resources/epilot-workflow_workflow_definition/resource.tf index 01410ce..d3fc7af 100644 --- a/examples/resources/epilot-workflow_workflow_definition/resource.tf +++ b/examples/resources/epilot-workflow_workflow_definition/resource.tf @@ -7,9 +7,9 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { flow = [ { section = { - id = "2a31ed4e-b201-4187-9740-15a348b64814" - name = "Meredith Bruen" - order = 1.95 + id = "452e3f02-980e-44cf-845d-81d428f0e4f5" + name = "Luther Greenfelder" + order = 12.7 steps = [ { assigned_to = [ @@ -19,45 +19,45 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { flow_id = "...my_flow_id..." } description = { - enabled = true + enabled = false value = "...my_value..." } due_date = "2021-04-27T12:00:00.000Z" dynamic_due_date = { - action_type_condition = "STEP_CLOSED" - number_of_units = 73.8 + action_type_condition = "WORKFLOW_STARTED" + number_of_units = 95.2 step_id = "...my_step_id..." time_period = "weeks" } ecp = { description = "...my_description..." - enabled = false + enabled = true journey = { - id = "64361b27-76d7-498c-b5f3-e120ea0dc9e1" + id = "56e082d1-2997-4428-b0e6-c4cc2bdf6697" journey_id = "...my_journey_id..." - name = "Lorraine Witting" + name = "Floyd Pacocha" } label = "...my_label..." } - execution_type = "AUTOMATION" - id = "3f96aa0e-3408-45f7-9b11-76521d792fea" + execution_type = "MANUAL" + id = "7a2ecac9-f13d-48a1-a6b9-dc969f95f0ea" installer = { description = "...my_description..." enabled = true journey = { - id = "830af35a-c0f0-4516-986c-6d56674fb26d" + id = "4100e0ec-f324-443f-89bc-c4a7284764a3" journey_id = "...my_journey_id..." - name = "Paulette O'Hara" + name = "Kara Hoppe" } label = "...my_label..." } journey = { - id = "9b2b84e8-8293-4d18-a93f-16fc9936c940" + id = "eff3a06c-e7de-4f51-84a6-068ca5b78833" journey_id = "...my_journey_id..." - name = "Dr. Joel Hermann" + name = "Brandy Senger" } - name = "Lorene Denesik" - order = 4.83 + name = "Sammy Gislason" + order = 14.54 requirements = [ { condition = "CLOSED" @@ -65,17 +65,17 @@ resource "epilot-workflow_workflow_definition" "my_workflowdefinition" { type = "STEP" }, ] - type = "SECTION" + type = "STEP" user_ids = [ - 9.27, + 94.55, ] }, ] - type = "STEP" + type = "SECTION" } }, ] - id = "70408a19-3e72-4165-b76b-6381b5dd263e" + id = "6301351b-2bbd-41bf-80cf-7a2f75db8f8a" last_update_time = "2021-04-27T12:01:13.000Z" - name = "Nina Bednar" + name = "Dr. Matthew Cronin" } \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 6ba32af..c176f79 100644 --- a/gen.yaml +++ b/gen.yaml @@ -27,7 +27,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.11.0 + version: 0.12.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/internal/planmodifiers/boolplanmodifier/suppress_diff.go b/internal/planmodifiers/boolplanmodifier/suppress_diff.go index b2efe2b..ab17812 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package boolplanmodifier diff --git a/internal/planmodifiers/float64planmodifier/suppress_diff.go b/internal/planmodifiers/float64planmodifier/suppress_diff.go index 569e717..1c99fab 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package float64planmodifier diff --git a/internal/planmodifiers/int64planmodifier/suppress_diff.go b/internal/planmodifiers/int64planmodifier/suppress_diff.go index 8ee73d1..bf5c5b6 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package int64planmodifier diff --git a/internal/planmodifiers/listplanmodifier/suppress_diff.go b/internal/planmodifiers/listplanmodifier/suppress_diff.go index 0e69684..d16d6c3 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package listplanmodifier diff --git a/internal/planmodifiers/mapplanmodifier/suppress_diff.go b/internal/planmodifiers/mapplanmodifier/suppress_diff.go index de3a1d1..28d40f7 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package mapplanmodifier diff --git a/internal/planmodifiers/numberplanmodifier/suppress_diff.go b/internal/planmodifiers/numberplanmodifier/suppress_diff.go index 5a84a10..108e998 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package numberplanmodifier diff --git a/internal/planmodifiers/objectplanmodifier/suppress_diff.go b/internal/planmodifiers/objectplanmodifier/suppress_diff.go index 42b7d06..88e16e6 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package objectplanmodifier diff --git a/internal/planmodifiers/setplanmodifier/suppress_diff.go b/internal/planmodifiers/setplanmodifier/suppress_diff.go index 81b0f44..10a391a 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package setplanmodifier diff --git a/internal/planmodifiers/stringplanmodifier/suppress_diff.go b/internal/planmodifiers/stringplanmodifier/suppress_diff.go index 53a1c43..94ab6a7 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package stringplanmodifier diff --git a/internal/planmodifiers/utils/state_check.go b/internal/planmodifiers/utils/state_check.go index 66d9150..6b126bf 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/provider/closingreason_data_source.go b/internal/provider/closingreason_data_source.go new file mode 100644 index 0000000..0324a9f --- /dev/null +++ b/internal/provider/closingreason_data_source.go @@ -0,0 +1,139 @@ +// 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 new file mode 100644 index 0000000..bb62dec --- /dev/null +++ b/internal/provider/closingreason_data_source_sdk.go @@ -0,0 +1,18 @@ +// 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 new file mode 100644 index 0000000..8e1eb73 --- /dev/null +++ b/internal/provider/closingreason_resource.go @@ -0,0 +1,266 @@ +// 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 new file mode 100644 index 0000000..4e40548 --- /dev/null +++ b/internal/provider/closingreason_resource_sdk.go @@ -0,0 +1,49 @@ +// 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 c85b4b5..076f8fb 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package provider @@ -85,12 +85,14 @@ 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, } } func (p *EpilotWorkflowProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ + NewClosingReasonDataSource, NewWorkflowDefinitionDataSource, } } diff --git a/internal/provider/reflect/diags.go b/internal/provider/reflect/diags.go index a91bba9..ce8aa51 100644 --- a/internal/provider/reflect/diags.go +++ b/internal/provider/reflect/diags.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/doc.go b/internal/provider/reflect/doc.go index ec91111..2978edc 100644 --- a/internal/provider/reflect/doc.go +++ b/internal/provider/reflect/doc.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.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 430ce2f..39454f5 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/helpers.go b/internal/provider/reflect/helpers.go index 42d19f2..398049d 100644 --- a/internal/provider/reflect/helpers.go +++ b/internal/provider/reflect/helpers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/interfaces.go b/internal/provider/reflect/interfaces.go index 364ff86..f5bd513 100644 --- a/internal/provider/reflect/interfaces.go +++ b/internal/provider/reflect/interfaces.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/into.go b/internal/provider/reflect/into.go index c53d1be..45b15ef 100644 --- a/internal/provider/reflect/into.go +++ b/internal/provider/reflect/into.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/map.go b/internal/provider/reflect/map.go index 3310d42..affbabe 100644 --- a/internal/provider/reflect/map.go +++ b/internal/provider/reflect/map.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/number.go b/internal/provider/reflect/number.go index 37eef21..e0021c3 100644 --- a/internal/provider/reflect/number.go +++ b/internal/provider/reflect/number.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/options.go b/internal/provider/reflect/options.go index d735aff..c6d7b44 100644 --- a/internal/provider/reflect/options.go +++ b/internal/provider/reflect/options.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/outof.go b/internal/provider/reflect/outof.go index 7852781..4fc5d24 100644 --- a/internal/provider/reflect/outof.go +++ b/internal/provider/reflect/outof.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/pointer.go b/internal/provider/reflect/pointer.go index e02c9eb..0ac5ebb 100644 --- a/internal/provider/reflect/pointer.go +++ b/internal/provider/reflect/pointer.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/primitive.go b/internal/provider/reflect/primitive.go index 3113c39..fc6b0e6 100644 --- a/internal/provider/reflect/primitive.go +++ b/internal/provider/reflect/primitive.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/slice.go b/internal/provider/reflect/slice.go index b91f729..7eea860 100644 --- a/internal/provider/reflect/slice.go +++ b/internal/provider/reflect/slice.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/reflect/struct.go b/internal/provider/reflect/struct.go index c730135..01ceb7b 100644 --- a/internal/provider/reflect/struct.go +++ b/internal/provider/reflect/struct.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package reflect diff --git a/internal/provider/types/automation_config.go b/internal/provider/types/automation_config.go index a1d19d5..bc17436 100644 --- a/internal/provider/types/automation_config.go +++ b/internal/provider/types/automation_config.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/closing_reason_id.go b/internal/provider/types/closing_reason_id.go index 652a232..062c0f6 100644 --- a/internal/provider/types/closing_reason_id.go +++ b/internal/provider/types/closing_reason_id.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/dynamic_due_date.go b/internal/provider/types/dynamic_due_date.go index 686bd69..9f9fc11 100644 --- a/internal/provider/types/dynamic_due_date.go +++ b/internal/provider/types/dynamic_due_date.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/ecp_details.go b/internal/provider/types/ecp_details.go index 5363e25..bc5f699 100644 --- a/internal/provider/types/ecp_details.go +++ b/internal/provider/types/ecp_details.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/flow.go b/internal/provider/types/flow.go index caf506b..90a97e6 100644 --- a/internal/provider/types/flow.go +++ b/internal/provider/types/flow.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/section.go b/internal/provider/types/section.go index 9b815b9..f913732 100644 --- a/internal/provider/types/section.go +++ b/internal/provider/types/section.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/step.go b/internal/provider/types/step.go index ce86cec..b5cf70d 100644 --- a/internal/provider/types/step.go +++ b/internal/provider/types/step.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/step_description.go b/internal/provider/types/step_description.go index b394d45..3dc0868 100644 --- a/internal/provider/types/step_description.go +++ b/internal/provider/types/step_description.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/step_journey.go b/internal/provider/types/step_journey.go index 634a218..987c9e7 100644 --- a/internal/provider/types/step_journey.go +++ b/internal/provider/types/step_journey.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/step_requirement.go b/internal/provider/types/step_requirement.go index 6a2366c..2ccf9f9 100644 --- a/internal/provider/types/step_requirement.go +++ b/internal/provider/types/step_requirement.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/target.go b/internal/provider/types/target.go index 7529a3b..a4a65fa 100644 --- a/internal/provider/types/target.go +++ b/internal/provider/types/target.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/types/update_entity_attributes.go b/internal/provider/types/update_entity_attributes.go index 0a8aa9e..89cf9a9 100644 --- a/internal/provider/types/update_entity_attributes.go +++ b/internal/provider/types/update_entity_attributes.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 312f5e0..71fae09 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package provider diff --git a/internal/provider/workflowdefinition_data_source.go b/internal/provider/workflowdefinition_data_source.go index 3699084..dcbf483 100644 --- a/internal/provider/workflowdefinition_data_source.go +++ b/internal/provider/workflowdefinition_data_source.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package provider diff --git a/internal/provider/workflowdefinition_data_source_sdk.go b/internal/provider/workflowdefinition_data_source_sdk.go index ec17e80..f75daee 100644 --- a/internal/provider/workflowdefinition_data_source_sdk.go +++ b/internal/provider/workflowdefinition_data_source_sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package provider diff --git a/internal/provider/workflowdefinition_resource.go b/internal/provider/workflowdefinition_resource.go index 489bc8a..210ffba 100644 --- a/internal/provider/workflowdefinition_resource.go +++ b/internal/provider/workflowdefinition_resource.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package provider diff --git a/internal/provider/workflowdefinition_resource_sdk.go b/internal/provider/workflowdefinition_resource_sdk.go index e7b6a55..a6a6e28 100644 --- a/internal/provider/workflowdefinition_resource_sdk.go +++ b/internal/provider/workflowdefinition_resource_sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package provider diff --git a/internal/sdk/CONTRIBUTING.md b/internal/sdk/CONTRIBUTING.md new file mode 100644 index 0000000..d585717 --- /dev/null +++ b/internal/sdk/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/internal/sdk/closingreason.go b/internal/sdk/closingreason.go new file mode 100644 index 0000000..0eeec3c --- /dev/null +++ b/internal/sdk/closingreason.go @@ -0,0 +1,522 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package sdk + +import ( + "bytes" + "context" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/hooks" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/errors" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/operations" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/models/shared" + "io" + "net/http" + "net/url" +) + +type ClosingReason struct { + sdkConfiguration sdkConfiguration +} + +func newClosingReason(sdkConfig sdkConfiguration) *ClosingReason { + return &ClosingReason{ + sdkConfiguration: sdkConfig, + } +} + +// ChangeReasonStatus - changeReasonStatus +// Change the status of a Closing Reason (eg. ACTIVE to INACTIVE). +func (s *ClosingReason) ChangeReasonStatus(ctx context.Context, request operations.ChangeReasonStatusRequest, opts ...operations.Option) (*operations.ChangeReasonStatusResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "changeReasonStatus", + 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) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "ChangeReasonStatusReq", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.ChangeReasonStatusResponse{ + 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 == 202: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ErrorResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// CreateClosingReason - createClosingReason +// A created Closing Reason is stored for the organization and will be displayed in the library of reasons. +func (s *ClosingReason) CreateClosingReason(ctx context.Context, request shared.ClosingReason, opts ...operations.Option) (*operations.CreateClosingReasonResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "createClosingReason", + 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 := url.JoinPath(baseURL, "/v1/workflows/closing-reasons") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.CreateClosingReasonResponse{ + 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 == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReason + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReason = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetAllClosingReasons - getAllClosingReasons +// Get all Closing Reasons defined in the organization by default all Active. +func (s *ClosingReason) GetAllClosingReasons(ctx context.Context, request operations.GetAllClosingReasonsRequest, opts ...operations.Option) (*operations.GetAllClosingReasonsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getAllClosingReasons", + 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 := url.JoinPath(baseURL, "/v1/workflows/closing-reasons") + 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.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.GetAllClosingReasonsResponse{ + 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.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 { + return nil, err + } + + res.ClosingReason = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ErrorResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ErrorResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out shared.ClosingReasonNotFoundResp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ClosingReasonNotFoundResp = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/internal/sdk/internal/hooks/hooks.go b/internal/sdk/internal/hooks/hooks.go index ee97182..b978f6b 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package hooks diff --git a/internal/sdk/internal/hooks/registration.go b/internal/sdk/internal/hooks/registration.go index e68bf4c..99a3606 100644 --- a/internal/sdk/internal/hooks/registration.go +++ b/internal/sdk/internal/hooks/registration.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package hooks diff --git a/internal/sdk/internal/utils/contenttype.go b/internal/sdk/internal/utils/contenttype.go index 763f2d6..81e669d 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/form.go b/internal/sdk/internal/utils/form.go index 4878573..c6f0eb3 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/headers.go b/internal/sdk/internal/utils/headers.go index 107d210..7af15f9 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index 0eccb87..9f5e7ef 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/pathparams.go b/internal/sdk/internal/utils/pathparams.go index 5ed7e18..17fd796 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/queryparams.go b/internal/sdk/internal/utils/queryparams.go index e2c5b9d..6369a61 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils @@ -6,12 +6,23 @@ import ( "context" "encoding/json" "fmt" + "math/big" "net/http" "net/url" "reflect" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/types" ) func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error { + // Query parameters may already be present from overriding URL + if req.URL.RawQuery != "" { + return nil + } + values := url.Values{} globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{}) @@ -132,54 +143,97 @@ func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue refl return values } - if objType.Kind() == reflect.Pointer { - objType = objType.Elem() + if objValue.Kind() == reflect.Pointer { objValue = objValue.Elem() } - switch objType.Kind() { + switch objValue.Kind() { + case reflect.Map: + populateDeepObjectParamsMap(values, tag.ParamName, objValue) case reflect.Struct: - for i := 0; i < objType.NumField(); i++ { - fieldType := objType.Field(i) - valType := objValue.Field(i) + populateDeepObjectParamsStruct(values, tag.ParamName, objValue) + } - if isNil(fieldType.Type, valType) { - continue - } + return values +} - if fieldType.Type.Kind() == reflect.Pointer { - valType = valType.Elem() - } +func populateDeepObjectParamsArray(qsValues url.Values, priorScope string, value reflect.Value) { + if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { + return + } - qpTag := parseQueryParamTag(fieldType) - if qpTag == nil { - continue - } + for i := 0; i < value.Len(); i++ { + qsValues.Add(priorScope, valToString(value.Index(i).Interface())) + } +} - switch valType.Kind() { - case reflect.Array, reflect.Slice: - for i := 0; i < valType.Len(); i++ { - values.Add(fmt.Sprintf("%s[%s]", tag.ParamName, qpTag.ParamName), valToString(valType.Index(i).Interface())) - } - default: - values.Add(fmt.Sprintf("%s[%s]", tag.ParamName, qpTag.ParamName), valToString(valType.Interface())) - } +func populateDeepObjectParamsMap(qsValues url.Values, priorScope string, mapValue reflect.Value) { + if mapValue.Kind() != reflect.Map { + return + } + + iter := mapValue.MapRange() + + for iter.Next() { + scope := priorScope + "[" + iter.Key().String() + "]" + iterValue := iter.Value() + + switch iterValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, iterValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, iterValue) + default: + qsValues.Add(scope, valToString(iterValue.Interface())) } - case reflect.Map: - iter := objValue.MapRange() - for iter.Next() { - switch iter.Value().Kind() { - case reflect.Array, reflect.Slice: - for i := 0; i < iter.Value().Len(); i++ { - values.Add(fmt.Sprintf("%s[%s]", tag.ParamName, iter.Key().String()), valToString(iter.Value().Index(i).Interface())) - } - default: - values.Add(fmt.Sprintf("%s[%s]", tag.ParamName, iter.Key().String()), valToString(iter.Value().Interface())) + } +} + +func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, structValue reflect.Value) { + if structValue.Kind() != reflect.Struct { + return + } + + structType := structValue.Type() + + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + fieldValue := structValue.Field(i) + + if isNil(field.Type, fieldValue) { + continue + } + + if fieldValue.Kind() == reflect.Pointer { + fieldValue = fieldValue.Elem() + } + + qpTag := parseQueryParamTag(field) + + if qpTag == nil { + continue + } + + scope := priorScope + "[" + qpTag.ParamName + "]" + + switch fieldValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, fieldValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, fieldValue) + case reflect.Struct: + switch fieldValue.Type() { + case reflect.TypeOf(big.Int{}), reflect.TypeOf(decimal.Big{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): + qsValues.Add(scope, valToString(fieldValue.Interface())) + + continue } + + populateDeepObjectParamsStruct(qsValues, scope, fieldValue) + default: + qsValues.Add(scope, valToString(fieldValue.Interface())) } } - - return values } func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index cfb2ba6..b4e2b8b 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/retries.go b/internal/sdk/internal/utils/retries.go index fb9318c..8839a0b 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/security.go b/internal/sdk/internal/utils/security.go index f7abb69..ace81f7 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index eab3682..50482f2 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package utils diff --git a/internal/sdk/models/errors/sdkerror.go b/internal/sdk/models/errors/sdkerror.go index c5a89b6..ff3fad6 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package errors diff --git a/internal/sdk/models/operations/changereasonstatus.go b/internal/sdk/models/operations/changereasonstatus.go new file mode 100644 index 0000000..d245881 --- /dev/null +++ b/internal/sdk/models/operations/changereasonstatus.go @@ -0,0 +1,67 @@ +// 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 ChangeReasonStatusRequest struct { + // change the status of a closing reason + ChangeReasonStatusReq *shared.ChangeReasonStatusReq `request:"mediaType=application/json"` + ReasonID string `pathParam:"style=simple,explode=false,name=reasonId"` +} + +func (o *ChangeReasonStatusRequest) GetChangeReasonStatusReq() *shared.ChangeReasonStatusReq { + if o == nil { + return nil + } + return o.ChangeReasonStatusReq +} + +func (o *ChangeReasonStatusRequest) GetReasonID() string { + if o == nil { + return "" + } + return o.ReasonID +} + +type ChangeReasonStatusResponse struct { + // HTTP response content type for this operation + ContentType string + // bad request + 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 *ChangeReasonStatusResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *ChangeReasonStatusResponse) GetErrorResp() *shared.ErrorResp { + if o == nil { + return nil + } + return o.ErrorResp +} + +func (o *ChangeReasonStatusResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *ChangeReasonStatusResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/createclosingreason.go b/internal/sdk/models/operations/createclosingreason.go new file mode 100644 index 0000000..f413124 --- /dev/null +++ b/internal/sdk/models/operations/createclosingreason.go @@ -0,0 +1,47 @@ +// 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 CreateClosingReasonResponse struct { + // closing reason is stored successfully in the repository + ClosingReason *shared.ClosingReason + // 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 *CreateClosingReasonResponse) GetClosingReason() *shared.ClosingReason { + if o == nil { + return nil + } + return o.ClosingReason +} + +func (o *CreateClosingReasonResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *CreateClosingReasonResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *CreateClosingReasonResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/createdefinition.go b/internal/sdk/models/operations/createdefinition.go index 630923b..181616f 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/deletedefinition.go b/internal/sdk/models/operations/deletedefinition.go index eebcb2f..cd269b4 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getallclosingreasons.go b/internal/sdk/models/operations/getallclosingreasons.go new file mode 100644 index 0000000..f9221ea --- /dev/null +++ b/internal/sdk/models/operations/getallclosingreasons.go @@ -0,0 +1,59 @@ +// 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 GetAllClosingReasonsRequest struct { + // Filter Closing Reasons by status like active inactiv + IncludeInactive *bool `queryParam:"style=form,explode=true,name=includeInactive"` +} + +func (o *GetAllClosingReasonsRequest) GetIncludeInactive() *bool { + if o == nil { + return nil + } + return o.IncludeInactive +} + +type GetAllClosingReasonsResponse struct { + // Returns the entire catalog of closing reasons per organization + ClosingReasons *shared.ClosingReasons + // 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 *GetAllClosingReasonsResponse) GetClosingReasons() *shared.ClosingReasons { + if o == nil { + return nil + } + return o.ClosingReasons +} + +func (o *GetAllClosingReasonsResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetAllClosingReasonsResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetAllClosingReasonsResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/getclosingreason.go b/internal/sdk/models/operations/getclosingreason.go new file mode 100644 index 0000000..0a2e20f --- /dev/null +++ b/internal/sdk/models/operations/getclosingreason.go @@ -0,0 +1,77 @@ +// 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 5a915e2..edf5f75 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getdefinitions.go b/internal/sdk/models/operations/getdefinitions.go index 11b16b1..f4e1512 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getmaxallowedlimit.go b/internal/sdk/models/operations/getmaxallowedlimit.go index 2f590d4..b64ff93 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/operations/getworkflowclosingreasons.go b/internal/sdk/models/operations/getworkflowclosingreasons.go deleted file mode 100644 index 355930b..0000000 --- a/internal/sdk/models/operations/getworkflowclosingreasons.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). 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 new file mode 100644 index 0000000..6cf35c9 --- /dev/null +++ b/internal/sdk/models/operations/options.go @@ -0,0 +1,93 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "errors" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/internal/utils" + "github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk/retry" + "time" +) + +var ErrUnsupportedOption = errors.New("unsupported option") + +const ( + SupportedOptionServerURL = "serverURL" + SupportedOptionRetries = "retries" + SupportedOptionTimeout = "timeout" + SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" + SupportedOptionURLOverride = "urlOverride" +) + +type Options struct { + ServerURL *string + Retries *retry.Config + Timeout *time.Duration + URLOverride *string +} + +type Option func(*Options, ...string) error + +// WithServerURL allows providing an alternative server URL. +func WithServerURL(serverURL string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionServerURL) { + return ErrUnsupportedOption + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithTemplatedServerURL allows providing an alternative server URL with templated parameters. +func WithTemplatedServerURL(serverURL string, params map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionServerURL) { + return ErrUnsupportedOption + } + + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithRetries allows customizing the default retry configuration. +func WithRetries(config retry.Config) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Retries = &config + return nil + } +} + +// WithOperationTimeout allows setting the request timeout applied for an operation. +func WithOperationTimeout(timeout time.Duration) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Timeout = &timeout + return nil + } +} + +// WithURLOverride allows overriding the URL. +func WithURLOverride(urlOverride string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionURLOverride) { + return ErrUnsupportedOption + } + + opts.URLOverride = &urlOverride + return nil + } +} diff --git a/internal/sdk/models/operations/setworkflowclosingreasons.go b/internal/sdk/models/operations/setworkflowclosingreasons.go deleted file mode 100644 index ed48a62..0000000 --- a/internal/sdk/models/operations/setworkflowclosingreasons.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). 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 7886b96..c056fbc 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package operations diff --git a/internal/sdk/models/shared/changereasonstatusreq.go b/internal/sdk/models/shared/changereasonstatusreq.go new file mode 100644 index 0000000..98a057a --- /dev/null +++ b/internal/sdk/models/shared/changereasonstatusreq.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package shared + +type ChangeReasonStatusReq struct { + Status ClosingReasonsStatus `json:"status"` +} + +func (o *ChangeReasonStatusReq) GetStatus() ClosingReasonsStatus { + if o == nil { + return ClosingReasonsStatus("") + } + return o.Status +} diff --git a/internal/sdk/models/shared/closingreason.go b/internal/sdk/models/shared/closingreason.go new file mode 100644 index 0000000..6a62f45 --- /dev/null +++ b/internal/sdk/models/shared/closingreason.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package shared + +// ClosingReason - One Closing reason for a workflow +type ClosingReason struct { + CreationTime *string `json:"creationTime,omitempty"` + ID *string `json:"id,omitempty"` + LastUpdateTime *string `json:"lastUpdateTime,omitempty"` + Status ClosingReasonsStatus `json:"status"` + Title string `json:"title"` +} + +func (o *ClosingReason) GetCreationTime() *string { + if o == nil { + return nil + } + return o.CreationTime +} + +func (o *ClosingReason) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *ClosingReason) GetLastUpdateTime() *string { + if o == nil { + return nil + } + return o.LastUpdateTime +} + +func (o *ClosingReason) GetStatus() ClosingReasonsStatus { + if o == nil { + return ClosingReasonsStatus("") + } + return o.Status +} + +func (o *ClosingReason) GetTitle() string { + if o == nil { + return "" + } + return o.Title +} diff --git a/internal/sdk/models/shared/closingreasonid.go b/internal/sdk/models/shared/closingreasonid.go index bcf491a..bb88b11 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/closingreasonnotfoundresp.go b/internal/sdk/models/shared/closingreasonnotfoundresp.go new file mode 100644 index 0000000..828e59a --- /dev/null +++ b/internal/sdk/models/shared/closingreasonnotfoundresp.go @@ -0,0 +1,15 @@ +// 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 new file mode 100644 index 0000000..d24ee4e --- /dev/null +++ b/internal/sdk/models/shared/closingreasons.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package shared + +type ClosingReasons struct { + Reasons []ClosingReason `json:"reasons"` +} + +func (o *ClosingReasons) GetReasons() []ClosingReason { + if o == nil { + return []ClosingReason{} + } + return o.Reasons +} diff --git a/internal/sdk/models/shared/closingreasonsids.go b/internal/sdk/models/shared/closingreasonsids.go deleted file mode 100644 index 5db01e5..0000000 --- a/internal/sdk/models/shared/closingreasonsids.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). 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 new file mode 100644 index 0000000..4818dac --- /dev/null +++ b/internal/sdk/models/shared/closingreasonsstatus.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type ClosingReasonsStatus string + +const ( + ClosingReasonsStatusActive ClosingReasonsStatus = "ACTIVE" + ClosingReasonsStatusInactive ClosingReasonsStatus = "INACTIVE" +) + +func (e ClosingReasonsStatus) ToPointer() *ClosingReasonsStatus { + return &e +} +func (e *ClosingReasonsStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "ACTIVE": + fallthrough + case "INACTIVE": + *e = ClosingReasonsStatus(v) + return nil + default: + return fmt.Errorf("invalid value for ClosingReasonsStatus: %v", v) + } +} diff --git a/internal/sdk/models/shared/definitionnotfoundresp.go b/internal/sdk/models/shared/definitionnotfoundresp.go index a63b55e..f7765f0 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/dynamicduedate.go b/internal/sdk/models/shared/dynamicduedate.go index b34b252..919b9f1 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/ecpdetails.go b/internal/sdk/models/shared/ecpdetails.go index 4e295cc..e736e90 100644 --- a/internal/sdk/models/shared/ecpdetails.go +++ b/internal/sdk/models/shared/ecpdetails.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/errorresp.go b/internal/sdk/models/shared/errorresp.go index 5f97f0f..499c86a 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/itemtype.go b/internal/sdk/models/shared/itemtype.go index e11b329..2f5ed03 100644 --- a/internal/sdk/models/shared/itemtype.go +++ b/internal/sdk/models/shared/itemtype.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/maxallowedlimit.go b/internal/sdk/models/shared/maxallowedlimit.go index 0ce4d10..440935d 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/section.go b/internal/sdk/models/shared/section.go index fb21e76..3304bef 100644 --- a/internal/sdk/models/shared/section.go +++ b/internal/sdk/models/shared/section.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/security.go b/internal/sdk/models/shared/security.go index 8cb424b..194e081 100644 --- a/internal/sdk/models/shared/security.go +++ b/internal/sdk/models/shared/security.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/step.go b/internal/sdk/models/shared/step.go index 7d56cc8..b1d3221 100644 --- a/internal/sdk/models/shared/step.go +++ b/internal/sdk/models/shared/step.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/stepdescription.go b/internal/sdk/models/shared/stepdescription.go index 3630715..9c522ef 100644 --- a/internal/sdk/models/shared/stepdescription.go +++ b/internal/sdk/models/shared/stepdescription.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/stepjourney.go b/internal/sdk/models/shared/stepjourney.go index 800240e..6a334d1 100644 --- a/internal/sdk/models/shared/stepjourney.go +++ b/internal/sdk/models/shared/stepjourney.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/steprequirement.go b/internal/sdk/models/shared/steprequirement.go index fbaa61b..6a739af 100644 --- a/internal/sdk/models/shared/steprequirement.go +++ b/internal/sdk/models/shared/steprequirement.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/steptype.go b/internal/sdk/models/shared/steptype.go index e10c2ce..1a7a91d 100644 --- a/internal/sdk/models/shared/steptype.go +++ b/internal/sdk/models/shared/steptype.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/updateentityattributes.go b/internal/sdk/models/shared/updateentityattributes.go index 37df8f3..4b1a63e 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/models/shared/workflowdefinition.go b/internal/sdk/models/shared/workflowdefinition.go index 47f97c2..7a70836 100644 --- a/internal/sdk/models/shared/workflowdefinition.go +++ b/internal/sdk/models/shared/workflowdefinition.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package shared diff --git a/internal/sdk/retry/config.go b/internal/sdk/retry/config.go index dbbd57e..a9b559b 100644 --- a/internal/sdk/retry/config.go +++ b/internal/sdk/retry/config.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package retry diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 335258e..29192d3 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package sdk @@ -53,6 +53,7 @@ type sdkConfiguration struct { UserAgent string RetryConfig *retry.Config Hooks *hooks.Hooks + Timeout *time.Duration } func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { @@ -65,7 +66,8 @@ func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { // SDK - Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization type SDK struct { - Workflows *Workflows + ClosingReason *ClosingReason + Workflows *Workflows sdkConfiguration sdkConfiguration } @@ -130,6 +132,13 @@ func WithRetryConfig(retryConfig retry.Config) SDKOption { } } +// WithTimeout Optional request timeout applied to each operation +func WithTimeout(timeout time.Duration) SDKOption { + return func(sdk *SDK) { + sdk.sdkConfiguration.Timeout = &timeout + } +} + // New creates a new instance of the SDK with the provided options func New(opts ...SDKOption) *SDK { sdk := &SDK{ @@ -137,8 +146,8 @@ func New(opts ...SDKOption) *SDK { Language: "go", OpenAPIDocVersion: "1.0.0", SDKVersion: "0.0.1", - GenVersion: "2.361.10", - UserAgent: "speakeasy-sdk/go 0.0.1 2.361.10 1.0.0 github.com/epilot-dev/terraform-provider-epilot-workflow/internal/sdk", + 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", Hooks: hooks.New(), }, } @@ -158,6 +167,8 @@ func New(opts ...SDKOption) *SDK { sdk.sdkConfiguration.ServerURL = serverURL } + sdk.ClosingReason = newClosingReason(sdk.sdkConfiguration) + sdk.Workflows = newWorkflows(sdk.sdkConfiguration) return sdk diff --git a/internal/sdk/types/bigint.go b/internal/sdk/types/bigint.go index afd0cd2..4765ef2 100644 --- a/internal/sdk/types/bigint.go +++ b/internal/sdk/types/bigint.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/date.go b/internal/sdk/types/date.go index c4648fa..131f364 100644 --- a/internal/sdk/types/date.go +++ b/internal/sdk/types/date.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/datetime.go b/internal/sdk/types/datetime.go index 0529b25..c07ddcd 100644 --- a/internal/sdk/types/datetime.go +++ b/internal/sdk/types/datetime.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/decimal.go b/internal/sdk/types/decimal.go index a42284b..f7def72 100644 --- a/internal/sdk/types/decimal.go +++ b/internal/sdk/types/decimal.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/sdk/types/pointers.go b/internal/sdk/types/pointers.go index 4f15e99..1ed80cf 100644 --- a/internal/sdk/types/pointers.go +++ b/internal/sdk/types/pointers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package types diff --git a/internal/sdk/workflows.go b/internal/sdk/workflows.go index 282f2ff..e5bb013 100644 --- a/internal/sdk/workflows.go +++ b/internal/sdk/workflows.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package sdk @@ -28,7 +28,7 @@ func newWorkflows(sdkConfig sdkConfiguration) *Workflows { // CreateDefinition - createDefinition // Create a Workflow Definition. -func (s *Workflows) CreateDefinition(ctx context.Context, request shared.WorkflowDefinition) (*operations.CreateDefinitionResponse, error) { +func (s *Workflows) CreateDefinition(ctx context.Context, request shared.WorkflowDefinition, opts ...operations.Option) (*operations.CreateDefinitionResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "createDefinition", @@ -36,6 +36,17 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo 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 := url.JoinPath(baseURL, "/v1/workflows/definitions") if err != nil { @@ -47,6 +58,17 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo return nil, err } + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) @@ -140,7 +162,7 @@ func (s *Workflows) CreateDefinition(ctx context.Context, request shared.Workflo // DeleteDefinition - deleteDefinition // Delete Workflow Definition. -func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.DeleteDefinitionRequest) (*operations.DeleteDefinitionResponse, error) { +func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.DeleteDefinitionRequest, opts ...operations.Option) (*operations.DeleteDefinitionResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "deleteDefinition", @@ -148,12 +170,34 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del 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}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) @@ -233,7 +277,7 @@ func (s *Workflows) DeleteDefinition(ctx context.Context, request operations.Del // GetDefinition - getDefinition // Get specific Definition by id from the Organization. -func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDefinitionRequest) (*operations.GetDefinitionResponse, error) { +func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDefinitionRequest, opts ...operations.Option) (*operations.GetDefinitionResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getDefinition", @@ -241,12 +285,34 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef 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}", 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) @@ -351,7 +417,7 @@ func (s *Workflows) GetDefinition(ctx context.Context, request operations.GetDef // GetDefinitions - getDefinitions // Retrieve all Workflow Definitions from an Organization -func (s *Workflows) GetDefinitions(ctx context.Context) (*operations.GetDefinitionsResponse, error) { +func (s *Workflows) GetDefinitions(ctx context.Context, opts ...operations.Option) (*operations.GetDefinitionsResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getDefinitions", @@ -359,12 +425,34 @@ func (s *Workflows) GetDefinitions(ctx context.Context) (*operations.GetDefiniti 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 := url.JoinPath(baseURL, "/v1/workflows/definitions") 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) @@ -453,7 +541,7 @@ func (s *Workflows) GetDefinitions(ctx context.Context) (*operations.GetDefiniti // GetMaxAllowedLimit - getMaxAllowedLimit // Get limits and number of created executions for an Organization. -func (s *Workflows) GetMaxAllowedLimit(ctx context.Context) (*operations.GetMaxAllowedLimitResponse, error) { +func (s *Workflows) GetMaxAllowedLimit(ctx context.Context, opts ...operations.Option) (*operations.GetMaxAllowedLimitResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getMaxAllowedLimit", @@ -461,12 +549,34 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context) (*operations.GetMaxA 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 := url.JoinPath(baseURL, "/v1/workflows/limits/max-allowed") 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) @@ -553,200 +663,47 @@ func (s *Workflows) GetMaxAllowedLimit(ctx context.Context) (*operations.GetMaxA } -// GetWorkflowClosingReasons - getWorkflowClosingReasons -// Returns all closing reasons defined for the workflow. -func (s *Workflows) GetWorkflowClosingReasons(ctx context.Context, request operations.GetWorkflowClosingReasonsRequest) (*operations.GetWorkflowClosingReasonsResponse, error) { +// UpdateDefinition - updateDefinition +// Update Workflow Definition. +func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.UpdateDefinitionRequest, opts ...operations.Option) (*operations.UpdateDefinitionResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "getWorkflowClosingReasons", + OperationID: "updateDefinition", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } - 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) - } - - 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 + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionTimeout, } - 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, - } - - 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.ClosingReasonsIds - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ClosingReasonsIds = &out - default: - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) } - default: - 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) (*operations.SetWorkflowClosingReasonsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "setWorkflowClosingReasons", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/workflows/definitions/{definitionId}/closing-reasons", request, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/workflows/definitions/{definitionId}", 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 - } - - 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) + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "WorkflowDefinition", "json", `request:"mediaType=application/json"`) 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, + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - - switch { - case httpRes.StatusCode == 201: - default: - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateDefinition - updateDefinition -// Update Workflow Definition. -func (s *Workflows) UpdateDefinition(ctx context.Context, request operations.UpdateDefinitionRequest) (*operations.UpdateDefinitionResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateDefinition", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/workflows/definitions/{definitionId}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "WorkflowDefinition", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() } req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) diff --git a/internal/validators/DateValidator.go b/internal/validators/DateValidator.go index 300a4d5..1bd2815 100644 --- a/internal/validators/DateValidator.go +++ b/internal/validators/DateValidator.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package validators diff --git a/internal/validators/ExactlyOneChild.go b/internal/validators/ExactlyOneChild.go index 5741558..dc9cd6a 100644 --- a/internal/validators/ExactlyOneChild.go +++ b/internal/validators/ExactlyOneChild.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package validators diff --git a/internal/validators/JSONParseValidator.go b/internal/validators/JSONParseValidator.go index 3a341e1..cb680b9 100644 --- a/internal/validators/JSONParseValidator.go +++ b/internal/validators/JSONParseValidator.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package validators diff --git a/internal/validators/RFC3339Validator.go b/internal/validators/RFC3339Validator.go index ad3d715..888f85c 100644 --- a/internal/validators/RFC3339Validator.go +++ b/internal/validators/RFC3339Validator.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package validators diff --git a/internal/validators/boolvalidators/not_null.go b/internal/validators/boolvalidators/not_null.go index 45e2e97..de7f756 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package boolvalidators diff --git a/internal/validators/float64validators/not_null.go b/internal/validators/float64validators/not_null.go index 75099c2..fed2c05 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package float64validators diff --git a/internal/validators/int64validators/not_null.go b/internal/validators/int64validators/not_null.go index 32192d8..c07e1de 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package int64validators diff --git a/internal/validators/listvalidators/not_null.go b/internal/validators/listvalidators/not_null.go index c7bfa6e..f39d6fa 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package listvalidators diff --git a/internal/validators/mapvalidators/not_null.go b/internal/validators/mapvalidators/not_null.go index 7d22172..9cdf99e 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package mapvalidators diff --git a/internal/validators/numbervalidators/not_null.go b/internal/validators/numbervalidators/not_null.go index b085170..e2baffe 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package numbervalidators diff --git a/internal/validators/objectvalidators/not_null.go b/internal/validators/objectvalidators/not_null.go index c45ca8d..480ec23 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package objectvalidators diff --git a/internal/validators/setvalidators/not_null.go b/internal/validators/setvalidators/not_null.go index 23d6c16..45369e3 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package setvalidators diff --git a/internal/validators/stringvalidators/not_null.go b/internal/validators/stringvalidators/not_null.go index f15f8ae..ce5f808 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.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package stringvalidators diff --git a/main.go b/main.go index 9c0828d..515bdb0 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. package main diff --git a/tools/tools.go b/tools/tools.go index 4f42a8c..08da0fd 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. //go:build tools diff --git a/workflow.yaml b/workflow.yaml index 919e2c8..ae0f733 100644 --- a/workflow.yaml +++ b/workflow.yaml @@ -434,52 +434,141 @@ paths: 404: description: No definition found - /v1/workflows/definitions/{definitionId}/closing-reasons: + /v1/workflows/closing-reasons: get: - operationId: getWorkflowClosingReasons - summary: getWorkflowClosingReasons - description: Returns all closing reasons defined for the workflow. + operationId: getAllClosingReasons + summary: getAllClosingReasons + description: Get all Closing Reasons defined in the organization by default all Active. + parameters: + - in: query + name: includeInactive + schema: + type: boolean + required: false + description: Filter Closing Reasons by status like active inactiv + example: true + tags: + - Closing Reason + responses: + 200: + description: Returns the entire catalog of closing reasons per organization + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasons" + post: + operationId: createClosingReason + x-speakeasy-entity-operation: ClosingReason#create + summary: createClosingReason + description: A created Closing Reason is stored for the organization and will be displayed in the library of reasons. + tags: + - Closing Reason + requestBody: + description: closing reason to store + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + example: + title: better offer + description: A customer closes the process because he found something better + responses: + 201: + description: closing reason is stored successfully in the repository + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + + /v1/workflows/closing-reasons/{reasonId}: + get: + operationId: getClosingReason + x-speakeasy-entity-operation: ClosingReason#get + summary: getClosingReason + description: Get specific closing reason by id from the organisation. + tags: + - Closing Reason parameters: - in: path - name: definitionId + name: reasonId + x-speakeasy-match: id schema: type: string required: true - description: ID of a workflow definition - example: fxcwfw - tags: - - Workflows + description: uuid to identify the closing reason. + example: -poOAPBa-jFZA_AWV3zN0 responses: 200: - description: Returns the entire catalog of closing reasons for a specific workflow + description: Returns the closing reason + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReason" + example: + id: -poOAPBa-jFZA_AWV3zN0 + title: Closing due to example reason + status: "ACTIVE" + lastUpdateTime: "2021-08-04T21:13:50.373Z" + creationTime: "2021-08-04T21:13:50.373Z" + 400: + description: Validation Errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 404: + description: Closing reason not found + content: + application/json: + schema: + $ref: "#/components/schemas/ClosingReasonNotFoundResp" + 401: + description: Authentication Errors content: application/json: schema: - $ref: "#/components/schemas/ClosingReasonsIds" + $ref: "#/components/schemas/ErrorResp" + 500: + description: Other errors + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" patch: - operationId: setWorkflowClosingReasons - summary: setWorkflowClosingReasons - description: Sets which closing reasons are defined for this workflow, based on the entire closing reasons catalog. + operationId: changeReasonStatus + summary: changeReasonStatus + description: Change the status of a Closing Reason (eg. ACTIVE to INACTIVE). tags: - - Workflows + - Closing Reason parameters: - in: path - name: definitionId + name: reasonId + required: true schema: type: string - required: true - description: ID of a workflow definition - example: 7889 requestBody: - description: set all closing reasons for a specific definition - required: true + description: change the status of a closing reason content: application/json: schema: - $ref: "#/components/schemas/ClosingReasonsIds" + $ref: "#/components/schemas/ChangeReasonStatusReq" + responses: - 201: - description: closing reasons are set for this workflow + 202: + description: The status change was accepted + 400: + description: bad request + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" + 500: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResp" components: securitySchemes: @@ -808,3 +897,9 @@ components: - definitionId - type - condition + + ClosingReasonNotFoundResp: + description: Closing reason could be not found + properties: + message: + type: string