diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 7873ea3..8a8c0ba 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 5a857039-7f4b-42d5-86fd-449767242ed2 management: - docChecksum: e4360dfb76bc6a89e63423a01fb462d3 + docChecksum: fdec2a87622dada6eb26dd0b357315a7 docVersion: 1.0.0 - speakeasyVersion: 1.396.7 - generationVersion: 2.415.6 - releaseVersion: 0.10.5 - configChecksum: d1007f22f98a4ca33da84ce78fb0fdb5 + speakeasyVersion: 1.420.0 + generationVersion: 2.438.15 + releaseVersion: 0.11.0 + configChecksum: b72aef552739dc67ea5c8e6f5b63de59 repoURL: https://github.com/epilot-dev/terraform-provider-epilot-product.git repoSubDirectory: . published: true @@ -22,9 +22,9 @@ features: terraform: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.4 - core: 3.24.11 + core: 3.25.0 envVarSecurityUsage: 0.1.0 - globalSecurity: 2.81.8 + globalSecurity: 2.81.9 globalServerURLs: 2.82.1 nullables: 0.0.0 retries: 2.81.1 @@ -336,7 +336,7 @@ examples: path: taxId: "123e4567-e89b-12d3-a456-426614174000" requestBody: - application/json: {"region": "DE"} + application/json: {"__additional": {}, "_files": {"$relation": [{"entity_id": "123e4567-e89b-12d3-a456-426614174000"}, {"entity_id": "123e4567-e89b-12d3-a456-426614174000"}]}, "_manifest": ["123e4567-e89b-12d3-a456-426614174000"], "active": false, "rate": "", "region": "DE", "type": "Custom"} responses: "200": application/json: {"__additional": {}, "_acl": {"delete": ["org:456"], "edit": ["org:456"], "view": ["org:456"]}, "_files": {"$relation": []}, "_id": "123e4567-e89b-12d3-a456-426614174000", "_manifest": ["123e4567-e89b-12d3-a456-426614174000"], "_org": "", "_owners": [], "_schema": "tax", "active": true, "rate": "", "region": "DE", "type": "VAT"} diff --git a/README.md b/README.md index 476ad82..d62e451 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ terraform { required_providers { epilot-product = { source = "epilot-dev/epilot-product" - version = "0.10.5" + version = "0.11.0" } } } diff --git a/docs/data-sources/price.md b/docs/data-sources/price.md index 92067db..9d535b2 100644 --- a/docs/data-sources/price.md +++ b/docs/data-sources/price.md @@ -14,7 +14,7 @@ Price DataSource ```terraform data "epilot-product_price" "my_price" { - hydrate = false + hydrate = true strict = true } ``` diff --git a/docs/data-sources/product.md b/docs/data-sources/product.md index c0e9040..6257b48 100644 --- a/docs/data-sources/product.md +++ b/docs/data-sources/product.md @@ -15,7 +15,7 @@ Product DataSource ```terraform data "epilot-product_product" "my_product" { hydrate = false - strict = false + strict = true } ``` diff --git a/docs/data-sources/tax.md b/docs/data-sources/tax.md index c799d18..1a5958a 100644 --- a/docs/data-sources/tax.md +++ b/docs/data-sources/tax.md @@ -14,7 +14,7 @@ Tax DataSource ```terraform data "epilot-product_tax" "my_tax" { - hydrate = false + hydrate = true strict = false } ``` diff --git a/docs/index.md b/docs/index.md index b39b323..275b540 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { epilot-product = { source = "epilot-dev/epilot-product" - version = "0.10.5" + version = "0.11.0" } } } diff --git a/docs/resources/price.md b/docs/resources/price.md index b2fef50..fba1dde 100644 --- a/docs/resources/price.md +++ b/docs/resources/price.md @@ -14,7 +14,7 @@ Price Resource ```terraform resource "epilot-product_price" "my_price" { - active = false + active = true additional = { "see" : jsonencode("documentation"), } @@ -31,7 +31,7 @@ resource "epilot-product_price" "my_price" { } ] } - is_composite_price = false + is_composite_price = true is_tax_inclusive = false long_description = "...my_long_description..." manifest = [ @@ -75,7 +75,7 @@ resource "epilot-product_price" "my_price" { unit_amount = 6.37 unit_amount_currency = "EUR" unit_amount_decimal = "...my_unit_amount_decimal..." - variable_price = true + variable_price = false } ``` diff --git a/docs/resources/tax.md b/docs/resources/tax.md index ac7666b..a145bee 100644 --- a/docs/resources/tax.md +++ b/docs/resources/tax.md @@ -14,7 +14,7 @@ Tax Resource ```terraform resource "epilot-product_tax" "my_tax" { - active = false + active = true additional = { "see" : jsonencode("documentation"), } @@ -54,12 +54,12 @@ resource "epilot-product_tax" "my_tax" { ### Optional -- `additional` (Map of String) Additional fields that are not part of the schema. Requires replacement if changed. +- `additional` (Map of String) Additional fields that are not part of the schema - `description` (String) -- `files` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--files)) -- `manifest` (List of String) Manifest ID used to create/update the entity. Requires replacement if changed. +- `files` (Attributes) (see [below for nested schema](#nestedatt--files)) +- `manifest` (List of String) Manifest ID used to create/update the entity - `schema` (String) must be "tax" -- `tags` (List of String) Requires replacement if changed. +- `tags` (List of String) ### Read-Only @@ -76,15 +76,15 @@ resource "epilot-product_tax" "my_tax" { Optional: -- `dollar_relation` (Attributes List) Requires replacement if changed. (see [below for nested schema](#nestedatt--files--dollar_relation)) +- `dollar_relation` (Attributes List) (see [below for nested schema](#nestedatt--files--dollar_relation)) ### Nested Schema for `files.dollar_relation` Optional: -- `entity_id` (String) Requires replacement if changed. -- `tags` (List of String) Requires replacement if changed. +- `entity_id` (String) +- `tags` (List of String) diff --git a/examples/data-sources/epilot-product_price/data-source.tf b/examples/data-sources/epilot-product_price/data-source.tf index 39f61bc..7679bb2 100644 --- a/examples/data-sources/epilot-product_price/data-source.tf +++ b/examples/data-sources/epilot-product_price/data-source.tf @@ -1,4 +1,4 @@ data "epilot-product_price" "my_price" { - hydrate = false + hydrate = true strict = true } \ No newline at end of file diff --git a/examples/data-sources/epilot-product_product/data-source.tf b/examples/data-sources/epilot-product_product/data-source.tf index 508dc01..6bc1187 100644 --- a/examples/data-sources/epilot-product_product/data-source.tf +++ b/examples/data-sources/epilot-product_product/data-source.tf @@ -1,4 +1,4 @@ data "epilot-product_product" "my_product" { hydrate = false - strict = false + strict = true } \ No newline at end of file diff --git a/examples/data-sources/epilot-product_tax/data-source.tf b/examples/data-sources/epilot-product_tax/data-source.tf index 800515a..5ba5bf4 100644 --- a/examples/data-sources/epilot-product_tax/data-source.tf +++ b/examples/data-sources/epilot-product_tax/data-source.tf @@ -1,4 +1,4 @@ data "epilot-product_tax" "my_tax" { - hydrate = false + hydrate = true strict = false } \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 1d1214c..4e81d3a 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-product = { source = "epilot-dev/epilot-product" - version = "0.10.5" + version = "0.11.0" } } } diff --git a/examples/resources/epilot-product_price/resource.tf b/examples/resources/epilot-product_price/resource.tf index c9175b7..c5da90d 100644 --- a/examples/resources/epilot-product_price/resource.tf +++ b/examples/resources/epilot-product_price/resource.tf @@ -1,5 +1,5 @@ resource "epilot-product_price" "my_price" { - active = false + active = true additional = { "see" : jsonencode("documentation"), } @@ -16,7 +16,7 @@ resource "epilot-product_price" "my_price" { } ] } - is_composite_price = false + is_composite_price = true is_tax_inclusive = false long_description = "...my_long_description..." manifest = [ @@ -60,5 +60,5 @@ resource "epilot-product_price" "my_price" { unit_amount = 6.37 unit_amount_currency = "EUR" unit_amount_decimal = "...my_unit_amount_decimal..." - variable_price = true + variable_price = false } \ No newline at end of file diff --git a/examples/resources/epilot-product_tax/resource.tf b/examples/resources/epilot-product_tax/resource.tf index 0b365ee..6936fa2 100644 --- a/examples/resources/epilot-product_tax/resource.tf +++ b/examples/resources/epilot-product_tax/resource.tf @@ -1,5 +1,5 @@ resource "epilot-product_tax" "my_tax" { - active = false + active = true additional = { "see" : jsonencode("documentation"), } diff --git a/gen.yaml b/gen.yaml index 0aed856..aa3a08e 100644 --- a/gen.yaml +++ b/gen.yaml @@ -27,7 +27,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.10.5 + version: 0.11.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/go.mod b/go.mod index 03d3c47..bd5408e 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/epilot-dev/terraform-provider-epilot-product -go 1.21 +go 1.22.0 require ( github.com/cenkalti/backoff/v4 v4.2.0 github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 github.com/hashicorp/terraform-plugin-docs v0.19.4 - github.com/hashicorp/terraform-plugin-framework v1.10.0 + 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.23.0 + github.com/hashicorp/terraform-plugin-go v0.24.0 ) require ( @@ -32,7 +32,7 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/hc-install v0.7.0 // indirect @@ -60,15 +60,15 @@ require ( github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.14.4 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.15.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.34.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect + google.golang.org/grpc v1.66.2 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 2d68f29..f9e8505 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= -github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= +github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -87,12 +87,12 @@ github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7 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.10.0 h1:xXhICE2Fns1RYZxEQebwkB2+kXouLC932Li9qelozrc= -github.com/hashicorp/terraform-plugin-framework v1.10.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= +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.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= -github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= +github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U= +github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= @@ -180,8 +180,8 @@ go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -191,10 +191,12 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -208,8 +210,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -217,20 +219,20 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= -google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= -google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/internal/provider/tax_resource.go b/internal/provider/tax_resource.go index 778431d..26c7ea9 100644 --- a/internal/provider/tax_resource.go +++ b/internal/provider/tax_resource.go @@ -5,10 +5,6 @@ package provider import ( "context" "fmt" - speakeasy_listplanmodifier "github.com/epilot-dev/terraform-provider-epilot-product/internal/planmodifiers/listplanmodifier" - speakeasy_mapplanmodifier "github.com/epilot-dev/terraform-provider-epilot-product/internal/planmodifiers/mapplanmodifier" - speakeasy_objectplanmodifier "github.com/epilot-dev/terraform-provider-epilot-product/internal/planmodifiers/objectplanmodifier" - speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-product/internal/planmodifiers/stringplanmodifier" tfTypes "github.com/epilot-dev/terraform-provider-epilot-product/internal/provider/types" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/operations" @@ -19,11 +15,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" @@ -93,14 +84,10 @@ func (r *TaxResource) Schema(ctx context.Context, req resource.SchemaRequest, re Required: true, }, "additional": schema.MapAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Map{ - mapplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_mapplanmodifier.SuppressDiff(speakeasy_mapplanmodifier.ExplicitSuppress), - }, + Computed: true, + Optional: true, ElementType: types.StringType, - Description: `Additional fields that are not part of the schema. Requires replacement if changed.`, + Description: `Additional fields that are not part of the schema`, Validators: []validator.Map{ mapvalidator.ValueStringsAre(validators.IsValidJSON()), }, @@ -118,65 +105,37 @@ func (r *TaxResource) Schema(ctx context.Context, req resource.SchemaRequest, re "files": schema.SingleNestedAttribute{ Computed: true, Optional: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, Attributes: map[string]schema.Attribute{ "dollar_relation": schema.ListNestedAttribute{ Computed: true, Optional: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, NestedObject: schema.NestedAttributeObject{ Validators: []validator.Object{ speakeasy_objectvalidators.NotNull(), }, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, Attributes: map[string]schema.Attribute{ "entity_id": schema.StringAttribute{ Computed: true, Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Description: `Requires replacement if changed.`, }, "tags": schema.ListAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, + Computed: true, + Optional: true, ElementType: types.StringType, - Description: `Requires replacement if changed.`, }, }, }, - Description: `Requires replacement if changed.`, }, }, - Description: `Requires replacement if changed.`, }, "id": schema.StringAttribute{ Computed: true, }, "manifest": schema.ListAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, + Computed: true, + Optional: true, ElementType: types.StringType, - Description: `Manifest ID used to create/update the entity. Requires replacement if changed.`, + Description: `Manifest ID used to create/update the entity`, }, "org": schema.StringAttribute{ Computed: true, @@ -210,14 +169,9 @@ func (r *TaxResource) Schema(ctx context.Context, req resource.SchemaRequest, re }, }, "tags": schema.ListAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, + Computed: true, + Optional: true, ElementType: types.StringType, - Description: `Requires replacement if changed.`, }, "title": schema.StringAttribute{ Computed: true, diff --git a/internal/provider/tax_resource_sdk.go b/internal/provider/tax_resource_sdk.go index fcf51f9..c33840a 100644 --- a/internal/provider/tax_resource_sdk.go +++ b/internal/provider/tax_resource_sdk.go @@ -180,44 +180,71 @@ func (r *TaxResourceModel) RefreshFromSharedTax(resp *shared.Tax) { } func (r *TaxResourceModel) ToSharedTaxPatch() *shared.TaxPatch { + additional := make(map[string]interface{}) + for additionalKey, additionalValue := range r.Additional { + var additionalInst interface{} + _ = json.Unmarshal([]byte(additionalValue.ValueString()), &additionalInst) + additional[additionalKey] = additionalInst + } + var files *shared.BaseRelation + if r.Files != nil { + var dollarRelation []shared.DollarRelation = []shared.DollarRelation{} + for _, dollarRelationItem := range r.Files.DollarRelation { + var tags []string = []string{} + for _, tagsItem := range dollarRelationItem.Tags { + tags = append(tags, tagsItem.ValueString()) + } + entityID := new(string) + if !dollarRelationItem.EntityID.IsUnknown() && !dollarRelationItem.EntityID.IsNull() { + *entityID = dollarRelationItem.EntityID.ValueString() + } else { + entityID = nil + } + dollarRelation = append(dollarRelation, shared.DollarRelation{ + Tags: tags, + EntityID: entityID, + }) + } + files = &shared.BaseRelation{ + DollarRelation: dollarRelation, + } + } + var manifest []string = []string{} + for _, manifestItem := range r.Manifest { + manifest = append(manifest, manifestItem.ValueString()) + } schema := new(shared.TaxPatchSchema) if !r.Schema.IsUnknown() && !r.Schema.IsNull() { *schema = shared.TaxPatchSchema(r.Schema.ValueString()) } else { schema = nil } - active := new(bool) - if !r.Active.IsUnknown() && !r.Active.IsNull() { - *active = r.Active.ValueBool() - } else { - active = nil + var tags1 []string = []string{} + for _, tagsItem1 := range r.Tags { + tags1 = append(tags1, tagsItem1.ValueString()) } + var active bool + active = r.Active.ValueBool() + description := new(string) if !r.Description.IsUnknown() && !r.Description.IsNull() { *description = r.Description.ValueString() } else { description = nil } - rate := new(string) - if !r.Rate.IsUnknown() && !r.Rate.IsNull() { - *rate = r.Rate.ValueString() - } else { - rate = nil - } - region := new(string) - if !r.Region.IsUnknown() && !r.Region.IsNull() { - *region = r.Region.ValueString() - } else { - region = nil - } - typeVar := new(shared.TaxPatchType) - if !r.Type.IsUnknown() && !r.Type.IsNull() { - *typeVar = shared.TaxPatchType(r.Type.ValueString()) - } else { - typeVar = nil - } + var rate string + rate = r.Rate.ValueString() + + var region string + region = r.Region.ValueString() + + typeVar := shared.TaxPatchType(r.Type.ValueString()) out := shared.TaxPatch{ + Additional: additional, + Files: files, + Manifest: manifest, Schema: schema, + Tags: tags1, Active: active, Description: description, Rate: rate, diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index adb2f70..f1ff9e0 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -3,10 +3,12 @@ package utils import ( + "bytes" "context" "fmt" "io" "math/big" + "net/http" "reflect" "regexp" "strconv" @@ -228,3 +230,15 @@ func contains(arr []string, str string) bool { } return false } + +func ConsumeRawBody(res *http.Response) ([]byte, error) { + rawBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + + res.Body.Close() + res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + return rawBody, nil +} diff --git a/internal/sdk/models/shared/clienterror.go b/internal/sdk/models/shared/clienterror.go index 2797033..8fc6667 100644 --- a/internal/sdk/models/shared/clienterror.go +++ b/internal/sdk/models/shared/clienterror.go @@ -2,6 +2,7 @@ package shared +// ClientError - Any error based on client data errors type ClientError struct { Message string `json:"message"` Status int64 `json:"status"` diff --git a/internal/sdk/models/shared/servererror.go b/internal/sdk/models/shared/servererror.go index f8bea38..9ba15e2 100644 --- a/internal/sdk/models/shared/servererror.go +++ b/internal/sdk/models/shared/servererror.go @@ -2,6 +2,7 @@ package shared +// ServerError - Any error based on the server-side type ServerError struct { Message string `json:"message"` Status int64 `json:"status"` diff --git a/internal/sdk/models/shared/taxpatch.go b/internal/sdk/models/shared/taxpatch.go index 94b33e9..bdf2ad6 100644 --- a/internal/sdk/models/shared/taxpatch.go +++ b/internal/sdk/models/shared/taxpatch.go @@ -57,12 +57,39 @@ func (e *TaxPatchType) UnmarshalJSON(data []byte) error { } type TaxPatch struct { + // Additional fields that are not part of the schema + Additional map[string]any `json:"__additional,omitempty"` + Files *BaseRelation `json:"_files,omitempty"` + // Manifest ID used to create/update the entity + Manifest []string `json:"_manifest,omitempty"` Schema *TaxPatchSchema `json:"_schema,omitempty"` - Active *bool `json:"active,omitempty"` + Tags []string `json:"_tags,omitempty"` + Active bool `json:"active"` Description *string `json:"description,omitempty"` - Rate *string `json:"rate,omitempty"` - Region *string `json:"region,omitempty"` - Type *TaxPatchType `json:"type,omitempty"` + Rate string `json:"rate"` + Region string `json:"region"` + Type TaxPatchType `json:"type"` +} + +func (o *TaxPatch) GetAdditional() map[string]any { + if o == nil { + return nil + } + return o.Additional +} + +func (o *TaxPatch) GetFiles() *BaseRelation { + if o == nil { + return nil + } + return o.Files +} + +func (o *TaxPatch) GetManifest() []string { + if o == nil { + return nil + } + return o.Manifest } func (o *TaxPatch) GetSchema() *TaxPatchSchema { @@ -72,10 +99,17 @@ func (o *TaxPatch) GetSchema() *TaxPatchSchema { return o.Schema } -func (o *TaxPatch) GetActive() *bool { +func (o *TaxPatch) GetTags() []string { if o == nil { return nil } + return o.Tags +} + +func (o *TaxPatch) GetActive() bool { + if o == nil { + return false + } return o.Active } @@ -86,23 +120,23 @@ func (o *TaxPatch) GetDescription() *string { return o.Description } -func (o *TaxPatch) GetRate() *string { +func (o *TaxPatch) GetRate() string { if o == nil { - return nil + return "" } return o.Rate } -func (o *TaxPatch) GetRegion() *string { +func (o *TaxPatch) GetRegion() string { if o == nil { - return nil + return "" } return o.Region } -func (o *TaxPatch) GetType() *TaxPatchType { +func (o *TaxPatch) GetType() TaxPatchType { if o == nil { - return nil + return TaxPatchType("") } return o.Type } diff --git a/internal/sdk/price.go b/internal/sdk/price.go index ac25d9e..4aa0565 100644 --- a/internal/sdk/price.go +++ b/internal/sdk/price.go @@ -13,7 +13,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/shared" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/retry" - "io" "net/http" "net/url" ) @@ -182,21 +181,11 @@ func (s *Price) CreatePrice(ctx context.Context, request shared.PriceCreate, opt RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -208,17 +197,16 @@ func (s *Price) CreatePrice(ctx context.Context, request shared.PriceCreate, opt res.Price = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -230,17 +218,16 @@ func (s *Price) CreatePrice(ctx context.Context, request shared.PriceCreate, opt res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -252,19 +239,17 @@ func (s *Price) CreatePrice(ctx context.Context, request shared.PriceCreate, opt res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -419,21 +404,11 @@ func (s *Price) DeletePrice(ctx context.Context, request operations.DeletePriceR RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -445,17 +420,16 @@ func (s *Price) DeletePrice(ctx context.Context, request operations.DeletePriceR res.Price = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -467,17 +441,16 @@ func (s *Price) DeletePrice(ctx context.Context, request operations.DeletePriceR res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -489,19 +462,17 @@ func (s *Price) DeletePrice(ctx context.Context, request operations.DeletePriceR res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -660,21 +631,11 @@ func (s *Price) GetPrice(ctx context.Context, request operations.GetPriceRequest RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -686,17 +647,16 @@ func (s *Price) GetPrice(ctx context.Context, request operations.GetPriceRequest res.Price = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -708,17 +668,16 @@ func (s *Price) GetPrice(ctx context.Context, request operations.GetPriceRequest res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -730,19 +689,17 @@ func (s *Price) GetPrice(ctx context.Context, request operations.GetPriceRequest res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -903,21 +860,11 @@ func (s *Price) PatchPrice(ctx context.Context, request operations.PatchPriceReq RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -929,17 +876,16 @@ func (s *Price) PatchPrice(ctx context.Context, request operations.PatchPriceReq res.Price = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -951,17 +897,16 @@ func (s *Price) PatchPrice(ctx context.Context, request operations.PatchPriceReq res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -973,19 +918,17 @@ func (s *Price) PatchPrice(ctx context.Context, request operations.PatchPriceReq res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1146,21 +1089,11 @@ func (s *Price) UpdatePrice(ctx context.Context, request operations.UpdatePriceR RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1172,17 +1105,16 @@ func (s *Price) UpdatePrice(ctx context.Context, request operations.UpdatePriceR res.Price = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1194,17 +1126,16 @@ func (s *Price) UpdatePrice(ctx context.Context, request operations.UpdatePriceR res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1216,19 +1147,17 @@ func (s *Price) UpdatePrice(ctx context.Context, request operations.UpdatePriceR res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/sdk/product.go b/internal/sdk/product.go index 9a4bc17..c69149b 100644 --- a/internal/sdk/product.go +++ b/internal/sdk/product.go @@ -13,7 +13,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/shared" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/retry" - "io" "net/http" "net/url" ) @@ -182,21 +181,11 @@ func (s *Product) CreateProduct(ctx context.Context, request shared.ProductCreat RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -208,17 +197,16 @@ func (s *Product) CreateProduct(ctx context.Context, request shared.ProductCreat res.Product = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -230,17 +218,16 @@ func (s *Product) CreateProduct(ctx context.Context, request shared.ProductCreat res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -252,19 +239,17 @@ func (s *Product) CreateProduct(ctx context.Context, request shared.ProductCreat res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -419,21 +404,11 @@ func (s *Product) DeleteProduct(ctx context.Context, request operations.DeletePr RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -445,17 +420,16 @@ func (s *Product) DeleteProduct(ctx context.Context, request operations.DeletePr res.Product = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -467,17 +441,16 @@ func (s *Product) DeleteProduct(ctx context.Context, request operations.DeletePr res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -489,19 +462,17 @@ func (s *Product) DeleteProduct(ctx context.Context, request operations.DeletePr res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -660,21 +631,11 @@ func (s *Product) GetProduct(ctx context.Context, request operations.GetProductR RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -686,17 +647,16 @@ func (s *Product) GetProduct(ctx context.Context, request operations.GetProductR res.Product = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -708,17 +668,16 @@ func (s *Product) GetProduct(ctx context.Context, request operations.GetProductR res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -730,19 +689,17 @@ func (s *Product) GetProduct(ctx context.Context, request operations.GetProductR res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -903,21 +860,11 @@ func (s *Product) PatchProduct(ctx context.Context, request operations.PatchProd RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -929,17 +876,16 @@ func (s *Product) PatchProduct(ctx context.Context, request operations.PatchProd res.Product = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -951,17 +897,16 @@ func (s *Product) PatchProduct(ctx context.Context, request operations.PatchProd res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -973,19 +918,17 @@ func (s *Product) PatchProduct(ctx context.Context, request operations.PatchProd res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1146,21 +1089,11 @@ func (s *Product) UpdateProduct(ctx context.Context, request operations.UpdatePr RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1172,17 +1105,16 @@ func (s *Product) UpdateProduct(ctx context.Context, request operations.UpdatePr res.Product = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1194,17 +1126,16 @@ func (s *Product) UpdateProduct(ctx context.Context, request operations.UpdatePr res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1216,19 +1147,17 @@ func (s *Product) UpdateProduct(ctx context.Context, request operations.UpdatePr res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index bdeb019..a6287cf 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -153,8 +153,8 @@ func New(opts ...SDKOption) *SDK { Language: "go", OpenAPIDocVersion: "1.0.0", SDKVersion: "0.0.1", - GenVersion: "2.415.6", - UserAgent: "speakeasy-sdk/go 0.0.1 2.415.6 1.0.0 github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk", + GenVersion: "2.438.15", + UserAgent: "speakeasy-sdk/go 0.0.1 2.438.15 1.0.0 github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk", Hooks: hooks.New(), }, } diff --git a/internal/sdk/tax.go b/internal/sdk/tax.go index 957d56c..1883053 100644 --- a/internal/sdk/tax.go +++ b/internal/sdk/tax.go @@ -13,7 +13,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/models/shared" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/retry" - "io" "net/http" "net/url" ) @@ -182,21 +181,11 @@ func (s *Tax) CreateTax(ctx context.Context, request shared.TaxCreate, opts ...o RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -208,17 +197,16 @@ func (s *Tax) CreateTax(ctx context.Context, request shared.TaxCreate, opts ...o res.Tax = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -230,17 +218,16 @@ func (s *Tax) CreateTax(ctx context.Context, request shared.TaxCreate, opts ...o res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -252,19 +239,17 @@ func (s *Tax) CreateTax(ctx context.Context, request shared.TaxCreate, opts ...o res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -419,21 +404,11 @@ func (s *Tax) DeleteTax(ctx context.Context, request operations.DeleteTaxRequest RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -445,17 +420,16 @@ func (s *Tax) DeleteTax(ctx context.Context, request operations.DeleteTaxRequest res.Tax = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -467,17 +441,16 @@ func (s *Tax) DeleteTax(ctx context.Context, request operations.DeleteTaxRequest res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -489,19 +462,17 @@ func (s *Tax) DeleteTax(ctx context.Context, request operations.DeleteTaxRequest res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -660,21 +631,11 @@ func (s *Tax) GetTax(ctx context.Context, request operations.GetTaxRequest, opts RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -686,17 +647,16 @@ func (s *Tax) GetTax(ctx context.Context, request operations.GetTaxRequest, opts res.Tax = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -708,17 +668,16 @@ func (s *Tax) GetTax(ctx context.Context, request operations.GetTaxRequest, opts res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -730,19 +689,17 @@ func (s *Tax) GetTax(ctx context.Context, request operations.GetTaxRequest, opts res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -903,21 +860,11 @@ func (s *Tax) PatchTax(ctx context.Context, request operations.PatchTaxRequest, RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -929,17 +876,16 @@ func (s *Tax) PatchTax(ctx context.Context, request operations.PatchTaxRequest, res.Tax = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -951,17 +897,16 @@ func (s *Tax) PatchTax(ctx context.Context, request operations.PatchTaxRequest, res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -973,19 +918,17 @@ func (s *Tax) PatchTax(ctx context.Context, request operations.PatchTaxRequest, res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1146,21 +1089,11 @@ func (s *Tax) UpdateTax(ctx context.Context, request operations.UpdateTaxRequest RawResponse: httpRes, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1172,17 +1105,16 @@ func (s *Tax) UpdateTax(ctx context.Context, request operations.UpdateTaxRequest res.Tax = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1194,17 +1126,16 @@ func (s *Tax) UpdateTax(ctx context.Context, request operations.UpdateTaxRequest res.ClientError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1216,19 +1147,17 @@ func (s *Tax) UpdateTax(ctx context.Context, request operations.UpdateTaxRequest res.ServerError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/openapi.yml b/openapi.yml index b409232..68592cf 100644 --- a/openapi.yml +++ b/openapi.yml @@ -449,7 +449,10 @@ components: - $ref: "#/components/schemas/BaseTaxRequired" - $ref: "#/components/schemas/BaseSystemFields" TaxPatch: - $ref: "#/components/schemas/BaseTax" + allOf: + - $ref: "#/components/schemas/BaseTax" + - $ref: "#/components/schemas/BaseTaxRequired" + - $ref: "#/components/schemas/BaseSystemFields" BasePrice: type: object properties: