From 3928094e7552c287e0ccaf75001c6042bf278e71 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 20 Nov 2024 00:32:11 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.441.0 --- .speakeasy/gen.lock | 51 +- .speakeasy/workflow.lock | 28 + .speakeasy/workflow.yaml | 3 + README.md | 5 +- RELEASES.md | 12 +- docs/data-sources/custom_variable.md | 41 - docs/index.md | 2 +- docs/resources/custom_variable.md | 62 -- .../data-source.tf | 3 - examples/provider/provider.tf | 2 +- .../import.sh | 1 - .../resource.tf | 19 - gen.yaml | 4 +- go.mod | 36 +- go.sum | 68 +- .../provider/customvariable_data_source.go | 187 ---- .../customvariable_data_source_sdk.go | 42 - internal/provider/customvariable_resource.go | 381 ------- .../provider/customvariable_resource_sdk.go | 133 --- internal/provider/provider.go | 13 +- internal/provider/reflect/helpers.go | 2 +- internal/provider/utils.go | 185 ++++ internal/sdk/customvariables.go | 997 +++++------------- internal/sdk/internal/utils/utils.go | 14 + .../models/operations/createcustomvariable.go | 18 +- .../operations/getblueprinttableconfig.go | 18 +- .../sdk/models/operations/getcategories.go | 6 +- .../models/operations/getcustomvariable.go | 18 +- .../models/operations/getcustomvariables.go | 6 +- .../operations/searchcustomvariables.go | 12 +- .../sdk/models/operations/searchvariables.go | 52 +- .../models/operations/updatecustomvariable.go | 34 +- internal/sdk/models/shared/customvariable.go | 101 +- .../shared/customvariablessearchparams.go | 38 +- .../models/shared/externalcustomvariable.go | 10 +- internal/sdk/models/shared/variablecontext.go | 22 +- .../sdk/models/shared/variableparameters.go | 66 +- internal/sdk/models/shared/variableresult.go | 44 +- internal/sdk/sdk.go | 12 +- internal/sdk/variables.go | 519 ++------- 40 files changed, 901 insertions(+), 2366 deletions(-) create mode 100644 .speakeasy/workflow.lock delete mode 100644 docs/data-sources/custom_variable.md delete mode 100644 docs/resources/custom_variable.md delete mode 100644 examples/data-sources/epilot-custom-variable_custom_variable/data-source.tf delete mode 100644 examples/resources/epilot-custom-variable_custom_variable/import.sh delete mode 100644 examples/resources/epilot-custom-variable_custom_variable/resource.tf delete mode 100644 internal/provider/customvariable_data_source.go delete mode 100644 internal/provider/customvariable_data_source_sdk.go delete mode 100644 internal/provider/customvariable_resource.go delete mode 100644 internal/provider/customvariable_resource_sdk.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index a092270..7daa649 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,30 +1,27 @@ lockVersion: 2.0.0 id: 45f3018a-30de-4d91-ab55-1ad3f43bb6de management: - docChecksum: b2a8ea3da2c0564f2ac23b47baa1503a + docChecksum: 085375dfed9f0d113806b92ef0f5bc15 docVersion: 1.0.0 - speakeasyVersion: 1.405.9 - generationVersion: 2.429.0 - releaseVersion: 1.0.2 - configChecksum: 8385635e0dd549d2a448fcb26d4b9605 + speakeasyVersion: 1.441.0 + generationVersion: 2.460.1 + releaseVersion: 1.1.0 + configChecksum: 8e8f6e787746d6b8887d7280c07c6b24 + repoURL: https://github.com/epilot-dev/terraform-provider-epilot-custom-variable.git features: terraform: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.4 - core: 3.24.15 + constsAndDefaults: 0.2.0 + core: 3.26.3 envVarSecurityUsage: 0.1.0 - globalSecurity: 2.81.8 + globalSecurity: 2.81.9 globalServerURLs: 2.82.1 nullables: 0.0.0 - retries: 2.81.1 generatedFiles: - .gitattributes - USAGE.md - examples/README.md - - examples/data-sources/epilot-custom-variable_custom_variable/data-source.tf - examples/provider/provider.tf - - examples/resources/epilot-custom-variable_custom_variable/import.sh - - examples/resources/epilot-custom-variable_custom_variable/resource.tf - go.mod - go.sum - internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -37,10 +34,6 @@ generatedFiles: - internal/planmodifiers/setplanmodifier/suppress_diff.go - internal/planmodifiers/stringplanmodifier/suppress_diff.go - internal/planmodifiers/utils/state_check.go - - internal/provider/customvariable_data_source.go - - internal/provider/customvariable_data_source_sdk.go - - internal/provider/customvariable_resource.go - - internal/provider/customvariable_resource_sdk.go - internal/provider/provider.go - internal/provider/reflect/diags.go - internal/provider/reflect/doc.go @@ -127,21 +120,21 @@ examples: searchVariables: "": requestBody: - application/json: {"template_type": "document", "query": "logo", "entity_schemas": ["contact"]} + application/json: {"entity_schemas": ["contact"], "query": "logo", "template_type": "document"} responses: "200": - application/json: [{"type": "simple", "group": "Personal Details", "insert": "{{account.name}}", "description": "Company name"}, {"type": "simple", "group": "Personal Details", "insert": "{{account.tax_id}}", "description": "Tax ID"}, {"type": "partial", "qrdata": "{{account.address_details}}", "group": "Address details", "description": "Address Details"}, {"type": "simple", "group": "Address Details", "insert": "{{account.address.street}}", "description": "Address - Street name"}, {"type": "simple", "group": "Address Details", "insert": "{{account.address.street_number}}", "description": "Address - Street number"}, {"type": "simple", "group": "Address Details", "insert": "{{account.address.postal_code}}", "description": "Address - Postal code"}, {"type": "simple", "group": "Address Details", "insert": "{{account.address.city}}", "description": "Address - City"}] + application/json: [{"description": "Company name", "group": "Personal Details", "insert": "{{account.name}}", "type": "simple"}, {"description": "Tax ID", "group": "Personal Details", "insert": "{{account.tax_id}}", "type": "simple"}, {"description": "Address Details", "group": "Address details", "qrdata": "{{account.address_details}}", "type": "partial"}, {"description": "Address - Street name", "group": "Address Details", "insert": "{{account.address.street}}", "type": "simple"}, {"description": "Address - Street number", "group": "Address Details", "insert": "{{account.address.street_number}}", "type": "simple"}, {"description": "Address - Postal code", "group": "Address Details", "insert": "{{account.address.postal_code}}", "type": "simple"}, {"description": "Address - City", "group": "Address Details", "insert": "{{account.address.city}}", "type": "simple"}] getVariableContext: speakeasy-default-get-variable-context: requestBody: - application/json: {"parameters": {"template_type": "email", "main_entity_id": "63753437-c9e2-4e83-82bb-b1c666514561", "brand_id": 123451, "user_id": "50001", "user_org_id": "729224", "custom_variables": [{"variable": "{{craftsmen.invitation_link}}", "value": "https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19"}, {"variable": "{{craftsmen.invitation_link}}", "value": "https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19"}], "variables_version": "2"}} + application/json: {"parameters": {"brand_id": 123451, "custom_variables": [{"value": "https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19", "variable": "{{craftsmen.invitation_link}}"}, {"value": "https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19", "variable": "{{craftsmen.invitation_link}}"}], "main_entity_id": "63753437-c9e2-4e83-82bb-b1c666514561", "template_type": "email", "user_id": "50001", "user_org_id": "729224", "variables_version": "2"}} responses: "200": - application/json: {"unsubscribe_url": "https://consent.sls.epilot.io/v1/unsubscribe?token=abc123", "main": {"$ref": "#/components/examples/ExampleMain/value"}, "contact": {"$ref": "#/components/examples/ExampleContactEntity/value"}, "brand": {"$ref": "#/components/examples/ExampleBrand/value"}} + application/json: {"brand": {"$ref": "#/components/examples/ExampleBrand/value"}, "contact": {"$ref": "#/components/examples/ExampleContactEntity/value"}, "main": {"$ref": "#/components/examples/ExampleMain/value"}, "unsubscribe_url": "https://consent.sls.epilot.io/v1/unsubscribe?token=abc123"} replaceTemplates: speakeasy-default-replace-templates: requestBody: - application/json: {"inputs": ["Hello, {{contact.first_name}}!\n\n{{{brand.signature}}}\n"], "parameters": {"template_type": "email", "main_entity_id": "63753437-c9e2-4e83-82bb-b1c666514561", "brand_id": 123451, "user_id": "50001", "user_org_id": "729224", "custom_variables": [{"variable": "{{craftsmen.invitation_link}}", "value": "https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19"}], "variables_version": "2"}} + application/json: {"inputs": ["Hello, {{contact.first_name}}!\n\n{{{brand.signature}}}\n"], "parameters": {"brand_id": 123451, "custom_variables": [{"value": "https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19", "variable": "{{craftsmen.invitation_link}}"}], "main_entity_id": "63753437-c9e2-4e83-82bb-b1c666514561", "template_type": "email", "user_id": "50001", "user_org_id": "729224", "variables_version": "2"}} responses: "200": application/json: {"outputs": ["\"[Brand Name GmbH] Order confirmation\",\n\"Hello Customer Name\n\nBrand Name GmbH\n\"Brand\nimprint\n\"]\n"]} @@ -149,31 +142,31 @@ examples: speakeasy-default-get-custom-variables: responses: "200": - application/json: [{"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "custom", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}, {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}, {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}] + application/json: [{"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "custom", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}, {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "order_table", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}, {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "order_table", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}] createCustomVariable: speakeasy-default-create-custom-variable: requestBody: - application/json: {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "custom", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} + application/json: {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "custom", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} responses: "201": - application/json: {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} + application/json: {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} searchCustomVariables: speakeasy-default-search-custom-variables: requestBody: application/json: {"query": "logo", "sort_by": "[\"created_at\",\"created_at:desc\",\"name\",\"name:desc\",\"key\"]"} responses: "200": - application/json: {"results": [{"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "custom", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}, {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "custom", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}], "hits": 100} + application/json: {"hits": 100, "results": [{"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "custom", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}, {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "custom", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"}]} updateCustomVariable: "": parameters: path: id: "rbse777b-3cf8-4bff-bb0c-253fd1123250" requestBody: - application/json: {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "custom", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} + application/json: {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "custom", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} responses: "200": - application/json: {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} + application/json: {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} getCustomVariable: "": parameters: @@ -181,7 +174,7 @@ examples: id: "rbse777b-3cf8-4bff-bb0c-253fd1123250" responses: "200": - application/json: {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} + application/json: {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "order_table", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} deleteCustomVariable: "": parameters: @@ -191,4 +184,4 @@ examples: speakeasy-default-get-blue-print-table-config: responses: "200": - application/json: {"id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "custom", "name": "My Custom table", "key": "my_custom_table", "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} + application/json: {"created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "helper_logic": "return param1 * param2;", "helper_params": ["param1", "param2"], "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "key": "my_custom_table", "name": "My Custom table", "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "type": "custom", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042"} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock new file mode 100644 index 0000000..acb20cb --- /dev/null +++ b/.speakeasy/workflow.lock @@ -0,0 +1,28 @@ +speakeasyVersion: 1.441.0 +sources: + my-source: + sourceNamespace: my-source + sourceRevisionDigest: sha256:92de8ce7a2ac15e87af360d855496abcdf728677ba23379bcb3d8310bbf13aa9 + sourceBlobDigest: sha256:0ddb3a44f94ffd036d23b6b5548e3ff42e624b4bcb46057b79081cb4ea63b660 + tags: + - latest + - speakeasy-sdk-regen-1730852960 +targets: + terraform: + source: my-source + sourceNamespace: my-source + sourceRevisionDigest: sha256:92de8ce7a2ac15e87af360d855496abcdf728677ba23379bcb3d8310bbf13aa9 + sourceBlobDigest: sha256:0ddb3a44f94ffd036d23b6b5548e3ff42e624b4bcb46057b79081cb4ea63b660 +workflow: + workflowVersion: 1.0.0 + speakeasyVersion: latest + sources: + my-source: + inputs: + - location: https://docs.api.epilot.io/template-variables.yaml + registry: + location: registry.speakeasyapi.dev/epilot/epilot/my-source + targets: + terraform: + target: terraform + source: my-source diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml index 00162b9..3e7820a 100644 --- a/.speakeasy/workflow.yaml +++ b/.speakeasy/workflow.yaml @@ -1,8 +1,11 @@ workflowVersion: 1.0.0 +speakeasyVersion: latest sources: my-source: inputs: - location: https://docs.api.epilot.io/template-variables.yaml + registry: + location: registry.speakeasyapi.dev/epilot/epilot/my-source targets: terraform: target: terraform diff --git a/README.md b/README.md index 3a6f9ef..09e32e5 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ terraform { required_providers { epilot-custom-variable = { source = "epilot-dev/epilot-custom-variable" - version = "1.0.2" + version = "1.1.0" } } } @@ -58,10 +58,7 @@ provider "epilot-custom-variable" { ### Resources -* [epilot-custom-variable_custom_variable](docs/resources/custom_variable.md) ### Data Sources - -* [epilot-custom-variable_custom_variable](docs/data-sources/custom_variable.md) diff --git a/RELEASES.md b/RELEASES.md index f4a2be8..c17a3f1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -14,4 +14,14 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.147.0 (2.237.2) https://github.com/speakeasy-api/speakeasy ### Generated -- [terraform v0.4.4] . \ No newline at end of file +- [terraform v0.4.4] . + +## 2024-11-20 00:31:04 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.441.0 (2.460.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v1.1.0] . +### Releases +- [Terraform v1.1.0] https://registry.terraform.io/providers/epilot-dev/epilot-custom-variable/1.1.0 - . \ No newline at end of file diff --git a/docs/data-sources/custom_variable.md b/docs/data-sources/custom_variable.md deleted file mode 100644 index 9b1db09..0000000 --- a/docs/data-sources/custom_variable.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-custom-variable_custom_variable Data Source - terraform-provider-epilot-custom-variable" -subcategory: "" -description: |- - CustomVariable DataSource ---- - -# epilot-custom-variable_custom_variable (Data Source) - -CustomVariable DataSource - -## Example Usage - -```terraform -data "epilot-custom-variable_custom_variable" "my_customvariable" { - id = "rbse777b-3cf8-4bff-bb0c-253fd1123250" -} -``` - - -## Schema - -### Required - -- `id` (String) Custom vairable ID - -### Read-Only - -- `config` (String) Parsed as JSON. -- `created_at` (String) Creation time -- `created_by` (String) Created by -- `helper_logic` (String) The helper function logic -- `helper_params` (List of String) The helper function parameter's names -- `key` (String) The key which is used for Handlebar variable syntax {{"{{"}}key{{"}}"}} -- `name` (String) Custom variable name -- `tags` (List of String) The tags of custom variable -- `template` (String) Handlebar template that used to generate the variable content -- `type` (String) Custom variable type -- `updated_at` (String) Last update time -- `updated_by` (String) Updated by diff --git a/docs/index.md b/docs/index.md index 364abf9..d9892d7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { epilot-custom-variable = { source = "epilot-dev/epilot-custom-variable" - version = "1.0.2" + version = "1.1.0" } } } diff --git a/docs/resources/custom_variable.md b/docs/resources/custom_variable.md deleted file mode 100644 index 7e57278..0000000 --- a/docs/resources/custom_variable.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-custom-variable_custom_variable Resource - terraform-provider-epilot-custom-variable" -subcategory: "" -description: |- - CustomVariable Resource ---- - -# epilot-custom-variable_custom_variable (Resource) - -CustomVariable Resource - -## Example Usage - -```terraform -resource "epilot-custom-variable_custom_variable" "my_customvariable" { - config = "{ \"see\": \"documentation\" }" - created_at = "2022-04-19T12:41:43.662Z" - created_by = 100042 - helper_logic = "return param1 * param2;" - helper_params = [ - "..." - ] - id = "rbse777b-3cf8-4bff-bb0c-253fd1123250" - key = "my_custom_table" - name = "My Custom table" - tags = [ - "..." - ] - template = "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n" - type = "custom" - updated_at = "2022-04-20T12:41:43.662Z" - updated_by = 100042 -} -``` - - -## Schema - -### Optional - -- `config` (String) Requires replacement if changed.; Parsed as JSON. -- `created_at` (String) Creation time. Requires replacement if changed. -- `created_by` (String) Created by. Requires replacement if changed. -- `helper_logic` (String) The helper function logic. Requires replacement if changed. -- `helper_params` (List of String) The helper function parameter's names. Requires replacement if changed. -- `id` (String) ID. Requires replacement if changed. -- `key` (String) The key which is used for Handlebar variable syntax {{"{{"}}key{{"}}"}}. Requires replacement if changed. -- `name` (String) Custom variable name. Requires replacement if changed. -- `tags` (List of String) The tags of custom variable. Requires replacement if changed. -- `template` (String) Handlebar template that used to generate the variable content. Requires replacement if changed. -- `type` (String) Custom variable type. must be one of ["order_table", "custom", "journey_link"]; Requires replacement if changed. -- `updated_at` (String) Last update time. Requires replacement if changed. -- `updated_by` (String) Updated by. Requires replacement if changed. - -## Import - -Import is supported using the following syntax: - -```shell -terraform import epilot-custom-variable_custom_variable.my_epilot-custom-variable_custom_variable "rbse777b-3cf8-4bff-bb0c-253fd1123250" -``` diff --git a/examples/data-sources/epilot-custom-variable_custom_variable/data-source.tf b/examples/data-sources/epilot-custom-variable_custom_variable/data-source.tf deleted file mode 100644 index 0289a55..0000000 --- a/examples/data-sources/epilot-custom-variable_custom_variable/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "epilot-custom-variable_custom_variable" "my_customvariable" { - id = "rbse777b-3cf8-4bff-bb0c-253fd1123250" -} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index b3f06e8..445f83c 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-custom-variable = { source = "epilot-dev/epilot-custom-variable" - version = "1.0.2" + version = "1.1.0" } } } diff --git a/examples/resources/epilot-custom-variable_custom_variable/import.sh b/examples/resources/epilot-custom-variable_custom_variable/import.sh deleted file mode 100644 index cc2311a..0000000 --- a/examples/resources/epilot-custom-variable_custom_variable/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-custom-variable_custom_variable.my_epilot-custom-variable_custom_variable "rbse777b-3cf8-4bff-bb0c-253fd1123250" diff --git a/examples/resources/epilot-custom-variable_custom_variable/resource.tf b/examples/resources/epilot-custom-variable_custom_variable/resource.tf deleted file mode 100644 index b3f9b01..0000000 --- a/examples/resources/epilot-custom-variable_custom_variable/resource.tf +++ /dev/null @@ -1,19 +0,0 @@ -resource "epilot-custom-variable_custom_variable" "my_customvariable" { - config = "{ \"see\": \"documentation\" }" - created_at = "2022-04-19T12:41:43.662Z" - created_by = 100042 - helper_logic = "return param1 * param2;" - helper_params = [ - "..." - ] - id = "rbse777b-3cf8-4bff-bb0c-253fd1123250" - key = "my_custom_table" - name = "My Custom table" - tags = [ - "..." - ] - template = "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n" - type = "custom" - updated_at = "2022-04-20T12:41:43.662Z" - updated_by = 100042 -} \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index b7b6844..37fb0bf 100644 --- a/gen.yaml +++ b/gen.yaml @@ -10,15 +10,17 @@ generation: requestResponseComponentNamesFeb2024: false auth: oAuth2ClientCredentialsEnabled: false + oAuth2PasswordEnabled: false sdkFlattening: true telemetryEnabled: false terraform: - version: 1.0.2 + version: 1.1.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] allowUnknownFieldsInWeakUnions: false author: epilot-dev + defaultErrorName: SDKError environmentVariables: [] imports: option: openapi diff --git a/go.mod b/go.mod index c656d7b..42ba9ba 100644 --- a/go.mod +++ b/go.mod @@ -2,15 +2,15 @@ module github.com/epilot-dev/terraform-provider-epilot-custom-variable go 1.22.0 -toolchain go1.23.2 - require ( - github.com/cenkalti/backoff/v4 v4.3.0 - github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 + github.com/cenkalti/backoff/v4 v4.2.0 + github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 + github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-docs v0.19.4 github.com/hashicorp/terraform-plugin-framework v1.12.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.14.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 github.com/hashicorp/terraform-plugin-go v0.24.0 + github.com/hashicorp/terraform-plugin-log v0.9.0 ) require ( @@ -25,25 +25,23 @@ require ( github.com/bgentry/speakeasy v0.1.0 // indirect github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/fatih/color v1.18.0 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/cli v1.1.6 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.6.3 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.2 // indirect - github.com/hashicorp/go-uuid v1.0.3 // indirect + github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/hc-install v0.7.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect github.com/hashicorp/terraform-json v0.22.1 // indirect - github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect - github.com/hashicorp/yamux v0.1.2 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.15 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -52,7 +50,7 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/oklog/run v1.1.0 // indirect + github.com/oklog/run v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect @@ -62,15 +60,15 @@ require ( github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.14.4 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect - google.golang.org/grpc v1.67.1 // indirect - google.golang.org/protobuf v1.35.1 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect + google.golang.org/grpc v1.66.2 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 07a36fc..f9e8505 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwN github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= +github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= @@ -35,11 +35,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= -github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -67,13 +67,13 @@ github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuD github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= -github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog= -github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q= +github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= +github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -89,8 +89,8 @@ github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSey github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= github.com/hashicorp/terraform-plugin-framework v1.12.0 h1:7HKaueHPaikX5/7cbC1r9d1m12iYHY+FlNZEGxQ42CQ= github.com/hashicorp/terraform-plugin-framework v1.12.0/go.mod h1:N/IOQ2uYjW60Jp39Cp3mw7I/OpC/GfZ0385R0YibmkE= -github.com/hashicorp/terraform-plugin-framework-validators v0.14.0 h1:3PCn9iyzdVOgHYOBmncpSSOxjQhCTYmc+PGvbdlqSaI= -github.com/hashicorp/terraform-plugin-framework-validators v0.14.0/go.mod h1:LwDKNdzxrDY/mHBrlC6aYfE2fQ3Dk3gaJD64vNiXvo4= +github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E= +github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo= github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U= github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= @@ -99,8 +99,8 @@ github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTV github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= -github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= -github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -135,8 +135,8 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= -github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -160,8 +160,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -180,8 +180,8 @@ go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -191,12 +191,12 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -210,8 +210,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -219,20 +219,20 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/internal/provider/customvariable_data_source.go b/internal/provider/customvariable_data_source.go deleted file mode 100644 index a56569c..0000000 --- a/internal/provider/customvariable_data_source.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/operations" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ datasource.DataSource = &CustomVariableDataSource{} -var _ datasource.DataSourceWithConfigure = &CustomVariableDataSource{} - -func NewCustomVariableDataSource() datasource.DataSource { - return &CustomVariableDataSource{} -} - -// CustomVariableDataSource is the data source implementation. -type CustomVariableDataSource struct { - client *sdk.SDK -} - -// CustomVariableDataSourceModel describes the data model. -type CustomVariableDataSourceModel struct { - Config types.String `tfsdk:"config"` - CreatedAt types.String `tfsdk:"created_at"` - CreatedBy types.String `tfsdk:"created_by"` - HelperLogic types.String `tfsdk:"helper_logic"` - HelperParams []types.String `tfsdk:"helper_params"` - ID types.String `tfsdk:"id"` - Key types.String `tfsdk:"key"` - Name types.String `tfsdk:"name"` - Tags []types.String `tfsdk:"tags"` - Template types.String `tfsdk:"template"` - Type types.String `tfsdk:"type"` - UpdatedAt types.String `tfsdk:"updated_at"` - UpdatedBy types.String `tfsdk:"updated_by"` -} - -// Metadata returns the data source type name. -func (r *CustomVariableDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_custom_variable" -} - -// Schema defines the schema for the data source. -func (r *CustomVariableDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "CustomVariable DataSource", - - Attributes: map[string]schema.Attribute{ - "config": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: `Creation time`, - }, - "created_by": schema.StringAttribute{ - Computed: true, - Description: `Created by`, - }, - "helper_logic": schema.StringAttribute{ - Computed: true, - Description: `The helper function logic`, - }, - "helper_params": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `The helper function parameter's names`, - }, - "id": schema.StringAttribute{ - Required: true, - Description: `Custom vairable ID`, - }, - "key": schema.StringAttribute{ - Computed: true, - Description: `The key which is used for Handlebar variable syntax {{"{{"}}key{{"}}"}}`, - }, - "name": schema.StringAttribute{ - Computed: true, - Description: `Custom variable name`, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `The tags of custom variable`, - }, - "template": schema.StringAttribute{ - Computed: true, - Description: `Handlebar template that used to generate the variable content`, - }, - "type": schema.StringAttribute{ - Computed: true, - Description: `Custom variable type`, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Description: `Last update time`, - }, - "updated_by": schema.StringAttribute{ - Computed: true, - Description: `Updated by`, - }, - }, - } -} - -func (r *CustomVariableDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected DataSource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *CustomVariableDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *CustomVariableDataSourceModel - var item types.Object - - resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - var id string - id = data.ID.ValueString() - - request := operations.GetCustomVariableRequest{ - ID: id, - } - res, err := r.client.CustomVariables.GetCustomVariable(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.CustomVariable != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedCustomVariable(res.CustomVariable) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/customvariable_data_source_sdk.go b/internal/provider/customvariable_data_source_sdk.go deleted file mode 100644 index 0fa2ab5..0000000 --- a/internal/provider/customvariable_data_source_sdk.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "encoding/json" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *CustomVariableDataSourceModel) RefreshFromSharedCustomVariable(resp *shared.CustomVariable) { - if resp != nil { - r.Tags = []types.String{} - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - if resp.Config == nil { - r.Config = types.StringNull() - } else { - configResult, _ := json.Marshal(resp.Config) - r.Config = types.StringValue(string(configResult)) - } - r.CreatedAt = types.StringPointerValue(resp.CreatedAt) - r.CreatedBy = types.StringPointerValue(resp.CreatedBy) - r.HelperLogic = types.StringPointerValue(resp.HelperLogic) - r.HelperParams = []types.String{} - for _, v := range resp.HelperParams { - r.HelperParams = append(r.HelperParams, types.StringValue(v)) - } - r.ID = types.StringPointerValue(resp.ID) - r.Key = types.StringPointerValue(resp.Key) - r.Name = types.StringPointerValue(resp.Name) - r.Template = types.StringPointerValue(resp.Template) - if resp.Type != nil { - r.Type = types.StringValue(string(*resp.Type)) - } else { - r.Type = types.StringNull() - } - r.UpdatedAt = types.StringPointerValue(resp.UpdatedAt) - r.UpdatedBy = types.StringPointerValue(resp.UpdatedBy) - } -} diff --git a/internal/provider/customvariable_resource.go b/internal/provider/customvariable_resource.go deleted file mode 100644 index fab4b4c..0000000 --- a/internal/provider/customvariable_resource.go +++ /dev/null @@ -1,381 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - speakeasy_listplanmodifier "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/planmodifiers/listplanmodifier" - speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/planmodifiers/stringplanmodifier" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/validators" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -// Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &CustomVariableResource{} -var _ resource.ResourceWithImportState = &CustomVariableResource{} - -func NewCustomVariableResource() resource.Resource { - return &CustomVariableResource{} -} - -// CustomVariableResource defines the resource implementation. -type CustomVariableResource struct { - client *sdk.SDK -} - -// CustomVariableResourceModel describes the resource data model. -type CustomVariableResourceModel struct { - Config types.String `tfsdk:"config"` - CreatedAt types.String `tfsdk:"created_at"` - CreatedBy types.String `tfsdk:"created_by"` - HelperLogic types.String `tfsdk:"helper_logic"` - HelperParams []types.String `tfsdk:"helper_params"` - ID types.String `tfsdk:"id"` - Key types.String `tfsdk:"key"` - Name types.String `tfsdk:"name"` - Tags []types.String `tfsdk:"tags"` - Template types.String `tfsdk:"template"` - Type types.String `tfsdk:"type"` - UpdatedAt types.String `tfsdk:"updated_at"` - UpdatedBy types.String `tfsdk:"updated_by"` -} - -func (r *CustomVariableResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_custom_variable" -} - -func (r *CustomVariableResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "CustomVariable Resource", - Attributes: map[string]schema.Attribute{ - "config": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Requires replacement if changed.; Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Creation time. Requires replacement if changed.`, - }, - "created_by": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Created by. Requires replacement if changed.`, - }, - "helper_logic": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `The helper function logic. Requires replacement if changed.`, - }, - "helper_params": schema.ListAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - ElementType: types.StringType, - Description: `The helper function parameter's names. Requires replacement if changed.`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `ID. Requires replacement if changed.`, - }, - "key": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `The key which is used for Handlebar variable syntax {{"{{"}}key{{"}}"}}. Requires replacement if changed.`, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Custom variable name. Requires replacement if changed.`, - }, - "tags": schema.ListAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - ElementType: types.StringType, - Description: `The tags of custom variable. Requires replacement if changed.`, - }, - "template": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Handlebar template that used to generate the variable content. Requires replacement if changed.`, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Custom variable type. must be one of ["order_table", "custom", "journey_link"]; Requires replacement if changed.`, - Validators: []validator.String{ - stringvalidator.OneOf( - "order_table", - "custom", - "journey_link", - ), - }, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Last update time. Requires replacement if changed.`, - }, - "updated_by": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Updated by. Requires replacement if changed.`, - }, - }, - } -} - -func (r *CustomVariableResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*sdk.SDK) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -func (r *CustomVariableResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *CustomVariableResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request := data.ToSharedCustomVariable() - res, err := r.client.CustomVariables.CreateCustomVariable(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.CustomVariable != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedCustomVariable(res.CustomVariable) - refreshPlan(ctx, plan, &data, resp.Diagnostics) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *CustomVariableResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *CustomVariableResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - var id string - id = data.ID.ValueString() - - request := operations.GetCustomVariableRequest{ - ID: id, - } - res, err := r.client.CustomVariables.GetCustomVariable(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode == 404 { - resp.State.RemoveResource(ctx) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.CustomVariable != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromSharedCustomVariable(res.CustomVariable) - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *CustomVariableResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *CustomVariableResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - // Not Implemented; all attributes marked as RequiresReplace - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *CustomVariableResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *CustomVariableResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.Get(ctx, &item)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - var id string - id = data.ID.ValueString() - - request := operations.DeleteCustomVariableRequest{ - ID: id, - } - res, err := r.client.CustomVariables.DeleteCustomVariable(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *CustomVariableResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/customvariable_resource_sdk.go b/internal/provider/customvariable_resource_sdk.go deleted file mode 100644 index f115534..0000000 --- a/internal/provider/customvariable_resource_sdk.go +++ /dev/null @@ -1,133 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "encoding/json" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *CustomVariableResourceModel) ToSharedCustomVariable() *shared.CustomVariable { - id := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id = r.ID.ValueString() - } else { - id = nil - } - typeVar := new(shared.CustomVariableType) - if !r.Type.IsUnknown() && !r.Type.IsNull() { - *typeVar = shared.CustomVariableType(r.Type.ValueString()) - } else { - typeVar = nil - } - name := new(string) - if !r.Name.IsUnknown() && !r.Name.IsNull() { - *name = r.Name.ValueString() - } else { - name = nil - } - key := new(string) - if !r.Key.IsUnknown() && !r.Key.IsNull() { - *key = r.Key.ValueString() - } else { - key = nil - } - var tags []string = []string{} - for _, tagsItem := range r.Tags { - tags = append(tags, tagsItem.ValueString()) - } - var helperParams []string = []string{} - for _, helperParamsItem := range r.HelperParams { - helperParams = append(helperParams, helperParamsItem.ValueString()) - } - helperLogic := new(string) - if !r.HelperLogic.IsUnknown() && !r.HelperLogic.IsNull() { - *helperLogic = r.HelperLogic.ValueString() - } else { - helperLogic = nil - } - template := new(string) - if !r.Template.IsUnknown() && !r.Template.IsNull() { - *template = r.Template.ValueString() - } else { - template = nil - } - createdAt := new(string) - if !r.CreatedAt.IsUnknown() && !r.CreatedAt.IsNull() { - *createdAt = r.CreatedAt.ValueString() - } else { - createdAt = nil - } - createdBy := new(string) - if !r.CreatedBy.IsUnknown() && !r.CreatedBy.IsNull() { - *createdBy = r.CreatedBy.ValueString() - } else { - createdBy = nil - } - updatedAt := new(string) - if !r.UpdatedAt.IsUnknown() && !r.UpdatedAt.IsNull() { - *updatedAt = r.UpdatedAt.ValueString() - } else { - updatedAt = nil - } - updatedBy := new(string) - if !r.UpdatedBy.IsUnknown() && !r.UpdatedBy.IsNull() { - *updatedBy = r.UpdatedBy.ValueString() - } else { - updatedBy = nil - } - var config interface{} - if !r.Config.IsUnknown() && !r.Config.IsNull() { - _ = json.Unmarshal([]byte(r.Config.ValueString()), &config) - } - out := shared.CustomVariable{ - ID: id, - Type: typeVar, - Name: name, - Key: key, - Tags: tags, - HelperParams: helperParams, - HelperLogic: helperLogic, - Template: template, - CreatedAt: createdAt, - CreatedBy: createdBy, - UpdatedAt: updatedAt, - UpdatedBy: updatedBy, - Config: config, - } - return &out -} - -func (r *CustomVariableResourceModel) RefreshFromSharedCustomVariable(resp *shared.CustomVariable) { - if resp != nil { - r.Tags = []types.String{} - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - if resp.Config == nil { - r.Config = types.StringNull() - } else { - configResult, _ := json.Marshal(resp.Config) - r.Config = types.StringValue(string(configResult)) - } - r.CreatedAt = types.StringPointerValue(resp.CreatedAt) - r.CreatedBy = types.StringPointerValue(resp.CreatedBy) - r.HelperLogic = types.StringPointerValue(resp.HelperLogic) - r.HelperParams = []types.String{} - for _, v := range resp.HelperParams { - r.HelperParams = append(r.HelperParams, types.StringValue(v)) - } - r.ID = types.StringPointerValue(resp.ID) - r.Key = types.StringPointerValue(resp.Key) - r.Name = types.StringPointerValue(resp.Name) - r.Template = types.StringPointerValue(resp.Template) - if resp.Type != nil { - r.Type = types.StringValue(string(*resp.Type)) - } else { - r.Type = types.StringNull() - } - r.UpdatedAt = types.StringPointerValue(resp.UpdatedAt) - r.UpdatedBy = types.StringPointerValue(resp.UpdatedBy) - } -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index ef684bf..ae38a47 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -88,10 +88,13 @@ func (p *EpilotCustomVariableProvider) Configure(ctx context.Context, req provid EpilotOrg: epilotOrg, } + httpClient := http.DefaultClient + httpClient.Transport = NewLoggingHTTPTransport(http.DefaultTransport) + opts := []sdk.SDKOption{ sdk.WithServerURL(ServerURL), sdk.WithSecurity(security), - sdk.WithClient(http.DefaultClient), + sdk.WithClient(httpClient), } client := sdk.New(opts...) @@ -100,15 +103,11 @@ func (p *EpilotCustomVariableProvider) Configure(ctx context.Context, req provid } func (p *EpilotCustomVariableProvider) Resources(ctx context.Context) []func() resource.Resource { - return []func() resource.Resource{ - NewCustomVariableResource, - } + return []func() resource.Resource{} } func (p *EpilotCustomVariableProvider) DataSources(ctx context.Context) []func() datasource.DataSource { - return []func() datasource.DataSource{ - NewCustomVariableDataSource, - } + return []func() datasource.DataSource{} } func New(version string) func() provider.Provider { diff --git a/internal/provider/reflect/helpers.go b/internal/provider/reflect/helpers.go index b17719d..8085789 100644 --- a/internal/provider/reflect/helpers.go +++ b/internal/provider/reflect/helpers.go @@ -46,7 +46,7 @@ func commaSeparatedString(in []string) string { // getStructTags returns a map of Terraform field names to their position in // the tags of the struct `in`. `in` must be a struct. -func getStructTags(_ context.Context, in reflect.Value, path path.Path, opts Options) (map[string]int, error) { +func getStructTags(_ context.Context, in reflect.Value, path path.Path, _ Options) (map[string]int, error) { tags := map[string]int{} typ := trueReflectValue(in).Type() if typ.Kind() != reflect.Struct { diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 3e151fa..1dd5d69 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -3,17 +3,25 @@ package provider import ( + "bufio" + "bytes" "context" "encoding/json" + "errors" "fmt" tfReflect "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/provider/reflect" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "io" "net/http" "net/http/httputil" + "net/textproto" "reflect" + "strings" ) func debugResponse(response *http.Response) string { @@ -94,3 +102,180 @@ func refreshPlan(ctx context.Context, plan types.Object, target interface{}, dia SourceType: tfReflect.SourceTypePlan, }, path.Empty())...) } + +// Note: this is taken as a more minimal/specific version of https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/logging/logging_http_transport.go +func NewLoggingHTTPTransport(t http.RoundTripper) *loggingHttpTransport { + return &loggingHttpTransport{t} +} + +const ( + FieldHttpOperationType = "tf_http_op_type" + OperationHttpRequest = "request" + OperationHttpResponse = "response" + FieldHttpRequestMethod = "tf_http_req_method" + FieldHttpRequestUri = "tf_http_req_uri" + FieldHttpRequestProtoVersion = "tf_http_req_version" + FieldHttpRequestBody = "tf_http_req_body" + FieldHttpResponseProtoVersion = "tf_http_res_version" + FieldHttpResponseStatusCode = "tf_http_res_status_code" + FieldHttpResponseStatusReason = "tf_http_res_status_reason" + FieldHttpResponseBody = "tf_http_res_body" + FieldHttpTransactionId = "tf_http_trans_id" +) + +type loggingHttpTransport struct { + transport http.RoundTripper +} + +func (t *loggingHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { + ctx := req.Context() + ctx = t.addTransactionIdField(ctx) + + // Decompose the request bytes in a message (HTTP body) and fields (HTTP headers), then log it + fields, err := decomposeRequestForLogging(req) + if err != nil { + tflog.Error(ctx, "Failed to parse request bytes for logging", []map[string]interface{}{map[string]interface{}{ + "error": err, + }}...) + } else { + tflog.Debug(ctx, "Sending HTTP Request", []map[string]interface{}{fields}...) + } + + // Invoke the wrapped RoundTrip now + res, err := t.transport.RoundTrip(req) + if err != nil { + return res, err + } + + // Decompose the response bytes in a message (HTTP body) and fields (HTTP headers), then log it + fields, err = decomposeResponseForLogging(res) + if err != nil { + tflog.Error(ctx, "Failed to parse response bytes for logging", []map[string]interface{}{map[string]interface{}{ + "error": err, + }}...) + } else { + tflog.Debug(ctx, "Received HTTP Response", []map[string]interface{}{fields}...) + } + + return res, nil +} + +func (t *loggingHttpTransport) addTransactionIdField(ctx context.Context) context.Context { + tId, err := uuid.GenerateUUID() + + if err != nil { + tId = "Unable to assign Transaction ID: " + err.Error() + } + + return tflog.SetField(ctx, FieldHttpTransactionId, tId) +} + +func decomposeRequestForLogging(req *http.Request) (map[string]interface{}, error) { + fields := make(map[string]interface{}, len(req.Header)+4) + fields[FieldHttpOperationType] = OperationHttpRequest + + fields[FieldHttpRequestMethod] = req.Method + fields[FieldHttpRequestUri] = req.URL.RequestURI() + fields[FieldHttpRequestProtoVersion] = req.Proto + + // Get the full body of the request, including headers appended by http.Transport: + // this is necessary because the http.Request at this stage doesn't contain + // all the headers that will be eventually sent. + // We rely on `httputil.DumpRequestOut` to obtain the actual bytes that will be sent out. + reqBytes, err := httputil.DumpRequestOut(req, true) + if err != nil { + return nil, err + } + + // Create a reader around the request full body + reqReader := textproto.NewReader(bufio.NewReader(bytes.NewReader(reqBytes))) + + err = fieldHeadersFromRequestReader(reqReader, fields) + if err != nil { + return nil, err + } + + // Read the rest of the body content + fields[FieldHttpRequestBody] = bodyFromRestOfRequestReader(reqReader) + return fields, nil +} + +func fieldHeadersFromRequestReader(reader *textproto.Reader, fields map[string]interface{}) error { + // Ignore the first line: it contains non-header content + // that we have already captured. + // Skipping this step, would cause the following call to `ReadMIMEHeader()` + // to fail as it cannot parse the first line. + _, err := reader.ReadLine() + if err != nil { + return err + } + + // Read the MIME-style headers + mimeHeader, err := reader.ReadMIMEHeader() + if err != nil { + return err + } + + // Set the headers as fields to log + for k, v := range mimeHeader { + if len(v) == 1 { + fields[k] = v[0] + } else { + fields[k] = v + } + } + if _, ok := fields["Authorization"]; ok { + fields["Authorization"] = "(sensitive)" + } + if _, ok := fields["x-ivy-org-id"]; ok { + fields["x-ivy-org-id"] = "(sensitive)" + } + + return nil +} + +func bodyFromRestOfRequestReader(reader *textproto.Reader) string { + var builder strings.Builder + for { + line, err := reader.ReadContinuedLine() + if errors.Is(err, io.EOF) { + break + } + builder.WriteString(line) + } + + return builder.String() +} + +func decomposeResponseForLogging(res *http.Response) (map[string]interface{}, error) { + fields := make(map[string]interface{}, len(res.Header)+4) + fields[FieldHttpOperationType] = OperationHttpResponse + + fields[FieldHttpResponseProtoVersion] = res.Proto + fields[FieldHttpResponseStatusCode] = res.StatusCode + fields[FieldHttpResponseStatusReason] = res.Status + + // Set the headers as fields to log + for k, v := range res.Header { + if len(v) == 1 { + fields[k] = v[0] + } else { + fields[k] = v + } + } + + // Read the whole response body + resBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, err + } + + // Wrap the bytes from the response body, back into an io.ReadCloser, + // to respect the interface of http.Response, as expected by users of the + // http.Client + res.Body = io.NopCloser(bytes.NewBuffer(resBody)) + + fields[FieldHttpResponseBody] = string(resBody) + + return fields, nil +} diff --git a/internal/sdk/customvariables.go b/internal/sdk/customvariables.go index 706bad6..bed910e 100644 --- a/internal/sdk/customvariables.go +++ b/internal/sdk/customvariables.go @@ -6,14 +6,11 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/retry" - "io" "net/http" "net/url" ) @@ -28,19 +25,18 @@ func newCustomVariables(sdkConfig sdkConfiguration) *CustomVariables { } } -// GetCustomVariables - Get custom variables -// Get all custom variables of organization -func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operations.Option) (*operations.GetCustomVariablesResponse, error) { +// CreateCustomVariable - Create custom variable +// Create custom variable +func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *shared.CustomVariable, opts ...operations.Option) (*operations.CreateCustomVariableResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "getCustomVariables", + OperationID: "createCustomVariable", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -56,6 +52,11 @@ func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operat 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 @@ -67,154 +68,83 @@ func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operat defer cancel() } - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.GetCustomVariablesResponse{ + res := &operations.CreateCustomVariableResponse{ 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: + case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out []shared.CustomVariable + var out shared.CustomVariable if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.CustomVariables = out + res.CustomVariable = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 409: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -222,19 +152,18 @@ func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operat } -// CreateCustomVariable - Create custom variable -// Create custom variable -func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *shared.CustomVariable, opts ...operations.Option) (*operations.CreateCustomVariableResponse, error) { +// DeleteCustomVariable - Delete custom variable +// Immediately and permanently deletes a custom variable +func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request operations.DeleteCustomVariableRequest, opts ...operations.Option) (*operations.DeleteCustomVariableResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "createCustomVariable", + OperationID: "deleteCustomVariable", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -245,16 +174,11 @@ func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *sha } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/custom-variables") + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) 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 @@ -266,157 +190,61 @@ func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *sha defer cancel() } - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } - req.Header.Set("Accept", "application/json") + req.Header.Set("Accept", "*/*") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.CreateCustomVariableResponse{ + res := &operations.DeleteCustomVariableResponse{ 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 == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() - if err != nil { - return nil, err - } - - var out shared.CustomVariable - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.CustomVariable = &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) - } - case httpRes.StatusCode == 403: + case httpRes.StatusCode == 204: fallthrough - case httpRes.StatusCode == 409: + case httpRes.StatusCode == 403: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -424,19 +252,18 @@ func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *sha } -// SearchCustomVariables - searchCustomVariables -// Search custom variables -func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *shared.CustomVariablesSearchParams, opts ...operations.Option) (*operations.SearchCustomVariablesResponse, error) { +// GetBluePrintTableConfig - Get default table config +// Get default table config +func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...operations.Option) (*operations.GetBluePrintTableConfigResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "searchCustomVariables", + OperationID: "getBluePrintTableConfig", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -447,16 +274,11 @@ func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *sh } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/custom-variables:search") + opURL, err := url.JoinPath(baseURL, "/v1/custom-variables/order-table-blueprint") 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 @@ -468,155 +290,80 @@ func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *sh defer cancel() } - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.SearchCustomVariablesResponse{ + res := &operations.GetBluePrintTableConfigResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out operations.SearchCustomVariablesResponseBody + var out shared.CustomVariable if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.Object = &out + res.CustomVariable = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 403: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -624,19 +371,18 @@ func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *sh } -// UpdateCustomVariable - Update custom variable -// Update custom variable -func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request operations.UpdateCustomVariableRequest, opts ...operations.Option) (*operations.UpdateCustomVariableResponse, error) { +// GetCustomVariable - Get custom variable +// Get custom variable +func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operations.GetCustomVariableRequest, opts ...operations.Option) (*operations.GetCustomVariableResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "updateCustomVariable", + OperationID: "getCustomVariable", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -652,11 +398,6 @@ func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request oper return nil, fmt.Errorf("error generating URL: %w", err) } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "CustomVariable", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -668,130 +409,57 @@ func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request oper defer cancel() } - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.UpdateCustomVariableResponse{ + res := &operations.GetCustomVariableResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -803,22 +471,20 @@ func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request oper res.CustomVariable = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 403: fallthrough - case httpRes.StatusCode == 409: + case httpRes.StatusCode == 404: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -826,19 +492,18 @@ func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request oper } -// GetCustomVariable - Get custom variable -// Get custom variable -func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operations.GetCustomVariableRequest, opts ...operations.Option) (*operations.GetCustomVariableResponse, error) { +// GetCustomVariables - Get custom variables +// Get all custom variables of organization +func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operations.Option) (*operations.GetCustomVariablesResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "getCustomVariable", + OperationID: "getCustomVariables", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -849,7 +514,7 @@ func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operati } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) + opURL, err := url.JoinPath(baseURL, "/v1/custom-variables") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -876,145 +541,69 @@ func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operati 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, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.GetCustomVariableResponse{ + res := &operations.GetCustomVariablesResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out shared.CustomVariable + var out []shared.CustomVariable if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.CustomVariable = &out + res.Classes = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1022,19 +611,18 @@ func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operati } -// DeleteCustomVariable - Delete custom variable -// Immediately and permanently deletes a custom variable -func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request operations.DeleteCustomVariableRequest, opts ...operations.Option) (*operations.DeleteCustomVariableResponse, error) { +// SearchCustomVariables - searchCustomVariables +// Search custom variables +func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *shared.CustomVariablesSearchParams, opts ...operations.Option) (*operations.SearchCustomVariablesResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "deleteCustomVariable", + OperationID: "searchCustomVariables", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1045,11 +633,16 @@ func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request oper } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) + opURL, err := url.JoinPath(baseURL, "/v1/custom-variables:search") 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 @@ -1061,134 +654,81 @@ func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request oper defer cancel() } - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } - req.Header.Set("Accept", "*/*") + req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) + 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 { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + } else if _httpRes != nil { + httpRes = _httpRes } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } + } + + res := &operations.SearchCustomVariablesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") + return nil, err } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { + var out operations.SearchCustomVariablesResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err - } else if _httpRes != nil { - httpRes = _httpRes } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + + res.Object = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } - } - - res := &operations.DeleteCustomVariableResponse{ - 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 == 204: - fallthrough case httpRes.StatusCode == 403: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1196,19 +736,18 @@ func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request oper } -// GetBluePrintTableConfig - Get default table config -// Get default table config -func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...operations.Option) (*operations.GetBluePrintTableConfigResponse, error) { +// UpdateCustomVariable - Update custom variable +// Update custom variable +func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request operations.UpdateCustomVariableRequest, opts ...operations.Option) (*operations.UpdateCustomVariableResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "getBluePrintTableConfig", + OperationID: "updateCustomVariable", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1219,11 +758,16 @@ func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...o } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/custom-variables/order-table-blueprint") + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "CustomVariable", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1235,129 +779,58 @@ func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...o defer cancel() } - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.GetBluePrintTableConfigResponse{ + res := &operations.UpdateCustomVariableResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1369,20 +842,20 @@ func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...o res.CustomVariable = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 403: + fallthrough + case httpRes.StatusCode == 409: default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index adb2f70..f1ff9e0 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -3,10 +3,12 @@ package utils import ( + "bytes" "context" "fmt" "io" "math/big" + "net/http" "reflect" "regexp" "strconv" @@ -228,3 +230,15 @@ func contains(arr []string, str string) bool { } return false } + +func ConsumeRawBody(res *http.Response) ([]byte, error) { + rawBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + + res.Body.Close() + res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + return rawBody, nil +} diff --git a/internal/sdk/models/operations/createcustomvariable.go b/internal/sdk/models/operations/createcustomvariable.go index 747fd05..fe4d1ab 100644 --- a/internal/sdk/models/operations/createcustomvariable.go +++ b/internal/sdk/models/operations/createcustomvariable.go @@ -10,12 +10,12 @@ import ( type CreateCustomVariableResponse struct { // HTTP response content type for this operation ContentType string + // Success + CustomVariable *shared.CustomVariable // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response - // Success - CustomVariable *shared.CustomVariable } func (o *CreateCustomVariableResponse) GetContentType() string { @@ -25,6 +25,13 @@ func (o *CreateCustomVariableResponse) GetContentType() string { return o.ContentType } +func (o *CreateCustomVariableResponse) GetCustomVariable() *shared.CustomVariable { + if o == nil { + return nil + } + return o.CustomVariable +} + func (o *CreateCustomVariableResponse) GetStatusCode() int { if o == nil { return 0 @@ -38,10 +45,3 @@ func (o *CreateCustomVariableResponse) GetRawResponse() *http.Response { } return o.RawResponse } - -func (o *CreateCustomVariableResponse) GetCustomVariable() *shared.CustomVariable { - if o == nil { - return nil - } - return o.CustomVariable -} diff --git a/internal/sdk/models/operations/getblueprinttableconfig.go b/internal/sdk/models/operations/getblueprinttableconfig.go index 7079786..628a1aa 100644 --- a/internal/sdk/models/operations/getblueprinttableconfig.go +++ b/internal/sdk/models/operations/getblueprinttableconfig.go @@ -10,12 +10,12 @@ import ( type GetBluePrintTableConfigResponse struct { // HTTP response content type for this operation ContentType string + // Success + CustomVariable *shared.CustomVariable // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response - // Success - CustomVariable *shared.CustomVariable } func (o *GetBluePrintTableConfigResponse) GetContentType() string { @@ -25,6 +25,13 @@ func (o *GetBluePrintTableConfigResponse) GetContentType() string { return o.ContentType } +func (o *GetBluePrintTableConfigResponse) GetCustomVariable() *shared.CustomVariable { + if o == nil { + return nil + } + return o.CustomVariable +} + func (o *GetBluePrintTableConfigResponse) GetStatusCode() int { if o == nil { return 0 @@ -38,10 +45,3 @@ func (o *GetBluePrintTableConfigResponse) GetRawResponse() *http.Response { } return o.RawResponse } - -func (o *GetBluePrintTableConfigResponse) GetCustomVariable() *shared.CustomVariable { - if o == nil { - return nil - } - return o.CustomVariable -} diff --git a/internal/sdk/models/operations/getcategories.go b/internal/sdk/models/operations/getcategories.go index b53c63c..0a7f2c4 100644 --- a/internal/sdk/models/operations/getcategories.go +++ b/internal/sdk/models/operations/getcategories.go @@ -38,7 +38,7 @@ type GetCategoriesResponse struct { // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response // ok - CategoryResults []shared.CategoryResult + Classes []shared.CategoryResult } func (o *GetCategoriesResponse) GetContentType() string { @@ -62,9 +62,9 @@ func (o *GetCategoriesResponse) GetRawResponse() *http.Response { return o.RawResponse } -func (o *GetCategoriesResponse) GetCategoryResults() []shared.CategoryResult { +func (o *GetCategoriesResponse) GetClasses() []shared.CategoryResult { if o == nil { return nil } - return o.CategoryResults + return o.Classes } diff --git a/internal/sdk/models/operations/getcustomvariable.go b/internal/sdk/models/operations/getcustomvariable.go index aa2fec0..ed7a55b 100644 --- a/internal/sdk/models/operations/getcustomvariable.go +++ b/internal/sdk/models/operations/getcustomvariable.go @@ -22,12 +22,12 @@ func (o *GetCustomVariableRequest) GetID() string { type GetCustomVariableResponse struct { // HTTP response content type for this operation ContentType string + // Success + CustomVariable *shared.CustomVariable // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response - // Success - CustomVariable *shared.CustomVariable } func (o *GetCustomVariableResponse) GetContentType() string { @@ -37,6 +37,13 @@ func (o *GetCustomVariableResponse) GetContentType() string { return o.ContentType } +func (o *GetCustomVariableResponse) GetCustomVariable() *shared.CustomVariable { + if o == nil { + return nil + } + return o.CustomVariable +} + func (o *GetCustomVariableResponse) GetStatusCode() int { if o == nil { return 0 @@ -50,10 +57,3 @@ func (o *GetCustomVariableResponse) GetRawResponse() *http.Response { } return o.RawResponse } - -func (o *GetCustomVariableResponse) GetCustomVariable() *shared.CustomVariable { - if o == nil { - return nil - } - return o.CustomVariable -} diff --git a/internal/sdk/models/operations/getcustomvariables.go b/internal/sdk/models/operations/getcustomvariables.go index dd2379b..65f80e3 100644 --- a/internal/sdk/models/operations/getcustomvariables.go +++ b/internal/sdk/models/operations/getcustomvariables.go @@ -15,7 +15,7 @@ type GetCustomVariablesResponse struct { // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response // Success - CustomVariables []shared.CustomVariable + Classes []shared.CustomVariable } func (o *GetCustomVariablesResponse) GetContentType() string { @@ -39,9 +39,9 @@ func (o *GetCustomVariablesResponse) GetRawResponse() *http.Response { return o.RawResponse } -func (o *GetCustomVariablesResponse) GetCustomVariables() []shared.CustomVariable { +func (o *GetCustomVariablesResponse) GetClasses() []shared.CustomVariable { if o == nil { return nil } - return o.CustomVariables + return o.Classes } diff --git a/internal/sdk/models/operations/searchcustomvariables.go b/internal/sdk/models/operations/searchcustomvariables.go index ed5c5de..2bf8d6b 100644 --- a/internal/sdk/models/operations/searchcustomvariables.go +++ b/internal/sdk/models/operations/searchcustomvariables.go @@ -9,23 +9,23 @@ import ( // SearchCustomVariablesResponseBody - Success type SearchCustomVariablesResponseBody struct { - Results []shared.CustomVariable `json:"results,omitempty"` // Total number of results - Hits *int64 `json:"hits,omitempty"` + Hits *int64 `json:"hits,omitempty"` + Results []shared.CustomVariable `json:"results,omitempty"` } -func (o *SearchCustomVariablesResponseBody) GetResults() []shared.CustomVariable { +func (o *SearchCustomVariablesResponseBody) GetHits() *int64 { if o == nil { return nil } - return o.Results + return o.Hits } -func (o *SearchCustomVariablesResponseBody) GetHits() *int64 { +func (o *SearchCustomVariablesResponseBody) GetResults() []shared.CustomVariable { if o == nil { return nil } - return o.Hits + return o.Results } type SearchCustomVariablesResponse struct { diff --git a/internal/sdk/models/operations/searchvariables.go b/internal/sdk/models/operations/searchvariables.go index 9e1e9ad..5943962 100644 --- a/internal/sdk/models/operations/searchvariables.go +++ b/internal/sdk/models/operations/searchvariables.go @@ -9,14 +9,14 @@ import ( ) type SearchVariablesRequestBody struct { - TemplateType shared.TemplateType `json:"template_type"` - // Search string - Query string `json:"query"` - From *int64 `default:"0" json:"from"` - Size *int64 `default:"25" json:"size"` - // 2-letter language code (ISO 639-1) - Lang *string `default:"de" json:"lang"` EntitySchemas []string `json:"entity_schemas,omitempty"` + From *int64 `default:"0" json:"from"` + // 2-letter language code (ISO 639-1) + Lang *string `default:"de" json:"lang"` + // Search string + Query string `json:"query"` + Size *int64 `default:"25" json:"size"` + TemplateType shared.TemplateType `json:"template_type"` } func (s SearchVariablesRequestBody) MarshalJSON() ([]byte, error) { @@ -30,46 +30,46 @@ func (s *SearchVariablesRequestBody) UnmarshalJSON(data []byte) error { return nil } -func (o *SearchVariablesRequestBody) GetTemplateType() shared.TemplateType { +func (o *SearchVariablesRequestBody) GetEntitySchemas() []string { if o == nil { - return shared.TemplateType("") + return nil } - return o.TemplateType + return o.EntitySchemas } -func (o *SearchVariablesRequestBody) GetQuery() string { +func (o *SearchVariablesRequestBody) GetFrom() *int64 { if o == nil { - return "" + return nil } - return o.Query + return o.From } -func (o *SearchVariablesRequestBody) GetFrom() *int64 { +func (o *SearchVariablesRequestBody) GetLang() *string { if o == nil { return nil } - return o.From + return o.Lang } -func (o *SearchVariablesRequestBody) GetSize() *int64 { +func (o *SearchVariablesRequestBody) GetQuery() string { if o == nil { - return nil + return "" } - return o.Size + return o.Query } -func (o *SearchVariablesRequestBody) GetLang() *string { +func (o *SearchVariablesRequestBody) GetSize() *int64 { if o == nil { return nil } - return o.Lang + return o.Size } -func (o *SearchVariablesRequestBody) GetEntitySchemas() []string { +func (o *SearchVariablesRequestBody) GetTemplateType() shared.TemplateType { if o == nil { - return nil + return shared.TemplateType("") } - return o.EntitySchemas + return o.TemplateType } type SearchVariablesResponse struct { @@ -80,7 +80,7 @@ type SearchVariablesResponse struct { // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response // ok - VariableResults []shared.VariableResult + Classes []shared.VariableResult } func (o *SearchVariablesResponse) GetContentType() string { @@ -104,9 +104,9 @@ func (o *SearchVariablesResponse) GetRawResponse() *http.Response { return o.RawResponse } -func (o *SearchVariablesResponse) GetVariableResults() []shared.VariableResult { +func (o *SearchVariablesResponse) GetClasses() []shared.VariableResult { if o == nil { return nil } - return o.VariableResults + return o.Classes } diff --git a/internal/sdk/models/operations/updatecustomvariable.go b/internal/sdk/models/operations/updatecustomvariable.go index d2ec6d3..a3da371 100644 --- a/internal/sdk/models/operations/updatecustomvariable.go +++ b/internal/sdk/models/operations/updatecustomvariable.go @@ -8,34 +8,34 @@ import ( ) type UpdateCustomVariableRequest struct { - // Custom variable ID - ID string `pathParam:"style=simple,explode=false,name=id"` CustomVariable *shared.CustomVariable `request:"mediaType=application/json"` + // Custom variable ID + ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *UpdateCustomVariableRequest) GetID() string { +func (o *UpdateCustomVariableRequest) GetCustomVariable() *shared.CustomVariable { if o == nil { - return "" + return nil } - return o.ID + return o.CustomVariable } -func (o *UpdateCustomVariableRequest) GetCustomVariable() *shared.CustomVariable { +func (o *UpdateCustomVariableRequest) GetID() string { if o == nil { - return nil + return "" } - return o.CustomVariable + return o.ID } type UpdateCustomVariableResponse struct { // HTTP response content type for this operation ContentType string + // Success + CustomVariable *shared.CustomVariable // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response - // Success - CustomVariable *shared.CustomVariable } func (o *UpdateCustomVariableResponse) GetContentType() string { @@ -45,6 +45,13 @@ func (o *UpdateCustomVariableResponse) GetContentType() string { return o.ContentType } +func (o *UpdateCustomVariableResponse) GetCustomVariable() *shared.CustomVariable { + if o == nil { + return nil + } + return o.CustomVariable +} + func (o *UpdateCustomVariableResponse) GetStatusCode() int { if o == nil { return 0 @@ -58,10 +65,3 @@ func (o *UpdateCustomVariableResponse) GetRawResponse() *http.Response { } return o.RawResponse } - -func (o *UpdateCustomVariableResponse) GetCustomVariable() *shared.CustomVariable { - if o == nil { - return nil - } - return o.CustomVariable -} diff --git a/internal/sdk/models/shared/customvariable.go b/internal/sdk/models/shared/customvariable.go index aaf841b..ca495c4 100644 --- a/internal/sdk/models/shared/customvariable.go +++ b/internal/sdk/models/shared/customvariable.go @@ -7,19 +7,23 @@ import ( "fmt" ) -// CustomVariableType - Custom variable type -type CustomVariableType string +// Config - Variable configuration +type Config struct { +} + +// Type - Custom variable type +type Type string const ( - CustomVariableTypeOrderTable CustomVariableType = "order_table" - CustomVariableTypeCustom CustomVariableType = "custom" - CustomVariableTypeJourneyLink CustomVariableType = "journey_link" + TypeOrderTable Type = "order_table" + TypeCustom Type = "custom" + TypeJourneyLink Type = "journey_link" ) -func (e CustomVariableType) ToPointer() *CustomVariableType { +func (e Type) ToPointer() *Type { return &e } -func (e *CustomVariableType) UnmarshalJSON(data []byte) error { +func (e *Type) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -30,74 +34,75 @@ func (e *CustomVariableType) UnmarshalJSON(data []byte) error { case "custom": fallthrough case "journey_link": - *e = CustomVariableType(v) + *e = Type(v) return nil default: - return fmt.Errorf("invalid value for CustomVariableType: %v", v) + return fmt.Errorf("invalid value for Type: %v", v) } } type CustomVariable struct { - // ID - ID *string `json:"id,omitempty"` - // Custom variable type - Type *CustomVariableType `json:"type,omitempty"` - // Custom variable name - Name *string `json:"name,omitempty"` - // The key which is used for Handlebar variable syntax {{"{{"}}key}} - Key *string `json:"key,omitempty"` // The tags of custom variable Tags []string `json:"_tags,omitempty"` - // The helper function parameter's names - HelperParams []string `json:"helper_params,omitempty"` - // The helper function logic - HelperLogic *string `json:"helper_logic,omitempty"` - // Handlebar template that used to generate the variable content - Template *string `json:"template,omitempty"` + // Variable configuration + Config *Config `json:"config,omitempty"` // Creation time CreatedAt *string `json:"created_at,omitempty"` // Created by CreatedBy *string `json:"created_by,omitempty"` + // The helper function logic + HelperLogic *string `json:"helper_logic,omitempty"` + // The helper function parameter's names + HelperParams []string `json:"helper_params,omitempty"` + // ID + ID *string `json:"id,omitempty"` + // The key which is used for Handlebar variable syntax {{"{{"}}key}} + Key *string `json:"key,omitempty"` + // Custom variable name + Name *string `json:"name,omitempty"` + // Handlebar template that used to generate the variable content + Template *string `json:"template,omitempty"` + // Custom variable type + Type *Type `json:"type,omitempty"` // Last update time UpdatedAt *string `json:"updated_at,omitempty"` // Updated by UpdatedBy *string `json:"updated_by,omitempty"` - Config any `json:"config,omitempty"` } -func (o *CustomVariable) GetID() *string { +func (o *CustomVariable) GetTags() []string { if o == nil { return nil } - return o.ID + return o.Tags } -func (o *CustomVariable) GetType() *CustomVariableType { +func (o *CustomVariable) GetConfig() *Config { if o == nil { return nil } - return o.Type + return o.Config } -func (o *CustomVariable) GetName() *string { +func (o *CustomVariable) GetCreatedAt() *string { if o == nil { return nil } - return o.Name + return o.CreatedAt } -func (o *CustomVariable) GetKey() *string { +func (o *CustomVariable) GetCreatedBy() *string { if o == nil { return nil } - return o.Key + return o.CreatedBy } -func (o *CustomVariable) GetTags() []string { +func (o *CustomVariable) GetHelperLogic() *string { if o == nil { return nil } - return o.Tags + return o.HelperLogic } func (o *CustomVariable) GetHelperParams() []string { @@ -107,51 +112,51 @@ func (o *CustomVariable) GetHelperParams() []string { return o.HelperParams } -func (o *CustomVariable) GetHelperLogic() *string { +func (o *CustomVariable) GetID() *string { if o == nil { return nil } - return o.HelperLogic + return o.ID } -func (o *CustomVariable) GetTemplate() *string { +func (o *CustomVariable) GetKey() *string { if o == nil { return nil } - return o.Template + return o.Key } -func (o *CustomVariable) GetCreatedAt() *string { +func (o *CustomVariable) GetName() *string { if o == nil { return nil } - return o.CreatedAt + return o.Name } -func (o *CustomVariable) GetCreatedBy() *string { +func (o *CustomVariable) GetTemplate() *string { if o == nil { return nil } - return o.CreatedBy + return o.Template } -func (o *CustomVariable) GetUpdatedAt() *string { +func (o *CustomVariable) GetType() *Type { if o == nil { return nil } - return o.UpdatedAt + return o.Type } -func (o *CustomVariable) GetUpdatedBy() *string { +func (o *CustomVariable) GetUpdatedAt() *string { if o == nil { return nil } - return o.UpdatedBy + return o.UpdatedAt } -func (o *CustomVariable) GetConfig() any { +func (o *CustomVariable) GetUpdatedBy() *string { if o == nil { return nil } - return o.Config + return o.UpdatedBy } diff --git a/internal/sdk/models/shared/customvariablessearchparams.go b/internal/sdk/models/shared/customvariablessearchparams.go index ce039f8..5dd6040 100644 --- a/internal/sdk/models/shared/customvariablessearchparams.go +++ b/internal/sdk/models/shared/customvariablessearchparams.go @@ -39,18 +39,18 @@ func (e *CustomVariablesSearchParamsType) UnmarshalJSON(data []byte) error { } type CustomVariablesSearchParams struct { - // Variable type - Type *CustomVariablesSearchParamsType `json:"type,omitempty"` - // The tags of custom variable - Tags []string `json:"tags,omitempty"` + // Fields to return + Fields []string `json:"fields,omitempty"` + From *int64 `default:"0" json:"from"` // Search string Query *string `json:"query,omitempty"` - From *int64 `default:"0" json:"from"` Size *int64 `default:"25" json:"size"` // Sort by field SortBy *string `json:"sort_by,omitempty"` - // Fields to return - Fields []string `json:"fields,omitempty"` + // The tags of custom variable + Tags []string `json:"tags,omitempty"` + // Variable type + Type *CustomVariablesSearchParamsType `json:"type,omitempty"` } func (c CustomVariablesSearchParams) MarshalJSON() ([]byte, error) { @@ -64,18 +64,18 @@ func (c *CustomVariablesSearchParams) UnmarshalJSON(data []byte) error { return nil } -func (o *CustomVariablesSearchParams) GetType() *CustomVariablesSearchParamsType { +func (o *CustomVariablesSearchParams) GetFields() []string { if o == nil { return nil } - return o.Type + return o.Fields } -func (o *CustomVariablesSearchParams) GetTags() []string { +func (o *CustomVariablesSearchParams) GetFrom() *int64 { if o == nil { return nil } - return o.Tags + return o.From } func (o *CustomVariablesSearchParams) GetQuery() *string { @@ -85,30 +85,30 @@ func (o *CustomVariablesSearchParams) GetQuery() *string { return o.Query } -func (o *CustomVariablesSearchParams) GetFrom() *int64 { +func (o *CustomVariablesSearchParams) GetSize() *int64 { if o == nil { return nil } - return o.From + return o.Size } -func (o *CustomVariablesSearchParams) GetSize() *int64 { +func (o *CustomVariablesSearchParams) GetSortBy() *string { if o == nil { return nil } - return o.Size + return o.SortBy } -func (o *CustomVariablesSearchParams) GetSortBy() *string { +func (o *CustomVariablesSearchParams) GetTags() []string { if o == nil { return nil } - return o.SortBy + return o.Tags } -func (o *CustomVariablesSearchParams) GetFields() []string { +func (o *CustomVariablesSearchParams) GetType() *CustomVariablesSearchParamsType { if o == nil { return nil } - return o.Fields + return o.Type } diff --git a/internal/sdk/models/shared/externalcustomvariable.go b/internal/sdk/models/shared/externalcustomvariable.go index 6dd5858..10cd2a0 100644 --- a/internal/sdk/models/shared/externalcustomvariable.go +++ b/internal/sdk/models/shared/externalcustomvariable.go @@ -3,20 +3,20 @@ package shared type ExternalCustomVariable struct { - Variable *string `json:"variable,omitempty"` Value *string `json:"value,omitempty"` + Variable *string `json:"variable,omitempty"` } -func (o *ExternalCustomVariable) GetVariable() *string { +func (o *ExternalCustomVariable) GetValue() *string { if o == nil { return nil } - return o.Variable + return o.Value } -func (o *ExternalCustomVariable) GetValue() *string { +func (o *ExternalCustomVariable) GetVariable() *string { if o == nil { return nil } - return o.Value + return o.Variable } diff --git a/internal/sdk/models/shared/variablecontext.go b/internal/sdk/models/shared/variablecontext.go index 87f1938..b31ded5 100644 --- a/internal/sdk/models/shared/variablecontext.go +++ b/internal/sdk/models/shared/variablecontext.go @@ -3,36 +3,36 @@ package shared type VariableContext struct { - UnsubscribeURL *string `json:"unsubscribe_url,omitempty"` - Main map[string]any `json:"main,omitempty"` - Contact map[string]any `json:"contact,omitempty"` Brand map[string]any `json:"brand,omitempty"` + Contact map[string]any `json:"contact,omitempty"` + Main map[string]any `json:"main,omitempty"` + UnsubscribeURL *string `json:"unsubscribe_url,omitempty"` } -func (o *VariableContext) GetUnsubscribeURL() *string { +func (o *VariableContext) GetBrand() map[string]any { if o == nil { return nil } - return o.UnsubscribeURL + return o.Brand } -func (o *VariableContext) GetMain() map[string]any { +func (o *VariableContext) GetContact() map[string]any { if o == nil { return nil } - return o.Main + return o.Contact } -func (o *VariableContext) GetContact() map[string]any { +func (o *VariableContext) GetMain() map[string]any { if o == nil { return nil } - return o.Contact + return o.Main } -func (o *VariableContext) GetBrand() map[string]any { +func (o *VariableContext) GetUnsubscribeURL() *string { if o == nil { return nil } - return o.Brand + return o.UnsubscribeURL } diff --git a/internal/sdk/models/shared/variableparameters.go b/internal/sdk/models/shared/variableparameters.go index 36b9b03..e7eb50c 100644 --- a/internal/sdk/models/shared/variableparameters.go +++ b/internal/sdk/models/shared/variableparameters.go @@ -11,25 +11,25 @@ type ContextData struct { } type VariableParameters struct { - TemplateType TemplateType `json:"template_type"` + // Brand ID + BrandID *float64 `json:"brand_id,omitempty"` + // If context data is avaialble, this data will be used for variable replace. + ContextData *ContextData `json:"context_data,omitempty"` + // Custom variables with specified values form other services. + CustomVariables []ExternalCustomVariable `json:"custom_variables,omitempty"` // 2-letter language code (ISO 639-1) Language *string `default:"de" json:"language"` // The main entity ID. Use main entity in order to use the variable without schema slug prefix - or just pass directly to other object ID. MainEntityID *string `json:"main_entity_id,omitempty"` - // Brand ID - BrandID *float64 `json:"brand_id,omitempty"` + // The name of email template + TemplateName *string `json:"template_name,omitempty"` + // The tags of email template + TemplateTags []string `json:"template_tags,omitempty"` + TemplateType TemplateType `json:"template_type"` // User ID UserID *string `json:"user_id,omitempty"` // Organization ID of the user UserOrgID *string `json:"user_org_id,omitempty"` - // Custom variables with specified values form other services. - CustomVariables []ExternalCustomVariable `json:"custom_variables,omitempty"` - // If context data is avaialble, this data will be used for variable replace. - ContextData *ContextData `json:"context_data,omitempty"` - // The name of email template - TemplateName *string `json:"template_name,omitempty"` - // The tags of email template - TemplateTags []string `json:"template_tags,omitempty"` // The version of the variables syntax supported. Default is 1.0 VariablesVersion *string `json:"variables_version,omitempty"` } @@ -45,74 +45,74 @@ func (v *VariableParameters) UnmarshalJSON(data []byte) error { return nil } -func (o *VariableParameters) GetTemplateType() TemplateType { +func (o *VariableParameters) GetBrandID() *float64 { if o == nil { - return TemplateType("") + return nil } - return o.TemplateType + return o.BrandID } -func (o *VariableParameters) GetLanguage() *string { +func (o *VariableParameters) GetContextData() *ContextData { if o == nil { return nil } - return o.Language + return o.ContextData } -func (o *VariableParameters) GetMainEntityID() *string { +func (o *VariableParameters) GetCustomVariables() []ExternalCustomVariable { if o == nil { return nil } - return o.MainEntityID + return o.CustomVariables } -func (o *VariableParameters) GetBrandID() *float64 { +func (o *VariableParameters) GetLanguage() *string { if o == nil { return nil } - return o.BrandID + return o.Language } -func (o *VariableParameters) GetUserID() *string { +func (o *VariableParameters) GetMainEntityID() *string { if o == nil { return nil } - return o.UserID + return o.MainEntityID } -func (o *VariableParameters) GetUserOrgID() *string { +func (o *VariableParameters) GetTemplateName() *string { if o == nil { return nil } - return o.UserOrgID + return o.TemplateName } -func (o *VariableParameters) GetCustomVariables() []ExternalCustomVariable { +func (o *VariableParameters) GetTemplateTags() []string { if o == nil { return nil } - return o.CustomVariables + return o.TemplateTags } -func (o *VariableParameters) GetContextData() *ContextData { +func (o *VariableParameters) GetTemplateType() TemplateType { if o == nil { - return nil + return TemplateType("") } - return o.ContextData + return o.TemplateType } -func (o *VariableParameters) GetTemplateName() *string { +func (o *VariableParameters) GetUserID() *string { if o == nil { return nil } - return o.TemplateName + return o.UserID } -func (o *VariableParameters) GetTemplateTags() []string { +func (o *VariableParameters) GetUserOrgID() *string { if o == nil { return nil } - return o.TemplateTags + return o.UserOrgID } func (o *VariableParameters) GetVariablesVersion() *string { diff --git a/internal/sdk/models/shared/variableresult.go b/internal/sdk/models/shared/variableresult.go index 882aca2..6778bf0 100644 --- a/internal/sdk/models/shared/variableresult.go +++ b/internal/sdk/models/shared/variableresult.go @@ -7,17 +7,17 @@ import ( "fmt" ) -type Type string +type VariableResultType string const ( - TypeSimple Type = "simple" - TypePartial Type = "partial" + VariableResultTypeSimple VariableResultType = "simple" + VariableResultTypePartial VariableResultType = "partial" ) -func (e Type) ToPointer() *Type { +func (e VariableResultType) ToPointer() *VariableResultType { return &e } -func (e *Type) UnmarshalJSON(data []byte) error { +func (e *VariableResultType) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -26,56 +26,56 @@ func (e *Type) UnmarshalJSON(data []byte) error { case "simple": fallthrough case "partial": - *e = Type(v) + *e = VariableResultType(v) return nil default: - return fmt.Errorf("invalid value for Type: %v", v) + return fmt.Errorf("invalid value for VariableResultType: %v", v) } } type VariableResult struct { - Type *Type `json:"type,omitempty"` - // Payload for the QR data - Qrdata *string `json:"qrdata,omitempty"` + // Variable description + Description *string `json:"description,omitempty"` // Variable group Group *string `json:"group,omitempty"` // The value which is used to insert to template Insert *string `json:"insert,omitempty"` - // Variable description - Description *string `json:"description,omitempty"` + // Payload for the QR data + Qrdata *string `json:"qrdata,omitempty"` + Type *VariableResultType `json:"type,omitempty"` } -func (o *VariableResult) GetType() *Type { +func (o *VariableResult) GetDescription() *string { if o == nil { return nil } - return o.Type + return o.Description } -func (o *VariableResult) GetQrdata() *string { +func (o *VariableResult) GetGroup() *string { if o == nil { return nil } - return o.Qrdata + return o.Group } -func (o *VariableResult) GetGroup() *string { +func (o *VariableResult) GetInsert() *string { if o == nil { return nil } - return o.Group + return o.Insert } -func (o *VariableResult) GetInsert() *string { +func (o *VariableResult) GetQrdata() *string { if o == nil { return nil } - return o.Insert + return o.Qrdata } -func (o *VariableResult) GetDescription() *string { +func (o *VariableResult) GetType() *VariableResultType { if o == nil { return nil } - return o.Description + return o.Type } diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 151251b..6b11d7c 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -69,9 +69,9 @@ func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { // SDK - Template Variables API: API to provide variables for email and document templates. type SDK struct { - // Variables - Variables *Variables CustomVariables *CustomVariables + // Variables + Variables *Variables sdkConfiguration sdkConfiguration } @@ -150,8 +150,8 @@ func New(opts ...SDKOption) *SDK { Language: "go", OpenAPIDocVersion: "1.0.0", SDKVersion: "0.0.1", - GenVersion: "2.429.0", - UserAgent: "speakeasy-sdk/go 0.0.1 2.429.0 1.0.0 github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk", + GenVersion: "2.460.1", + UserAgent: "speakeasy-sdk/go 0.0.1 2.460.1 1.0.0 github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk", Hooks: hooks.New(), }, } @@ -171,9 +171,9 @@ func New(opts ...SDKOption) *SDK { sdk.sdkConfiguration.ServerURL = serverURL } - sdk.Variables = newVariables(sdk.sdkConfiguration) - sdk.CustomVariables = newCustomVariables(sdk.sdkConfiguration) + sdk.Variables = newVariables(sdk.sdkConfiguration) + return sdk } diff --git a/internal/sdk/variables.go b/internal/sdk/variables.go index 62de212..47450da 100644 --- a/internal/sdk/variables.go +++ b/internal/sdk/variables.go @@ -6,14 +6,11 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/errors" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/retry" - "io" "net/http" "net/url" ) @@ -41,7 +38,6 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -83,94 +79,32 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat 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, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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 - } } } @@ -180,21 +114,11 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -204,21 +128,19 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat return nil, err } - res.CategoryResults = out + res.Classes = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -226,19 +148,20 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat } -// SearchVariables - searchVariables -// Search variables -func (s *Variables) SearchVariables(ctx context.Context, request *operations.SearchVariablesRequestBody, opts ...operations.Option) (*operations.SearchVariablesResponse, error) { +// GetVariableContext - getVariableContext +// Get full variable context +// +// Calls Entity API, User API, Brand API and others to construct full context object used for template variable replace +func (s *Variables) GetVariableContext(ctx context.Context, request *operations.GetVariableContextRequestBody, opts ...operations.Option) (*operations.GetVariableContextResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "searchVariables", + OperationID: "getVariableContext", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -249,7 +172,7 @@ func (s *Variables) SearchVariables(ctx context.Context, request *operations.Sea } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/template-variables:search") + opURL, err := url.JoinPath(baseURL, "/v1/template-variables:context") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -282,142 +205,68 @@ func (s *Variables) SearchVariables(ctx context.Context, request *operations.Sea 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, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.SearchVariablesResponse{ + res := &operations.GetVariableContextResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out []shared.VariableResult + var out shared.VariableContext if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.VariableResults = out + res.VariableContext = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -425,21 +274,20 @@ func (s *Variables) SearchVariables(ctx context.Context, request *operations.Sea } -// GetVariableContext - getVariableContext -// Get full variable context +// ReplaceTemplates - replaceTemplates +// Replace variables in handlebars templates // -// Calls Entity API, User API, Brand API and others to construct full context object used for template variable replace -func (s *Variables) GetVariableContext(ctx context.Context, request *operations.GetVariableContextRequestBody, opts ...operations.Option) (*operations.GetVariableContextResponse, error) { +// Takes in an array of input templates and outputs the output text with replaced variables +func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.ReplaceTemplatesRequestBody, opts ...operations.Option) (*operations.ReplaceTemplatesResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "getVariableContext", + OperationID: "replaceTemplates", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -450,7 +298,7 @@ func (s *Variables) GetVariableContext(ctx context.Context, request *operations. } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/template-variables:context") + opURL, err := url.JoinPath(baseURL, "/v1/template-variables:replace") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -483,142 +331,68 @@ func (s *Variables) GetVariableContext(ctx context.Context, request *operations. 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, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.GetVariableContextResponse{ + res := &operations.ReplaceTemplatesResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out shared.VariableContext + var out operations.ReplaceTemplatesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.VariableContext = &out + res.Object = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -626,21 +400,18 @@ func (s *Variables) GetVariableContext(ctx context.Context, request *operations. } -// ReplaceTemplates - replaceTemplates -// Replace variables in handlebars templates -// -// Takes in an array of input templates and outputs the output text with replaced variables -func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.ReplaceTemplatesRequestBody, opts ...operations.Option) (*operations.ReplaceTemplatesResponse, error) { +// SearchVariables - searchVariables +// Search variables +func (s *Variables) SearchVariables(ctx context.Context, request *operations.SearchVariablesRequestBody, opts ...operations.Option) (*operations.SearchVariablesResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, - OperationID: "replaceTemplates", + OperationID: "searchVariables", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -651,7 +422,7 @@ func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.Re } baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/template-variables:replace") + opURL, err := url.JoinPath(baseURL, "/v1/template-variables:search") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -684,142 +455,68 @@ func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.Re 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, - } - } + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err } - 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 - }) - + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - return nil, err + err = fmt.Errorf("error sending request: %w", err) } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } + err = fmt.Errorf("error sending request: no response") } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + + _, 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 } - - 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) + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { 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.ReplaceTemplatesResponse{ + res := &operations.SearchVariablesResponse{ 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() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out operations.ReplaceTemplatesResponseBody + var out []shared.VariableResult if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.Object = &out + res.Classes = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) }