From ead3720196d460eb577a340422d6692df2ce880f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Thu, 7 Dec 2023 12:42:13 +0800 Subject: [PATCH] feat: fix nas and opt doc --- common/common_volcengine_version.go | 2 +- example/nasPermissionGroup/main.tf | 2 +- .../resource_volcengine_bandwidth_package.go | 21 ++++++++++++------- ...esource_volcengine_nas_permission_group.go | 2 +- ...service_volcengine_nas_permission_group.go | 16 ++++++++++++-- .../docs/r/bandwidth_package.html.markdown | 4 ++-- .../docs/r/nas_permission_group.html.markdown | 2 +- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 4997afb7..764a08ec 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.128" + TerraformProviderVersion = "0.0.129" ) diff --git a/example/nasPermissionGroup/main.tf b/example/nasPermissionGroup/main.tf index c4410cca..d004a637 100644 --- a/example/nasPermissionGroup/main.tf +++ b/example/nasPermissionGroup/main.tf @@ -9,6 +9,6 @@ resource "volcengine_nas_permission_group" "foo" { permission_rules { cidr_ip = "192.168.0.0" rw_mode = "RO" - use_mode = "All_squash" + use_mode = "No_all_squash" } } \ No newline at end of file diff --git a/volcengine/bandwidth_package/bandwidth_package/resource_volcengine_bandwidth_package.go b/volcengine/bandwidth_package/bandwidth_package/resource_volcengine_bandwidth_package.go index 28dcc02c..9593dad3 100644 --- a/volcengine/bandwidth_package/bandwidth_package/resource_volcengine_bandwidth_package.go +++ b/volcengine/bandwidth_package/bandwidth_package/resource_volcengine_bandwidth_package.go @@ -53,16 +53,21 @@ func ResourceVolcengineBandwidthPackage() *schema.Resource { Description: "Route type, default to BGP.", }, "billing_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: "PostPaidByBandwidth", - Description: "BillingType of the Ipv6 bandwidth. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`.", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "PostPaidByBandwidth", + Description: "BillingType of the bandwidth package. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`." + + " The billing method of IPv6 does not include `PrePaid`, and the billing method is only based on the `PostPaidByBandwidth`.", }, "bandwidth": { - Type: schema.TypeInt, - Required: true, - Description: "Bandwidth upper limit of shared bandwidth package, unit: Mbps. Valid values: 2 to 5000.", + Type: schema.TypeInt, + Required: true, + Description: "Bandwidth upper limit of shared bandwidth package, unit: Mbps. " + + "When BillingType is set to PrePaid: the value range is 5 to 5000. " + + "When BillingType is set to PostPaidByBandwidth: the value range is 2 to 5000. " + + "When BillingType is set to PostPaidByTraffic: the value range is 2 to 2000. " + + "When BillingType is set to PayBy95Peak: the value range is 2 to 5000.", }, "protocol": { Type: schema.TypeString, diff --git a/volcengine/nas/nas_permission_group/resource_volcengine_nas_permission_group.go b/volcengine/nas/nas_permission_group/resource_volcengine_nas_permission_group.go index 2003a234..b42bb1a2 100644 --- a/volcengine/nas/nas_permission_group/resource_volcengine_nas_permission_group.go +++ b/volcengine/nas/nas_permission_group/resource_volcengine_nas_permission_group.go @@ -133,6 +133,6 @@ func permissionRuleHash(v interface{}) int { ) buf.WriteString(fmt.Sprintf("%v:", m["cidr_ip"])) buf.WriteString(fmt.Sprintf("%v:", m["rw_mode"])) - buf.WriteString(fmt.Sprintf("%v:", m["user_mode"])) + buf.WriteString(fmt.Sprintf("%v:", m["use_mode"])) return hashcode.String(buf.String()) } diff --git a/volcengine/nas/nas_permission_group/service_volcengine_nas_permission_group.go b/volcengine/nas/nas_permission_group/service_volcengine_nas_permission_group.go index cc5461ea..1fb45f69 100644 --- a/volcengine/nas/nas_permission_group/service_volcengine_nas_permission_group.go +++ b/volcengine/nas/nas_permission_group/service_volcengine_nas_permission_group.go @@ -111,6 +111,18 @@ func (v *VolcengineNasPermissionGroupService) RefreshResourceState(data *schema. func (v *VolcengineNasPermissionGroupService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { + if rules, ok := m["PermissionRules"].([]interface{}); ok { + newRules := make([]interface{}, 0) + for _, rule := range rules { + ruleMap := rule.(map[string]interface{}) + if mode, ok := ruleMap["UserMode"]; ok { + ruleMap["UseMode"] = mode + } + delete(ruleMap, "UserMode") + newRules = append(newRules, ruleMap) + } + m["PermissionRules"] = newRules + } return m, map[string]ve.ResponseConvert{}, nil } return []ve.ResourceResponseHandler{handler} @@ -158,7 +170,7 @@ func (v *VolcengineNasPermissionGroupService) CreateResource(resData *schema.Res if ruleMap, ok := rule.(map[string]interface{}); ok { ruleMapValue["CidrIp"] = ruleMap["cidr_ip"] ruleMapValue["RwMode"] = ruleMap["rw_mode"] - ruleMapValue["UseMode"] = ruleMap["use_mode"] + ruleMapValue["UserMode"] = ruleMap["use_mode"] } rulesValue = append(rulesValue, ruleMapValue) } @@ -222,7 +234,7 @@ func (v *VolcengineNasPermissionGroupService) ModifyResource(resData *schema.Res if ruleMap, ok := rule.(map[string]interface{}); ok { ruleMapValue["CidrIp"] = ruleMap["cidr_ip"] ruleMapValue["RwMode"] = ruleMap["rw_mode"] - ruleMapValue["UseMode"] = ruleMap["use_mode"] + ruleMapValue["UserMode"] = ruleMap["use_mode"] } rulesValue = append(rulesValue, ruleMapValue) } diff --git a/website/docs/r/bandwidth_package.html.markdown b/website/docs/r/bandwidth_package.html.markdown index f63e5148..8a2ee7d1 100644 --- a/website/docs/r/bandwidth_package.html.markdown +++ b/website/docs/r/bandwidth_package.html.markdown @@ -32,9 +32,9 @@ resource "volcengine_bandwidth_package" "foo" { ``` ## Argument Reference The following arguments are supported: -* `bandwidth` - (Required) Bandwidth upper limit of shared bandwidth package, unit: Mbps. Valid values: 2 to 5000. +* `bandwidth` - (Required) Bandwidth upper limit of shared bandwidth package, unit: Mbps. When BillingType is set to PrePaid: the value range is 5 to 5000. When BillingType is set to PostPaidByBandwidth: the value range is 2 to 5000. When BillingType is set to PostPaidByTraffic: the value range is 2 to 2000. When BillingType is set to PayBy95Peak: the value range is 2 to 5000. * `bandwidth_package_name` - (Optional) The name of the bandwidth package. -* `billing_type` - (Optional, ForceNew) BillingType of the Ipv6 bandwidth. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`. +* `billing_type` - (Optional, ForceNew) BillingType of the bandwidth package. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`. The billing method of IPv6 does not include `PrePaid`, and the billing method is only based on the `PostPaidByBandwidth`. * `description` - (Optional) The description of the bandwidth package. * `isp` - (Optional, ForceNew) Route type, default to BGP. * `period` - (Optional, ForceNew) Duration of purchasing shared bandwidth package on an annual or monthly basis. The valid value range in 1~9 or 12, 24 or 36. Default value is 1. The period unit defaults to `Month`. diff --git a/website/docs/r/nas_permission_group.html.markdown b/website/docs/r/nas_permission_group.html.markdown index b80adeaa..4b525bc4 100644 --- a/website/docs/r/nas_permission_group.html.markdown +++ b/website/docs/r/nas_permission_group.html.markdown @@ -21,7 +21,7 @@ resource "volcengine_nas_permission_group" "foo" { permission_rules { cidr_ip = "192.168.0.0" rw_mode = "RO" - use_mode = "All_squash" + use_mode = "No_all_squash" } } ```