From 3d8c6dce0fa2c5687744642ca94b5a80a88d3bcf Mon Sep 17 00:00:00 2001 From: Nishu Goel Date: Sat, 2 Mar 2024 19:41:55 +0100 Subject: [PATCH] Update provider to not return internal fields except id --- .speakeasy/gen.lock | 11 +- README.md | 2 +- docs/data-sources/price.md | 19 +-- docs/data-sources/product.md | 29 +---- docs/index.md | 2 +- docs/resources/price.md | 20 +-- docs/resources/product.md | 45 ++----- docs/resources/tax.md | 5 +- examples/provider/provider.tf | 2 +- .../epilot-product_product/resource.tf | 25 ++-- examples/test/bla.tf | 22 ++-- examples/test/main.tf | 72 +++++------ examples/test/resource.tf | 22 ++++ gen.yaml | 2 +- internal/provider/price_data_source.go | 113 ++++------------- internal/provider/price_data_source_sdk.go | 42 ------ internal/provider/price_resource.go | 120 ++++-------------- internal/provider/price_resource_sdk.go | 42 ------ internal/provider/product_data_source.go | 87 ++----------- internal/provider/product_data_source_sdk.go | 42 ------ internal/provider/product_resource.go | 94 ++------------ internal/provider/product_resource_sdk.go | 42 ------ internal/provider/tax_data_source.go | 77 +---------- internal/provider/tax_data_source_sdk.go | 43 ------- internal/provider/tax_resource.go | 85 +------------ internal/provider/tax_resource_sdk.go | 43 ------- internal/provider/type_base_entity_acl.go | 12 -- internal/provider/type_base_entity_owner.go | 10 -- .../sdk/pkg/models/shared/baseentityacl.go | 54 -------- .../sdk/pkg/models/shared/baseentityowner.go | 25 ---- internal/sdk/pkg/models/shared/price.go | 69 +--------- internal/sdk/pkg/models/shared/product.go | 71 +---------- internal/sdk/pkg/models/shared/tax.go | 91 +------------ internal/sdk/sdk.go | 4 +- product.yaml | 15 +-- 35 files changed, 209 insertions(+), 1250 deletions(-) create mode 100644 examples/test/resource.tf delete mode 100644 internal/provider/type_base_entity_acl.go delete mode 100644 internal/provider/type_base_entity_owner.go delete mode 100644 internal/sdk/pkg/models/shared/baseentityacl.go delete mode 100644 internal/sdk/pkg/models/shared/baseentityowner.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 772fd68..909aff8 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: 996704943fed939b0f554e9a1ff48fd6 + docChecksum: 49ed280caef5eeece793d407c91311b9 docVersion: 1.0.0 speakeasyVersion: internal generationVersion: 2.230.1 - releaseVersion: 0.5.5 - configChecksum: 85cc1dec9461e8a74c3880ab671532cf + releaseVersion: 0.6.0 + configChecksum: 7343b8d7750f297d93a3e264e8b3bccf repoURL: https://github.com/epilot-dev/terraform-provider-epilot-product.git repoSubDirectory: . published: true @@ -20,7 +20,6 @@ features: globalServerURLs: 2.82.0 unions: 2.85.0 terraform: - additionalProperties: 0.1.2 constsAndDefaults: 0.1.2 core: 3.8.1 globalSecurity: 2.81.2 @@ -110,8 +109,6 @@ generatedFiles: - internal/sdk/pkg/models/shared/price.go - internal/sdk/pkg/models/shared/pricetier.go - internal/sdk/pkg/models/shared/pricetierdisplaymode.go - - internal/sdk/pkg/models/shared/baseentityowner.go - - internal/sdk/pkg/models/shared/baseentityacl.go - internal/sdk/pkg/models/shared/clienterror.go - internal/sdk/pkg/models/shared/pricecreate.go - internal/sdk/pkg/models/shared/pricepatch.go @@ -123,8 +120,6 @@ generatedFiles: - internal/sdk/pkg/models/shared/taxcreate.go - internal/sdk/pkg/models/shared/taxpatch.go - internal/sdk/pkg/models/shared/security.go - - internal/provider/type_base_entity_acl.go - - internal/provider/type_base_entity_owner.go - internal/provider/type_price_tier.go - internal/provider/type_price_create_unit.go - internal/provider/type_dollar_relation.go diff --git a/README.md b/README.md index bb62add..fd776a9 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ terraform { required_providers { epilot-product = { source = "epilot-dev/epilot-product" - version = "0.5.5" + version = "0.6.0" } } } diff --git a/docs/data-sources/price.md b/docs/data-sources/price.md index 55d5302..fe78d91 100644 --- a/docs/data-sources/price.md +++ b/docs/data-sources/price.md @@ -57,7 +57,7 @@ must be one of ["per_unit", "tiered_volume", "tiered_graduated", "tiered_flatfee - `renewal_duration_unit` (String) The renewal period duration unit. must be one of ["weeks", "months", "years"] - `schema` (String) - `tags` (List of String) -- `tax` (Attributes) (see [below for nested schema](#nestedatt--tax)) +- `tax` (String) Parsed as JSON. - `termination_time_amount` (Number) The termination period duration - `termination_time_unit` (String) The termination period duration unit. must be one of ["weeks", "months", "years"] - `tiers` (Attributes List) Defines an array of tiers. Each tier has an upper bound, an unit amount and a flat fee. (see [below for nested schema](#nestedatt--tiers)) @@ -90,23 +90,6 @@ Read-Only: - `user_id` (String) - -### Nested Schema for `tax` - -Read-Only: - -- `dollar_relation` (Attributes List) (see [below for nested schema](#nestedatt--tax--dollar_relation)) - - -### Nested Schema for `tax.dollar_relation` - -Read-Only: - -- `entity_id` (String) -- `tags` (List of String) - - - ### Nested Schema for `tiers` diff --git a/docs/data-sources/product.md b/docs/data-sources/product.md index 5649c07..cce7469 100644 --- a/docs/data-sources/product.md +++ b/docs/data-sources/product.md @@ -32,21 +32,15 @@ data "epilot-product_product" "my_product" { ### Read-Only -- `acl` (Attributes) Access control list (ACL) for an entity. Defines sharing access to external orgs or users. (see [below for nested schema](#nestedatt--acl)) - `active` (Boolean) - `code` (String) The product code -- `created_at` (String) - `description` (String) A description of the product. Multi-line supported. - `feature` (List of String) - `internal_name` (String) Not visible to customers, only in internal tables - `name` (String) The description for the product -- `org` (String) Organization Id the entity belongs to -- `owners` (Attributes List) (see [below for nested schema](#nestedatt--owners)) - `price_options` (Attributes) (see [below for nested schema](#nestedatt--price_options)) +- `product_downloads` (String) Parsed as JSON. - `product_images` (String) Parsed as JSON. -- `schema` (String) -- `tags` (List of String) -- `title` (String) - `type` (String) The type of Product: | type | description | @@ -55,27 +49,6 @@ data "epilot-product_product" "my_product" { | `service` | Represents a service or virtual product | must be one of ["product", "service"]; Default: "product" -- `updated_at` (String) - - -### Nested Schema for `acl` - -Read-Only: - -- `additional_properties` (String) Parsed as JSON. -- `delete` (List of String) -- `edit` (List of String) -- `view` (List of String) - - - -### Nested Schema for `owners` - -Read-Only: - -- `org_id` (String) -- `user_id` (String) - ### Nested Schema for `price_options` diff --git a/docs/index.md b/docs/index.md index 3d30ca5..42127fb 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.5.4" + version = "0.5.6" } } } diff --git a/docs/resources/price.md b/docs/resources/price.md index 650c495..c70aeb8 100644 --- a/docs/resources/price.md +++ b/docs/resources/price.md @@ -27,6 +27,7 @@ resource "epilot-product_price" "my_price" { pricing_model = "per_unit" renewal_duration_amount = 66.53 renewal_duration_unit = "months" + tax = "{ \"see\": \"documentation\" }" termination_time_amount = 20 termination_time_unit = "weeks" type = "recurring" @@ -64,7 +65,7 @@ resource "epilot-product_price" "my_price" { must be one of ["per_unit", "tiered_volume", "tiered_graduated", "tiered_flatfee"]; Default: "per_unit" - `renewal_duration_amount` (Number) The renewal period duration - `renewal_duration_unit` (String) The renewal period duration unit. must be one of ["weeks", "months", "years"] -- `tax` (Attributes) (see [below for nested schema](#nestedatt--tax)) +- `tax` (String) Parsed as JSON. - `termination_time_amount` (Number) The termination period duration - `termination_time_unit` (String) The termination period duration unit. must be one of ["weeks", "months", "years"] - `tiers` (Attributes List) Defines an array of tiers. Each tier has an upper bound, an unit amount and a flat fee. (see [below for nested schema](#nestedatt--tiers)) @@ -87,23 +88,6 @@ must be one of ["per_unit", "tiered_volume", "tiered_graduated", "tiered_flatfee - `title` (String) - `updated_at` (String) - -### Nested Schema for `tax` - -Optional: - -- `dollar_relation` (Attributes List) (see [below for nested schema](#nestedatt--tax--dollar_relation)) - - -### Nested Schema for `tax.dollar_relation` - -Optional: - -- `entity_id` (String) -- `tags` (List of String) - - - ### Nested Schema for `tiers` diff --git a/docs/resources/product.md b/docs/resources/product.md index 0de3b89..3d4de07 100644 --- a/docs/resources/product.md +++ b/docs/resources/product.md @@ -14,13 +14,14 @@ Product Resource ```terraform resource "epilot-product_product" "my_product" { - active = true - code = "...my_code..." - description = "...my_description..." - internal_name = "...my_internal_name..." - name = "Juan Morar Jr." - product_images = "{ \"see\": \"documentation\" }" - type = "product" + active = true + code = "...my_code..." + description = "...my_description..." + internal_name = "...my_internal_name..." + name = "Juan Morar Jr." + product_downloads = "{ \"see\": \"documentation\" }" + product_images = "{ \"see\": \"documentation\" }" + type = "product" } ``` @@ -39,6 +40,7 @@ resource "epilot-product_product" "my_product" { - `feature` (List of String) - `internal_name` (String) Not visible to customers, only in internal tables - `price_options` (Attributes) (see [below for nested schema](#nestedatt--price_options)) +- `product_downloads` (String) Parsed as JSON. - `product_images` (String) Parsed as JSON. - `type` (String) The type of Product: @@ -51,15 +53,7 @@ must be one of ["product", "service"]; Default: "product" ### Read-Only -- `acl` (Attributes) Access control list (ACL) for an entity. Defines sharing access to external orgs or users. (see [below for nested schema](#nestedatt--acl)) -- `created_at` (String) - `id` (String) The product id -- `org` (String) Organization Id the entity belongs to -- `owners` (Attributes List) (see [below for nested schema](#nestedatt--owners)) -- `schema` (String) -- `tags` (List of String) -- `title` (String) -- `updated_at` (String) ### Nested Schema for `price_options` @@ -77,24 +71,3 @@ Optional: - `tags` (List of String) - - -### Nested Schema for `acl` - -Read-Only: - -- `additional_properties` (String) Parsed as JSON. -- `delete` (List of String) -- `edit` (List of String) -- `view` (List of String) - - - -### Nested Schema for `owners` - -Read-Only: - -- `org_id` (String) -- `user_id` (String) - - diff --git a/docs/resources/tax.md b/docs/resources/tax.md index 66b0673..2ba62a4 100644 --- a/docs/resources/tax.md +++ b/docs/resources/tax.md @@ -28,11 +28,14 @@ resource "epilot-product_tax" "my_tax" { ### Required - `active` (Boolean) -- `description` (String) - `rate` (String) - `region` (String) must be one of ["DE", "AT", "CH"] - `type` (String) must be one of ["VAT", "Custom"] +### Optional + +- `description` (String) + ### Read-Only - `acl` (Attributes) Access control list (ACL) for an entity. Defines sharing access to external orgs or users. (see [below for nested schema](#nestedatt--acl)) diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 58c8123..0532c47 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.5.5" + version = "0.6.0" } } } diff --git a/examples/resources/epilot-product_product/resource.tf b/examples/resources/epilot-product_product/resource.tf index 0bd6222..9238110 100644 --- a/examples/resources/epilot-product_product/resource.tf +++ b/examples/resources/epilot-product_product/resource.tf @@ -1,15 +1,10 @@ -# resource "epilot-product_product" "my_product" { -# active = true -# code = "...my_code..." -# description = "...my_description..." -# internal_name = "...my_internal_name..." -# name = "Juan Morar Jr." -# product_downloads = "{ \"see\": \"documentation\" }" -# product_images = "{ \"see\": \"documentation\" }" -# type = "product" -# } - - -# resource "epilot-product_product" "new_product" {} - -resource "epilot-product_price" "new_price" {} \ No newline at end of file +resource "epilot-product_product" "my_product" { + active = true + code = "...my_code..." + description = "...my_description..." + internal_name = "...my_internal_name..." + name = "Juan Morar Jr." + product_downloads = "{ \"see\": \"documentation\" }" + product_images = "{ \"see\": \"documentation\" }" + type = "product" +} \ No newline at end of file diff --git a/examples/test/bla.tf b/examples/test/bla.tf index 3dae462..567713f 100644 --- a/examples/test/bla.tf +++ b/examples/test/bla.tf @@ -1,9 +1,9 @@ terraform { required_providers { - epilot-journey = { - source = "epilot-dev/epilot-journey" - version = "0.3.0" - } + # epilot-journey = { + # source = "epilot-dev/epilot-journey" + # version = "0.3.0" + # } epilot-product = { source = "epilot-dev/epilot-product" version = "0.6.0" @@ -25,11 +25,17 @@ provider "epilot-product" { epilot_auth = var.epilot_auth } -import { - to = epilot-product_product.s_product - id = "103f1186-7f7c-42d1-8891-00868a589cf3" -} +# import { +# to = epilot-product_product.s_product +# id = "103f1186-7f7c-42d1-8891-00868a589cf3" +# # } # resource "epilot-product_product" "s_product" { # } + + + +# resource "epilot-product_tax" "s_tax" { +# # (resource arguments) +# } \ No newline at end of file diff --git a/examples/test/main.tf b/examples/test/main.tf index 06c0f3e..f12ee28 100644 --- a/examples/test/main.tf +++ b/examples/test/main.tf @@ -1,36 +1,36 @@ -# epilot-product_product.s_product: -resource "epilot-product_product" "s_product" { - acl = { - delete = [ - "org_66", - ] - edit = [ - "org_66", - ] - view = [ - "org_66", - ] - } - active = true - created_at = "2024-02-07T14:44:33.799Z" - id = "103f1186-7f7c-42d1-8891-00868a589cf3" - name = "Product PH - Heating" - org = "66" - owners = [ - { - org_id = "66" - user_id = "77701" - }, - ] - price_options = { - dollar_relation = [ - { - entity_id = "cbcf02eb-bfca-4317-912b-7f4db997a739" - }, - ] - } - schema = "product" - title = "Product PH - Heating" - type = "product" - updated_at = "2024-02-07T14:44:33.799Z" -} +# # epilot-product_product.s_product: +# resource "epilot-product_product" "s_product" { +# acl = { +# delete = [ +# "org_66", +# ] +# edit = [ +# "org_66", +# ] +# view = [ +# "org_66", +# ] +# } +# active = true +# created_at = "2024-02-07T14:44:33.799Z" +# id = "103f1186-7f7c-42d1-8891-00868a589cf3" +# name = "Product PH - Heating" +# org = "66" +# owners = [ +# { +# org_id = "66" +# user_id = "77701" +# }, +# ] +# price_options = { +# dollar_relation = [ +# { +# entity_id = "cbcf02eb-bfca-4317-912b-7f4db997a739" +# }, +# ] +# } +# schema = "product" +# title = "Product PH - Heating" +# type = "product" +# updated_at = "2024-02-07T14:44:33.799Z" +# } diff --git a/examples/test/resource.tf b/examples/test/resource.tf new file mode 100644 index 0000000..50bfdb5 --- /dev/null +++ b/examples/test/resource.tf @@ -0,0 +1,22 @@ +# epilot-product_product.s_product: +resource "epilot-product_product" "s_product" { + active = true + internal_name = "Price testing" + name = "Night storage heating tariff" + price_options = { + dollar_relation = [ + { + entity_id = "f6194ac9-eb96-49e3-a21a-9ee9d19420b9" + }, + ] + } + type = "product" +} + +# epilot-product_tax.s_tax: +resource "epilot-product_tax" "s_tax" { + active = true + rate = "0" + region = "DE" + type = "VAT" +} diff --git a/gen.yaml b/gen.yaml index c19c6e5..71a8500 100644 --- a/gen.yaml +++ b/gen.yaml @@ -23,7 +23,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.5.5 + version: 0.6.0 author: epilot-dev imports: option: openapi diff --git a/internal/provider/price_data_source.go b/internal/provider/price_data_source.go index d3e5787..ab5bc4f 100644 --- a/internal/provider/price_data_source.go +++ b/internal/provider/price_data_source.go @@ -28,39 +28,31 @@ type PriceDataSource struct { // PriceDataSourceModel describes the data model. type PriceDataSourceModel struct { - ACL BaseEntityACL `tfsdk:"acl"` - CreatedAt types.String `tfsdk:"created_at"` - Org types.String `tfsdk:"org"` - Owners []BaseEntityOwner `tfsdk:"owners"` - Schema types.String `tfsdk:"schema"` - Tags []types.String `tfsdk:"tags"` - Title types.String `tfsdk:"title"` - UpdatedAt types.String `tfsdk:"updated_at"` - Active types.Bool `tfsdk:"active"` - BillingDurationAmount types.Number `tfsdk:"billing_duration_amount"` - BillingDurationUnit types.String `tfsdk:"billing_duration_unit"` - Description types.String `tfsdk:"description"` - Hydrate types.Bool `tfsdk:"hydrate"` - ID types.String `tfsdk:"id"` - IsCompositePrice types.Bool `tfsdk:"is_composite_price"` - IsTaxInclusive types.Bool `tfsdk:"is_tax_inclusive"` - LongDescription types.String `tfsdk:"long_description"` - NoticeTimeAmount types.Number `tfsdk:"notice_time_amount"` - NoticeTimeUnit types.String `tfsdk:"notice_time_unit"` - PriceDisplayInJourneys types.String `tfsdk:"price_display_in_journeys"` - PricingModel types.String `tfsdk:"pricing_model"` - RenewalDurationAmount types.Number `tfsdk:"renewal_duration_amount"` - RenewalDurationUnit types.String `tfsdk:"renewal_duration_unit"` - Tax types.String `tfsdk:"tax"` - TerminationTimeAmount types.Number `tfsdk:"termination_time_amount"` - TerminationTimeUnit types.String `tfsdk:"termination_time_unit"` - Tiers []PriceTier `tfsdk:"tiers"` - Type types.String `tfsdk:"type"` - Unit *PriceCreateUnit `tfsdk:"unit"` - UnitAmount types.Number `tfsdk:"unit_amount"` - UnitAmountCurrency types.String `tfsdk:"unit_amount_currency"` - UnitAmountDecimal types.String `tfsdk:"unit_amount_decimal"` - VariablePrice types.Bool `tfsdk:"variable_price"` + Active types.Bool `tfsdk:"active"` + BillingDurationAmount types.Number `tfsdk:"billing_duration_amount"` + BillingDurationUnit types.String `tfsdk:"billing_duration_unit"` + Description types.String `tfsdk:"description"` + Hydrate types.Bool `tfsdk:"hydrate"` + ID types.String `tfsdk:"id"` + IsCompositePrice types.Bool `tfsdk:"is_composite_price"` + IsTaxInclusive types.Bool `tfsdk:"is_tax_inclusive"` + LongDescription types.String `tfsdk:"long_description"` + NoticeTimeAmount types.Number `tfsdk:"notice_time_amount"` + NoticeTimeUnit types.String `tfsdk:"notice_time_unit"` + PriceDisplayInJourneys types.String `tfsdk:"price_display_in_journeys"` + PricingModel types.String `tfsdk:"pricing_model"` + RenewalDurationAmount types.Number `tfsdk:"renewal_duration_amount"` + RenewalDurationUnit types.String `tfsdk:"renewal_duration_unit"` + Tax types.String `tfsdk:"tax"` + TerminationTimeAmount types.Number `tfsdk:"termination_time_amount"` + TerminationTimeUnit types.String `tfsdk:"termination_time_unit"` + Tiers []PriceTier `tfsdk:"tiers"` + Type types.String `tfsdk:"type"` + Unit *PriceCreateUnit `tfsdk:"unit"` + UnitAmount types.Number `tfsdk:"unit_amount"` + UnitAmountCurrency types.String `tfsdk:"unit_amount_currency"` + UnitAmountDecimal types.String `tfsdk:"unit_amount_decimal"` + VariablePrice types.Bool `tfsdk:"variable_price"` } // Metadata returns the data source type name. @@ -74,61 +66,6 @@ func (r *PriceDataSource) Schema(ctx context.Context, req datasource.SchemaReque MarkdownDescription: "Price DataSource", Attributes: map[string]schema.Attribute{ - "acl": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "delete": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "edit": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "view": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Access control list (ACL) for an entity. Defines sharing access to external orgs or users.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - }, - "org": schema.StringAttribute{ - Computed: true, - Description: `Organization Id the entity belongs to`, - }, - "owners": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - }, "active": schema.BoolAttribute{ Computed: true, Description: `Whether the price can be used for new purchases.`, diff --git a/internal/provider/price_data_source_sdk.go b/internal/provider/price_data_source_sdk.go index d43e2e3..a0bff82 100644 --- a/internal/provider/price_data_source_sdk.go +++ b/internal/provider/price_data_source_sdk.go @@ -7,51 +7,9 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" "math/big" - "time" ) func (r *PriceDataSourceModel) RefreshFromSharedPrice(resp *shared.Price) { - if resp.ACL.AdditionalProperties == nil { - r.ACL.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.ACL.AdditionalProperties) - r.ACL.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - r.ACL.Delete = nil - for _, v := range resp.ACL.Delete { - r.ACL.Delete = append(r.ACL.Delete, types.StringValue(v)) - } - r.ACL.Edit = nil - for _, v := range resp.ACL.Edit { - r.ACL.Edit = append(r.ACL.Edit, types.StringValue(v)) - } - r.ACL.View = nil - for _, v := range resp.ACL.View { - r.ACL.View = append(r.ACL.View, types.StringValue(v)) - } - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) - r.Org = types.StringValue(resp.Org) - if len(r.Owners) > len(resp.Owners) { - r.Owners = r.Owners[:len(resp.Owners)] - } - for ownersCount, ownersItem := range resp.Owners { - var owners1 BaseEntityOwner - owners1.OrgID = types.StringValue(ownersItem.OrgID) - owners1.UserID = types.StringPointerValue(ownersItem.UserID) - if ownersCount+1 > len(r.Owners) { - r.Owners = append(r.Owners, owners1) - } else { - r.Owners[ownersCount].OrgID = owners1.OrgID - r.Owners[ownersCount].UserID = owners1.UserID - } - } - r.Schema = types.StringValue(resp.Schema) - r.Tags = nil - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - r.Title = types.StringValue(resp.Title) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) r.Active = types.BoolValue(resp.Active) if resp.BillingDurationAmount != nil { r.BillingDurationAmount = types.NumberValue(big.NewFloat(float64(*resp.BillingDurationAmount))) diff --git a/internal/provider/price_resource.go b/internal/provider/price_resource.go index 1877406..ba0980f 100644 --- a/internal/provider/price_resource.go +++ b/internal/provider/price_resource.go @@ -32,38 +32,30 @@ type PriceResource struct { // PriceResourceModel describes the resource data model. type PriceResourceModel struct { - ACL BaseEntityACL `tfsdk:"acl"` - CreatedAt types.String `tfsdk:"created_at"` - ID types.String `tfsdk:"id"` - Org types.String `tfsdk:"org"` - Owners []BaseEntityOwner `tfsdk:"owners"` - Schema types.String `tfsdk:"schema"` - Tags []types.String `tfsdk:"tags"` - Title types.String `tfsdk:"title"` - UpdatedAt types.String `tfsdk:"updated_at"` - Active types.Bool `tfsdk:"active"` - BillingDurationAmount types.Number `tfsdk:"billing_duration_amount"` - BillingDurationUnit types.String `tfsdk:"billing_duration_unit"` - Description types.String `tfsdk:"description"` - IsCompositePrice types.Bool `tfsdk:"is_composite_price"` - IsTaxInclusive types.Bool `tfsdk:"is_tax_inclusive"` - LongDescription types.String `tfsdk:"long_description"` - NoticeTimeAmount types.Number `tfsdk:"notice_time_amount"` - NoticeTimeUnit types.String `tfsdk:"notice_time_unit"` - PriceDisplayInJourneys types.String `tfsdk:"price_display_in_journeys"` - PricingModel types.String `tfsdk:"pricing_model"` - RenewalDurationAmount types.Number `tfsdk:"renewal_duration_amount"` - RenewalDurationUnit types.String `tfsdk:"renewal_duration_unit"` - Tax types.String `tfsdk:"tax"` - TerminationTimeAmount types.Number `tfsdk:"termination_time_amount"` - TerminationTimeUnit types.String `tfsdk:"termination_time_unit"` - Tiers []PriceTier `tfsdk:"tiers"` - Type types.String `tfsdk:"type"` - Unit *PriceCreateUnit `tfsdk:"unit"` - UnitAmount types.Number `tfsdk:"unit_amount"` - UnitAmountCurrency types.String `tfsdk:"unit_amount_currency"` - UnitAmountDecimal types.String `tfsdk:"unit_amount_decimal"` - VariablePrice types.Bool `tfsdk:"variable_price"` + ID types.String `tfsdk:"id"` + Active types.Bool `tfsdk:"active"` + BillingDurationAmount types.Number `tfsdk:"billing_duration_amount"` + BillingDurationUnit types.String `tfsdk:"billing_duration_unit"` + Description types.String `tfsdk:"description"` + IsCompositePrice types.Bool `tfsdk:"is_composite_price"` + IsTaxInclusive types.Bool `tfsdk:"is_tax_inclusive"` + LongDescription types.String `tfsdk:"long_description"` + NoticeTimeAmount types.Number `tfsdk:"notice_time_amount"` + NoticeTimeUnit types.String `tfsdk:"notice_time_unit"` + PriceDisplayInJourneys types.String `tfsdk:"price_display_in_journeys"` + PricingModel types.String `tfsdk:"pricing_model"` + RenewalDurationAmount types.Number `tfsdk:"renewal_duration_amount"` + RenewalDurationUnit types.String `tfsdk:"renewal_duration_unit"` + Tax types.String `tfsdk:"tax"` + TerminationTimeAmount types.Number `tfsdk:"termination_time_amount"` + TerminationTimeUnit types.String `tfsdk:"termination_time_unit"` + Tiers []PriceTier `tfsdk:"tiers"` + Type types.String `tfsdk:"type"` + Unit *PriceCreateUnit `tfsdk:"unit"` + UnitAmount types.Number `tfsdk:"unit_amount"` + UnitAmountCurrency types.String `tfsdk:"unit_amount_currency"` + UnitAmountDecimal types.String `tfsdk:"unit_amount_decimal"` + VariablePrice types.Bool `tfsdk:"variable_price"` } func (r *PriceResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -75,74 +67,10 @@ func (r *PriceResource) Schema(ctx context.Context, req resource.SchemaRequest, MarkdownDescription: "Price Resource", Attributes: map[string]schema.Attribute{ - "acl": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "delete": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "edit": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "view": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Access control list (ACL) for an entity. Defines sharing access to external orgs or users.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, "id": schema.StringAttribute{ Computed: true, Description: `The price id`, }, - "org": schema.StringAttribute{ - Computed: true, - Description: `Organization Id the entity belongs to`, - }, - "owners": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, "active": schema.BoolAttribute{ Required: true, Description: `Whether the price can be used for new purchases.`, diff --git a/internal/provider/price_resource_sdk.go b/internal/provider/price_resource_sdk.go index 63b19b0..5bfe133 100644 --- a/internal/provider/price_resource_sdk.go +++ b/internal/provider/price_resource_sdk.go @@ -7,7 +7,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" "math/big" - "time" ) func (r *PriceResourceModel) ToSharedPriceCreate() *shared.PriceCreate { @@ -226,48 +225,7 @@ func (r *PriceResourceModel) ToSharedPriceCreate() *shared.PriceCreate { } func (r *PriceResourceModel) RefreshFromSharedPrice(resp *shared.Price) { - if resp.ACL.AdditionalProperties == nil { - r.ACL.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.ACL.AdditionalProperties) - r.ACL.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - r.ACL.Delete = nil - for _, v := range resp.ACL.Delete { - r.ACL.Delete = append(r.ACL.Delete, types.StringValue(v)) - } - r.ACL.Edit = nil - for _, v := range resp.ACL.Edit { - r.ACL.Edit = append(r.ACL.Edit, types.StringValue(v)) - } - r.ACL.View = nil - for _, v := range resp.ACL.View { - r.ACL.View = append(r.ACL.View, types.StringValue(v)) - } - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) r.ID = types.StringValue(resp.ID) - r.Org = types.StringValue(resp.Org) - if len(r.Owners) > len(resp.Owners) { - r.Owners = r.Owners[:len(resp.Owners)] - } - for ownersCount, ownersItem := range resp.Owners { - var owners1 BaseEntityOwner - owners1.OrgID = types.StringValue(ownersItem.OrgID) - owners1.UserID = types.StringPointerValue(ownersItem.UserID) - if ownersCount+1 > len(r.Owners) { - r.Owners = append(r.Owners, owners1) - } else { - r.Owners[ownersCount].OrgID = owners1.OrgID - r.Owners[ownersCount].UserID = owners1.UserID - } - } - r.Schema = types.StringValue(resp.Schema) - r.Tags = nil - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - r.Title = types.StringValue(resp.Title) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) r.Active = types.BoolValue(resp.Active) if resp.BillingDurationAmount != nil { r.BillingDurationAmount = types.NumberValue(big.NewFloat(float64(*resp.BillingDurationAmount))) diff --git a/internal/provider/product_data_source.go b/internal/provider/product_data_source.go index 422b443..b22ea3f 100644 --- a/internal/provider/product_data_source.go +++ b/internal/provider/product_data_source.go @@ -28,26 +28,18 @@ type ProductDataSource struct { // ProductDataSourceModel describes the data model. type ProductDataSourceModel struct { - ACL BaseEntityACL `tfsdk:"acl"` - CreatedAt types.String `tfsdk:"created_at"` - Org types.String `tfsdk:"org"` - Owners []BaseEntityOwner `tfsdk:"owners"` - Schema types.String `tfsdk:"schema"` - Tags []types.String `tfsdk:"tags"` - Title types.String `tfsdk:"title"` - UpdatedAt types.String `tfsdk:"updated_at"` - Active types.Bool `tfsdk:"active"` - Code types.String `tfsdk:"code"` - Description types.String `tfsdk:"description"` - Feature []types.String `tfsdk:"feature"` - Hydrate types.Bool `tfsdk:"hydrate"` - ID types.String `tfsdk:"id"` - InternalName types.String `tfsdk:"internal_name"` - Name types.String `tfsdk:"name"` - PriceOptions *BaseRelation `tfsdk:"price_options"` - ProductDownloads types.String `tfsdk:"product_downloads"` - ProductImages types.String `tfsdk:"product_images"` - Type types.String `tfsdk:"type"` + Active types.Bool `tfsdk:"active"` + Code types.String `tfsdk:"code"` + Description types.String `tfsdk:"description"` + Feature []types.String `tfsdk:"feature"` + Hydrate types.Bool `tfsdk:"hydrate"` + ID types.String `tfsdk:"id"` + InternalName types.String `tfsdk:"internal_name"` + Name types.String `tfsdk:"name"` + PriceOptions *BaseRelation `tfsdk:"price_options"` + ProductDownloads types.String `tfsdk:"product_downloads"` + ProductImages types.String `tfsdk:"product_images"` + Type types.String `tfsdk:"type"` } // Metadata returns the data source type name. @@ -61,61 +53,6 @@ func (r *ProductDataSource) Schema(ctx context.Context, req datasource.SchemaReq MarkdownDescription: "Product DataSource", Attributes: map[string]schema.Attribute{ - "acl": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "delete": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "edit": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "view": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Access control list (ACL) for an entity. Defines sharing access to external orgs or users.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - }, - "org": schema.StringAttribute{ - Computed: true, - Description: `Organization Id the entity belongs to`, - }, - "owners": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - }, "active": schema.BoolAttribute{ Computed: true, }, diff --git a/internal/provider/product_data_source_sdk.go b/internal/provider/product_data_source_sdk.go index 4f10849..87e77e6 100644 --- a/internal/provider/product_data_source_sdk.go +++ b/internal/provider/product_data_source_sdk.go @@ -6,51 +6,9 @@ import ( "encoding/json" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" - "time" ) func (r *ProductDataSourceModel) RefreshFromSharedProduct(resp *shared.Product) { - if resp.ACL.AdditionalProperties == nil { - r.ACL.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.ACL.AdditionalProperties) - r.ACL.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - r.ACL.Delete = nil - for _, v := range resp.ACL.Delete { - r.ACL.Delete = append(r.ACL.Delete, types.StringValue(v)) - } - r.ACL.Edit = nil - for _, v := range resp.ACL.Edit { - r.ACL.Edit = append(r.ACL.Edit, types.StringValue(v)) - } - r.ACL.View = nil - for _, v := range resp.ACL.View { - r.ACL.View = append(r.ACL.View, types.StringValue(v)) - } - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) - r.Org = types.StringValue(resp.Org) - if len(r.Owners) > len(resp.Owners) { - r.Owners = r.Owners[:len(resp.Owners)] - } - for ownersCount, ownersItem := range resp.Owners { - var owners1 BaseEntityOwner - owners1.OrgID = types.StringValue(ownersItem.OrgID) - owners1.UserID = types.StringPointerValue(ownersItem.UserID) - if ownersCount+1 > len(r.Owners) { - r.Owners = append(r.Owners, owners1) - } else { - r.Owners[ownersCount].OrgID = owners1.OrgID - r.Owners[ownersCount].UserID = owners1.UserID - } - } - r.Schema = types.StringValue(resp.Schema) - r.Tags = nil - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - r.Title = types.StringValue(resp.Title) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) r.Active = types.BoolValue(resp.Active) r.Code = types.StringPointerValue(resp.Code) r.Description = types.StringPointerValue(resp.Description) diff --git a/internal/provider/product_resource.go b/internal/provider/product_resource.go index f27660a..416aefe 100644 --- a/internal/provider/product_resource.go +++ b/internal/provider/product_resource.go @@ -33,25 +33,17 @@ type ProductResource struct { // ProductResourceModel describes the resource data model. type ProductResourceModel struct { - ACL BaseEntityACL `tfsdk:"acl"` - CreatedAt types.String `tfsdk:"created_at"` - ID types.String `tfsdk:"id"` - Org types.String `tfsdk:"org"` - Owners []BaseEntityOwner `tfsdk:"owners"` - Schema types.String `tfsdk:"schema"` - Tags []types.String `tfsdk:"tags"` - Title types.String `tfsdk:"title"` - UpdatedAt types.String `tfsdk:"updated_at"` - Active types.Bool `tfsdk:"active"` - Code types.String `tfsdk:"code"` - Description types.String `tfsdk:"description"` - Feature []types.String `tfsdk:"feature"` - InternalName types.String `tfsdk:"internal_name"` - Name types.String `tfsdk:"name"` - PriceOptions *BaseRelation `tfsdk:"price_options"` - ProductDownloads types.String `tfsdk:"product_downloads"` - ProductImages types.String `tfsdk:"product_images"` - Type types.String `tfsdk:"type"` + ID types.String `tfsdk:"id"` + Active types.Bool `tfsdk:"active"` + Code types.String `tfsdk:"code"` + Description types.String `tfsdk:"description"` + Feature []types.String `tfsdk:"feature"` + InternalName types.String `tfsdk:"internal_name"` + Name types.String `tfsdk:"name"` + PriceOptions *BaseRelation `tfsdk:"price_options"` + ProductDownloads types.String `tfsdk:"product_downloads"` + ProductImages types.String `tfsdk:"product_images"` + Type types.String `tfsdk:"type"` } func (r *ProductResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -63,74 +55,10 @@ func (r *ProductResource) Schema(ctx context.Context, req resource.SchemaRequest MarkdownDescription: "Product Resource", Attributes: map[string]schema.Attribute{ - "acl": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "delete": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "edit": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "view": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Access control list (ACL) for an entity. Defines sharing access to external orgs or users.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, "id": schema.StringAttribute{ Computed: true, Description: `The product id`, }, - "org": schema.StringAttribute{ - Computed: true, - Description: `Organization Id the entity belongs to`, - }, - "owners": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, "active": schema.BoolAttribute{ Required: true, }, diff --git a/internal/provider/product_resource_sdk.go b/internal/provider/product_resource_sdk.go index c69266b..fb917ff 100644 --- a/internal/provider/product_resource_sdk.go +++ b/internal/provider/product_resource_sdk.go @@ -6,7 +6,6 @@ import ( "encoding/json" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" - "time" ) func (r *ProductResourceModel) ToSharedProductCreate() *shared.ProductCreate { @@ -89,48 +88,7 @@ func (r *ProductResourceModel) ToSharedProductCreate() *shared.ProductCreate { } func (r *ProductResourceModel) RefreshFromSharedProduct(resp *shared.Product) { - if resp.ACL.AdditionalProperties == nil { - r.ACL.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.ACL.AdditionalProperties) - r.ACL.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - r.ACL.Delete = nil - for _, v := range resp.ACL.Delete { - r.ACL.Delete = append(r.ACL.Delete, types.StringValue(v)) - } - r.ACL.Edit = nil - for _, v := range resp.ACL.Edit { - r.ACL.Edit = append(r.ACL.Edit, types.StringValue(v)) - } - r.ACL.View = nil - for _, v := range resp.ACL.View { - r.ACL.View = append(r.ACL.View, types.StringValue(v)) - } - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) r.ID = types.StringValue(resp.ID) - r.Org = types.StringValue(resp.Org) - if len(r.Owners) > len(resp.Owners) { - r.Owners = r.Owners[:len(resp.Owners)] - } - for ownersCount, ownersItem := range resp.Owners { - var owners1 BaseEntityOwner - owners1.OrgID = types.StringValue(ownersItem.OrgID) - owners1.UserID = types.StringPointerValue(ownersItem.UserID) - if ownersCount+1 > len(r.Owners) { - r.Owners = append(r.Owners, owners1) - } else { - r.Owners[ownersCount].OrgID = owners1.OrgID - r.Owners[ownersCount].UserID = owners1.UserID - } - } - r.Schema = types.StringValue(resp.Schema) - r.Tags = nil - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - r.Title = types.StringValue(resp.Title) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) r.Active = types.BoolValue(resp.Active) r.Code = types.StringPointerValue(resp.Code) r.Description = types.StringPointerValue(resp.Description) diff --git a/internal/provider/tax_data_source.go b/internal/provider/tax_data_source.go index fdf1a2e..84bfc10 100644 --- a/internal/provider/tax_data_source.go +++ b/internal/provider/tax_data_source.go @@ -28,21 +28,13 @@ type TaxDataSource struct { // TaxDataSourceModel describes the data model. type TaxDataSourceModel struct { - ACL BaseEntityACL `tfsdk:"acl"` - CreatedAt types.String `tfsdk:"created_at"` - Org types.String `tfsdk:"org"` - Owners []BaseEntityOwner `tfsdk:"owners"` - Schema types.String `tfsdk:"schema"` - Tags []types.String `tfsdk:"tags"` - Title types.String `tfsdk:"title"` - UpdatedAt types.String `tfsdk:"updated_at"` - Active types.Bool `tfsdk:"active"` - Description types.String `tfsdk:"description"` - Hydrate types.Bool `tfsdk:"hydrate"` - ID types.String `tfsdk:"id"` - Rate types.String `tfsdk:"rate"` - Region types.String `tfsdk:"region"` - Type types.String `tfsdk:"type"` + Active types.Bool `tfsdk:"active"` + Description types.String `tfsdk:"description"` + Hydrate types.Bool `tfsdk:"hydrate"` + ID types.String `tfsdk:"id"` + Rate types.String `tfsdk:"rate"` + Region types.String `tfsdk:"region"` + Type types.String `tfsdk:"type"` } // Metadata returns the data source type name. @@ -56,61 +48,6 @@ func (r *TaxDataSource) Schema(ctx context.Context, req datasource.SchemaRequest MarkdownDescription: "Tax DataSource", Attributes: map[string]schema.Attribute{ - "acl": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "delete": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "edit": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "view": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Access control list (ACL) for an entity. Defines sharing access to external orgs or users.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - }, - "org": schema.StringAttribute{ - Computed: true, - Description: `Organization Id the entity belongs to`, - }, - "owners": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - }, "active": schema.BoolAttribute{ Computed: true, }, diff --git a/internal/provider/tax_data_source_sdk.go b/internal/provider/tax_data_source_sdk.go index 7b8aadb..17959fc 100644 --- a/internal/provider/tax_data_source_sdk.go +++ b/internal/provider/tax_data_source_sdk.go @@ -3,54 +3,11 @@ package provider import ( - "encoding/json" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" - "time" ) func (r *TaxDataSourceModel) RefreshFromSharedTax(resp *shared.Tax) { - if resp.ACL.AdditionalProperties == nil { - r.ACL.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.ACL.AdditionalProperties) - r.ACL.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - r.ACL.Delete = nil - for _, v := range resp.ACL.Delete { - r.ACL.Delete = append(r.ACL.Delete, types.StringValue(v)) - } - r.ACL.Edit = nil - for _, v := range resp.ACL.Edit { - r.ACL.Edit = append(r.ACL.Edit, types.StringValue(v)) - } - r.ACL.View = nil - for _, v := range resp.ACL.View { - r.ACL.View = append(r.ACL.View, types.StringValue(v)) - } - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) - r.Org = types.StringValue(resp.Org) - if len(r.Owners) > len(resp.Owners) { - r.Owners = r.Owners[:len(resp.Owners)] - } - for ownersCount, ownersItem := range resp.Owners { - var owners1 BaseEntityOwner - owners1.OrgID = types.StringValue(ownersItem.OrgID) - owners1.UserID = types.StringPointerValue(ownersItem.UserID) - if ownersCount+1 > len(r.Owners) { - r.Owners = append(r.Owners, owners1) - } else { - r.Owners[ownersCount].OrgID = owners1.OrgID - r.Owners[ownersCount].UserID = owners1.UserID - } - } - r.Schema = types.StringValue(resp.Schema) - r.Tags = nil - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - r.Title = types.StringValue(resp.Title) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) r.Active = types.BoolValue(resp.Active) r.Description = types.StringPointerValue(resp.Description) r.ID = types.StringValue(resp.ID) diff --git a/internal/provider/tax_resource.go b/internal/provider/tax_resource.go index 7bc83d8..ab88232 100644 --- a/internal/provider/tax_resource.go +++ b/internal/provider/tax_resource.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-product/internal/validators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -32,20 +31,12 @@ type TaxResource struct { // TaxResourceModel describes the resource data model. type TaxResourceModel struct { - ACL BaseEntityACL `tfsdk:"acl"` - CreatedAt types.String `tfsdk:"created_at"` - ID types.String `tfsdk:"id"` - Org types.String `tfsdk:"org"` - Owners []BaseEntityOwner `tfsdk:"owners"` - Schema types.String `tfsdk:"schema"` - Tags []types.String `tfsdk:"tags"` - Title types.String `tfsdk:"title"` - UpdatedAt types.String `tfsdk:"updated_at"` - Active types.Bool `tfsdk:"active"` - Description types.String `tfsdk:"description"` - Rate types.String `tfsdk:"rate"` - Region types.String `tfsdk:"region"` - Type types.String `tfsdk:"type"` + ID types.String `tfsdk:"id"` + Active types.Bool `tfsdk:"active"` + Description types.String `tfsdk:"description"` + Rate types.String `tfsdk:"rate"` + Region types.String `tfsdk:"region"` + Type types.String `tfsdk:"type"` } func (r *TaxResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -57,74 +48,10 @@ func (r *TaxResource) Schema(ctx context.Context, req resource.SchemaRequest, re MarkdownDescription: "Tax Resource", Attributes: map[string]schema.Attribute{ - "acl": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "delete": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "edit": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "view": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Access control list (ACL) for an entity. Defines sharing access to external orgs or users.`, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, "id": schema.StringAttribute{ Computed: true, Description: `The tax id`, }, - "org": schema.StringAttribute{ - Computed: true, - Description: `Organization Id the entity belongs to`, - }, - "owners": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "schema": schema.StringAttribute{ - Computed: true, - }, - "tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "title": schema.StringAttribute{ - Computed: true, - }, - "updated_at": schema.StringAttribute{ - Computed: true, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, "active": schema.BoolAttribute{ Required: true, }, diff --git a/internal/provider/tax_resource_sdk.go b/internal/provider/tax_resource_sdk.go index 1d52c89..c846086 100644 --- a/internal/provider/tax_resource_sdk.go +++ b/internal/provider/tax_resource_sdk.go @@ -3,10 +3,8 @@ package provider import ( - "encoding/json" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" - "time" ) func (r *TaxResourceModel) ToSharedTaxCreate() *shared.TaxCreate { @@ -31,48 +29,7 @@ func (r *TaxResourceModel) ToSharedTaxCreate() *shared.TaxCreate { } func (r *TaxResourceModel) RefreshFromSharedTax(resp *shared.Tax) { - if resp.ACL.AdditionalProperties == nil { - r.ACL.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.ACL.AdditionalProperties) - r.ACL.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - r.ACL.Delete = nil - for _, v := range resp.ACL.Delete { - r.ACL.Delete = append(r.ACL.Delete, types.StringValue(v)) - } - r.ACL.Edit = nil - for _, v := range resp.ACL.Edit { - r.ACL.Edit = append(r.ACL.Edit, types.StringValue(v)) - } - r.ACL.View = nil - for _, v := range resp.ACL.View { - r.ACL.View = append(r.ACL.View, types.StringValue(v)) - } - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) r.ID = types.StringValue(resp.ID) - r.Org = types.StringValue(resp.Org) - if len(r.Owners) > len(resp.Owners) { - r.Owners = r.Owners[:len(resp.Owners)] - } - for ownersCount, ownersItem := range resp.Owners { - var owners1 BaseEntityOwner - owners1.OrgID = types.StringValue(ownersItem.OrgID) - owners1.UserID = types.StringPointerValue(ownersItem.UserID) - if ownersCount+1 > len(r.Owners) { - r.Owners = append(r.Owners, owners1) - } else { - r.Owners[ownersCount].OrgID = owners1.OrgID - r.Owners[ownersCount].UserID = owners1.UserID - } - } - r.Schema = types.StringValue(resp.Schema) - r.Tags = nil - for _, v := range resp.Tags { - r.Tags = append(r.Tags, types.StringValue(v)) - } - r.Title = types.StringValue(resp.Title) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) r.Active = types.BoolValue(resp.Active) r.Description = types.StringPointerValue(resp.Description) r.Rate = types.StringValue(resp.Rate) diff --git a/internal/provider/type_base_entity_acl.go b/internal/provider/type_base_entity_acl.go deleted file mode 100644 index 0c89d60..0000000 --- a/internal/provider/type_base_entity_acl.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package provider - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type BaseEntityACL struct { - AdditionalProperties types.String `tfsdk:"additional_properties"` - Delete []types.String `tfsdk:"delete"` - Edit []types.String `tfsdk:"edit"` - View []types.String `tfsdk:"view"` -} diff --git a/internal/provider/type_base_entity_owner.go b/internal/provider/type_base_entity_owner.go deleted file mode 100644 index 687f94b..0000000 --- a/internal/provider/type_base_entity_owner.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package provider - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type BaseEntityOwner struct { - OrgID types.String `tfsdk:"org_id"` - UserID types.String `tfsdk:"user_id"` -} diff --git a/internal/sdk/pkg/models/shared/baseentityacl.go b/internal/sdk/pkg/models/shared/baseentityacl.go deleted file mode 100644 index 539b2db..0000000 --- a/internal/sdk/pkg/models/shared/baseentityacl.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/utils" -) - -// BaseEntityACL - Access control list (ACL) for an entity. Defines sharing access to external orgs or users. -type BaseEntityACL struct { - AdditionalProperties interface{} `additionalProperties:"true" json:"-"` - Delete []string `json:"delete,omitempty"` - Edit []string `json:"edit,omitempty"` - View []string `json:"view,omitempty"` -} - -func (b BaseEntityACL) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(b, "", false) -} - -func (b *BaseEntityACL) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { - return err - } - return nil -} - -func (o *BaseEntityACL) GetAdditionalProperties() interface{} { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *BaseEntityACL) GetDelete() []string { - if o == nil { - return nil - } - return o.Delete -} - -func (o *BaseEntityACL) GetEdit() []string { - if o == nil { - return nil - } - return o.Edit -} - -func (o *BaseEntityACL) GetView() []string { - if o == nil { - return nil - } - return o.View -} diff --git a/internal/sdk/pkg/models/shared/baseentityowner.go b/internal/sdk/pkg/models/shared/baseentityowner.go deleted file mode 100644 index 453ca03..0000000 --- a/internal/sdk/pkg/models/shared/baseentityowner.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package shared - -// BaseEntityOwner - The user / organization owning this entity. -// -// Note: Owner implicitly has access to the entity regardless of ACLs. -type BaseEntityOwner struct { - OrgID string `json:"org_id"` - UserID *string `json:"user_id,omitempty"` -} - -func (o *BaseEntityOwner) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *BaseEntityOwner) GetUserID() *string { - if o == nil { - return nil - } - return o.UserID -} diff --git a/internal/sdk/pkg/models/shared/price.go b/internal/sdk/pkg/models/shared/price.go index 753abe9..daeb8de 100644 --- a/internal/sdk/pkg/models/shared/price.go +++ b/internal/sdk/pkg/models/shared/price.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/utils" - "time" ) // BillingDurationUnit - The billing period duration unit @@ -357,17 +356,7 @@ func (u Unit) MarshalJSON() ([]byte, error) { } type Price struct { - // Access control list (ACL) for an entity. Defines sharing access to external orgs or users. - ACL BaseEntityACL `json:"_acl"` - CreatedAt time.Time `json:"_created_at"` - ID string `json:"_id"` - // Organization Id the entity belongs to - Org string `json:"_org"` - Owners []BaseEntityOwner `json:"_owners"` - Schema string `json:"_schema"` - Tags []string `json:"_tags"` - Title string `json:"_title"` - UpdatedAt time.Time `json:"_updated_at"` + ID string `json:"_id"` // Whether the price can be used for new purchases. Active bool `json:"active"` // The billing period duration @@ -432,20 +421,6 @@ func (p *Price) UnmarshalJSON(data []byte) error { return nil } -func (o *Price) GetACL() BaseEntityACL { - if o == nil { - return BaseEntityACL{} - } - return o.ACL -} - -func (o *Price) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - func (o *Price) GetID() string { if o == nil { return "" @@ -453,48 +428,6 @@ func (o *Price) GetID() string { return o.ID } -func (o *Price) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Price) GetOwners() []BaseEntityOwner { - if o == nil { - return []BaseEntityOwner{} - } - return o.Owners -} - -func (o *Price) GetSchema() string { - if o == nil { - return "" - } - return o.Schema -} - -func (o *Price) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Price) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Price) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - func (o *Price) GetActive() bool { if o == nil { return false diff --git a/internal/sdk/pkg/models/shared/product.go b/internal/sdk/pkg/models/shared/product.go index f8877d5..5574ea6 100644 --- a/internal/sdk/pkg/models/shared/product.go +++ b/internal/sdk/pkg/models/shared/product.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/utils" - "time" ) // ProductType - The type of Product: @@ -43,18 +42,8 @@ func (e *ProductType) UnmarshalJSON(data []byte) error { } type Product struct { - // Access control list (ACL) for an entity. Defines sharing access to external orgs or users. - ACL BaseEntityACL `json:"_acl"` - CreatedAt time.Time `json:"_created_at"` - ID string `json:"_id"` - // Organization Id the entity belongs to - Org string `json:"_org"` - Owners []BaseEntityOwner `json:"_owners"` - Schema string `json:"_schema"` - Tags []string `json:"_tags"` - Title string `json:"_title"` - UpdatedAt time.Time `json:"_updated_at"` - Active bool `json:"active"` + ID string `json:"_id"` + Active bool `json:"active"` // The product code Code *string `json:"code,omitempty"` // A description of the product. Multi-line supported. @@ -88,20 +77,6 @@ func (p *Product) UnmarshalJSON(data []byte) error { return nil } -func (o *Product) GetACL() BaseEntityACL { - if o == nil { - return BaseEntityACL{} - } - return o.ACL -} - -func (o *Product) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - func (o *Product) GetID() string { if o == nil { return "" @@ -109,48 +84,6 @@ func (o *Product) GetID() string { return o.ID } -func (o *Product) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Product) GetOwners() []BaseEntityOwner { - if o == nil { - return []BaseEntityOwner{} - } - return o.Owners -} - -func (o *Product) GetSchema() string { - if o == nil { - return "" - } - return o.Schema -} - -func (o *Product) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Product) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Product) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - func (o *Product) GetActive() bool { if o == nil { return false diff --git a/internal/sdk/pkg/models/shared/tax.go b/internal/sdk/pkg/models/shared/tax.go index 8b97d50..bfc9d7a 100644 --- a/internal/sdk/pkg/models/shared/tax.go +++ b/internal/sdk/pkg/models/shared/tax.go @@ -5,8 +5,6 @@ package shared import ( "encoding/json" "fmt" - "github.com/epilot-dev/terraform-provider-epilot-product/internal/sdk/pkg/utils" - "time" ) type Region string @@ -67,47 +65,12 @@ func (e *TaxType) UnmarshalJSON(data []byte) error { } type Tax struct { - // Access control list (ACL) for an entity. Defines sharing access to external orgs or users. - ACL BaseEntityACL `json:"_acl"` - CreatedAt time.Time `json:"_created_at"` - ID string `json:"_id"` - // Organization Id the entity belongs to - Org string `json:"_org"` - Owners []BaseEntityOwner `json:"_owners"` - Schema string `json:"_schema"` - Tags []string `json:"_tags"` - Title string `json:"_title"` - UpdatedAt time.Time `json:"_updated_at"` - Active bool `json:"active"` - Description *string `json:"description,omitempty"` - Rate string `json:"rate"` - Region Region `json:"region"` - Type TaxType `json:"type"` -} - -func (t Tax) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(t, "", false) -} - -func (t *Tax) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &t, "", false, false); err != nil { - return err - } - return nil -} - -func (o *Tax) GetACL() BaseEntityACL { - if o == nil { - return BaseEntityACL{} - } - return o.ACL -} - -func (o *Tax) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt + ID string `json:"_id"` + Active bool `json:"active"` + Description *string `json:"description,omitempty"` + Rate string `json:"rate"` + Region Region `json:"region"` + Type TaxType `json:"type"` } func (o *Tax) GetID() string { @@ -117,48 +80,6 @@ func (o *Tax) GetID() string { return o.ID } -func (o *Tax) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Tax) GetOwners() []BaseEntityOwner { - if o == nil { - return []BaseEntityOwner{} - } - return o.Owners -} - -func (o *Tax) GetSchema() string { - if o == nil { - return "" - } - return o.Schema -} - -func (o *Tax) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Tax) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Tax) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - func (o *Tax) GetActive() bool { if o == nil { return false diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index e3a8a42..9a0e791 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -145,9 +145,9 @@ func New(opts ...SDKOption) *SDK { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.5.5", + SDKVersion: "0.6.0", GenVersion: "2.230.1", - UserAgent: "speakeasy-sdk/go 0.5.5 2.230.1 1.0.0 epilot-product", + UserAgent: "speakeasy-sdk/go 0.6.0 2.230.1 1.0.0 epilot-product", }, } for _, opt := range opts { diff --git a/product.yaml b/product.yaml index 25d0a8f..1ecb2e0 100644 --- a/product.yaml +++ b/product.yaml @@ -452,8 +452,8 @@ components: - $ref: '#/components/schemas/BaseTax' - $ref: '#/components/schemas/BaseTaxRequired' - $ref: '#/components/schemas/BaseSystemId' - - $ref: '#/components/schemas/BaseSystemFields' - - $ref: '#/components/schemas/BaseSystemFieldsRequired' + # - $ref: '#/components/schemas/BaseSystemFields' + # - $ref: '#/components/schemas/BaseSystemFieldsRequired' TaxCreate: allOf: - $ref: '#/components/schemas/BaseTax' @@ -628,8 +628,8 @@ components: - $ref: '#/components/schemas/BasePrice' - $ref: '#/components/schemas/BasePriceRequired' - $ref: '#/components/schemas/BaseSystemId' - - $ref: '#/components/schemas/BaseSystemFields' - - $ref: '#/components/schemas/BaseSystemFieldsRequired' + # - $ref: '#/components/schemas/BaseSystemFields' + # - $ref: '#/components/schemas/BaseSystemFieldsRequired' PriceCreate: allOf: - $ref: '#/components/schemas/BasePrice' @@ -686,8 +686,8 @@ components: - $ref: '#/components/schemas/BaseProduct' - $ref: '#/components/schemas/BaseProductRequired' - $ref: '#/components/schemas/BaseSystemId' - - $ref: '#/components/schemas/BaseSystemFields' - - $ref: '#/components/schemas/BaseSystemFieldsRequired' + # - $ref: '#/components/schemas/BaseSystemFields' + # - $ref: '#/components/schemas/BaseSystemFieldsRequired' ProductCreate: allOf: - $ref: '#/components/schemas/BaseProduct' @@ -820,5 +820,4 @@ components: content: application/json: schema: - $ref: '#/components/schemas/Product' - + $ref: '#/components/schemas/Product' \ No newline at end of file