From 293dd76bb98ac5a6540192b54a4ccec81626e890 Mon Sep 17 00:00:00 2001 From: Steve Ramage <49958178+steve-r-west@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:21:23 -0800 Subject: [PATCH] Another pass at adding field level documentation for #78 (#161) --- ep.png | Bin 0 -> 977 bytes internal/provider/data_source_epcc_catalog.go | 5 +- .../data_source_epcc_catalog_rules.go | 5 +- internal/provider/data_source_epcc_file.go | 34 ++++++++------ .../provider/data_source_epcc_hierarchy.go | 20 ++++---- internal/provider/data_source_epcc_node.go | 30 +++++++----- .../provider/data_source_epcc_node_product.go | 21 +++++---- .../provider/data_source_epcc_pricebook.go | 15 +++--- .../provider/data_source_epcc_promotion.go | 19 ++++---- .../provider/data_source_epcc_settings.go | 8 ++-- internal/provider/provider_test.go | 26 ++++++++--- internal/provider/resource_epcc_catalog.go | 21 +++++---- .../provider/resource_epcc_catalog_rule.go | 21 +++++---- internal/provider/resource_epcc_file.go | 43 ++++++++++-------- internal/provider/resource_epcc_file_test.go | 14 ++---- internal/provider/resource_epcc_hierarchy.go | 30 ++++++------ internal/provider/resource_epcc_node.go | 38 +++++++++------- .../provider/resource_epcc_node_product.go | 21 +++++---- internal/provider/resource_epcc_pricebook.go | 15 +++--- internal/provider/resource_epcc_promotion.go | 23 ++++------ internal/provider/resource_epcc_settings.go | 8 ++-- 21 files changed, 237 insertions(+), 180 deletions(-) create mode 100644 ep.png diff --git a/ep.png b/ep.png new file mode 100644 index 0000000000000000000000000000000000000000..915773e420dfe96c3e58da39fdec3df0ce575bb0 GIT binary patch literal 977 zcmV;?11|iDP))nv`)=AtnIff&+8%&l~#7_3~@R_GtChb;+eNN_v}%7Z6H9(TvZ z-F^Gx@{XT(M}7YLd_SMx>-+vZe1DP}GJdyph3u$y>$Zw3W+Q@nJQ zN%5e^+gv!R#t7XJNs{5?qgm`JO!@y%Aq0)5U6fUi6IVW9GRO>df_$Jy`xWO^pR>I{Y5+n2K@ zQx{fhDe4i|Tnk}Gg07SIVKyZ3MCkxyQ&FG<)W2!P@nRZ>k5BO4i77&%=w&*sMBPCv zCC{g#xeWx!v*~##*TB}&el<{n#<#4z`a&A7*IcFH)9W!M`xgYSRgIBlQP3<7Xf+Z5 z(=!2;!lpy3+4o#32dc+uJnc%@OCg}LbqaY!a#G~*H>a1;Nk5ei3(2M=OnRA?!}qf9 z*;Mvd#R4CDz`&QsY?utuJ^s1ZgIu&JIdTvP!k&r|^4A-2eQRf?)6UB~Qz)q%qp3{| z+?Z$No5mdOS)nBmhz?q-k&rI+dBmfy^r@PDmqBKGz8SqDbFs_Kwd)Hi;HC$SeASRc z|CM}x|4#D+M_bejp2!O9Vc_LqA4U5I`D-o;)F~1_w5|)ks3RpA z94cOkBrOfx^00~X4LS4<`6zTaV}NZ{YuT{Qp#DpJ-#y2>A5HT0kGEogk8dz>t}dG% zr;l9+oZRw6`?XAwI9qLFS3!6_s+G!LZzOHGhIm$6Zspg0FHe;X;`S~A>Ll8$Z7d#m zL}?%>C_XaE$@4ekLR0V7;PwRZFGMG;*GY8LWV0jRtjdkZYC7Xe2n4t>8&LUrox~Tl z**v+?9FrT_+K~yrDzGEpOhxg^xEC1pGUw{z0|5~KTHlCIWES=a9{EK)Q|=Vr`Jf1e zLgMqzn_~0cKZI#>mq^>zEncb^5|@X)Vk!FvzLSa2uCt!@00000NkvXXu0mjf{4UZ4 literal 0 HcmV?d00001 diff --git a/internal/provider/data_source_epcc_catalog.go b/internal/provider/data_source_epcc_catalog.go index f245d3c..35b8d32 100644 --- a/internal/provider/data_source_epcc_catalog.go +++ b/internal/provider/data_source_epcc_catalog.go @@ -12,8 +12,9 @@ func dataSourceEpccCatalog() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccCatalogRead), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The id of the catalog.", }, "name": { Type: schema.TypeString, diff --git a/internal/provider/data_source_epcc_catalog_rules.go b/internal/provider/data_source_epcc_catalog_rules.go index 755bbf3..93eb5d3 100644 --- a/internal/provider/data_source_epcc_catalog_rules.go +++ b/internal/provider/data_source_epcc_catalog_rules.go @@ -12,8 +12,9 @@ func dataSourceEpccCatalogRule() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccCatalogRuleRead), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier of the catalog rule.", }, "name": { Type: schema.TypeString, diff --git a/internal/provider/data_source_epcc_file.go b/internal/provider/data_source_epcc_file.go index 16c509d..d7f75ec 100644 --- a/internal/provider/data_source_epcc_file.go +++ b/internal/provider/data_source_epcc_file.go @@ -11,30 +11,36 @@ func dataSourceEpccFile() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccFileRead), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier for the file.", }, "file_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The name of the file", }, "file_link": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A link to the file", }, "mime_type": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The MIME type of the file", }, "file_size": { - Type: schema.TypeInt, - Computed: true, + Type: schema.TypeInt, + Computed: true, + Description: "The size of the file", }, "public": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: "Whether the file is public.", }, }, } diff --git a/internal/provider/data_source_epcc_hierarchy.go b/internal/provider/data_source_epcc_hierarchy.go index 6293170..1816fed 100644 --- a/internal/provider/data_source_epcc_hierarchy.go +++ b/internal/provider/data_source_epcc_hierarchy.go @@ -11,20 +11,24 @@ func dataSourceEpccHierarchy() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccHierarchyRead), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier of the hierarchy.", }, "name": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The name of the hierarchy. The maximum length is 1000 characters.", }, "description": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A description of the hierarchy.", }, "slug": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A unique slug for the hierarchy.", }, }, } diff --git a/internal/provider/data_source_epcc_node.go b/internal/provider/data_source_epcc_node.go index f4eef7b..dd8511a 100644 --- a/internal/provider/data_source_epcc_node.go +++ b/internal/provider/data_source_epcc_node.go @@ -12,28 +12,34 @@ func dataSourceEpccNode() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccNodeRead), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier of the node.", }, "hierarchy_id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier of the hierarchy.", }, "name": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A name for the node. Names must be unique among sibling nodes in the hierarchy, but otherwise a name can be non-unique. Cannot be null.", }, "description": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A description of the node.", }, "slug": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A slug for the node. Slugs must be unique among sibling nodes in the hierarchy, but otherwise a slug can be non-unique.", }, "parent_id": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: "The node ID for the parent node. The new node is created as a child of this parent node.", }, }, } diff --git a/internal/provider/data_source_epcc_node_product.go b/internal/provider/data_source_epcc_node_product.go index dccc58a..197b4d2 100644 --- a/internal/provider/data_source_epcc_node_product.go +++ b/internal/provider/data_source_epcc_node_product.go @@ -17,19 +17,22 @@ func dataSourceEpccNodeProduct() *schema.Resource { Required: true, }, "hierarchy_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the hierarchy.", }, "node_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the node in the hierarchy.", }, "product_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the product.", }, }, } diff --git a/internal/provider/data_source_epcc_pricebook.go b/internal/provider/data_source_epcc_pricebook.go index 91216b7..ed13841 100644 --- a/internal/provider/data_source_epcc_pricebook.go +++ b/internal/provider/data_source_epcc_pricebook.go @@ -12,16 +12,19 @@ func dataSourceEpccPricebook() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccPricebookRead), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier of the price book.", }, "name": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A unique name for the price book.", }, "description": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The purpose for the price book, such as flash sale pricing or preferred customer pricing.", }, }, } diff --git a/internal/provider/data_source_epcc_promotion.go b/internal/provider/data_source_epcc_promotion.go index 0af1d5c..48ffbf8 100644 --- a/internal/provider/data_source_epcc_promotion.go +++ b/internal/provider/data_source_epcc_promotion.go @@ -11,12 +11,11 @@ func dataSourceEpccPromotion() *schema.Resource { ReadContext: addDiagToContext(dataSourceEpccPromotionRead), Schema: map[string]*schema.Schema{ "id": {Type: schema.TypeString, Required: true}, - "type": {Type: schema.TypeString, Computed: true}, - "name": {Type: schema.TypeString, Computed: true}, - "description": {Type: schema.TypeString, Computed: true}, - "enabled": {Type: schema.TypeBool, Computed: true}, - "automatic": {Type: schema.TypeBool, Optional: true}, - "promotion_type": {Type: schema.TypeString, Computed: true}, + "name": {Type: schema.TypeString, Computed: true, Description: "Specifies a name for the promotion."}, + "description": {Type: schema.TypeString, Computed: true, Description: "Specifies a description for the promotion."}, + "enabled": {Type: schema.TypeBool, Computed: true, Description: "Specifies whether the promotion is enabled. The options are `true` or `false`, and the default setting is `false`."}, + "automatic": {Type: schema.TypeBool, Optional: true, Description: "Specifies whether the promotion is applied automatically to the cart or a code is required to apply the promotion. The default setting is `false`. When this value is set `true`, a code is autogenerated. If this value is set `false`, you must create the code manually"}, + "promotion_type": {Type: schema.TypeString, Computed: true, Description: "Specifies the type of the promotion."}, "schema": {Type: schema.TypeList, Required: true, Elem: &schema.Resource{Schema: map[string]*schema.Schema{ "currencies": {Type: schema.TypeList, Optional: true, @@ -25,14 +24,14 @@ func dataSourceEpccPromotion() *schema.Resource { "amount": {Type: schema.TypeInt, Optional: true}, }}}, }}}, - "start": {Type: schema.TypeString, Computed: true}, - "end": {Type: schema.TypeString, Computed: true}, - "min_cart_value": {Type: schema.TypeList, Optional: true, + "start": {Type: schema.TypeString, Computed: true, Description: "Specifies the start date and time of the promotion or the start date of the promotion. You can provide a specific time in the HH:MM format. For example, `\"start\": \"2000-01-01 12:00\"`."}, + "end": {Type: schema.TypeString, Computed: true, Description: "Specifies the end date and time of the promotion or the end date of the promotion."}, + "min_cart_value": {Type: schema.TypeList, Optional: true, Description: "Provide the minimum cart value required for the promotion to apply.", Elem: &schema.Resource{Schema: map[string]*schema.Schema{ "promotion": {Type: schema.TypeString, Optional: true}, "amount": {Type: schema.TypeInt, Optional: true}, }}}, - "max_discount_value": {Type: schema.TypeList, Optional: true, + "max_discount_value": {Type: schema.TypeList, Optional: true, Description: "Provides the maximum possible discount for the cart", Elem: &schema.Resource{Schema: map[string]*schema.Schema{ "promotion": {Type: schema.TypeString, Optional: true}, "amount": {Type: schema.TypeInt, Optional: true}, diff --git a/internal/provider/data_source_epcc_settings.go b/internal/provider/data_source_epcc_settings.go index 665cccc..16452b8 100644 --- a/internal/provider/data_source_epcc_settings.go +++ b/internal/provider/data_source_epcc_settings.go @@ -10,10 +10,10 @@ func dataSourceEpccSettings() *schema.Resource { return &schema.Resource{ ReadContext: addDiagToContext(dataSourceEpccSettingsRead), Schema: map[string]*schema.Schema{ - "page_length": {Type: schema.TypeInt, Computed: true}, - "list_child_products": {Type: schema.TypeBool, Computed: true}, - "additional_languages": {Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}}, - "calculation_method": {Type: schema.TypeString, Computed: true}, + "page_length": {Type: schema.TypeInt, Computed: true, Description: "The number of results per page when paginating results"}, + "list_child_products": {Type: schema.TypeBool, Computed: true, Description: "Whether to display child products in product listings."}, + "additional_languages": {Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, Description: "You can define additional language codes that are enabled for a project, this applies only to the legacy catalog and does not apply to PCM products, hierarchies, and catalogs."}, + "calculation_method": {Type: schema.TypeString, Computed: true, Description: "This option defines the method used to calculate cart and order totals."}, }, } } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index f969b60..24e4770 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -36,18 +36,26 @@ func TestProvider(t *testing.T) { resourceAttributesWithNoDescription := make([]string, 0) + totalBadCount := 0 for key, resource := range provider.ResourcesMap { if resource.Description == "" { resourcesWithNoDescription = append(resourcesWithNoDescription, key) } - for attributeName, schema := range resource.Schema { + count := 0 + for _, schema := range resource.Schema { + if schema.Description == "" { - resourceAttributesWithNoDescription = append(resourceAttributesWithNoDescription, fmt.Sprintf("Resource %s attribute %s", key, attributeName)) + count++ + totalBadCount++ } } + if count > 0 { + resourceAttributesWithNoDescription = append(resourceAttributesWithNoDescription, fmt.Sprintf("%s => %d", key, count)) + } + } dataSourcesWithNoDescription := make([]string, 0) @@ -57,11 +65,16 @@ func TestProvider(t *testing.T) { dataSourcesWithNoDescription = append(dataSourcesWithNoDescription, key) } - for attributeName, schema := range dataSource.Schema { + count := 0 + for _, schema := range dataSource.Schema { if schema.Description == "" { - dataSourceAttributesWithNoDescription = append(dataSourceAttributesWithNoDescription, fmt.Sprintf("Resource %s attribute %s", key, attributeName)) + count++ + totalBadCount++ } } + if count > 0 { + dataSourceAttributesWithNoDescription = append(dataSourceAttributesWithNoDescription, fmt.Sprintf("%s => %d", key, count)) + } } dataSourceAndResourcesMissingDescriptions := len(resourcesWithNoDescription) + len(dataSourcesWithNoDescription) @@ -70,12 +83,11 @@ func TestProvider(t *testing.T) { t.Fatalf("%d object's don't have descriptions:\n\tResources:%s\nData Sources:%s\n", dataSourceAndResourcesMissingDescriptions, resourcesWithNoDescription, dataSourcesWithNoDescription) } - dataSourceAndResourceAttributesMissingDescription := len(resourceAttributesWithNoDescription) + len(dataSourceAttributesWithNoDescription) currentDay := int(time.Now().Unix() / 86400) currentTarget := max(19110-currentDay, 0) - if dataSourceAndResourceAttributesMissingDescription > currentTarget { - t.Fatalf("%d object's don't have descriptions\n\tWe have a lot of technical debt so this tests permits a non zero value but over time decreases the number of descriptions needed by 1 per day, so just go and get below this number: %d\n\tResources:%s\nData Sources:%s\n", dataSourceAndResourceAttributesMissingDescription, currentTarget, resourceAttributesWithNoDescription, dataSourceAttributesWithNoDescription) + if totalBadCount+10 > currentTarget { + t.Fatalf("%d object's don't have descriptions\n\tWe have a lot of technical debt so this tests permits a non zero value but over time decreases the number of descriptions needed by 1 per day, so just go and get below this number: %d\n\tResources:%s\nData Sources:%s\n", totalBadCount, currentTarget, resourceAttributesWithNoDescription, dataSourceAttributesWithNoDescription) } } diff --git a/internal/provider/resource_epcc_catalog.go b/internal/provider/resource_epcc_catalog.go index eb58008..680820b 100644 --- a/internal/provider/resource_epcc_catalog.go +++ b/internal/provider/resource_epcc_catalog.go @@ -19,16 +19,19 @@ func resourceEpccCatalog() *schema.Resource { }, Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The id of the catalog.", }, "name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The name of the catalog.", }, "description": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: " A description of the catalog, such as the purpose for the catalog.", }, "hierarchies": { Type: schema.TypeSet, @@ -36,10 +39,12 @@ func resourceEpccCatalog() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, + Description: "The unique identifiers of the hierarchies to associate with this catalog.", }, "pricebook": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the price book to associate with this catalog.", }, }, } diff --git a/internal/provider/resource_epcc_catalog_rule.go b/internal/provider/resource_epcc_catalog_rule.go index cc8e987..6a981ab 100644 --- a/internal/provider/resource_epcc_catalog_rule.go +++ b/internal/provider/resource_epcc_catalog_rule.go @@ -19,20 +19,24 @@ func resourceEpccCatalogRule() *schema.Resource { }, Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier of the catalog rule.", }, "name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The name of the rule without spaces.", }, "description": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: "The purpose for this rule.", }, "catalog": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "The unique identifier of the catalog for this rule. If you want to display a catalog that contains V2 Products, Brands, Categories, and Collections, specify `legacy`", }, "customers": { Type: schema.TypeSet, @@ -40,6 +44,7 @@ func resourceEpccCatalogRule() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, + Description: "The list of customers who are eligible to see this catalog. If empty, the rule matches all customers.", }, }, } diff --git a/internal/provider/resource_epcc_file.go b/internal/provider/resource_epcc_file.go index df8e934..8c1bf68 100644 --- a/internal/provider/resource_epcc_file.go +++ b/internal/provider/resource_epcc_file.go @@ -19,41 +19,48 @@ func resourceEpccFile() *schema.Resource { }, Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier for the file.", }, "file_link": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "A link to the file", }, "mime_type": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The MIME type of the file", }, "file_size": { - Type: schema.TypeInt, - Computed: true, + Type: schema.TypeInt, + Computed: true, + Description: "The size of the file", }, "file_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The name of the file", }, "file_location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The URL that points to an image file.", }, "public": { Type: schema.TypeBool, - Description: "TBD.", Optional: true, ForceNew: true, + Description: "Whether the file is public.", }, "file_hash": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "A hash of the file contents", }, }, } diff --git a/internal/provider/resource_epcc_file_test.go b/internal/provider/resource_epcc_file_test.go index c91b039..92f95f5 100644 --- a/internal/provider/resource_epcc_file_test.go +++ b/internal/provider/resource_epcc_file_test.go @@ -1,31 +1,25 @@ package provider import ( - "io/ioutil" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccResourceFile(t *testing.T) { - tempDir := t.TempDir() resource.UnitTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - err := ioutil.WriteFile(tempDir+"/hello_world.txt", []byte("hello world"), 0644) - if err != nil { - t.Fatal(err) - } }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ { PreventDiskCleanup: true, - Config: `resource "epcc_file" "my_text_file"{ - file_name = "` + tempDir + `/hello_world.txt" - file_hash = filemd5("` + tempDir + `/hello_world.txt") + Config: `resource "epcc_file" "my_logo"{ + file_name = "ep.png" + file_hash = filemd5("ep.png") public = true } resource "epcc_file" "my_image_link" { @@ -33,7 +27,7 @@ func TestAccResourceFile(t *testing.T) { } `, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("epcc_file.my_text_file", "file_name", tempDir+"/hello_world.txt"), + resource.TestCheckResourceAttr("epcc_file.my_logo", "file_name", "ep.png"), resource.TestCheckResourceAttr("epcc_file.my_image_link", "file_location", "https://my.example.com/images/abc.png"), ), }, diff --git a/internal/provider/resource_epcc_hierarchy.go b/internal/provider/resource_epcc_hierarchy.go index 4ee9338..348bebc 100644 --- a/internal/provider/resource_epcc_hierarchy.go +++ b/internal/provider/resource_epcc_hierarchy.go @@ -19,25 +19,29 @@ func resourceEpccHierarchy() *schema.Resource { }, Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier of the hierarchy.", }, "name": { - Type: schema.TypeString, - Required: true, - Computed: false, + Type: schema.TypeString, + Required: true, + Computed: false, + Description: "The name of the hierarchy. The maximum length is 1000 characters.", }, "description": { - Type: schema.TypeString, - Required: false, - Computed: false, - Optional: true, + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Description: "A description of the hierarchy.", }, "slug": { - Type: schema.TypeString, - Required: false, - Computed: false, - Optional: true, + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Description: "A unique slug for the hierarchy.", }, }, } diff --git a/internal/provider/resource_epcc_node.go b/internal/provider/resource_epcc_node.go index b8a461b..acd02a0 100644 --- a/internal/provider/resource_epcc_node.go +++ b/internal/provider/resource_epcc_node.go @@ -16,32 +16,38 @@ func resourceEpccNode() *schema.Resource { DeleteContext: addDiagToContext(resourceEpccNodeDelete), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier of the node.", }, "hierarchy_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the hierarchy.", }, "name": { - Type: schema.TypeString, - Required: true, - Computed: false, + Type: schema.TypeString, + Required: true, + Computed: false, + Description: "A name for the node. Names must be unique among sibling nodes in the hierarchy, but otherwise a name can be non-unique. Cannot be null.", }, "description": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: "A description of the node.", }, "slug": { - Type: schema.TypeString, - Required: false, - Computed: false, - Optional: true, + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Description: "A slug for the node. Slugs must be unique among sibling nodes in the hierarchy, but otherwise a slug can be non-unique.", }, "parent_id": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: "The node ID for the parent node. The new node is created as a child of this parent node.", }, }, } diff --git a/internal/provider/resource_epcc_node_product.go b/internal/provider/resource_epcc_node_product.go index 9614e1d..1d420e9 100644 --- a/internal/provider/resource_epcc_node_product.go +++ b/internal/provider/resource_epcc_node_product.go @@ -26,19 +26,22 @@ func resourceEpccNodeProduct() *schema.Resource { Computed: true, }, "hierarchy_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the hierarchy.", }, "node_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the node in the hierarchy.", }, "product_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique identifier of the product.", }, }, } diff --git a/internal/provider/resource_epcc_pricebook.go b/internal/provider/resource_epcc_pricebook.go index cfd6e2b..4423325 100644 --- a/internal/provider/resource_epcc_pricebook.go +++ b/internal/provider/resource_epcc_pricebook.go @@ -17,16 +17,19 @@ func resourceEpccPricebook() *schema.Resource { DeleteContext: addDiagToContext(resourceEpccPricebookDelete), Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier of the price book.", }, "name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "A unique name for the price book.", }, "description": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Description: "The purpose for the price book, such as flash sale pricing or preferred customer pricing.", }, }, } diff --git a/internal/provider/resource_epcc_promotion.go b/internal/provider/resource_epcc_promotion.go index ef2f438..0b2a274 100644 --- a/internal/provider/resource_epcc_promotion.go +++ b/internal/provider/resource_epcc_promotion.go @@ -22,12 +22,11 @@ func resourceEpccPromotion() *schema.Resource { }, Schema: map[string]*schema.Schema{ "id": {Type: schema.TypeString, Computed: true}, - "type": {Type: schema.TypeString, Required: true}, - "name": {Type: schema.TypeString, Required: true}, - "description": {Type: schema.TypeString, Required: true}, - "enabled": {Type: schema.TypeBool, Required: true}, - "automatic": {Type: schema.TypeBool, Optional: true}, - "promotion_type": {Type: schema.TypeString, Required: true}, + "name": {Type: schema.TypeString, Required: true, Description: "Specifies a name for the promotion."}, + "description": {Type: schema.TypeString, Required: true, Description: "Specifies a description for the promotion."}, + "enabled": {Type: schema.TypeBool, Required: true, Description: "Specifies whether the promotion is enabled. The options are `true` or `false`, and the default setting is `false`."}, + "automatic": {Type: schema.TypeBool, Optional: true, Description: "Specifies whether the promotion is applied automatically to the cart or a code is required to apply the promotion. The default setting is `false`. When this value is set `true`, a code is autogenerated. If this value is set `false`, you must create the code manually"}, + "promotion_type": {Type: schema.TypeString, Required: true, Description: "Specifies the type of the promotion."}, "schema": {Type: schema.TypeList, Required: true, Elem: &schema.Resource{Schema: map[string]*schema.Schema{ "currencies": {Type: schema.TypeList, Optional: true, @@ -36,14 +35,14 @@ func resourceEpccPromotion() *schema.Resource { "amount": {Type: schema.TypeInt, Optional: true}, }}}, }}}, - "start": {Type: schema.TypeString, Required: true}, - "end": {Type: schema.TypeString, Required: true}, - "min_cart_value": {Type: schema.TypeList, Optional: true, + "start": {Type: schema.TypeString, Required: true, Description: "Specifies the start date and time of the promotion or the start date of the promotion. You can provide a specific time in the HH:MM format. For example, `\"start\": \"2000-01-01 12:00\"`."}, + "end": {Type: schema.TypeString, Required: true, Description: "Specifies the end date and time of the promotion or the end date of the promotion."}, + "min_cart_value": {Type: schema.TypeList, Optional: true, Description: "Provide the minimum cart value required for the promotion to apply", Elem: &schema.Resource{Schema: map[string]*schema.Schema{ "currency": {Type: schema.TypeString, Optional: true}, "amount": {Type: schema.TypeInt, Optional: true}, }}}, - "max_discount_value": {Type: schema.TypeList, Optional: true, + "max_discount_value": {Type: schema.TypeList, Optional: true, Description: "provides the maximum possible discount for the cart", Elem: &schema.Resource{Schema: map[string]*schema.Schema{ "currency": {Type: schema.TypeString, Optional: true}, "amount": {Type: schema.TypeInt, Optional: true}, @@ -111,10 +110,6 @@ func resourceEpccPromotionRead(ctx context.Context, d *schema.ResourceData, m in return } - if err := d.Set("type", promotion.Data.Type); err != nil { - addToDiag(ctx, diag.FromErr(err)) - return - } if err := d.Set("name", promotion.Data.Name); err != nil { addToDiag(ctx, diag.FromErr(err)) return diff --git a/internal/provider/resource_epcc_settings.go b/internal/provider/resource_epcc_settings.go index 37f19bc..9c9fd68 100644 --- a/internal/provider/resource_epcc_settings.go +++ b/internal/provider/resource_epcc_settings.go @@ -19,10 +19,10 @@ func resourceEpccSettings() *schema.Resource { }, Schema: map[string]*schema.Schema{ "id": {Type: schema.TypeString, Computed: true}, - "page_length": {Type: schema.TypeInt, Optional: true}, - "list_child_products": {Type: schema.TypeBool, Optional: true}, - "additional_languages": {Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}}, - "calculation_method": {Type: schema.TypeString, Optional: true}, + "page_length": {Type: schema.TypeInt, Optional: true, Description: "The number of results per page when paginating results."}, + "list_child_products": {Type: schema.TypeBool, Optional: true, Description: "Whether to display child products in product listings."}, + "additional_languages": {Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, Description: "You can define additional language codes that are enabled for a project, this applies only to the legacy catalog and does not apply to PCM products, hierarchies, and catalogs."}, + "calculation_method": {Type: schema.TypeString, Optional: true, Description: "This option defines the method used to calculate cart and order totals."}, }, } }