diff --git a/.gitignore b/.gitignore index 7a8a44a..1a5a0a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ +**/.speakeasy/temp/ +**/.speakeasy/logs/ .terraform .terraform* *.tfstate* .DS_Store - original.yaml original_modified.yaml diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index bd71cff..6c90c8a 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,34 +1,33 @@ lockVersion: 2.0.0 id: 45f3018a-30de-4d91-ab55-1ad3f43bb6de management: - docChecksum: 3cac38273733de79e2a8196e211ae08a + docChecksum: be172ee9183e5ba6369a11f5967756d6 docVersion: 1.0.0 - speakeasyVersion: 1.453.0 - generationVersion: 2.472.1 - releaseVersion: 1.2.0 - configChecksum: 5f95423ff24fb9f1ed01acda96dda1c1 + speakeasyVersion: 1.587.1 + generationVersion: 2.662.0 + releaseVersion: 1.3.0 + configChecksum: 9cf38ffbb2bd89a809b57696b996b6e7 + repoURL: https://github.com/epilot-dev/terraform-provider-epilot-custom-variable.git features: terraform: additionalDependencies: 0.1.0 - constsAndDefaults: 0.2.0 - core: 3.27.0 - envVarSecurityUsage: 0.1.0 - globalSecurity: 2.81.9 - globalServerURLs: 2.82.1 + constsAndDefaults: 0.2.1 + core: 3.42.0 + globalSecurity: 2.81.12 + globalServerURLs: 2.82.2 + inputOutputModels: 2.83.0 nullables: 0.0.0 - retries: 2.81.2 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 + - internal/planmodifiers/float32planmodifier/suppress_diff.go - internal/planmodifiers/float64planmodifier/suppress_diff.go + - internal/planmodifiers/int32planmodifier/suppress_diff.go - internal/planmodifiers/int64planmodifier/suppress_diff.go - internal/planmodifiers/listplanmodifier/suppress_diff.go - internal/planmodifiers/mapplanmodifier/suppress_diff.go @@ -37,10 +36,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 @@ -56,11 +51,13 @@ generatedFiles: - internal/provider/reflect/primitive.go - internal/provider/reflect/slice.go - internal/provider/reflect/struct.go + - internal/provider/typeconvert/date.go + - internal/provider/typeconvert/datetime.go + - internal/provider/typeconvert/int.go - internal/provider/utils.go - internal/sdk/.gitattributes - - internal/sdk/.gitignore - - internal/sdk/CONTRIBUTING.md - internal/sdk/customvariables.go + - internal/sdk/internal/config/sdkconfiguration.go - internal/sdk/internal/hooks/hooks.go - internal/sdk/internal/utils/contenttype.go - internal/sdk/internal/utils/env.go @@ -108,7 +105,9 @@ generatedFiles: - internal/validators/JSONParseValidator.go - internal/validators/RFC3339Validator.go - internal/validators/boolvalidators/not_null.go + - internal/validators/float32validators/not_null.go - internal/validators/float64validators/not_null.go + - internal/validators/int32validators/not_null.go - internal/validators/int64validators/not_null.go - internal/validators/listvalidators/not_null.go - internal/validators/mapvalidators/not_null.go @@ -123,12 +122,12 @@ examples: createCustomVariable: speakeasy-default-create-custom-variable: requestBody: - 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"} + application/json: {"config": {}, "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"} responses: "201": - 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"} + application/json: {"config": {}, "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"} deleteCustomVariable: - "": + speakeasy-default-delete-custom-variable: parameters: path: id: "rbse777b-3cf8-4bff-bb0c-253fd1123250" @@ -136,61 +135,65 @@ examples: speakeasy-default-get-blue-print-table-config: responses: "200": - 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"} - getCategories: - "": - responses: - "200": - application/json: [{"category": "contact", "description": "Contact"}, {"category": "account", "description": "Account"}, {"category": "organization", "description": "Organization"}] + application/json: {"config": {}, "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: - "": + speakeasy-default-get-custom-variable: parameters: path: id: "rbse777b-3cf8-4bff-bb0c-253fd1123250" responses: "200": - 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"} + application/json: {"config": {}, "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"} getCustomVariables: speakeasy-default-get-custom-variables: responses: "200": - 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"}] - getVariableContext: - speakeasy-default-get-variable-context: + application/json: [{"config": {}, "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: {"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"}} + application/json: {"from": 0, "query": "logo", "size": 25, "sort_by": "created_at, name, key"} responses: "200": - 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: + application/json: {"hits": 100, "results": [{"config": {}, "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"}]} + updateCustomVariable: + speakeasy-default-update-custom-variable: + parameters: + path: + id: "rbse777b-3cf8-4bff-bb0c-253fd1123250" requestBody: - 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"}} + application/json: {"config": {}, "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"} responses: "200": - application/json: {"outputs": ["\"[Brand Name GmbH] Order confirmation\",\n\"Hello Customer Name\n\nBrand Name GmbH\n\"Brand\nimprint\n\"]\n"]} - searchCustomVariables: - speakeasy-default-search-custom-variables: + application/json: {"config": {}, "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"} + getCategories: + speakeasy-default-get-categories: + parameters: + query: + lang: "de" + responses: + "200": + application/json: [{"category": "contact", "description": "Contact"}] + getVariableContext: + speakeasy-default-get-variable-context: requestBody: - application/json: {"query": "logo", "sort_by": "[\"created_at\",\"created_at:desc\",\"name\",\"name:desc\",\"key\"]"} + 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}}"}], "language": "de", "main_entity_id": "63753437-c9e2-4e83-82bb-b1c666514561", "template_type": "document", "user_id": "50001", "user_org_id": "729224", "variables_version": "2"}} responses: "200": - 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"}]} - searchVariables: - "": + application/json: {"brand": {"id": 123453, "name": "Brand name", "signature": "Signature"}, "contact": {"_id": "03be777b-3cf8-4bff-bb0c-253fd1128479", "_title": "Example Customer", "customer_number": 123, "first_name": "Example", "last_name": "Customer", "title": "Prof.", "salutation": "Ms. / Mrs.", "birthdate": "2018-03-03", "email": [{"email": "contact.primary@domain.com", "_tags": ["primary"]}, {"email": "sale@domain.com"}], "phone": [{"phone": "+49123456789", "_tags": ["primary", "support"]}, {"phone": "+49504305025"}], "address": [{"_tags": ["primary", "delivery"], "country": "Germany", "city": "Köln", "postal_code": "50825", "street": "Im Mediapark", "street_number": "8a", "additional_info": "11th floor"}, {"_tags": ["billing"], "country": "Finland", "city": "Köln", "postal_code": "50670", "street": "Im Mediapark", "street_number": "8a", "additional_info": ""}], "account": [{"status": "Active", "_id": "c8d20ff6-df7a-465a-a26e-e5d28c2a3f79", "tax_id": "123abc", "name": "name", "email": [{"email": "account.primary@domain.com", "_tags": ["primary"]}, {"email": "account.sale@domain.com"}], "phone": [{"phone": "+49123456789", "_tags": ["primary", "support"]}, {"phone": "+49504305025"}], "address": [{"_tags": ["primary", "delivery"], "country": "Germany", "city": "KölnSS", "postal_code": "50825", "street": "Im Mediapark", "street_number": "8a", "additional_info": "11th floor"}]}]}, "main": {"_id": "03be777b-3cf8-4bff-bb0c-253fd1128479", "_title": "Example Customer", "customer_number": 123, "first_name": "Example", "last_name": "Customer", "title": "Prof.", "salutation": "Ms. / Mrs.", "birthdate": "2018-03-03", "email": [{"email": "contact.primary@domain.com", "_tags": ["primary"]}, {"email": "sale@domain.com"}], "phone": [{"phone": "+49123456789", "_tags": ["primary", "support"]}, {"phone": "+49504305025"}], "address": [{"_tags": ["primary", "delivery"], "country": "Germany", "city": "Köln", "postal_code": "50825", "street": "Im Mediapark", "street_number": "8a", "additional_info": "11th floor"}, {"_tags": ["billing"], "country": "Finland", "city": "Köln", "postal_code": "50670", "street": "Im Mediapark", "street_number": "8a", "additional_info": ""}], "account": [{"status": "Active", "_id": "c8d20ff6-df7a-465a-a26e-e5d28c2a3f79", "tax_id": "123abc", "name": "name", "email": [{"email": "account.primary@domain.com", "_tags": ["primary"]}, {"email": "account.sale@domain.com"}], "phone": [{"phone": "+49123456789", "_tags": ["primary", "support"]}, {"phone": "+49504305025"}], "address": [{"_tags": ["primary", "delivery"], "country": "Germany", "city": "Köln", "postal_code": "50825", "street": "Im Mediapark", "street_number": "8a", "additional_info": "11th floor"}]}]}, "unsubscribe_url": "https://consent.sls.epilot.io/v1/unsubscribe?token=abc123"} + replaceTemplates: + speakeasy-default-replace-templates: requestBody: - application/json: {"entity_schemas": ["contact"], "query": "logo", "template_type": "document"} + 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}}"}], "language": "de", "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: [{"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"}] - updateCustomVariable: - "": - parameters: - path: - id: "rbse777b-3cf8-4bff-bb0c-253fd1123250" + application/json: {"outputs": ["[Brand Name GmbH] Order confirmation\nHello Customer Name\n\nBrand Name GmbH\n\"Brand\nimprint\n"]} + searchVariables: + speakeasy-default-search-variables: requestBody: - 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"} + application/json: {"entity_schemas": ["contact"], "from": 0, "lang": "de", "query": "logo", "size": 25, "template_type": "document"} responses: "200": - 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"} + application/json: [{}] +examplesVersion: 1.0.2 generatedTests: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock new file mode 100644 index 0000000..ec8975c --- /dev/null +++ b/.speakeasy/workflow.lock @@ -0,0 +1,29 @@ +speakeasyVersion: 1.587.1 +sources: + my-source: + sourceNamespace: my-source + sourceRevisionDigest: sha256:519b33eef977c85955e57cf30855c4cd3342c9999451b2d94f2deffb14caedd1 + sourceBlobDigest: sha256:f5e8d713dc18b3ce08392a3cac12709b30e5e02e1239fe363d22fe580559578f + tags: + - latest + - speakeasy-sdk-regen-1751330486 + - 1.0.0 +targets: + terraform: + source: my-source + sourceNamespace: my-source + sourceRevisionDigest: sha256:519b33eef977c85955e57cf30855c4cd3342c9999451b2d94f2deffb14caedd1 + sourceBlobDigest: sha256:f5e8d713dc18b3ce08392a3cac12709b30e5e02e1239fe363d22fe580559578f +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 7b83e59..da902eb 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ terraform { required_providers { epilot-custom-variable = { source = "epilot-dev/epilot-custom-variable" - version = "1.2.0" + version = "1.3.0" } } } @@ -63,10 +63,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..b551a02 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] . + +## 2025-07-24 00:37:53 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.587.1 (2.662.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v1.3.0] . +### Releases +- [Terraform v1.3.0] https://registry.terraform.io/providers/epilot-dev/epilot-custom-variable/1.3.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 d37ad7a..f5b26cd 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.2.0" + version = "1.3.0" } } } diff --git a/docs/resources/custom_variable.md b/docs/resources/custom_variable.md deleted file mode 100644 index b5b7f09..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) 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 -- `id` (String) ID -- `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. must be one of ["order_table", "custom", "journey_link"] -- `updated_at` (String) Last update time -- `updated_by` (String) Updated by - -## 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 b1774a6..b00335c 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.2.0" + version = "1.3.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 decfeea..ae5b5ab 100644 --- a/gen.yaml +++ b/gen.yaml @@ -4,22 +4,34 @@ generation: sdkClassName: SDK usageSnippets: optionalPropertyRendering: withExample + sdkInitStyle: constructor fixes: - nameResolutionDec2023: false + nameResolutionFeb2025: false parameterOrderingFeb2024: false requestResponseComponentNamesFeb2024: false + securityFeb2025: false + sharedErrorComponentsApr2025: false auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false + tests: + generateTests: true + generateNewTests: false + skipResponseBodyAssertions: false sdkFlattening: true telemetryEnabled: false terraform: - version: 1.2.0 + version: 1.3.0 additionalDataSources: [] additionalDependencies: {} + additionalEphemeralResources: [] + additionalProviderAttributes: + httpHeaders: "" + tlsSkipVerify: "" additionalResources: [] allowUnknownFieldsInWeakUnions: false author: epilot-dev + baseErrorName: SDKBaseError defaultErrorName: SDKError enableTypeDeduplication: true environmentVariables: [] diff --git a/go.mod b/go.mod index 9298687..80a2f81 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/epilot-dev/terraform-provider-epilot-custom-variable -go 1.22.0 +go 1.23.0 require ( 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.13.0 - github.com/hashicorp/terraform-plugin-go v0.24.0 + github.com/hashicorp/terraform-plugin-docs v0.20.1 + github.com/hashicorp/terraform-plugin-framework v1.15.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 + github.com/hashicorp/terraform-plugin-go v0.28.0 github.com/hashicorp/terraform-plugin-log v0.9.0 ) @@ -22,7 +22,7 @@ require ( github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect + github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -31,14 +31,15 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.1 // indirect + github.com/hashicorp/go-plugin v1.6.3 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/hc-install v0.7.0 // indirect + github.com/hashicorp/hc-install v0.9.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect - github.com/hashicorp/terraform-json v0.22.1 // indirect - github.com/hashicorp/terraform-registry-address v0.2.3 // indirect + github.com/hashicorp/terraform-json v0.23.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.5 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/huandu/xstrings v1.3.3 // indirect @@ -55,19 +56,19 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/yuin/goldmark v1.7.1 // indirect + github.com/yuin/goldmark v1.7.7 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect - github.com/zclconf/go-cty v1.14.4 // indirect + github.com/zclconf/go-cty v1.15.0 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.37.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect - google.golang.org/grpc v1.66.2 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.39.0 // indirect + golang.org/x/sys v0.32.0 // indirect + golang.org/x/text v0.24.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/grpc v1.72.1 // indirect + google.golang.org/protobuf v1.36.6 // 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 762ad5a..f4c24b7 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= -github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q= +github.com/bmatcuk/doublestar/v4 v4.7.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/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= @@ -46,12 +46,16 @@ github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+ github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -65,36 +69,38 @@ 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.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +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-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.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= -github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= +github.com/hashicorp/go-plugin v1.6.3 h1:xgHB+ZUSYeuJi96WtxEjzi23uh7YQpznjGh0U0UUrwg= +github.com/hashicorp/go-plugin v1.6.3/go.mod h1:MRobyh+Wc/nYy1V4KAXUiYfzxoYhs7V1mlH1Z7iY2h0= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= -github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= +github.com/hashicorp/hc-install v0.9.0 h1:2dIk8LcvANwtv3QZLckxcjyF5w8KVtiMxu6G6eLhghE= +github.com/hashicorp/hc-install v0.9.0/go.mod h1:+6vOP+mf3tuGgMApVYtmsnDoKWMDcFXeTxCACYZ8SFg= github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= -github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= -github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= -github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= -github.com/hashicorp/terraform-plugin-framework v1.12.0 h1:7HKaueHPaikX5/7cbC1r9d1m12iYHY+FlNZEGxQ42CQ= -github.com/hashicorp/terraform-plugin-framework v1.12.0/go.mod h1:N/IOQ2uYjW60Jp39Cp3mw7I/OpC/GfZ0385R0YibmkE= -github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E= -github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo= -github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U= -github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg= +github.com/hashicorp/terraform-json v0.23.0 h1:sniCkExU4iKtTADReHzACkk8fnpQXrdD2xoR+lppBkI= +github.com/hashicorp/terraform-json v0.23.0/go.mod h1:MHdXbBAbSg0GvzuWazEGKAn/cyNfIB7mN6y7KJN6y2c= +github.com/hashicorp/terraform-plugin-docs v0.20.1 h1:Fq7E/HrU8kuZu3hNliZGwloFWSYfWEOWnylFhYQIoys= +github.com/hashicorp/terraform-plugin-docs v0.20.1/go.mod h1:Yz6HoK7/EgzSrHPB9J/lWFzwl9/xep2OPnc5jaJDV90= +github.com/hashicorp/terraform-plugin-framework v1.15.0 h1:LQ2rsOfmDLxcn5EeIwdXFtr03FVsNktbbBci8cOKdb4= +github.com/hashicorp/terraform-plugin-framework v1.15.0/go.mod h1:hxrNI/GY32KPISpWqlCoTLM9JZsGH3CyYlir09bD/fI= +github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 h1:0uYQcqqgW3BMyyve07WJgpKorXST3zkpzvrOnf3mpbg= +github.com/hashicorp/terraform-plugin-framework-validators v0.17.0/go.mod h1:VwdfgE/5Zxm43flraNa0VjcvKQOGVrcO4X8peIri0T0= +github.com/hashicorp/terraform-plugin-go v0.28.0 h1:zJmu2UDwhVN0J+J20RE5huiF3XXlTYVIleaevHZgKPA= +github.com/hashicorp/terraform-plugin-go v0.28.0/go.mod h1:FDa2Bb3uumkTGSkTFpWSOwWJDwA7bf3vdP3ltLDTH6o= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= -github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= +github.com/hashicorp/terraform-registry-address v0.2.5 h1:2GTftHqmUhVOeuu9CW3kwDkRe4pcBDq0uuK5VJngU1M= +github.com/hashicorp/terraform-registry-address v0.2.5/go.mod h1:PpzXWINwB5kuVS5CA7m1+eO2f1jKb5ZDIxrOPfpnGkg= 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.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= @@ -141,8 +147,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -158,8 +164,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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +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/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= @@ -167,34 +173,46 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= -github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU= +github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= +github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= 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.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 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= @@ -208,8 +226,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.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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= @@ -217,20 +235,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.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= 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/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= -google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 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/planmodifiers/float32planmodifier/suppress_diff.go b/internal/planmodifiers/float32planmodifier/suppress_diff.go new file mode 100644 index 0000000..a82a09f --- /dev/null +++ b/internal/planmodifiers/float32planmodifier/suppress_diff.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package float32planmodifier + +import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/planmodifiers/utils" + + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" +) + +const ( + // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation + ExplicitSuppress = iota +) + +// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown +func SuppressDiff(strategy int) planmodifier.Float32 { + return suppressDiff{ + strategy: strategy, + } +} + +// suppressDiff implements the plan modifier. +type suppressDiff struct { + strategy int +} + +// Description returns a human-readable description of the plan modifier. +func (m suppressDiff) Description(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// MarkdownDescription returns a markdown description of the plan modifier. +func (m suppressDiff) MarkdownDescription(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// PlanModifyFloat32 implements the plan modification logic. +func (m suppressDiff) PlanModifyFloat32(ctx context.Context, req planmodifier.Float32Request, resp *planmodifier.Float32Response) { + // Do nothing if there is a known planned value. + if !req.PlanValue.IsUnknown() { + return + } + + // Do nothing if there is an unknown configuration value + if req.ConfigValue.IsUnknown() { + return + } + + if utils.IsAllStateUnknown(ctx, req.State) { + return + } + + resp.PlanValue = req.StateValue +} diff --git a/internal/planmodifiers/int32planmodifier/suppress_diff.go b/internal/planmodifiers/int32planmodifier/suppress_diff.go new file mode 100644 index 0000000..b2b5e4c --- /dev/null +++ b/internal/planmodifiers/int32planmodifier/suppress_diff.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package int32planmodifier + +import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/planmodifiers/utils" + + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" +) + +const ( + // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation + ExplicitSuppress = iota +) + +// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown +func SuppressDiff(strategy int) planmodifier.Int32 { + return suppressDiff{ + strategy: strategy, + } +} + +// suppressDiff implements the plan modifier. +type suppressDiff struct { + strategy int +} + +// Description returns a human-readable description of the plan modifier. +func (m suppressDiff) Description(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// MarkdownDescription returns a markdown description of the plan modifier. +func (m suppressDiff) MarkdownDescription(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// PlanModifyInt32 implements the plan modification logic. +func (m suppressDiff) PlanModifyInt32(ctx context.Context, req planmodifier.Int32Request, resp *planmodifier.Int32Response) { + // Do nothing if there is a known planned value. + if !req.PlanValue.IsUnknown() { + return + } + + // Do nothing if there is an unknown configuration value + if req.ConfigValue.IsUnknown() { + return + } + + if utils.IsAllStateUnknown(ctx, req.State) { + return + } + + resp.PlanValue = req.StateValue +} diff --git a/internal/planmodifiers/utils/state_check.go b/internal/planmodifiers/utils/state_check.go index 51d5362..0ea64fb 100644 --- a/internal/planmodifiers/utils/state_check.go +++ b/internal/planmodifiers/utils/state_check.go @@ -4,6 +4,7 @@ package utils import ( "context" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/tfsdk" @@ -12,7 +13,7 @@ import ( func IsAllStateUnknown(ctx context.Context, state tfsdk.State) bool { attrs := state.Schema.GetAttributes() anyFound := false - for k, _ := range attrs { + for k := range attrs { attrValue := new(attr.Value) state.GetAttribute(ctx, path.Root(k), attrValue) if attrValue != nil && !(*attrValue).IsUnknown() && !(*attrValue).IsNull() { 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 d8dde2b..0000000 --- a/internal/provider/customvariable_resource.go +++ /dev/null @@ -1,353 +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/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/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, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Creation time`, - }, - "created_by": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Created by`, - }, - "helper_logic": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The helper function logic`, - }, - "helper_params": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `The helper function parameter's names`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ID`, - }, - "key": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The key which is used for Handlebar variable syntax {{"{{"}}key{{"}}"}}`, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Custom variable name`, - }, - "tags": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `The tags of custom variable`, - }, - "template": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Handlebar template that used to generate the variable content`, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Custom variable type. must be one of ["order_table", "custom", "journey_link"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "order_table", - "custom", - "journey_link", - ), - }, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Last update time`, - }, - "updated_by": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Updated by`, - }, - }, - } -} - -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 - } - - customVariable := data.ToSharedCustomVariable() - var id string - id = data.ID.ValueString() - - request := operations.UpdateCustomVariableRequest{ - CustomVariable: customVariable, - ID: id, - } - res, err := r.client.CustomVariables.UpdateCustomVariable(ctx, request) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res != nil && res.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) - } - return - } - if res == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) - return - } - if res.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.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) 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 36152e0..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 { - var tags []string = []string{} - for _, tagsItem := range r.Tags { - tags = append(tags, tagsItem.ValueString()) - } - var config interface{} - if !r.Config.IsUnknown() && !r.Config.IsNull() { - _ = json.Unmarshal([]byte(r.Config.ValueString()), &config) - } - 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 - } - helperLogic := new(string) - if !r.HelperLogic.IsUnknown() && !r.HelperLogic.IsNull() { - *helperLogic = r.HelperLogic.ValueString() - } else { - helperLogic = nil - } - var helperParams []string = []string{} - for _, helperParamsItem := range r.HelperParams { - helperParams = append(helperParams, helperParamsItem.ValueString()) - } - id := new(string) - if !r.ID.IsUnknown() && !r.ID.IsNull() { - *id = r.ID.ValueString() - } else { - id = nil - } - key := new(string) - if !r.Key.IsUnknown() && !r.Key.IsNull() { - *key = r.Key.ValueString() - } else { - key = nil - } - name := new(string) - if !r.Name.IsUnknown() && !r.Name.IsNull() { - *name = r.Name.ValueString() - } else { - name = nil - } - template := new(string) - if !r.Template.IsUnknown() && !r.Template.IsNull() { - *template = r.Template.ValueString() - } else { - template = nil - } - typeVar := new(shared.Type) - if !r.Type.IsUnknown() && !r.Type.IsNull() { - *typeVar = shared.Type(r.Type.ValueString()) - } else { - typeVar = 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 - } - out := shared.CustomVariable{ - Tags: tags, - Config: config, - CreatedAt: createdAt, - CreatedBy: createdBy, - HelperLogic: helperLogic, - HelperParams: helperParams, - ID: id, - Key: key, - Name: name, - Template: template, - Type: typeVar, - UpdatedAt: updatedAt, - UpdatedBy: updatedBy, - } - 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 5ec1bc6..037ed32 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -7,6 +7,7 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/models/shared" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/ephemeral" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -14,7 +15,8 @@ import ( "net/http" ) -var _ provider.Provider = &EpilotCustomVariableProvider{} +var _ provider.Provider = (*EpilotCustomVariableProvider)(nil) +var _ provider.ProviderWithEphemeralResources = (*EpilotCustomVariableProvider)(nil) type EpilotCustomVariableProvider struct { // version is set to the provider version on release, "dev" when the @@ -25,9 +27,9 @@ type EpilotCustomVariableProvider struct { // EpilotCustomVariableProviderModel describes the provider data model. type EpilotCustomVariableProviderModel struct { - ServerURL types.String `tfsdk:"server_url"` EpilotAuth types.String `tfsdk:"epilot_auth"` EpilotOrg types.String `tfsdk:"epilot_org"` + ServerURL types.String `tfsdk:"server_url"` } func (p *EpilotCustomVariableProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { @@ -37,22 +39,21 @@ func (p *EpilotCustomVariableProvider) Metadata(ctx context.Context, req provide func (p *EpilotCustomVariableProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ - Description: `Template Variables API: API to provide variables for email and document templates.`, Attributes: map[string]schema.Attribute{ - "server_url": schema.StringAttribute{ - MarkdownDescription: "Server URL (defaults to https://template-variables-api.sls.epilot.io)", - Optional: true, - Required: false, - }, "epilot_auth": schema.StringAttribute{ - Sensitive: true, Optional: true, + Sensitive: true, }, "epilot_org": schema.StringAttribute{ - Sensitive: true, Optional: true, + Sensitive: true, + }, + "server_url": schema.StringAttribute{ + Description: `Server URL (defaults to https://template-variables-api.sls.epilot.io)`, + Optional: true, }, }, + MarkdownDescription: `Template Variables API: API to provide variables for email and document templates.`, } } @@ -71,47 +72,46 @@ func (p *EpilotCustomVariableProvider) Configure(ctx context.Context, req provid ServerURL = "https://template-variables-api.sls.epilot.io" } - epilotAuth := new(string) - if !data.EpilotAuth.IsUnknown() && !data.EpilotAuth.IsNull() { - *epilotAuth = data.EpilotAuth.ValueString() - } else { - epilotAuth = nil + security := shared.Security{} + + if !data.EpilotAuth.IsUnknown() { + security.EpilotAuth = data.EpilotAuth.ValueStringPointer() } - epilotOrg := new(string) - if !data.EpilotOrg.IsUnknown() && !data.EpilotOrg.IsNull() { - *epilotOrg = data.EpilotOrg.ValueString() - } else { - epilotOrg = nil + + if !data.EpilotOrg.IsUnknown() { + security.EpilotOrg = data.EpilotOrg.ValueStringPointer() } - security := shared.Security{ - EpilotAuth: epilotAuth, - EpilotOrg: epilotOrg, + + providerHTTPTransportOpts := ProviderHTTPTransportOpts{ + SetHeaders: make(map[string]string), + Transport: http.DefaultTransport, } httpClient := http.DefaultClient - httpClient.Transport = NewLoggingHTTPTransport(http.DefaultTransport) + httpClient.Transport = NewProviderHTTPTransport(providerHTTPTransportOpts) opts := []sdk.SDKOption{ sdk.WithServerURL(ServerURL), sdk.WithSecurity(security), sdk.WithClient(httpClient), } - client := sdk.New(opts...) + client := sdk.New(opts...) resp.DataSourceData = client + resp.EphemeralResourceData = client resp.ResourceData = client } 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 (p *EpilotCustomVariableProvider) EphemeralResources(ctx context.Context) []func() ephemeral.EphemeralResource { + return []func() ephemeral.EphemeralResource{} } func New(version string) func() provider.Provider { diff --git a/internal/provider/typeconvert/date.go b/internal/provider/typeconvert/date.go new file mode 100644 index 0000000..563cc03 --- /dev/null +++ b/internal/provider/typeconvert/date.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package typeconvert + +import ( + sdkTypes "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/types" +) + +// Converts a date types.Date to string. +func DateToString(value sdkTypes.Date) string { + return value.String() +} + +// Converts a date *types.Date to *string. +func DatePointerToStringPointer(value *sdkTypes.Date) *string { + if value == nil { + return nil + } + + stringValue := DateToString(*value) + + return &stringValue +} diff --git a/internal/provider/typeconvert/datetime.go b/internal/provider/typeconvert/datetime.go new file mode 100644 index 0000000..7bfdc55 --- /dev/null +++ b/internal/provider/typeconvert/datetime.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package typeconvert + +import ( + "time" +) + +// Converts a date-time time.Time to string. +func TimeToString(value time.Time) string { + return value.Format(time.RFC3339Nano) +} + +// Converts a date-time *time.Time to *string. +func TimePointerToStringPointer(value *time.Time) *string { + if value == nil { + return nil + } + + stringValue := TimeToString(*value) + + return &stringValue +} diff --git a/internal/provider/typeconvert/int.go b/internal/provider/typeconvert/int.go new file mode 100644 index 0000000..54763e7 --- /dev/null +++ b/internal/provider/typeconvert/int.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package typeconvert + +// Converts an *int to *int32. +func IntPointerToInt32Pointer(value *int) *int32 { + if value == nil { + return nil + } + + int32Value := int32(*value) + + return &int32Value +} + +// Converts an *int to *int64. +func IntPointerToInt64Pointer(value *int) *int64 { + if value == nil { + return nil + } + + int64Value := int64(*value) + + return &int64Value +} + +// Converts an *int32 to *int. +func Int32PointerToIntPointer(value *int32) *int { + if value == nil { + return nil + } + + intValue := int(*value) + + return &intValue +} + +// Converts an *int64 to *int32. +func Int64PointerToInt32Pointer(value *int64) *int32 { + if value == nil { + return nil + } + + // This may panic and if it does, represents a schema mismatch between + // response and response types. Request and response types should always + // be consistent with the highest integer size necessary. + int32Value := int32(*value) + + return &int32Value +} diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 1dd5d69..91affe6 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -6,22 +6,22 @@ import ( "bufio" "bytes" "context" - "encoding/json" "errors" "fmt" - tfReflect "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/provider/reflect" + "io" + "net/http" + "net/http/httputil" + "net/textproto" + "strings" + "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" + + tfReflect "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/provider/reflect" ) func debugResponse(response *http.Response) string { @@ -48,19 +48,6 @@ func debugResponse(response *http.Response) string { return fmt.Sprintf("**Request**:\n%s\n**Response**:\n%s", string(dumpReq), string(dumpRes)) } -func reflectJSONKey(data any, key string) reflect.Value { - jsonIfied, err := json.Marshal(data) - if err != nil { - panic(fmt.Errorf("failed to marshal data: %w", err)) - } - var jsonMap map[string]interface{} - err = json.Unmarshal(jsonIfied, &jsonMap) - if err != nil { - panic(fmt.Errorf("failed to unmarshal data: %w", err)) - } - return reflect.ValueOf(jsonMap[key]) -} - func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse, target interface{}) { var plan types.Object var state types.Object @@ -86,26 +73,46 @@ func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.Updat return } - refreshPlan(ctx, plan, target, resp.Diagnostics) + resp.Diagnostics.Append(refreshPlan(ctx, plan, target)...) } -func refreshPlan(ctx context.Context, plan types.Object, target interface{}, diagnostics diag.Diagnostics) { +func refreshPlan(ctx context.Context, plan types.Object, target any) diag.Diagnostics { + var diags diag.Diagnostics + obj := types.ObjectType{AttrTypes: plan.AttributeTypes(ctx)} val, err := plan.ToTerraformValue(ctx) if err != nil { - diagnostics.Append(diag.NewErrorDiagnostic("Object Conversion Error", "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error())) - return + diags.AddError( + "Object Conversion Error", + "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), + ) + return diags } - diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ + + diags.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, SourceType: tfReflect.SourceTypePlan, }, path.Empty())...) + + return diags +} + +// Configurable options for the provider HTTP transport. +type ProviderHTTPTransportOpts struct { + // HTTP headers to set on all requests. + SetHeaders map[string]string + + // Underlying HTTP transport. + Transport http.RoundTripper } // 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} +func NewProviderHTTPTransport(opts ProviderHTTPTransportOpts) *providerHttpTransport { + return &providerHttpTransport{ + setHeaders: opts.SetHeaders, + transport: opts.Transport, + } } const ( @@ -123,14 +130,18 @@ const ( FieldHttpTransactionId = "tf_http_trans_id" ) -type loggingHttpTransport struct { - transport http.RoundTripper +type providerHttpTransport struct { + setHeaders map[string]string + transport http.RoundTripper } -func (t *loggingHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { +func (t *providerHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { ctx := req.Context() ctx = t.addTransactionIdField(ctx) + // Set globally defined HTTP headers in the request + t.setRequestHeaders(req) + // Decompose the request bytes in a message (HTTP body) and fields (HTTP headers), then log it fields, err := decomposeRequestForLogging(req) if err != nil { @@ -160,7 +171,8 @@ func (t *loggingHttpTransport) RoundTrip(req *http.Request) (*http.Response, err return res, nil } -func (t *loggingHttpTransport) addTransactionIdField(ctx context.Context) context.Context { +// Generates UUID and sets it into the tf_http_trans_id logging field. +func (t *providerHttpTransport) addTransactionIdField(ctx context.Context) context.Context { tId, err := uuid.GenerateUUID() if err != nil { @@ -170,6 +182,13 @@ func (t *loggingHttpTransport) addTransactionIdField(ctx context.Context) contex return tflog.SetField(ctx, FieldHttpTransactionId, tId) } +// Sets globally defined HTTP headers in the request. +func (t *providerHttpTransport) setRequestHeaders(req *http.Request) { + for name, value := range t.setHeaders { + req.Header.Set(name, value) + } +} + func decomposeRequestForLogging(req *http.Request) (map[string]interface{}, error) { fields := make(map[string]interface{}, len(req.Header)+4) fields[FieldHttpOperationType] = OperationHttpRequest diff --git a/internal/sdk/.gitignore b/internal/sdk/.gitignore index d3c2f59..5f88fc7 100644 --- a/internal/sdk/.gitignore +++ b/internal/sdk/.gitignore @@ -1 +1,5 @@ +.DS_Store +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.speakeasy/reports # .gitignore diff --git a/internal/sdk/customvariables.go b/internal/sdk/customvariables.go index 5d120c2..6102ab4 100644 --- a/internal/sdk/customvariables.go +++ b/internal/sdk/customvariables.go @@ -6,39 +6,36 @@ import ( "bytes" "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/config" "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" "net/http" "net/url" ) +// CustomVariables - Custom variables type CustomVariables struct { - sdkConfiguration sdkConfiguration + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } -func newCustomVariables(sdkConfig sdkConfiguration) *CustomVariables { +func newCustomVariables(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *CustomVariables { return &CustomVariables{ + rootSDK: rootSDK, sdkConfiguration: sdkConfig, + hooks: hooks, } } // 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: "createCustomVariable", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - +func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *shared.CustomVariableInput, opts ...operations.Option) (*operations.CreateCustomVariableResponse, error) { o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -48,12 +45,26 @@ func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *sha } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/custom-variables") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createCustomVariable", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -76,105 +87,44 @@ func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *sha } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if reqContentType != "" { + 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -224,16 +174,8 @@ func (s *CustomVariables) CreateCustomVariable(ctx context.Context, request *sha // 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: "deleteCustomVariable", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -243,12 +185,27 @@ func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request oper } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteCustomVariable", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -271,99 +228,36 @@ func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request oper 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -375,7 +269,6 @@ func (s *CustomVariables) DeleteCustomVariable(ctx context.Context, request oper switch { case httpRes.StatusCode == 204: - fallthrough case httpRes.StatusCode == 403: default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -392,16 +285,8 @@ 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) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getBluePrintTableConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -411,12 +296,27 @@ func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...o } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/custom-variables/order-table-blueprint") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getBluePrintTableConfig", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -439,99 +339,36 @@ func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...o 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -579,16 +416,8 @@ func (s *CustomVariables) GetBluePrintTableConfig(ctx context.Context, opts ...o // 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: "getCustomVariable", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -598,12 +427,27 @@ func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operati } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getCustomVariable", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -626,99 +470,36 @@ 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -768,16 +549,8 @@ func (s *CustomVariables) GetCustomVariable(ctx context.Context, request operati // 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: "getCustomVariables", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -787,12 +560,27 @@ func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operat } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/custom-variables") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getCustomVariables", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -815,100 +603,37 @@ func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operat 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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") - } + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } - _, 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } } res := &operations.GetCustomVariablesResponse{ @@ -955,16 +680,8 @@ func (s *CustomVariables) GetCustomVariables(ctx context.Context, opts ...operat // 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: "searchCustomVariables", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -974,12 +691,26 @@ func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *sh } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/custom-variables:search") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "searchCustomVariables", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1002,105 +733,44 @@ func (s *CustomVariables) SearchCustomVariables(ctx context.Context, request *sh } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if reqContentType != "" { + 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -1148,16 +818,8 @@ 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) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateCustomVariable", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -1167,12 +829,26 @@ func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request oper } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/custom-variables/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updateCustomVariable", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "CustomVariable", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1195,105 +871,44 @@ func (s *CustomVariables) UpdateCustomVariable(ctx context.Context, request oper } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if reqContentType != "" { + 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } diff --git a/internal/sdk/internal/config/sdkconfiguration.go b/internal/sdk/internal/config/sdkconfiguration.go new file mode 100644 index 0000000..aa2ccc6 --- /dev/null +++ b/internal/sdk/internal/config/sdkconfiguration.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package config + +import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/retry" + "net/http" + "time" +) + +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +type SDKConfiguration struct { + Client HTTPClient + Security func(context.Context) (interface{}, error) + ServerURL string + ServerIndex int + ServerList []string + UserAgent string + RetryConfig *retry.Config + Timeout *time.Duration +} + +func (c *SDKConfiguration) GetServerDetails() (string, map[string]string) { + if c.ServerURL != "" { + return c.ServerURL, nil + } + + return c.ServerList[c.ServerIndex], nil +} diff --git a/internal/sdk/internal/hooks/hooks.go b/internal/sdk/internal/hooks/hooks.go index 8ea491a..1cd66d0 100644 --- a/internal/sdk/internal/hooks/hooks.go +++ b/internal/sdk/internal/hooks/hooks.go @@ -5,6 +5,7 @@ package hooks import ( "context" "errors" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/config" "net/http" ) @@ -24,10 +25,13 @@ type HTTPClient interface { } type HookContext struct { - Context context.Context - OperationID string - OAuth2Scopes []string - SecuritySource func(context.Context) (interface{}, error) + SDK any + SDKConfiguration config.SDKConfiguration + BaseURL string + Context context.Context + OperationID string + OAuth2Scopes []string + SecuritySource func(context.Context) (interface{}, error) } type BeforeRequestContext struct { @@ -70,6 +74,11 @@ type Hooks struct { afterErrorHook []afterErrorHook } +var _ sdkInitHook = (*Hooks)(nil) +var _ beforeRequestHook = (*Hooks)(nil) +var _ afterSuccessHook = (*Hooks)(nil) +var _ afterErrorHook = (*Hooks)(nil) + func New() *Hooks { h := &Hooks{ sdkInitHooks: []sdkInitHook{}, diff --git a/internal/sdk/internal/utils/form.go b/internal/sdk/internal/utils/form.go index 19dcb76..3a44739 100644 --- a/internal/sdk/internal/utils/form.go +++ b/internal/sdk/internal/utils/form.go @@ -15,11 +15,15 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/types" ) -func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string, getFieldName func(reflect.StructField) string) url.Values { formValues := url.Values{} if isNil(objType, objValue) { + if defaultValue != nil { + formValues.Add(paramName, *defaultValue) + } + return formValues } diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index 57e3a4b..9719f6b 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -186,8 +186,8 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool value, ok := unmarhsaled[fieldName] if !ok { - defaultTag := field.Tag.Get("default") - if defaultTag != "" { + defaultTag, defaultOk := field.Tag.Lookup("default") + if defaultOk { value = handleDefaultConstValue(defaultTag, fieldVal.Interface(), field.Tag) ok = true } @@ -257,8 +257,8 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) } if isNil(reflect.TypeOf(v), reflect.ValueOf(v)) { - defaultTag := tag.Get("default") - if defaultTag != "" { + defaultTag, ok := tag.Lookup("default") + if ok { return handleDefaultConstValue(defaultTag, v, tag), nil } diff --git a/internal/sdk/internal/utils/queryparams.go b/internal/sdk/internal/utils/queryparams.go index b21584e..c3a290a 100644 --- a/internal/sdk/internal/utils/queryparams.go +++ b/internal/sdk/internal/utils/queryparams.go @@ -65,6 +65,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur continue } + constValue := parseConstTag(fieldType) + if constValue != nil { + values.Add(qpTag.ParamName, *constValue) + continue + } + + defaultValue := parseDefaultTag(fieldType) + if globals != nil { var globalFound bool fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) @@ -91,14 +99,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur } } case "form": - vals := populateFormParams(qpTag, fieldType.Type, valType, ",") + vals := populateFormParams(qpTag, fieldType.Type, valType, ",", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } case "pipeDelimited": - vals := populateFormParams(qpTag, fieldType.Type, valType, "|") + vals := populateFormParams(qpTag, fieldType.Type, valType, "|", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) @@ -214,7 +222,11 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru continue } - scope := priorScope + "[" + qpTag.ParamName + "]" + scope := priorScope + + if !qpTag.Inline { + scope = priorScope + "[" + qpTag.ParamName + "]" + } switch fieldValue.Kind() { case reflect.Array, reflect.Slice: @@ -236,8 +248,8 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru } } -func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { - return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, defaultValue, func(fieldType reflect.StructField) string { qpTag := parseQueryParamTag(fieldType) if qpTag == nil { return "" @@ -252,6 +264,13 @@ type paramTag struct { Explode bool ParamName string Serialization string + + // Inline is a special case for union/oneOf. When a wrapper struct type is + // used, each union/oneOf value field should be inlined (e.g. not appended + // in deepObject style with the name) as if the value was directly on the + // parent struct field. Without this annotation, the value would not be + // encoded by downstream logic that requires the struct field tag. + Inline bool } func parseQueryParamTag(field reflect.StructField) *paramTag { diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index 000226e..8622ec5 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -7,8 +7,11 @@ import ( "context" "fmt" "io" + "mime" "mime/multipart" + "net/textproto" "net/url" + "path/filepath" "reflect" "regexp" ) @@ -166,9 +169,21 @@ func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { tag := parseMultipartFormTag(field) if tag.File { - if err := encodeMultipartFormDataFile(writer, fieldType, valType); err != nil { - writer.Close() - return "", err + switch fieldType.Kind() { + case reflect.Slice, reflect.Array: + for i := 0; i < valType.Len(); i++ { + arrayVal := valType.Index(i) + + if err := encodeMultipartFormDataFile(writer, tag.Name+"[]", arrayVal.Type(), arrayVal); err != nil { + writer.Close() + return "", err + } + } + default: + if err := encodeMultipartFormDataFile(writer, tag.Name, fieldType, valType); err != nil { + writer.Close() + return "", err + } } } else if tag.JSON { jw, err := writer.CreateFormField(tag.Name) @@ -211,12 +226,11 @@ func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { return writer.FormDataContentType(), nil } -func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, valType reflect.Value) error { +func encodeMultipartFormDataFile(w *multipart.Writer, fieldName string, fieldType reflect.Type, valType reflect.Value) error { if fieldType.Kind() != reflect.Struct { return fmt.Errorf("invalid type %s for multipart/form-data file", valType.Type()) } - var fieldName string var fileName string var reader io.Reader @@ -236,16 +250,26 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va reader = val.Interface().(io.Reader) } } else { - fieldName = tag.Name fileName = val.String() } } - if fieldName == "" || fileName == "" || reader == nil { + if fileName == "" || reader == nil { return fmt.Errorf("invalid multipart/form-data file") } - fw, err := w.CreateFormFile(fieldName, fileName) + // Detect content type based on file extension + contentType := mime.TypeByExtension(filepath.Ext(fileName)) + if contentType == "" { + contentType = "application/octet-stream" + } + + // Create multipart header with proper content type + h := make(textproto.MIMEHeader) + h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="%s"; filename="%s"`, fieldName, fileName)) + h.Set("Content-Type", contentType) + + fw, err := w.CreatePart(h) if err != nil { return err } @@ -253,6 +277,11 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va return err } + // Reset seek position to 0 if the reader supports seeking + if seeker, ok := reader.(io.Seeker); ok { + _, _ = seeker.Seek(0, io.SeekStart) + } + return nil } @@ -294,7 +323,7 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { switch tag.Style { // TODO: support other styles case "form": - values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", func(sf reflect.StructField) string { + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", nil, func(sf reflect.StructField) string { tag := parseFormTag(field) if tag == nil { return "" diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index f1ff9e0..6f1f538 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -96,6 +96,26 @@ func AsSecuritySource(security interface{}) func(context.Context) (interface{}, } } +func parseConstTag(field reflect.StructField) *string { + value := field.Tag.Get("const") + + if value == "" { + return nil + } + + return &value +} + +func parseDefaultTag(field reflect.StructField) *string { + value := field.Tag.Get("default") + + if value == "" { + return nil + } + + return &value +} + func parseStructTag(tagKey string, field reflect.StructField) map[string]string { tag := field.Tag.Get(tagKey) if tag == "" { @@ -127,6 +147,7 @@ func parseStructTag(tagKey string, field reflect.StructField) map[string]string func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string, defaultExplode bool) *paramTag { // example `{tagKey}:"style=simple,explode=false,name=apiID"` + // example `{tagKey}:"inline"` values := parseStructTag(tagKey, field) if values == nil { return nil @@ -140,6 +161,8 @@ func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string for k, v := range values { switch k { + case "inline": + tag.Inline = v == "true" case "style": tag.Style = v case "explode": diff --git a/internal/sdk/models/operations/options.go b/internal/sdk/models/operations/options.go index dc26f62..d995fe5 100644 --- a/internal/sdk/models/operations/options.go +++ b/internal/sdk/models/operations/options.go @@ -12,7 +12,6 @@ import ( var ErrUnsupportedOption = errors.New("unsupported option") const ( - SupportedOptionServerURL = "serverURL" SupportedOptionRetries = "retries" SupportedOptionTimeout = "timeout" SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" @@ -22,8 +21,8 @@ const ( type AcceptHeaderEnum string const ( - AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" - AcceptHeaderEnumWildcardWildcard AcceptHeaderEnum = "*/*" + AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" + AcceptHeaderEnumWildcardRootWildcard AcceptHeaderEnum = "*/*" ) func (e AcceptHeaderEnum) ToPointer() *AcceptHeaderEnum { @@ -36,6 +35,7 @@ type Options struct { Timeout *time.Duration AcceptHeaderOverride *AcceptHeaderEnum URLOverride *string + SetHeaders map[string]string } type Option func(*Options, ...string) error @@ -43,10 +43,6 @@ type Option func(*Options, ...string) error // WithServerURL allows providing an alternative server URL. func WithServerURL(serverURL string) Option { return func(opts *Options, supportedOptions ...string) error { - if !utils.Contains(supportedOptions, SupportedOptionServerURL) { - return ErrUnsupportedOption - } - opts.ServerURL = &serverURL return nil } @@ -55,10 +51,6 @@ func WithServerURL(serverURL string) Option { // WithTemplatedServerURL allows providing an alternative server URL with templated parameters. func WithTemplatedServerURL(serverURL string, params map[string]string) Option { return func(opts *Options, supportedOptions ...string) error { - if !utils.Contains(supportedOptions, SupportedOptionServerURL) { - return ErrUnsupportedOption - } - if params != nil { serverURL = utils.ReplaceParameters(serverURL, params) } @@ -114,3 +106,12 @@ func WithURLOverride(urlOverride string) Option { return nil } } + +// WithSetHeaders takes a map of headers that will applied to a request. If the +// request contains headers that are in the map then they will be overwritten. +func WithSetHeaders(hdrs map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + opts.SetHeaders = hdrs + return nil + } +} diff --git a/internal/sdk/models/operations/updatecustomvariable.go b/internal/sdk/models/operations/updatecustomvariable.go index a3da371..13e2c5d 100644 --- a/internal/sdk/models/operations/updatecustomvariable.go +++ b/internal/sdk/models/operations/updatecustomvariable.go @@ -8,12 +8,12 @@ import ( ) type UpdateCustomVariableRequest struct { - CustomVariable *shared.CustomVariable `request:"mediaType=application/json"` + CustomVariable *shared.CustomVariableInput `request:"mediaType=application/json"` // Custom variable ID ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *UpdateCustomVariableRequest) GetCustomVariable() *shared.CustomVariable { +func (o *UpdateCustomVariableRequest) GetCustomVariable() *shared.CustomVariableInput { if o == nil { return nil } diff --git a/internal/sdk/models/shared/customvariable.go b/internal/sdk/models/shared/customvariable.go index 5a6a4f4..673f34a 100644 --- a/internal/sdk/models/shared/customvariable.go +++ b/internal/sdk/models/shared/customvariable.go @@ -7,6 +7,10 @@ import ( "fmt" ) +// Config - Variable configuration +type Config struct { +} + // Type - Custom variable type type Type string @@ -39,8 +43,9 @@ func (e *Type) UnmarshalJSON(data []byte) error { type CustomVariable struct { // The tags of custom variable - Tags []string `json:"_tags,omitempty"` - Config any `json:"config,omitempty"` + Tags []string `json:"_tags,omitempty"` + // Variable configuration + Config *Config `json:"config,omitempty"` // Creation time CreatedAt *string `json:"created_at,omitempty"` // Created by @@ -52,11 +57,11 @@ type CustomVariable struct { // ID ID *string `json:"id,omitempty"` // The key which is used for Handlebar variable syntax {{"{{"}}key}} - Key *string `json:"key,omitempty"` + Key string `json:"key"` // Custom variable name Name *string `json:"name,omitempty"` // Handlebar template that used to generate the variable content - Template *string `json:"template,omitempty"` + Template string `json:"template"` // Custom variable type Type *Type `json:"type,omitempty"` // Last update time @@ -72,7 +77,7 @@ func (o *CustomVariable) GetTags() []string { return o.Tags } -func (o *CustomVariable) GetConfig() any { +func (o *CustomVariable) GetConfig() *Config { if o == nil { return nil } @@ -114,9 +119,9 @@ func (o *CustomVariable) GetID() *string { return o.ID } -func (o *CustomVariable) GetKey() *string { +func (o *CustomVariable) GetKey() string { if o == nil { - return nil + return "" } return o.Key } @@ -128,9 +133,9 @@ func (o *CustomVariable) GetName() *string { return o.Name } -func (o *CustomVariable) GetTemplate() *string { +func (o *CustomVariable) GetTemplate() string { if o == nil { - return nil + return "" } return o.Template } @@ -155,3 +160,87 @@ func (o *CustomVariable) GetUpdatedBy() *string { } return o.UpdatedBy } + +type CustomVariableInput struct { + // The tags of custom variable + Tags []string `json:"_tags,omitempty"` + // Variable configuration + Config *Config `json:"config,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"` + // Custom variable name + Name *string `json:"name,omitempty"` + // Handlebar template that used to generate the variable content + Template string `json:"template"` + // Custom variable type + Type *Type `json:"type,omitempty"` +} + +func (o *CustomVariableInput) GetTags() []string { + if o == nil { + return nil + } + return o.Tags +} + +func (o *CustomVariableInput) GetConfig() *Config { + if o == nil { + return nil + } + return o.Config +} + +func (o *CustomVariableInput) GetHelperLogic() *string { + if o == nil { + return nil + } + return o.HelperLogic +} + +func (o *CustomVariableInput) GetHelperParams() []string { + if o == nil { + return nil + } + return o.HelperParams +} + +func (o *CustomVariableInput) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *CustomVariableInput) GetKey() string { + if o == nil { + return "" + } + return o.Key +} + +func (o *CustomVariableInput) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *CustomVariableInput) GetTemplate() string { + if o == nil { + return "" + } + return o.Template +} + +func (o *CustomVariableInput) GetType() *Type { + if o == nil { + return nil + } + return o.Type +} diff --git a/internal/sdk/models/shared/variableparameters.go b/internal/sdk/models/shared/variableparameters.go index e7eb50c..e2d4394 100644 --- a/internal/sdk/models/shared/variableparameters.go +++ b/internal/sdk/models/shared/variableparameters.go @@ -6,14 +6,14 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/utils" ) -// ContextData - If context data is avaialble, this data will be used for variable replace. +// ContextData - If context data is available, this data will be used for variable replace. type ContextData struct { } type VariableParameters struct { // Brand ID BrandID *float64 `json:"brand_id,omitempty"` - // If context data is avaialble, this data will be used for variable replace. + // If context data is available, 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"` diff --git a/internal/sdk/retry/config.go b/internal/sdk/retry/config.go index aa4b334..aa809fc 100644 --- a/internal/sdk/retry/config.go +++ b/internal/sdk/retry/config.go @@ -20,6 +20,9 @@ type BackoffStrategy struct { // Config configures a retry policy. type Config struct { + // Strategy sets the algorithm to use for a retry loop. It can be one of: + // - "backoff": retry with exponential backoff and random jitter. + // - "none" or "": disables retries. Strategy string Backoff *BackoffStrategy RetryConnectionErrors bool diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index f9920b5..9b3dc48 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -2,9 +2,12 @@ package sdk +// Generated from OpenAPI doc version 1.0.0 and generator version 2.662.0 + import ( "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/config" "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/shared" @@ -16,9 +19,11 @@ import ( // ServerList contains the list of servers available to the SDK var ServerList = []string{ "https://template-variables-api.sls.epilot.io", + // Production server + "https://template-variables-api.dev.sls.epilot.io", } -// HTTPClient provides an interface for suplying the SDK with a custom HTTP client +// HTTPClient provides an interface for supplying the SDK with a custom HTTP client type HTTPClient interface { Do(req *http.Request) (*http.Response, error) } @@ -44,36 +49,16 @@ func Float64(f float64) *float64 { return &f } // Pointer provides a helper function to return a pointer to a type func Pointer[T any](v T) *T { return &v } -type sdkConfiguration struct { - Client HTTPClient - Security func(context.Context) (interface{}, error) - ServerURL string - ServerIndex int - Language string - OpenAPIDocVersion string - SDKVersion string - GenVersion string - UserAgent string - RetryConfig *retry.Config - Hooks *hooks.Hooks - Timeout *time.Duration -} - -func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { - if c.ServerURL != "" { - return c.ServerURL, nil - } - - return ServerList[c.ServerIndex], nil -} - // SDK - Template Variables API: API to provide variables for email and document templates. type SDK struct { + SDKVersion string + // Custom variables CustomVariables *CustomVariables // Variables Variables *Variables - sdkConfiguration sdkConfiguration + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } type SDKOption func(*SDK) @@ -146,14 +131,12 @@ func WithTimeout(timeout time.Duration) SDKOption { // New creates a new instance of the SDK with the provided options func New(opts ...SDKOption) *SDK { sdk := &SDK{ - sdkConfiguration: sdkConfiguration{ - Language: "go", - OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.0.1", - GenVersion: "2.472.1", - UserAgent: "speakeasy-sdk/go 0.0.1 2.472.1 1.0.0 github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk", - Hooks: hooks.New(), + SDKVersion: "1.3.0", + sdkConfiguration: config.SDKConfiguration{ + UserAgent: "speakeasy-sdk/terraform 1.3.0 2.662.0 1.0.0 github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk", + ServerList: ServerList, }, + hooks: hooks.New(), } for _, opt := range opts { opt(sdk) @@ -166,14 +149,13 @@ func New(opts ...SDKOption) *SDK { currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails() serverURL := currentServerURL - serverURL, sdk.sdkConfiguration.Client = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client) - if serverURL != currentServerURL { + serverURL, sdk.sdkConfiguration.Client = sdk.hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client) + if currentServerURL != serverURL { sdk.sdkConfiguration.ServerURL = serverURL } - sdk.CustomVariables = newCustomVariables(sdk.sdkConfiguration) - - sdk.Variables = newVariables(sdk.sdkConfiguration) + sdk.CustomVariables = newCustomVariables(sdk, sdk.sdkConfiguration, sdk.hooks) + sdk.Variables = newVariables(sdk, sdk.sdkConfiguration, sdk.hooks) return sdk } diff --git a/internal/sdk/variables.go b/internal/sdk/variables.go index a55aee9..7496239 100644 --- a/internal/sdk/variables.go +++ b/internal/sdk/variables.go @@ -6,40 +6,36 @@ import ( "bytes" "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-custom-variable/internal/sdk/internal/config" "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" "net/http" "net/url" ) // Variables type Variables struct { - sdkConfiguration sdkConfiguration + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } -func newVariables(sdkConfig sdkConfiguration) *Variables { +func newVariables(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Variables { return &Variables{ + rootSDK: rootSDK, sdkConfiguration: sdkConfig, + hooks: hooks, } } // GetCategories - getCategories // Get all template variable categories func (s *Variables) GetCategories(ctx context.Context, request operations.GetCategoriesRequest, opts ...operations.Option) (*operations.GetCategoriesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getCategories", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -49,12 +45,27 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/template-variables/categories") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getCategories", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -81,99 +92,36 @@ 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -222,16 +170,8 @@ func (s *Variables) GetCategories(ctx context.Context, request operations.GetCat // // 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: "getVariableContext", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -241,12 +181,26 @@ func (s *Variables) GetVariableContext(ctx context.Context, request *operations. } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/template-variables:context") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getVariableContext", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -269,105 +223,44 @@ func (s *Variables) GetVariableContext(ctx context.Context, request *operations. } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if reqContentType != "" { + 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -416,16 +309,8 @@ func (s *Variables) GetVariableContext(ctx context.Context, request *operations. // // 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: "replaceTemplates", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -435,12 +320,26 @@ func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.Re } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/template-variables:replace") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "replaceTemplates", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -463,105 +362,44 @@ func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.Re } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if reqContentType != "" { + 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } @@ -608,16 +446,8 @@ func (s *Variables) ReplaceTemplates(ctx context.Context, request *operations.Re // 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: "searchVariables", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ - operations.SupportedOptionRetries, operations.SupportedOptionTimeout, } @@ -627,12 +457,26 @@ func (s *Variables) SearchVariables(ctx context.Context, request *operations.Sea } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/v1/template-variables:search") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "searchVariables", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -655,105 +499,44 @@ func (s *Variables) SearchVariables(ctx context.Context, request *operations.Sea } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if reqContentType != "" { + 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, - } - } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) } - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - "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 { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.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 - }) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { if err != nil { - 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.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.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.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 - } } } diff --git a/internal/validators/float32validators/not_null.go b/internal/validators/float32validators/not_null.go new file mode 100644 index 0000000..c9a8973 --- /dev/null +++ b/internal/validators/float32validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package float32validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Float32 = Float32NotNullValidator{} + +// Float32NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Float32NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Float32NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Float32NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Float32NotNullValidator) ValidateFloat32(ctx context.Context, req validator.Float32Request, resp *validator.Float32Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Float32 { + return Float32NotNullValidator{} +} diff --git a/internal/validators/int32validators/not_null.go b/internal/validators/int32validators/not_null.go new file mode 100644 index 0000000..ec9a3f1 --- /dev/null +++ b/internal/validators/int32validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package int32validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Int32 = Int32NotNullValidator{} + +// Int32NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Int32NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Int32NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Int32NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Int32NotNullValidator) ValidateInt32(ctx context.Context, req validator.Int32Request, resp *validator.Int32Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Int32 { + return Int32NotNullValidator{} +}