From 8e93ec1cca9f5b252cd3d64f4b4dc706975d0cee Mon Sep 17 00:00:00 2001 From: Markus Blomqvist Date: Mon, 16 Sep 2024 14:46:16 +0300 Subject: [PATCH] Update openapi spec with live prod version --- .speakeasy/gen.lock | 241 +++-- Makefile | 8 +- README.md | 66 +- docs/data-sources/journey.md | 11 +- docs/index.md | 2 +- docs/resources/journey.md | 71 +- .../epilot-journey_journey/data-source.tf | 1 - examples/provider/provider.tf | 2 +- .../epilot-journey_journey/resource.tf | 71 +- gen.yaml | 2 +- internal/provider/journey_data_source.go | 15 +- internal/provider/journey_resource.go | 10 + internal/sdk/internal/utils/json.go | 25 +- internal/sdk/internal/utils/requestbody.go | 5 +- internal/sdk/internal/utils/security.go | 12 +- internal/sdk/journeys.go | 441 +++++++- internal/sdk/journeysv2.go | 130 ++- .../sdk/models/operations/generatedocument.go | 58 + internal/sdk/models/operations/getjourney.go | 11 + .../models/operations/getjourneyproducts.go | 9 - .../models/shared/generatedocumentrequest.go | 45 + .../models/shared/generatedocumentresponse.go | 196 ++++ internal/sdk/models/shared/journey.go | 8 + .../models/shared/journeycreationrequest.go | 8 + internal/sdk/models/shared/s3reference.go | 22 + .../models/shared/searchjourneysresponse.go | 14 +- .../sdk/models/shared/templatesettings.go | 123 +++ internal/sdk/sdk.go | 7 +- internal/sdk/types/pointers.go | 1 + openapi.yml | 991 ------------------ 30 files changed, 1397 insertions(+), 1209 deletions(-) create mode 100644 internal/sdk/models/operations/generatedocument.go create mode 100644 internal/sdk/models/shared/generatedocumentrequest.go create mode 100644 internal/sdk/models/shared/generatedocumentresponse.go create mode 100644 internal/sdk/models/shared/s3reference.go create mode 100644 internal/sdk/models/shared/templatesettings.go delete mode 100644 openapi.yml diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index e280f54..4aec747 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 1afd37bc-cea9-4679-ac40-35ad5de414fc management: - docChecksum: b9a09d98391fd5759e163be37edd17bc + docChecksum: 3901f7467d14573d45f36f2600928081 docVersion: 1.0.0 - speakeasyVersion: 1.381.1 - generationVersion: 2.404.9 - releaseVersion: 0.4.0 - configChecksum: f83f174849770bbe062f6cc92d3b40f9 + speakeasyVersion: 1.396.7 + generationVersion: 2.415.6 + releaseVersion: 0.5.0 + configChecksum: 591bb96d74dcfe2214dad3c54e33a388 repoURL: https://github.com/epilot-dev/terraform-provider-epilot-journey.git repoSubDirectory: . published: true @@ -15,63 +15,23 @@ features: additionalDependencies: 0.1.0 additionalProperties: 0.1.2 constsAndDefaults: 0.1.4 - core: 3.24.7 + core: 3.24.11 deprecations: 2.81.1 envVarSecurityUsage: 0.1.0 globalSecurity: 2.81.8 globalServerURLs: 2.82.1 + methodSecurity: 2.82.1 nullables: 0.0.0 retries: 2.81.1 generatedFiles: - - internal/sdk/journeys.go - - internal/sdk/journeysv2.go - - internal/sdk/sdk.go - - internal/sdk/models/errors/sdkerror.go - - internal/sdk/retry/config.go - - internal/sdk/types/bigint.go - - internal/sdk/types/date.go - - internal/sdk/types/datetime.go - - internal/sdk/types/decimal.go - - internal/sdk/types/pointers.go - - internal/sdk/internal/utils/contenttype.go - - internal/sdk/internal/utils/form.go - - internal/sdk/internal/utils/headers.go - - internal/sdk/internal/utils/json.go - - internal/sdk/internal/utils/pathparams.go - - internal/sdk/internal/utils/queryparams.go - - internal/sdk/internal/utils/requestbody.go - - internal/sdk/internal/utils/retries.go - - internal/sdk/internal/utils/security.go - - internal/sdk/internal/utils/utils.go - - internal/sdk/models/operations/createjourney.go - - internal/sdk/models/operations/getjourney.go - - internal/sdk/models/operations/getjourneyproducts.go - - internal/sdk/models/operations/getjourneysbyorgid.go - - internal/sdk/models/operations/patchupdatejourney.go - - internal/sdk/models/operations/removejourney.go - - internal/sdk/models/operations/searchjourneys.go - - internal/sdk/models/operations/updatejourney.go - - internal/sdk/models/operations/createjourneyv2.go - - internal/sdk/models/operations/getjourneyv2.go - - internal/sdk/models/operations/patchupdatejourneyv2.go - - internal/sdk/models/operations/removejourneyv2.go - - internal/sdk/models/operations/updatejourneyv2.go - - internal/sdk/models/shared/journey.go - - internal/sdk/models/shared/journeycreationrequest.go - - internal/sdk/models/shared/journeyproductsresponse.go - - internal/sdk/models/shared/getjourneysresponse.go - - internal/sdk/models/shared/journeyresponse.go - - internal/sdk/models/shared/patchupdatejourneyrequest.go - - internal/sdk/models/shared/searchjourneysresponse.go - - internal/sdk/models/shared/searchjourneysqueryrequest.go - - internal/sdk/models/shared/journeycreationrequestv2.go - - internal/sdk/models/shared/security.go - - internal/sdk/.gitignore - - internal/sdk/models/operations/options.go - - internal/sdk/.gitattributes - - internal/sdk/internal/hooks/hooks.go - - internal/sdk/CONTRIBUTING.md + - .gitattributes + - CONTRIBUTING.md + - USAGE.md - examples/README.md + - examples/data-sources/epilot-journey_journey/data-source.tf + - examples/provider/provider.tf + - examples/resources/epilot-journey_journey/import.sh + - examples/resources/epilot-journey_journey/resource.tf - go.mod - go.sum - internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -84,6 +44,11 @@ generatedFiles: - internal/planmodifiers/setplanmodifier/suppress_diff.go - internal/planmodifiers/stringplanmodifier/suppress_diff.go - internal/planmodifiers/utils/state_check.go + - internal/provider/journey_data_source.go + - internal/provider/journey_data_source_sdk.go + - internal/provider/journey_resource.go + - internal/provider/journey_resource_sdk.go + - internal/provider/provider.go - internal/provider/reflect/diags.go - internal/provider/reflect/doc.go - internal/provider/reflect/generic_attr_value.go @@ -98,7 +63,67 @@ generatedFiles: - internal/provider/reflect/primitive.go - internal/provider/reflect/slice.go - internal/provider/reflect/struct.go + - internal/provider/types/journey_creation_request_v2_button.go + - internal/provider/types/journey_creation_request_v2_context_schema.go + - internal/provider/types/journey_creation_request_v2_design.go + - internal/provider/types/journey_creation_request_v2_embed_options.go + - internal/provider/types/journey_creation_request_v2_logics.go + - internal/provider/types/journey_creation_request_v2_rules.go + - internal/provider/types/journey_creation_request_v2_settings.go - internal/provider/utils.go + - internal/sdk/.gitattributes + - internal/sdk/.gitignore + - internal/sdk/CONTRIBUTING.md + - internal/sdk/internal/hooks/hooks.go + - internal/sdk/internal/utils/contenttype.go + - internal/sdk/internal/utils/form.go + - internal/sdk/internal/utils/headers.go + - internal/sdk/internal/utils/json.go + - internal/sdk/internal/utils/pathparams.go + - internal/sdk/internal/utils/queryparams.go + - internal/sdk/internal/utils/requestbody.go + - internal/sdk/internal/utils/retries.go + - internal/sdk/internal/utils/security.go + - internal/sdk/internal/utils/utils.go + - internal/sdk/journeys.go + - internal/sdk/journeysv2.go + - internal/sdk/models/errors/sdkerror.go + - internal/sdk/models/operations/createjourney.go + - internal/sdk/models/operations/createjourneyv2.go + - internal/sdk/models/operations/generatedocument.go + - internal/sdk/models/operations/getjourney.go + - internal/sdk/models/operations/getjourneyproducts.go + - internal/sdk/models/operations/getjourneysbyorgid.go + - internal/sdk/models/operations/getjourneyv2.go + - internal/sdk/models/operations/options.go + - internal/sdk/models/operations/patchupdatejourney.go + - internal/sdk/models/operations/patchupdatejourneyv2.go + - internal/sdk/models/operations/removejourney.go + - internal/sdk/models/operations/removejourneyv2.go + - internal/sdk/models/operations/searchjourneys.go + - internal/sdk/models/operations/updatejourney.go + - internal/sdk/models/operations/updatejourneyv2.go + - internal/sdk/models/shared/generatedocumentrequest.go + - internal/sdk/models/shared/generatedocumentresponse.go + - internal/sdk/models/shared/getjourneysresponse.go + - internal/sdk/models/shared/journey.go + - internal/sdk/models/shared/journeycreationrequest.go + - internal/sdk/models/shared/journeycreationrequestv2.go + - internal/sdk/models/shared/journeyproductsresponse.go + - internal/sdk/models/shared/journeyresponse.go + - internal/sdk/models/shared/patchupdatejourneyrequest.go + - internal/sdk/models/shared/s3reference.go + - internal/sdk/models/shared/searchjourneysqueryrequest.go + - internal/sdk/models/shared/searchjourneysresponse.go + - internal/sdk/models/shared/security.go + - internal/sdk/models/shared/templatesettings.go + - internal/sdk/retry/config.go + - internal/sdk/sdk.go + - internal/sdk/types/bigint.go + - internal/sdk/types/date.go + - internal/sdk/types/datetime.go + - internal/sdk/types/decimal.go + - internal/sdk/types/pointers.go - internal/validators/DateValidator.go - internal/validators/ExactlyOneChild.go - internal/validators/JSONParseValidator.go @@ -115,22 +140,92 @@ generatedFiles: - main.go - terraform-registry-manifest.json - tools/tools.go - - internal/provider/types/journey_creation_request_v2_context_schema.go - - internal/provider/types/journey_creation_request_v2_design.go - - internal/provider/types/journey_creation_request_v2_logics.go - - internal/provider/types/journey_creation_request_v2_rules.go - - internal/provider/types/journey_creation_request_v2_button.go - - internal/provider/types/journey_creation_request_v2_embed_options.go - - internal/provider/types/journey_creation_request_v2_settings.go - - USAGE.md - - internal/provider/provider.go - - examples/provider/provider.tf - - examples/resources/epilot-journey_journey/import.sh - - internal/provider/journey_resource.go - - internal/provider/journey_resource_sdk.go - - examples/resources/epilot-journey_journey/resource.tf - - internal/provider/journey_data_source.go - - internal/provider/journey_data_source_sdk.go - - examples/data-sources/epilot-journey_journey/data-source.tf - - .gitattributes - - CONTRIBUTING.md +examples: + createJourney: + speakeasy-default-create-journey: + parameters: + query: + skipAutomation: "true" + responses: + "201": + application/json: {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "createdAt": "", "lastModifiedAt": "", "name": "", "organizationId": "", "revisions": "988.35", "steps": [], "version": "5568.25"} + generateDocument: + speakeasy-default-generate-document: + requestBody: + application/json: {"file_id": "1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p", "language": "de"} + responses: + "200": + application/json: {"docx_output": {"output_document": {"filename": "my-template-OR-001.docx", "s3ref": {"bucket": "document-api-preview-prod", "key": "preview/my-template.docx"}}, "preview_url": "https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx"}, "pdf_output": {"output_document": {"filename": "my-template-OR-001.pdf", "s3ref": {"bucket": "document-api-preview-prod", "key": "preview/my-template.pdf"}}, "preview_url": "https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf"}, "template_settings": {"custom_margins": {"bottom": 2.54, "top": 2.54}, "display_margin_guidelines": true, "enable_data_table_margin_autofix": false, "enabled_template_settings_persistence": false, "file_entity_id": "1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p", "misconfigured_margins": false, "suggested_margins": {"bottom": 2.54, "top": 2.54}, "template_with_datatable": false}} + getJourney: + speakeasy-default-get-journey: + parameters: + path: + id: "509cdffe-424f-457a-95c2-9708c304ce77" + query: {} + responses: + "200": + application/json: {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "createdAt": "", "lastModifiedAt": "", "name": "", "organizationId": "", "revisions": "6940.07", "steps": [], "version": "4044.02"} + getJourneyProducts: + speakeasy-default-get-journey-products: + parameters: + path: + id: "509cdffe-424f-457a-95c2-9708c304ce77" + query: {} + responses: + "200": + application/json: [] + getJourneysByOrgId: + speakeasy-default-get-journeys-by-org-id: + parameters: + path: + id: "123" + query: + hydrate: "true" + patchUpdateJourney: + "": + requestBody: + application/json: {"journeyId": "509cdffe-424f-457a-95c2-9708c304ce77", "name": "New Journey Name", "steps[0].uischema.elements[0].products": ["123456", "654321"]} + removeJourney: + speakeasy-default-remove-journey: + parameters: + path: + id: "509cdffe-424f-457a-95c2-9708c304ce77" + searchJourneys: + speakeasy-default-search-journeys: + requestBody: + application/json: {"from": 0, "q": "_tags:*Flex*", "size": 25, "sort": "_created_at:desc"} + responses: + "200": + application/json: {"hits": 1, "results": []} + updateJourney: + speakeasy-default-update-journey: {} + createJourneyV2: + speakeasy-default-create-journey-v2: + responses: + "201": + application/json: {"name": "", "steps": ""} + getJourneyV2: + speakeasy-default-get-journey-v2: + parameters: + path: + id: "509cdffe-424f-457a-95c2-9708c304ce77" + responses: + "200": + application/json: {"name": "", "steps": ""} + patchUpdateJourneyV2: + "": + requestBody: + application/json: {"journeyId": "509cdffe-424f-457a-95c2-9708c304ce77", "name": "New Journey Name", "steps[0].uischema.elements[0].products": ["123456", "654321"]} + responses: + "200": + application/json: {"name": "", "steps": ""} + removeJourneyV2: + speakeasy-default-remove-journey-v2: + parameters: + path: + id: "509cdffe-424f-457a-95c2-9708c304ce77" + updateJourneyV2: + speakeasy-default-update-journey-v2: + responses: + "200": + application/json: {"name": "", "steps": ""} diff --git a/Makefile b/Makefile index a068a38..5105232 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ all: speakeasy docs original.yaml: -# curl https://docs.api.epilot.io/file.yaml > original.yaml - cp openapi.yml original.yaml + curl https://docs.api.epilot.io/journey-config.yaml > original.yaml +# cp openapi.yml original.yaml original_modified.yaml: original.yaml overlay.yaml speakeasy overlay apply -s original.yaml -o overlay.yaml > original_modified.yaml @@ -13,8 +13,8 @@ overlay.yaml: speakeasy: $(eval TMP := $(shell mktemp -d)) -# curl https://docs.api.epilot.io/file.yaml > $(TMP)/openapi.yaml - cp openapi.yml $(TMP)/openapi.yaml + curl https://docs.api.epilot.io/journey-config.yaml > $(TMP)/openapi.yaml +# cp openapi.yml $(TMP)/openapi.yaml speakeasy overlay apply -s $(TMP)/openapi.yaml -o overlay.yaml > $(TMP)/final.yaml speakeasy generate sdk --lang terraform -o . -s $(TMP)/final.yaml diff --git a/README.md b/README.md index 932066e..1f0d78c 100755 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ - -## SDK Installation + +## Installation To install this provider, copy and paste this code into your Terraform configuration. Then, run `terraform init`. @@ -18,7 +18,7 @@ terraform { required_providers { epilot-journey = { source = "epilot-dev/epilot-journey" - version = "0.4.0" + version = "0.5.0" } } } @@ -27,19 +27,17 @@ provider "epilot-journey" { # Configuration options } ``` - + - -## SDK Example Usage + +## Testing the provider locally -### Testing the provider locally +#### Local Provider Should you want to validate a change locally, the `--debug` flag allows you to execute the provider against a terraform instance locally. This also allows for debuggers (e.g. delve) to be attached to the provider. -### Example - ```sh go run main.go --debug # Copy the TF_REATTACH_PROVIDERS env var @@ -48,7 +46,55 @@ cd examples/your-example TF_REATTACH_PROVIDERS=... terraform init TF_REATTACH_PROVIDERS=... terraform apply ``` - + +#### Compiled Provider + +Terraform allows you to use local provider builds by setting a `dev_overrides` block in a configuration file called `.terraformrc`. This block overrides all other configured installation methods. + +1. Execute `go build` to construct a binary called `terraform-provider-epilot-journey` +2. Ensure that the `.terraformrc` file is configured with a `dev_overrides` section such that your local copy of terraform can see the provider binary + +Terraform searches for the `.terraformrc` file in your home directory and applies any configuration settings you set. + +``` +provider_installation { + + dev_overrides { + "registry.terraform.io/epilot-dev/epilot-journey" = "" + } + + # For all other providers, install them directly from their origin provider + # registries as normal. If you omit this, Terraform will _only_ use + # the dev_overrides block, and so no other providers will be available. + direct {} +} +``` + + + +## Summary + +Journey API: API to configure journeys + + + +## Table of Contents + +* [Installation](#installation) +* [Available Resources and Data Sources](#available-resources-and-data-sources) +* [Testing the provider locally](#testing-the-provider-locally) + + + +## Available Resources and Data Sources + +### Resources + +* [epilot-journey_journey](docs/resources/journey.md) +### Data Sources + +* [epilot-journey_journey](docs/data-sources/journey.md) + diff --git a/docs/data-sources/journey.md b/docs/data-sources/journey.md index 739d767..f887037 100644 --- a/docs/data-sources/journey.md +++ b/docs/data-sources/journey.md @@ -14,7 +14,6 @@ Journey DataSource ```terraform data "epilot-journey_journey" "my_journey" { - id = "509cdffe-424f-457a-95c2-9708c304ce77" } ``` @@ -69,9 +68,9 @@ Read-Only: Read-Only: - `source` (String) -- `source_type` (String) must be one of ["journey", "step", "block"] +- `source_type` (String) - `target` (String) -- `type` (String) must be one of ["inject", "injectWithKey"] +- `type` (String) @@ -99,8 +98,8 @@ Read-Only: Read-Only: - `button` (Attributes) (see [below for nested schema](#nestedatt--settings--embed_options--button)) -- `lang` (String) must be one of ["de", "en", "fr"] -- `mode` (String) must be one of ["full-screen", "inline"] +- `lang` (String) +- `mode` (String) - `scroll_to_top` (Boolean) - `top_bar` (Boolean) - `width` (String) @@ -110,5 +109,5 @@ Read-Only: Read-Only: -- `align` (String) must be one of ["left", "center", "right"] +- `align` (String) - `text` (String) diff --git a/docs/index.md b/docs/index.md index aeec4bc..d6e4521 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { epilot-journey = { source = "epilot-dev/epilot-journey" - version = "0.4.0" + version = "0.5.0" } } } diff --git a/docs/resources/journey.md b/docs/resources/journey.md index 0e81906..1a4e205 100644 --- a/docs/resources/journey.md +++ b/docs/resources/journey.md @@ -14,11 +14,74 @@ Journey Resource ```terraform resource "epilot-journey_journey" "my_journey" { - brand_id = "...my_brand_id..." - id = "509cdffe-424f-457a-95c2-9708c304ce77" + brand_id = "...my_brand_id..." + context_schema = [ + { + is_required = false + param_key = "...my_param_key..." + should_load_entity = false + type = "...my_type..." + } + ] + design = { + logo_url = "...my_logo_url..." + theme = { + "see" : jsonencode("documentation"), + } + } journey_id = "...my_journey_id..." - name = "Tasha Macejkovic MD" - steps = "{ \"see\": \"documentation\" }" + logics = [ + { + actions = [ + "..." + ] + auto_generated_id = "...my_auto_generated_id..." + conditions = [ + "..." + ] + } + ] + name = "...my_name..." + rules = [ + { + source = "...my_source..." + source_type = "step" + target = "...my_target..." + type = "inject" + } + ] + settings = { + address_suggestions_file_id = "...my_address_suggestions_file_id..." + address_suggestions_file_url = "...my_address_suggestions_file_url..." + description = "...my_description..." + design_id = "...my_design_id..." + embed_options = { + button = { + align = "center" + text = "...my_text..." + } + lang = "en" + mode = "inline" + scroll_to_top = false + top_bar = false + width = "...my_width..." + } + entity_id = "...my_entity_id..." + entity_tags = [ + "..." + ] + file_purposes = [ + "..." + ] + mappings_automation_id = "...my_mappings_automation_id..." + runtime_entities = [ + "ORDER" + ] + safe_mode_automation = false + targeted_customer = "...my_targeted_customer..." + template_id = "...my_template_id..." + } + steps = "{ \"see\": \"documentation\" }" } ``` diff --git a/examples/data-sources/epilot-journey_journey/data-source.tf b/examples/data-sources/epilot-journey_journey/data-source.tf index 3b0794d..ab713cc 100644 --- a/examples/data-sources/epilot-journey_journey/data-source.tf +++ b/examples/data-sources/epilot-journey_journey/data-source.tf @@ -1,3 +1,2 @@ data "epilot-journey_journey" "my_journey" { - id = "509cdffe-424f-457a-95c2-9708c304ce77" } \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index a00996a..535df40 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-journey = { source = "epilot-dev/epilot-journey" - version = "0.4.0" + version = "0.5.0" } } } diff --git a/examples/resources/epilot-journey_journey/resource.tf b/examples/resources/epilot-journey_journey/resource.tf index 15940ba..dee0eec 100644 --- a/examples/resources/epilot-journey_journey/resource.tf +++ b/examples/resources/epilot-journey_journey/resource.tf @@ -1,7 +1,70 @@ resource "epilot-journey_journey" "my_journey" { - brand_id = "...my_brand_id..." - id = "509cdffe-424f-457a-95c2-9708c304ce77" + brand_id = "...my_brand_id..." + context_schema = [ + { + is_required = false + param_key = "...my_param_key..." + should_load_entity = false + type = "...my_type..." + } + ] + design = { + logo_url = "...my_logo_url..." + theme = { + "see" : jsonencode("documentation"), + } + } journey_id = "...my_journey_id..." - name = "Tasha Macejkovic MD" - steps = "{ \"see\": \"documentation\" }" + logics = [ + { + actions = [ + "..." + ] + auto_generated_id = "...my_auto_generated_id..." + conditions = [ + "..." + ] + } + ] + name = "...my_name..." + rules = [ + { + source = "...my_source..." + source_type = "step" + target = "...my_target..." + type = "inject" + } + ] + settings = { + address_suggestions_file_id = "...my_address_suggestions_file_id..." + address_suggestions_file_url = "...my_address_suggestions_file_url..." + description = "...my_description..." + design_id = "...my_design_id..." + embed_options = { + button = { + align = "center" + text = "...my_text..." + } + lang = "en" + mode = "inline" + scroll_to_top = false + top_bar = false + width = "...my_width..." + } + entity_id = "...my_entity_id..." + entity_tags = [ + "..." + ] + file_purposes = [ + "..." + ] + mappings_automation_id = "...my_mappings_automation_id..." + runtime_entities = [ + "ORDER" + ] + safe_mode_automation = false + targeted_customer = "...my_targeted_customer..." + template_id = "...my_template_id..." + } + steps = "{ \"see\": \"documentation\" }" } \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 42ae804..64f49a5 100755 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: sdkFlattening: true telemetryEnabled: false terraform: - version: 0.4.0 + version: 0.5.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/internal/provider/journey_data_source.go b/internal/provider/journey_data_source.go index 992a48d..f44dcda 100644 --- a/internal/provider/journey_data_source.go +++ b/internal/provider/journey_data_source.go @@ -117,15 +117,13 @@ func (r *JourneyDataSource) Schema(ctx context.Context, req datasource.SchemaReq Computed: true, }, "source_type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["journey", "step", "block"]`, + Computed: true, }, "target": schema.StringAttribute{ Computed: true, }, "type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["inject", "injectWithKey"]`, + Computed: true, }, }, }, @@ -153,8 +151,7 @@ func (r *JourneyDataSource) Schema(ctx context.Context, req datasource.SchemaReq Computed: true, Attributes: map[string]schema.Attribute{ "align": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["left", "center", "right"]`, + Computed: true, }, "text": schema.StringAttribute{ Computed: true, @@ -162,12 +159,10 @@ func (r *JourneyDataSource) Schema(ctx context.Context, req datasource.SchemaReq }, }, "lang": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["de", "en", "fr"]`, + Computed: true, }, "mode": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["full-screen", "inline"]`, + Computed: true, }, "scroll_to_top": schema.BoolAttribute{ Computed: true, diff --git a/internal/provider/journey_resource.go b/internal/provider/journey_resource.go index ff3d70a..42a0141 100644 --- a/internal/provider/journey_resource.go +++ b/internal/provider/journey_resource.go @@ -10,6 +10,7 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-journey/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-journey/internal/validators" speakeasy_listvalidators "github.com/epilot-dev/terraform-provider-epilot-journey/internal/validators/listvalidators" + speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-journey/internal/validators/objectvalidators" speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-journey/internal/validators/stringvalidators" "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -63,6 +64,9 @@ func (r *JourneyResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ + Validators: []validator.Object{ + speakeasy_objectvalidators.NotNull(), + }, Attributes: map[string]schema.Attribute{ "is_required": schema.BoolAttribute{ Computed: true, @@ -117,6 +121,9 @@ func (r *JourneyResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ + Validators: []validator.Object{ + speakeasy_objectvalidators.NotNull(), + }, Attributes: map[string]schema.Attribute{ "actions": schema.ListAttribute{ Computed: true, @@ -150,6 +157,9 @@ func (r *JourneyResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ + Validators: []validator.Object{ + speakeasy_objectvalidators.NotNull(), + }, Attributes: map[string]schema.Attribute{ "source": schema.StringAttribute{ Computed: true, diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index d2f214c..807d40b 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -487,30 +487,29 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa v.Set(m) return nil case reflect.Slice, reflect.Array: - if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { - if v.CanAddr() { - return json.Unmarshal(value, v.Addr().Interface()) - } else { - return json.Unmarshal(value, v.Interface()) - } - } - - var unmarhsaled []json.RawMessage + var unmarshaled []json.RawMessage - if err := json.Unmarshal(value, &unmarhsaled); err != nil { + if err := json.Unmarshal(value, &unmarshaled); err != nil { return err } - arrVal := v + arrVal := reflect.MakeSlice(typ, len(unmarshaled), len(unmarshaled)) - for _, value := range unmarhsaled { + for index, value := range unmarshaled { itemVal := reflect.New(typ.Elem()) if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { return err } - arrVal = reflect.Append(arrVal, itemVal.Elem()) + arrVal.Index(index).Set(itemVal.Elem()) + } + + if v.Kind() == reflect.Pointer { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() } v.Set(arrVal) diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index cee9da2..000226e 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -66,15 +66,16 @@ func serializeRequestBody(request interface{}, nullable, optional bool, requestF if tag != nil { // request object (non-flattened) requestVal := requestValType.FieldByName(requestFieldName) + val := reflect.ValueOf(requestVal.Interface()) if isNil(requestField.Type, requestVal) { if !nullable && optional { return nil, "", nil } - return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) } - return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) } } diff --git a/internal/sdk/internal/utils/security.go b/internal/sdk/internal/utils/security.go index c8503f9..19dfa6f 100644 --- a/internal/sdk/internal/utils/security.go +++ b/internal/sdk/internal/utils/security.go @@ -119,9 +119,14 @@ func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *secu } if schemeType.Kind() == reflect.Struct { - if schemeTag.Type == "http" && schemeTag.SubType == "basic" { - handleBasicAuthScheme(headers, schemeVal.Interface()) - return + if schemeTag.Type == "http" { + switch schemeTag.SubType { + case "basic": + handleBasicAuthScheme(headers, schemeVal.Interface()) + return + case "custom": + return + } } for i := 0; i < schemeType.NumField(); i++ { @@ -171,6 +176,7 @@ func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag switch schemeTag.SubType { case "bearer": headers[secTag.Name] = prefixBearer(valToString(val)) + case "custom": default: panic("not supported") } diff --git a/internal/sdk/journeys.go b/internal/sdk/journeys.go index f3ba9aa..4fd7718 100644 --- a/internal/sdk/journeys.go +++ b/internal/sdk/journeys.go @@ -185,17 +185,25 @@ func (s *Journeys) CreateJourney(ctx context.Context, request operations.CreateJ RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.Journey if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -203,9 +211,228 @@ func (s *Journeys) CreateJourney(ctx context.Context, request operations.CreateJ res.Journey = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GenerateDocument - generateDocument +// Builds document generated from a template with journey values." +// +// Supported input document types: +// - .docx +// +// Supported output document types: +// - .pdf +// - .docx but limited to only text based variables +// +// Uses [Document API](https://gitlab.com/e-pilot/product/file-management/document-api) to generate the document. +// Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document. +func (s *Journeys) GenerateDocument(ctx context.Context, request *shared.GenerateDocumentRequest, security *operations.GenerateDocumentSecurity, opts ...operations.Option) (*operations.GenerateDocumentResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "generateDocument", + OAuth2Scopes: []string{}, + SecuritySource: utils.AsSecuritySource(security), + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/v1/journey/document:generate") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "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, utils.AsSecuritySource(security)); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GenerateDocumentResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out shared.GenerateDocumentResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.GenerateDocumentResponse = &out + default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -214,13 +441,13 @@ func (s *Journeys) CreateJourney(ctx context.Context, request operations.CreateJ } // GetJourney - getJourney -// Get journey by id -func (s *Journeys) GetJourney(ctx context.Context, request operations.GetJourneyRequest, opts ...operations.Option) (*operations.GetJourneyResponse, error) { +// Get journey by id. Private journeys requires valid private token to be passed +func (s *Journeys) GetJourney(ctx context.Context, request operations.GetJourneyRequest, security *operations.GetJourneySecurity, opts ...operations.Option) (*operations.GetJourneyResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getJourney", OAuth2Scopes: []string{}, - SecuritySource: nil, + SecuritySource: utils.AsSecuritySource(security), } o := operations.Options{} @@ -263,6 +490,10 @@ func (s *Journeys) GetJourney(ctx context.Context, request operations.GetJourney return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, utils.AsSecuritySource(security)); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -360,17 +591,25 @@ func (s *Journeys) GetJourney(ctx context.Context, request operations.GetJourney RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.Journey if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -378,9 +617,19 @@ func (s *Journeys) GetJourney(ctx context.Context, request operations.GetJourney res.Journey = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -389,13 +638,13 @@ func (s *Journeys) GetJourney(ctx context.Context, request operations.GetJourney } // GetJourneyProducts - getJourneyProducts -// Get products available in the journey by id +// Get products available in the journey by id. requires public journey token to be passed. func (s *Journeys) GetJourneyProducts(ctx context.Context, request operations.GetJourneyProductsRequest, opts ...operations.Option) (*operations.GetJourneyProductsResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getJourneyProducts", OAuth2Scopes: []string{}, - SecuritySource: nil, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -438,6 +687,10 @@ func (s *Journeys) GetJourneyProducts(ctx context.Context, request operations.Ge return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -535,17 +788,25 @@ func (s *Journeys) GetJourneyProducts(ctx context.Context, request operations.Ge RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []shared.JourneyProductsResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -553,9 +814,19 @@ func (s *Journeys) GetJourneyProducts(ctx context.Context, request operations.Ge res.JourneyProductsResponse = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -714,17 +985,25 @@ func (s *Journeys) GetJourneysByOrgID(ctx context.Context, request operations.Ge RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.GetJourneysResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -732,9 +1011,19 @@ func (s *Journeys) GetJourneysByOrgID(ctx context.Context, request operations.Ge res.GetJourneysResponse = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -895,17 +1184,25 @@ func (s *Journeys) PatchUpdateJourney(ctx context.Context, request *shared.Patch RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.JourneyResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -913,9 +1210,19 @@ func (s *Journeys) PatchUpdateJourney(ctx context.Context, request *shared.Patch res.JourneyResponse = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1070,16 +1377,24 @@ func (s *Journeys) RemoveJourney(ctx context.Context, request operations.RemoveJ RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1240,17 +1555,25 @@ func (s *Journeys) SearchJourneys(ctx context.Context, request *shared.SearchJou RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.SearchJourneysResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1258,9 +1581,19 @@ func (s *Journeys) SearchJourneys(ctx context.Context, request *shared.SearchJou res.SearchJourneysResponse = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1421,17 +1754,25 @@ func (s *Journeys) UpdateJourney(ctx context.Context, request *shared.JourneyCre RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.JourneyResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1439,9 +1780,19 @@ func (s *Journeys) UpdateJourney(ctx context.Context, request *shared.JourneyCre res.JourneyResponse = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/sdk/journeysv2.go b/internal/sdk/journeysv2.go index d49e3da..8bc6e13 100644 --- a/internal/sdk/journeysv2.go +++ b/internal/sdk/journeysv2.go @@ -181,17 +181,25 @@ func (s *JourneysV2) CreateJourneyV2(ctx context.Context, request *shared.Journe RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.JourneyCreationRequestV2 if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -199,9 +207,19 @@ func (s *JourneysV2) CreateJourneyV2(ctx context.Context, request *shared.Journe res.JourneyCreationRequestV2 = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -356,17 +374,25 @@ func (s *JourneysV2) GetJourneyV2(ctx context.Context, request operations.GetJou RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.JourneyCreationRequestV2 if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -374,9 +400,19 @@ func (s *JourneysV2) GetJourneyV2(ctx context.Context, request operations.GetJou res.JourneyCreationRequestV2 = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -537,17 +573,25 @@ func (s *JourneysV2) PatchUpdateJourneyV2(ctx context.Context, request *shared.P RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.JourneyCreationRequestV2 if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -555,9 +599,19 @@ func (s *JourneysV2) PatchUpdateJourneyV2(ctx context.Context, request *shared.P res.JourneyCreationRequestV2 = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -712,16 +766,24 @@ func (s *JourneysV2) RemoveJourneyV2(ctx context.Context, request operations.Rem RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -882,17 +944,25 @@ func (s *JourneysV2) UpdateJourneyV2(ctx context.Context, request *shared.Journe RawResponse: httpRes, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out shared.JourneyCreationRequestV2 if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -900,9 +970,19 @@ func (s *JourneysV2) UpdateJourneyV2(ctx context.Context, request *shared.Journe res.JourneyCreationRequestV2 = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/sdk/models/operations/generatedocument.go b/internal/sdk/models/operations/generatedocument.go new file mode 100644 index 0000000..9f8a751 --- /dev/null +++ b/internal/sdk/models/operations/generatedocument.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-journey/internal/sdk/models/shared" + "net/http" +) + +type GenerateDocumentSecurity struct { + EpilotAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` +} + +func (o *GenerateDocumentSecurity) GetEpilotAuth() *string { + if o == nil { + return nil + } + return o.EpilotAuth +} + +type GenerateDocumentResponse struct { + // HTTP response content type for this operation + ContentType string + // Generated document output + GenerateDocumentResponse *shared.GenerateDocumentResponse + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (o *GenerateDocumentResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GenerateDocumentResponse) GetGenerateDocumentResponse() *shared.GenerateDocumentResponse { + if o == nil { + return nil + } + return o.GenerateDocumentResponse +} + +func (o *GenerateDocumentResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GenerateDocumentResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} diff --git a/internal/sdk/models/operations/getjourney.go b/internal/sdk/models/operations/getjourney.go index 179993a..74fc74c 100644 --- a/internal/sdk/models/operations/getjourney.go +++ b/internal/sdk/models/operations/getjourney.go @@ -7,6 +7,17 @@ import ( "net/http" ) +type GetJourneySecurity struct { + EpilotAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` +} + +func (o *GetJourneySecurity) GetEpilotAuth() *string { + if o == nil { + return nil + } + return o.EpilotAuth +} + type GetJourneyRequest struct { // Journey ID ID string `pathParam:"style=simple,explode=false,name=id"` diff --git a/internal/sdk/models/operations/getjourneyproducts.go b/internal/sdk/models/operations/getjourneyproducts.go index 80ba007..b6505f9 100644 --- a/internal/sdk/models/operations/getjourneyproducts.go +++ b/internal/sdk/models/operations/getjourneyproducts.go @@ -12,8 +12,6 @@ type GetJourneyProductsRequest struct { City *string `queryParam:"style=form,explode=true,name=city"` // Journey ID ID string `pathParam:"style=simple,explode=false,name=id"` - // Organization ID - OrgID *string `queryParam:"style=form,explode=true,name=orgId"` // Zip Code for availibility PostalCode *string `queryParam:"style=form,explode=true,name=postal_code"` // What source ID. Journey or Entity ID @@ -38,13 +36,6 @@ func (o *GetJourneyProductsRequest) GetID() string { return o.ID } -func (o *GetJourneyProductsRequest) GetOrgID() *string { - if o == nil { - return nil - } - return o.OrgID -} - func (o *GetJourneyProductsRequest) GetPostalCode() *string { if o == nil { return nil diff --git a/internal/sdk/models/shared/generatedocumentrequest.go b/internal/sdk/models/shared/generatedocumentrequest.go new file mode 100644 index 0000000..68d7844 --- /dev/null +++ b/internal/sdk/models/shared/generatedocumentrequest.go @@ -0,0 +1,45 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// ContextData - Custom values for variables in the template. Takes the higher precedence than others. +type ContextData struct { + AdditionalProperties *string `json:"additionalProperties,omitempty"` +} + +func (o *ContextData) GetAdditionalProperties() *string { + if o == nil { + return nil + } + return o.AdditionalProperties +} + +type GenerateDocumentRequest struct { + // Custom values for variables in the template. Takes the higher precedence than others. + ContextData ContextData `json:"context_data"` + // Entity id for the template being used + FileID string `json:"file_id"` + // Language code for the document + Language *string `json:"language,omitempty"` +} + +func (o *GenerateDocumentRequest) GetContextData() ContextData { + if o == nil { + return ContextData{} + } + return o.ContextData +} + +func (o *GenerateDocumentRequest) GetFileID() string { + if o == nil { + return "" + } + return o.FileID +} + +func (o *GenerateDocumentRequest) GetLanguage() *string { + if o == nil { + return nil + } + return o.Language +} diff --git a/internal/sdk/models/shared/generatedocumentresponse.go b/internal/sdk/models/shared/generatedocumentresponse.go new file mode 100644 index 0000000..8c3f125 --- /dev/null +++ b/internal/sdk/models/shared/generatedocumentresponse.go @@ -0,0 +1,196 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" +) + +type OutputDocument struct { + // Generated document filename for DOCX + Filename *string `json:"filename,omitempty"` + S3ref *S3Reference `json:"s3ref,omitempty"` +} + +func (o *OutputDocument) GetFilename() *string { + if o == nil { + return nil + } + return o.Filename +} + +func (o *OutputDocument) GetS3ref() *S3Reference { + if o == nil { + return nil + } + return o.S3ref +} + +type DocxOutput struct { + OutputDocument *OutputDocument `json:"output_document,omitempty"` + // Pre-signed S3 GET URL for DOCX preview + PreviewURL *string `json:"preview_url,omitempty"` +} + +func (o *DocxOutput) GetOutputDocument() *OutputDocument { + if o == nil { + return nil + } + return o.OutputDocument +} + +func (o *DocxOutput) GetPreviewURL() *string { + if o == nil { + return nil + } + return o.PreviewURL +} + +// JobStatus - Status of the job +type JobStatus string + +const ( + JobStatusStarted JobStatus = "STARTED" + JobStatusProcessing JobStatus = "PROCESSING" + JobStatusSuccess JobStatus = "SUCCESS" + JobStatusFailed JobStatus = "FAILED" +) + +func (e JobStatus) ToPointer() *JobStatus { + return &e +} +func (e *JobStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "STARTED": + fallthrough + case "PROCESSING": + fallthrough + case "SUCCESS": + fallthrough + case "FAILED": + *e = JobStatus(v) + return nil + default: + return fmt.Errorf("invalid value for JobStatus: %v", v) + } +} + +type GenerateDocumentResponseOutputDocument struct { + // Generated document filename for PDF + Filename *string `json:"filename,omitempty"` + S3ref *S3Reference `json:"s3ref,omitempty"` +} + +func (o *GenerateDocumentResponseOutputDocument) GetFilename() *string { + if o == nil { + return nil + } + return o.Filename +} + +func (o *GenerateDocumentResponseOutputDocument) GetS3ref() *S3Reference { + if o == nil { + return nil + } + return o.S3ref +} + +type PdfOutput struct { + OutputDocument *GenerateDocumentResponseOutputDocument `json:"output_document,omitempty"` + // Pre-signed S3 GET URL for PDF preview + PreviewURL *string `json:"preview_url,omitempty"` +} + +func (o *PdfOutput) GetOutputDocument() *GenerateDocumentResponseOutputDocument { + if o == nil { + return nil + } + return o.OutputDocument +} + +func (o *PdfOutput) GetPreviewURL() *string { + if o == nil { + return nil + } + return o.PreviewURL +} + +// VariablePayload - List of variables and its corresponding replaced values from the document template +type VariablePayload struct { + AdditionalProperties *string `json:"additionalProperties,omitempty"` +} + +func (o *VariablePayload) GetAdditionalProperties() *string { + if o == nil { + return nil + } + return o.AdditionalProperties +} + +type GenerateDocumentResponse struct { + DocxOutput *DocxOutput `json:"docx_output,omitempty"` + JobID *string `json:"job_id,omitempty"` + // Status of the job + JobStatus *JobStatus `json:"job_status,omitempty"` + // A message explaining the progress + Message *string `json:"message,omitempty"` + PdfOutput *PdfOutput `json:"pdf_output,omitempty"` + // Template Settings for document generation + TemplateSettings *TemplateSettings `json:"template_settings,omitempty"` + // List of variables and its corresponding replaced values from the document template + VariablePayload *VariablePayload `json:"variable_payload,omitempty"` +} + +func (o *GenerateDocumentResponse) GetDocxOutput() *DocxOutput { + if o == nil { + return nil + } + return o.DocxOutput +} + +func (o *GenerateDocumentResponse) GetJobID() *string { + if o == nil { + return nil + } + return o.JobID +} + +func (o *GenerateDocumentResponse) GetJobStatus() *JobStatus { + if o == nil { + return nil + } + return o.JobStatus +} + +func (o *GenerateDocumentResponse) GetMessage() *string { + if o == nil { + return nil + } + return o.Message +} + +func (o *GenerateDocumentResponse) GetPdfOutput() *PdfOutput { + if o == nil { + return nil + } + return o.PdfOutput +} + +func (o *GenerateDocumentResponse) GetTemplateSettings() *TemplateSettings { + if o == nil { + return nil + } + return o.TemplateSettings +} + +func (o *GenerateDocumentResponse) GetVariablePayload() *VariablePayload { + if o == nil { + return nil + } + return o.VariablePayload +} diff --git a/internal/sdk/models/shared/journey.go b/internal/sdk/models/shared/journey.go index a2e3935..3b4297e 100644 --- a/internal/sdk/models/shared/journey.go +++ b/internal/sdk/models/shared/journey.go @@ -398,6 +398,7 @@ type Settings struct { EntityID *string `json:"entityId,omitempty"` EntityTags []string `json:"entityTags,omitempty"` FilePurposes []string `json:"filePurposes,omitempty"` + IsPublished *bool `json:"isPublished,omitempty"` MappingsAutomationID *string `json:"mappingsAutomationId,omitempty"` OrganizationSettings map[string]bool `json:"organizationSettings,omitempty"` PublicToken *string `json:"publicToken,omitempty"` @@ -471,6 +472,13 @@ func (o *Settings) GetFilePurposes() []string { return o.FilePurposes } +func (o *Settings) GetIsPublished() *bool { + if o == nil { + return nil + } + return o.IsPublished +} + func (o *Settings) GetMappingsAutomationID() *string { if o == nil { return nil diff --git a/internal/sdk/models/shared/journeycreationrequest.go b/internal/sdk/models/shared/journeycreationrequest.go index c14572b..ee3573d 100644 --- a/internal/sdk/models/shared/journeycreationrequest.go +++ b/internal/sdk/models/shared/journeycreationrequest.go @@ -398,6 +398,7 @@ type JourneyCreationRequestSettings struct { EntityID *string `json:"entityId,omitempty"` EntityTags []string `json:"entityTags,omitempty"` FilePurposes []string `json:"filePurposes,omitempty"` + IsPublished *bool `json:"isPublished,omitempty"` MappingsAutomationID *string `json:"mappingsAutomationId,omitempty"` OrganizationSettings map[string]bool `json:"organizationSettings,omitempty"` PublicToken *string `json:"publicToken,omitempty"` @@ -471,6 +472,13 @@ func (o *JourneyCreationRequestSettings) GetFilePurposes() []string { return o.FilePurposes } +func (o *JourneyCreationRequestSettings) GetIsPublished() *bool { + if o == nil { + return nil + } + return o.IsPublished +} + func (o *JourneyCreationRequestSettings) GetMappingsAutomationID() *string { if o == nil { return nil diff --git a/internal/sdk/models/shared/s3reference.go b/internal/sdk/models/shared/s3reference.go new file mode 100644 index 0000000..d994a21 --- /dev/null +++ b/internal/sdk/models/shared/s3reference.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +type S3Reference struct { + Bucket string `json:"bucket"` + Key string `json:"key"` +} + +func (o *S3Reference) GetBucket() string { + if o == nil { + return "" + } + return o.Bucket +} + +func (o *S3Reference) GetKey() string { + if o == nil { + return "" + } + return o.Key +} diff --git a/internal/sdk/models/shared/searchjourneysresponse.go b/internal/sdk/models/shared/searchjourneysresponse.go index 5d24e32..2ce7944 100644 --- a/internal/sdk/models/shared/searchjourneysresponse.go +++ b/internal/sdk/models/shared/searchjourneysresponse.go @@ -25,8 +25,7 @@ func (o *CreatedBy) GetID() *string { type JourneyVersion string const ( - JourneyVersionFlex JourneyVersion = "Flex" - JourneyVersionWidget JourneyVersion = "Widget" + JourneyVersionFlex JourneyVersion = "Flex" ) func (e JourneyVersion) ToPointer() *JourneyVersion { @@ -39,8 +38,6 @@ func (e *JourneyVersion) UnmarshalJSON(data []byte) error { } switch v { case "Flex": - fallthrough - case "Widget": *e = JourneyVersion(v) return nil default: @@ -52,6 +49,8 @@ type Results struct { CreatedAt *time.Time `json:"_created_at,omitempty"` // Journey Entity ID ID *string `json:"_id,omitempty"` + // Manifest ID used to create/update the entity + Manifest []string `json:"_manifest,omitempty"` // Organization ID Org *string `json:"_org,omitempty"` // Entity Schema (journey always in this case) @@ -98,6 +97,13 @@ func (o *Results) GetID() *string { return o.ID } +func (o *Results) GetManifest() []string { + if o == nil { + return nil + } + return o.Manifest +} + func (o *Results) GetOrg() *string { if o == nil { return nil diff --git a/internal/sdk/models/shared/templatesettings.go b/internal/sdk/models/shared/templatesettings.go new file mode 100644 index 0000000..5f51fbb --- /dev/null +++ b/internal/sdk/models/shared/templatesettings.go @@ -0,0 +1,123 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// CustomMargins - Custom margins for the document +type CustomMargins struct { + // Bottom margin in cm + Bottom *float64 `json:"bottom,omitempty"` + // Top margin in cm + Top *float64 `json:"top,omitempty"` +} + +func (o *CustomMargins) GetBottom() *float64 { + if o == nil { + return nil + } + return o.Bottom +} + +func (o *CustomMargins) GetTop() *float64 { + if o == nil { + return nil + } + return o.Top +} + +// SuggestedMargins - Suggested margins for the document +type SuggestedMargins struct { + // Bottom margin in cm + Bottom *float64 `json:"bottom,omitempty"` + // Top margin in cm + Top *float64 `json:"top,omitempty"` +} + +func (o *SuggestedMargins) GetBottom() *float64 { + if o == nil { + return nil + } + return o.Bottom +} + +func (o *SuggestedMargins) GetTop() *float64 { + if o == nil { + return nil + } + return o.Top +} + +// TemplateSettings - Template Settings for document generation +type TemplateSettings struct { + // Custom margins for the document + CustomMargins *CustomMargins `json:"custom_margins,omitempty"` + // Display margin guidelines (applicable to partial generation only) + DisplayMarginGuidelines *bool `json:"display_margin_guidelines,omitempty"` + // Enable data table margin autofix + EnableDataTableMarginAutofix *bool `json:"enable_data_table_margin_autofix,omitempty"` + // Enables the persistance of template settings + EnabledTemplateSettingsPersistence *bool `json:"enabled_template_settings_persistence,omitempty"` + // The file entity id, used when persisting a new template version with updated settings + FileEntityID *string `json:"file_entity_id,omitempty"` + // An indication that the page margins are misconfigured + MisconfiguredMargins *bool `json:"misconfigured_margins,omitempty"` + // Suggested margins for the document + SuggestedMargins *SuggestedMargins `json:"suggested_margins,omitempty"` + // A flag that indicates whether the template has 1 or more data tables in it + TemplateWithDatatable *bool `json:"template_with_datatable,omitempty"` +} + +func (o *TemplateSettings) GetCustomMargins() *CustomMargins { + if o == nil { + return nil + } + return o.CustomMargins +} + +func (o *TemplateSettings) GetDisplayMarginGuidelines() *bool { + if o == nil { + return nil + } + return o.DisplayMarginGuidelines +} + +func (o *TemplateSettings) GetEnableDataTableMarginAutofix() *bool { + if o == nil { + return nil + } + return o.EnableDataTableMarginAutofix +} + +func (o *TemplateSettings) GetEnabledTemplateSettingsPersistence() *bool { + if o == nil { + return nil + } + return o.EnabledTemplateSettingsPersistence +} + +func (o *TemplateSettings) GetFileEntityID() *string { + if o == nil { + return nil + } + return o.FileEntityID +} + +func (o *TemplateSettings) GetMisconfiguredMargins() *bool { + if o == nil { + return nil + } + return o.MisconfiguredMargins +} + +func (o *TemplateSettings) GetSuggestedMargins() *SuggestedMargins { + if o == nil { + return nil + } + return o.SuggestedMargins +} + +func (o *TemplateSettings) GetTemplateWithDatatable() *bool { + if o == nil { + return nil + } + return o.TemplateWithDatatable +} diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 1210f6a..b2c2d6a 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -41,6 +41,9 @@ func Float32(f float32) *float32 { return &f } // Float64 provides a helper function to return a pointer to a float64 func Float64(f float64) *float64 { return &f } +// Pointer provides a helper function to return a pointer to a type +func Pointer[T any](v T) *T { return &v } + type sdkConfiguration struct { Client HTTPClient Security func(context.Context) (interface{}, error) @@ -146,8 +149,8 @@ func New(opts ...SDKOption) *SDK { Language: "go", OpenAPIDocVersion: "1.0.0", SDKVersion: "0.0.1", - GenVersion: "2.404.9", - UserAgent: "speakeasy-sdk/go 0.0.1 2.404.9 1.0.0 github.com/epilot-dev/terraform-provider-epilot-journey/internal/sdk", + GenVersion: "2.415.6", + UserAgent: "speakeasy-sdk/go 0.0.1 2.415.6 1.0.0 github.com/epilot-dev/terraform-provider-epilot-journey/internal/sdk", Hooks: hooks.New(), }, } diff --git a/internal/sdk/types/pointers.go b/internal/sdk/types/pointers.go index 950d6a3..35c439d 100644 --- a/internal/sdk/types/pointers.go +++ b/internal/sdk/types/pointers.go @@ -8,3 +8,4 @@ func Int(i int) *int { return &i } func Int64(i int64) *int64 { return &i } func Float32(f float32) *float32 { return &f } func Float64(f float64) *float64 { return &f } +func Pointer[T any](v T) *T { return &v } diff --git a/openapi.yml b/openapi.yml deleted file mode 100644 index 987a0a0..0000000 --- a/openapi.yml +++ /dev/null @@ -1,991 +0,0 @@ -openapi: 3.0.0 -info: - title: Journey API - description: API to configure journeys - version: 1.0.0 -security: - - EpilotAuth: [] -paths: - "/v1/journey/organization/{id}": - get: - operationId: getJourneysByOrgId - summary: getJourneysByOrgId - description: Get all journeys by organization id - tags: - - Journeys - parameters: - - name: id - in: path - description: Organization ID - required: true - schema: - type: string - example: "123" - - name: hydrate - in: query - description: Hydrate - required: false - schema: - type: string - example: "true" - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/GetJourneysResponse" - "/v1/journey/configuration/{id}": - get: - operationId: getJourney - summary: getJourney - description: Get journey by id - security: [] - tags: - - Journeys - parameters: - - name: id - in: path - description: Journey ID - required: true - schema: - type: string - format: uuid - example: 509cdffe-424f-457a-95c2-9708c304ce77 - - name: source - in: query - description: What source ID. Journey or Entity ID - required: false - schema: - type: string - - name: orgId - in: query - description: Organization ID - required: false - schema: - type: string - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/Journey" - delete: - operationId: removeJourney - summary: removeJourney - description: Remove journey by id - tags: - - Journeys - parameters: - - name: id - in: path - description: Journey ID - required: true - schema: - type: string - format: uuid - example: 509cdffe-424f-457a-95c2-9708c304ce77 - responses: - "200": - description: Success - content: {} - "/v1/journey/products/{id}": - get: - operationId: getJourneyProducts - summary: getJourneyProducts - description: Get products available in the journey by id - security: [] - tags: - - Journeys - parameters: - - name: id - in: path - description: Journey ID - required: true - schema: - type: string - format: uuid - example: 509cdffe-424f-457a-95c2-9708c304ce77 - - name: source - in: query - description: What source ID. Journey or Entity ID - required: false - schema: - type: string - - name: orgId - in: query - description: Organization ID - required: false - schema: - type: string - - name: postal_code - in: query - description: Zip Code for availibility - required: false - schema: - type: string - - name: city - in: query - description: city for availibility - required: false - schema: - type: string - - name: street - in: query - description: street name for availibility - required: false - schema: - type: string - - name: street_number - in: query - description: street number for availibility - required: false - schema: - type: string - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyProductsResponse" - /v1/journey/configuration: - post: - operationId: createJourney - summary: createJourney - description: Create a Journey - tags: - - Journeys - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequest" - description: Payload - parameters: - - name: skipAutomation - in: query - description: skip creating an Automation (it takes Yn format "true, yes, 1, y") - required: false - schema: - type: string - format: Yn - example: true - responses: - "201": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/Journey" - put: - operationId: updateJourney - summary: updateJourney - description: Update a Journey - tags: - - Journeys - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequest" - description: Payload - parameters: [] - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyResponse" - patch: - operationId: patchUpdateJourney - summary: patchUpdateJourney - description: Update a Journey (partially / patch). Support for nested properties updates (e.g. "property[0].name"). - tags: - - Journeys - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/PatchUpdateJourneyRequest" - example: - journeyId: 509cdffe-424f-457a-95c2-9708c304ce77 - name: "New Journey Name" - steps[0].uischema.elements[0].products: ["123456", "654321"] - description: Payload - parameters: [] - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyResponse" - /v1/journey/configuration/search: - post: - operationId: searchJourneys - summary: searchJourneys - description: Search Journeys - tags: - - Journeys - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/SearchJourneysQueryRequest" - description: Payload - parameters: [] - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/SearchJourneysResponse" - - # Journey V2 (Restful endpoints) - /v2/journey/configuration: - post: - operationId: createJourneyV2 - summary: createJourneyV2 - description: Create a Journey - tags: - - Journeys V2 - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequestV2" - description: Payload - parameters: - - name: skipAutomation - in: query - description: skip creating an Automation (it takes Yn format "true, yes, 1, y") - required: false - schema: - type: string - format: Yn - example: true - responses: - "201": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequestV2" - put: - operationId: updateJourneyV2 - summary: updateJourneyV2 - description: Update a Journey - tags: - - Journeys V2 - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequestV2" - description: Payload - parameters: [] - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequestV2" - patch: - operationId: patchUpdateJourneyV2 - summary: patchUpdateJourneyV2 - description: Update a Journey (partially / patch). Support for nested properties updates (e.g. "property[0].name"). - tags: - - Journeys V2 - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/PatchUpdateJourneyRequest" - example: - journeyId: 509cdffe-424f-457a-95c2-9708c304ce77 - name: "New Journey Name" - steps[0].uischema.elements[0].products: ["123456", "654321"] - description: Payload - parameters: [] - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequestV2" - "/v2/journey/configuration/{id}": - get: - operationId: getJourneyV2 - summary: getJourneyV2 - description: Get journey by id - security: [] - tags: - - Journeys V2 - parameters: - - name: id - in: path - description: Journey ID - required: true - schema: - type: string - format: uuid - example: 509cdffe-424f-457a-95c2-9708c304ce77 - responses: - "200": - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/JourneyCreationRequestV2" - delete: - operationId: removeJourneyV2 - summary: removeJourneyV2 - description: Remove journey by id - tags: - - Journeys V2 - parameters: - - name: id - in: path - description: Journey ID - required: true - schema: - type: string - format: uuid - example: 509cdffe-424f-457a-95c2-9708c304ce77 - responses: - "200": - description: Success - content: {} -components: - schemas: - GetJourneysResponse: - type: object - JourneyResponse: - type: object - properties: - createdJourney: - $ref: "#/components/schemas/Journey" - JourneyProductsResponse: - type: array - items: - type: object - properties: - type: - type: string - _schema: - type: string - _title: - type: string - name: - type: string - _id: - type: string - _org: - type: string - code: - type: string - description: - type: string - feature: - type: array - product_images: - type: array - legal_footnote: - type: string - product_downloads: - type: array - price: - type: object - PatchUpdateJourneyRequest: - type: object - properties: - journeyId: - type: string - format: uuid - example: 509cdffe-424f-457a-95c2-9708c304ce77 - __lastModifiedAt: - type: string - description: "If passed with value of null, the API won't modify the lastModifiedAt field on updating the journey" - nullable: true - additionalProperties: true - description: > - Patch request to update a journey (journey id is required) - Support for nested properties (e.g. steps[0].uischema.elements[0].products) is supported. - required: - - journeyId - JourneyCreationRequest: - type: object - properties: - journeyId: - type: string - organizationId: - type: string - brandId: - type: string - name: - type: string - steps: - type: array - items: - type: object - additionalProperties: false - properties: - showStepName: - type: boolean - nullable: true - title: - type: string - nullable: true - subTitle: - type: string - nullable: true - showStepSubtitle: - type: boolean - nullable: true - showStepper: - type: boolean - nullable: true - showStepperLabels: - type: boolean - nullable: true - hideNextButton: - type: boolean - nullable: true - name: - type: string - stepId: - type: string - schema: {} - uischema: {} - required: - - name - - schema - - uischema - design: - type: object - properties: - logoUrl: - type: string - nullable: true - theme: - type: object - additionalProperties: {} - required: - - theme - additionalProperties: false - rules: - type: array - items: - type: object - properties: - type: - type: string - enum: - - inject - - injectWithKey - sourceType: - type: string - enum: - - journey - - step - - block - source: - type: string - target: - type: string - required: - - type - - sourceType - - source - - target - additionalProperties: false - logics: - type: array - items: - type: object - properties: - autoGeneratedId: - type: string - conditions: - type: array - items: - type: string - actions: - type: array - items: - type: string - required: - - conditions - - actions - additionalProperties: false - contextSchema: - type: array - items: - type: object - properties: - type: - type: string - paramKey: - type: string - isRequired: - type: boolean - shouldLoadEntity: - type: boolean - required: - - paramKey - - type - additionalProperties: false - settings: - type: object - properties: - embedOptions: - type: object - properties: - mode: - type: string - enum: - - "full-screen" - - "inline" - lang: - type: string - enum: - - "de" - - "en" - - "fr" - width: - type: string - topBar: - type: boolean - scrollToTop: - type: boolean - button: - type: object - properties: - text: - type: string - nullable: true - align: - type: string - enum: - - "left" - - "center" - - "right" - safeModeAutomation: - type: boolean - designId: - type: string - templateId: - type: string - entityId: - type: string - nullable: true - mappingsAutomationId: - type: string - targetedCustomer: - type: string - description: - type: string - nullable: true - organizationSettings: - type: object - additionalProperties: - type: boolean - nullable: true - publicToken: - type: string - nullable: true - runtimeEntities: - type: array - items: - type: string - enum: - - ORDER - - OPPORTUNITY - filePurposes: - type: array - items: - type: string - entityTags: - type: array - items: - type: string - addressSuggestionsFileUrl: - type: string - nullable: true - deprecated: true - description: "@deprecated Use addressSuggestionsFileId instead" - addressSuggestionsFileId: - type: string - nullable: true - # When useNewDesign is true, the journey uses the design provided by the concorde-elements blocks - useNewDesign: - type: boolean - accessMode: - type: string - enum: - - PUBLIC - - PRIVATE - required: - - designId - additionalProperties: false - createdBy: - type: string - __lastModifiedAt: - type: string - description: "If passed with value of null, the API won't modify the lastModifiedAt field on updating the journey" - nullable: true - required: - - organizationId - - name - - steps - additionalProperties: true - JourneyCreationRequestV2: - type: object - properties: - journeyId: - type: string - brandId: - type: string - name: - type: string - steps: - type: array - items: - type: object - additionalProperties: false - properties: - showStepName: - type: boolean - nullable: true - title: - type: string - nullable: true - subTitle: - type: string - nullable: true - showStepSubtitle: - type: boolean - nullable: true - showStepper: - type: boolean - nullable: true - showStepperLabels: - type: boolean - nullable: true - hideNextButton: - type: boolean - nullable: true - name: - type: string - stepId: - type: string - schema: {} - uischema: {} - required: - - name - - schema - - uischema - design: - type: object - properties: - logoUrl: - type: string - nullable: true - theme: - type: object - additionalProperties: {} - additionalProperties: false - rules: - type: array - items: - type: object - properties: - type: - type: string - enum: - - inject - - injectWithKey - sourceType: - type: string - enum: - - journey - - step - - block - source: - type: string - target: - type: string - required: - - type - - sourceType - - source - - target - additionalProperties: false - logics: - type: array - items: - type: object - properties: - autoGeneratedId: - type: string - conditions: - type: array - items: - type: string - actions: - type: array - items: - type: string - required: - - conditions - - actions - additionalProperties: false - contextSchema: - type: array - items: - type: object - properties: - type: - type: string - paramKey: - type: string - isRequired: - type: boolean - shouldLoadEntity: - type: boolean - required: - - paramKey - - type - additionalProperties: false - settings: - type: object - properties: - embedOptions: - type: object - properties: - mode: - type: string - enum: - - "full-screen" - - "inline" - lang: - type: string - enum: - - "de" - - "en" - - "fr" - width: - type: string - topBar: - type: boolean - scrollToTop: - type: boolean - button: - type: object - properties: - text: - type: string - nullable: true - align: - type: string - enum: - - "left" - - "center" - - "right" - safeModeAutomation: - type: boolean - designId: - type: string - entityId: - type: string - nullable: true - mappingsAutomationId: - type: string - templateId: - type: string - targetedCustomer: - type: string - description: - type: string - nullable: true - runtimeEntities: - type: array - items: - type: string - enum: - - ORDER - - OPPORTUNITY - filePurposes: - type: array - items: - type: string - entityTags: - type: array - items: - type: string - addressSuggestionsFileUrl: - type: string - nullable: true - deprecated: true - description: "@deprecated Use addressSuggestionsFileId instead" - addressSuggestionsFileId: - type: string - nullable: true - additionalProperties: false - required: - - name - - steps - SearchJourneysQueryRequest: - type: object - properties: - q: - type: string - description: > - Lucene query syntax - - See https://lucene.apache.org/core/2_9_4/queryparsersyntax.html ; - https://www.elastic.co/guide/en/kibana/current/lucene-query.html - example: "_tags:*Flex*" - default: "*" - from: - type: integer - description: > - The offset of the first result to return. - - See - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html - example: 0 - default: 0 - size: - type: integer - description: > - The maximum number of results to return. - - See - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html - example: 25 - default: 25 - sort: - type: string - description: | - The sort order. Follows Lucene syntax. - example: "_created_at:desc" - default: "_created_at:desc" - SearchJourneysResponse: - type: object - properties: - hits: - type: number - description: | - The total number of hits. - example: 1 - results: - type: array - description: | - The results. - items: - type: object - properties: - _id: - type: string - description: Journey Entity ID - format: uuid - example: e0f8f8f8-f8f8-f8f8-f8f8-f8f8f8f8f8f8 - _schema: - type: string - description: Entity Schema (journey always in this case) - example: journey - _title: - type: string - description: Journey Entity Title - example: "Journey Entity Title" - _org: - type: string - description: Organization ID - example: "739224" - _created_at: - type: string - format: date-time - example: "2020-01-01T00:00:00.000Z" - _updated_at: - type: string - format: date-time - example: "2020-01-01T00:00:00.000Z" - _tags: - type: array - items: - type: string - example: Flex - journey_name: - type: string - description: Journey Name - example: Journey Name - journey_id: - type: string - format: uuid - description: Journey config ID - example: de7df470-253e-11ed-9174-116b8a718c0a - journey_type: - type: string - description: Journey Template - example: "Sales template" - design: - type: string - description: Journey Design Name - example: "Design EPILOT" - created_by: - type: array - items: - type: object - properties: - id: - type: string - description: "User ID" - example: "12345" - journey_version: - type: string - description: "Journey Version" - enum: - - Flex - - Widget - Journey: - allOf: - - $ref: "#/components/schemas/JourneyCreationRequest" - - $ref: "#/components/schemas/JourneyAuditInfo" - - $ref: "#/components/schemas/JourneyFeatureFlags" - JourneyFeatureFlags: - type: object - properties: - featureFlags: - type: object - additionalProperties: true - JourneyAuditInfo: - type: object - properties: - createdAt: - type: string - lastModifiedAt: - type: string - version: - type: number - revisions: - type: number - required: - - createdAt - - lastModifiedAt - - version - - revisions - securitySchemes: - EpilotAuth: - type: http - scheme: bearer - description: Authorization header with epilot OAuth2 bearer token - bearerFormat: JWT -servers: -- url: https://journey-config.sls.epilot.io