diff --git a/docs/resources/gaussdb_opengauss_parameter_template.md b/docs/resources/gaussdb_opengauss_parameter_template.md
new file mode 100644
index 0000000000..90460318c4
--- /dev/null
+++ b/docs/resources/gaussdb_opengauss_parameter_template.md
@@ -0,0 +1,152 @@
+---
+subcategory: "GaussDB"
+layout: "huaweicloud"
+page_title: "HuaweiCloud: huaweicloud_gaussdb_opengauss_parameter_template"
+description: |-
+ Manages a GaussDB OpenGauss parameter template resource within HuaweiCloud.
+---
+
+# huaweicloud_gaussdb_opengauss_parameter_template
+
+Manages a GaussDB OpenGauss parameter template resource within HuaweiCloud.
+
+## Example Usage
+
+### create parameter template
+
+```hcl
+resource "huaweicloud_gaussdb_opengauss_parameter_template" "test" {
+ name = "test_gaussdb_opengauss_parameter_template"
+ engine_version = "8.201"
+ instance_mode = "independent"
+
+ parameters {
+ name = "audit_system_object"
+ value = "100"
+ }
+
+ parameters {
+ name = "cms:enable_finishredo_retrieve"
+ value = "on"
+ }
+}
+```
+
+### replica parameter template from existed configuration
+
+```hcl
+variable "source_configuration_id" {}
+
+resource "huaweicloud_gaussdb_opengauss_parameter_template" "test" {
+ name = "test_copy_from_configuration"
+ source_configuration_id = var.source_configuration_id
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource.
+ If omitted, the provider-level region will be used. Changing this parameter will create a new resource.
+
+* `name` - (Required, String, ForceNew) Specifies the name of the parameter template, which must be unique. The template
+ name can contain up to **64** characters. It can contain only letters (case-sensitive), digits, hyphens (-),
+ underscores (_), and periods (.).
+
+ Changing this parameter will create a new resource.
+
+* `description` - (Optional, String, ForceNew) Specifies the Parameter template description. This parameter is left blank
+ by default. Up to **256** characters are displayed. Carriage return characters or special characters (>!<"&'=) are not
+ allowed.
+
+ Changing this parameter will create a new resource.
+
+* `engine_version` - (Optional, String, ForceNew) Specifies the DB engine version.
+
+ Changing this parameter will create a new resource.
+
+ -> **NOTE:** It is mandatory when `instance_mode` is specified, and can not be specified when `source_configuration_id`
+ is specified.
+
+* `instance_mode` - (Optional, String, ForceNew) Specifies the deployment model.
+
+ Changing this parameter will create a new resource.
+
+ -> **NOTE:** It is mandatory when `engine_version` is specified, and can not be specified when `source_configuration_id`
+ is specified.
+
+* `parameters` - (Optional, List, ForceNew) Specifies the list of the template parameters.
+ The [parameters](#parameters_struct) structure is documented below.
+
+ Changing this parameter will create a new resource.
+
+ -> **NOTE:** It can not be specified when `source_configuration_id` is specified.
+
+* `source_configuration_id` - (Optional, String, ForceNew) Specifies the source parameter template ID.
+
+ Changing this parameter will create a new resource.
+
+ -> **NOTE:** It can not be specified when `engine_version`, `instance_mode` or `parameters` are specified.
+
+ -> **NOTE:** Exactly one of `engine_version` and `source_configuration_id` must be provided.
+
+
+The `parameters` block supports:
+
+* `name` - (Required, String, ForceNew) Specifies the name of a specific parameter.
+
+* `value` - (Required, String, ForceNew) Specifies the value of a specific parameter.
+
+## Attribute Reference
+
+In addition to all arguments above, the following attributes are exported:
+
+* `id` - The resource ID.
+
+* `created_at` - Indicates the creation time in the **yyyy-mm-ddThh:mm:ssZ** format.
+
+* `updated_at` - Indicates the modification time in the **yyyy-mm-ddThh:mm:ssZ** format.
+
+* `parameters` - Indicates the list of the template parameters.
+ The [parameters](#parameters_struct) structure is documented below.
+
+
+The `parameters` block supports:
+
+* `need_restart` - Indicates whether the instance needs to be rebooted.
+
+* `readonly` - Indicates whether the parameter is read-only.
+
+* `value_range` - Indicates the parameter value range.
+
+* `data_type` - Indicates the data type. The value can be **string**, **integer**, **boolean**, **list**, **all**,
+ or **float**.
+
+* `description` - Indicates the parameter description.
+
+## Import
+
+The GaussDB OpenGauss parameter template can be imported using the `id`, e.g.
+
+```bash
+$ terraform import huaweicloud_gaussdb_opengauss_parameter_template.test
+```
+
+Note that the imported state may not be identical to your resource definition, due to some attributes missing from the
+API response, security or some other reason. The missing attributes include: `source_configuration_id` and `parameters`.
+It is generally recommended running `terraform plan` after importing a GaussDB OpenGauss parameter template. You can then
+decide if changes should be applied to the GaussDB OpenGauss parameter template, or the resource definition should be
+updated to align with the GaussDB OpenGauss parameter template. Also you can ignore changes as below.
+
+```hcl
+resource "huaweicloud_gaussdb_opengauss_parameter_template" "test" {
+ ...
+
+ lifecycle {
+ ignore_changes = [
+ source_configuration_id, parameters,
+ ]
+ }
+}
+```
diff --git a/huaweicloud/provider.go b/huaweicloud/provider.go
index 1acdab362c..fcf660a211 100644
--- a/huaweicloud/provider.go
+++ b/huaweicloud/provider.go
@@ -1752,6 +1752,7 @@ func Provider() *schema.Provider {
"huaweicloud_gaussdb_opengauss_backup_stop": gaussdb.ResourceOpenGaussBackupStop(),
"huaweicloud_gaussdb_opengauss_eip_associate": gaussdb.ResourceOpenGaussEipAssociate(),
"huaweicloud_gaussdb_opengauss_primary_standby_switch": gaussdb.ResourceOpenGaussPrimaryStandbySwitch(),
+ "huaweicloud_gaussdb_opengauss_parameter_template": gaussdb.ResourceOpenGaussParameterTemplate(),
"huaweicloud_ges_graph": ges.ResourceGesGraph(),
"huaweicloud_ges_metadata": ges.ResourceGesMetadata(),
diff --git a/huaweicloud/services/acceptance/gaussdb/resource_huaweicloud_gaussdb_opengauss_parameter_template_test.go b/huaweicloud/services/acceptance/gaussdb/resource_huaweicloud_gaussdb_opengauss_parameter_template_test.go
new file mode 100644
index 0000000000..30902e88e0
--- /dev/null
+++ b/huaweicloud/services/acceptance/gaussdb/resource_huaweicloud_gaussdb_opengauss_parameter_template_test.go
@@ -0,0 +1,177 @@
+package gaussdb
+
+import (
+ "fmt"
+ "strings"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+
+ "github.com/chnsz/golangsdk"
+
+ "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config"
+ "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
+ "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils"
+)
+
+func getOpenGaussParameterTemplateResourceFunc(cfg *config.Config, state *terraform.ResourceState) (interface{}, error) {
+ region := acceptance.HW_REGION_NAME
+ var (
+ httpUrl = "v3/{project_id}/configurations/{config_id}"
+ product = "opengauss"
+ )
+ client, err := cfg.NewServiceClient(product, region)
+ if err != nil {
+ return nil, fmt.Errorf("error creating GaussDB client: %s", err)
+ }
+
+ getPath := client.Endpoint + httpUrl
+ getPath = strings.ReplaceAll(getPath, "{project_id}", client.ProjectID)
+ getPath = strings.ReplaceAll(getPath, "{config_id}", state.Primary.ID)
+
+ getOpt := golangsdk.RequestOpts{
+ KeepResponseBody: true,
+ MoreHeaders: map[string]string{"Content-Type": "application/json"},
+ }
+
+ getResp, err := client.Request("GET", getPath, &getOpt)
+ if err != nil {
+ return nil, fmt.Errorf("error retrieving GaussDB OpenGauss parameter template: %s", err)
+ }
+
+ getRespBody, err := utils.FlattenResponse(getResp)
+ if err != nil {
+ return nil, fmt.Errorf("error retrieving GaussDB OpenGauss parameter template: %s", err)
+ }
+
+ return getRespBody, nil
+}
+
+func TestAccOpenGaussParameterTemplate_basic(t *testing.T) {
+ var obj interface{}
+
+ name := acceptance.RandomAccResourceName()
+ rName := "huaweicloud_gaussdb_opengauss_parameter_template.test"
+
+ rc := acceptance.InitResourceCheck(
+ rName,
+ &obj,
+ getOpenGaussParameterTemplateResourceFunc,
+ )
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() { acceptance.TestAccPreCheck(t) },
+ ProviderFactories: acceptance.TestAccProviderFactories,
+ CheckDestroy: rc.CheckResourceDestroy(),
+ Steps: []resource.TestStep{
+ {
+ Config: testOpenGaussParameterTemplate_basic(name),
+ Check: resource.ComposeTestCheckFunc(
+ rc.CheckResourceExists(),
+ resource.TestCheckResourceAttr(rName, "name", name),
+ resource.TestCheckResourceAttr(rName, "description", "test terraform description"),
+ resource.TestCheckResourceAttr(rName, "engine_version", "8.201"),
+ resource.TestCheckResourceAttr(rName, "instance_mode", "independent"),
+ resource.TestCheckResourceAttr(rName, "parameters.#", "1"),
+ resource.TestCheckResourceAttr(rName, "parameters.0.name", "audit_system_object"),
+ resource.TestCheckResourceAttr(rName, "parameters.0.value", "100"),
+ resource.TestCheckResourceAttrSet(rName, "created_at"),
+ resource.TestCheckResourceAttrSet(rName, "updated_at"),
+ resource.TestCheckResourceAttrSet(rName, "parameters.0.need_restart"),
+ resource.TestCheckResourceAttrSet(rName, "parameters.0.readonly"),
+ resource.TestCheckResourceAttrSet(rName, "parameters.0.value_range"),
+ resource.TestCheckResourceAttrSet(rName, "parameters.0.data_type"),
+ resource.TestCheckResourceAttrSet(rName, "parameters.0.description"),
+ ),
+ },
+ {
+ ResourceName: rName,
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{"source_configuration_id", "parameters"},
+ },
+ },
+ })
+}
+
+func TestAccOpenGaussParameterTemplate_copy(t *testing.T) {
+ var obj interface{}
+
+ name := acceptance.RandomAccResourceName()
+ rName := "huaweicloud_gaussdb_opengauss_parameter_template.test"
+
+ rc := acceptance.InitResourceCheck(
+ rName,
+ &obj,
+ getOpenGaussParameterTemplateResourceFunc,
+ )
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() { acceptance.TestAccPreCheck(t) },
+ ProviderFactories: acceptance.TestAccProviderFactories,
+ CheckDestroy: rc.CheckResourceDestroy(),
+ Steps: []resource.TestStep{
+ {
+ Config: testOpenGaussParameterTemplate_copy(name),
+ Check: resource.ComposeTestCheckFunc(
+ rc.CheckResourceExists(),
+ resource.TestCheckResourceAttr(rName, "name", name),
+ resource.TestCheckResourceAttr(rName, "description", "test terraform description"),
+ resource.TestCheckResourceAttrPair(rName, "engine_version",
+ "huaweicloud_gaussdb_opengauss_parameter_template.source", "engine_version"),
+ resource.TestCheckResourceAttrPair(rName, "instance_mode",
+ "huaweicloud_gaussdb_opengauss_parameter_template.source", "instance_mode"),
+ resource.TestCheckResourceAttrPair(rName, "source_configuration_id",
+ "huaweicloud_gaussdb_opengauss_parameter_template.source", "id"),
+ resource.TestCheckResourceAttrSet(rName, "created_at"),
+ resource.TestCheckResourceAttrSet(rName, "updated_at"),
+ ),
+ },
+ {
+ ResourceName: rName,
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{"source_configuration_id", "engine_version", "instance_mode"},
+ },
+ },
+ })
+}
+
+func testOpenGaussParameterTemplate_basic(name string) string {
+ return fmt.Sprintf(`
+resource "huaweicloud_gaussdb_opengauss_parameter_template" "test" {
+ name = "%[1]s"
+ description = "test terraform description"
+ engine_version = "8.201"
+ instance_mode = "independent"
+
+ parameters {
+ name = "audit_system_object"
+ value = "100"
+ }
+}
+`, name)
+}
+
+func testOpenGaussParameterTemplate_copy(name string) string {
+ return fmt.Sprintf(`
+resource "huaweicloud_gaussdb_opengauss_parameter_template" "source" {
+ name = "%[1]s_source"
+ description = "test terraform description"
+ engine_version = "8.201"
+ instance_mode = "independent"
+
+ parameters {
+ name = "audit_system_object"
+ value = "100"
+ }
+}
+
+resource "huaweicloud_gaussdb_opengauss_parameter_template" "test" {
+ name = "%[1]s"
+ description = "test terraform description"
+ source_configuration_id = huaweicloud_gaussdb_opengauss_parameter_template.source.id
+}
+`, name)
+}
diff --git a/huaweicloud/services/gaussdb/resource_huaweicloud_gaussdb_opengauss_parameter_template.go b/huaweicloud/services/gaussdb/resource_huaweicloud_gaussdb_opengauss_parameter_template.go
new file mode 100644
index 0000000000..be80179539
--- /dev/null
+++ b/huaweicloud/services/gaussdb/resource_huaweicloud_gaussdb_opengauss_parameter_template.go
@@ -0,0 +1,370 @@
+package gaussdb
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ "github.com/hashicorp/go-multierror"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+
+ "github.com/chnsz/golangsdk"
+
+ "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/common"
+ "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config"
+ "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils"
+)
+
+// @API GaussDB POST /v3/{project_id}/configurations
+// @API GaussDB POST /v3/{project_id}/configurations/{config_id}/copy
+// @API GaussDB GET /v3/{project_id}/configurations/{config_id}
+// @API GaussDB DELETE /v3/{project_id}/configurations/{config_id}
+func ResourceOpenGaussParameterTemplate() *schema.Resource {
+ return &schema.Resource{
+ CreateContext: resourceOpenGaussParameterTemplateCreate,
+ ReadContext: resourceOpenGaussParameterTemplateRead,
+ DeleteContext: resourceOpenGaussParameterTemplateDelete,
+ Importer: &schema.ResourceImporter{
+ StateContext: schema.ImportStatePassthroughContext,
+ },
+
+ Schema: map[string]*schema.Schema{
+ "region": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ },
+ "name": {
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "description": {
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ Computed: true,
+ },
+ "engine_version": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ RequiredWith: []string{"instance_mode"},
+ ConflictsWith: []string{"source_configuration_id"},
+ },
+ "instance_mode": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ RequiredWith: []string{"engine_version"},
+ ConflictsWith: []string{"source_configuration_id"},
+ },
+ "source_configuration_id": {
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ ConflictsWith: []string{"engine_version", "instance_mode"},
+ },
+ "parameters": {
+ Type: schema.TypeSet,
+ Elem: templateParametersSchema(),
+ Optional: true,
+ ForceNew: true,
+ Computed: true,
+ RequiredWith: []string{"engine_version", "instance_mode"},
+ ConflictsWith: []string{"source_configuration_id"},
+ },
+ "created_at": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
+ "updated_at": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
+ },
+ }
+}
+
+func templateParametersSchema() *schema.Resource {
+ sc := schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "name": {
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "value": {
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "need_restart": {
+ Type: schema.TypeBool,
+ Computed: true,
+ },
+ "readonly": {
+ Type: schema.TypeBool,
+ Computed: true,
+ },
+ "value_range": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
+ "data_type": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
+ "description": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
+ },
+ }
+ return &sc
+}
+
+func resourceOpenGaussParameterTemplateCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
+ cfg := meta.(*config.Config)
+ region := cfg.GetRegion(d)
+
+ var (
+ product = "opengauss"
+ )
+ client, err := cfg.NewServiceClient(product, region)
+ if err != nil {
+ return diag.Errorf("error creating GaussDB client: %s", err)
+ }
+
+ var id string
+ if _, ok := d.GetOk("source_configuration_id"); ok {
+ id, err = copyParameterTemplate(d, client)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+ } else {
+ id, err = createParameterTemplate(d, client)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+ }
+
+ d.SetId(id)
+
+ return resourceOpenGaussParameterTemplateRead(ctx, d, meta)
+}
+
+func createParameterTemplate(d *schema.ResourceData, client *golangsdk.ServiceClient) (string, error) {
+ httpUrl := "v3/{project_id}/configurations"
+ createPath := client.Endpoint + httpUrl
+ createPath = strings.ReplaceAll(createPath, "{project_id}", client.ProjectID)
+
+ createOpt := golangsdk.RequestOpts{
+ KeepResponseBody: true,
+ }
+ createOpt.JSONBody = utils.RemoveNil(buildCreateParameterTemplateBodyParams(d))
+ createResp, err := client.Request("POST", createPath, &createOpt)
+ if err != nil {
+ return "", fmt.Errorf("error creating GaussDB OpenGauss parameter template: %s", err)
+ }
+
+ createRespBody, err := utils.FlattenResponse(createResp)
+ if err != nil {
+ return "", err
+ }
+
+ id := utils.PathSearch("id", createRespBody, "").(string)
+ if id == "" {
+ return "", fmt.Errorf("error creating GaussDB OpenGauss parameter template: ID is not found in API response")
+ }
+ return id, nil
+}
+
+func buildCreateParameterTemplateBodyParams(d *schema.ResourceData) map[string]interface{} {
+ bodyParams := map[string]interface{}{
+ "name": d.Get("name"),
+ "description": utils.ValueIgnoreEmpty(d.Get("description")),
+ "datastore": buildCreateParameterTemplateDatastoreChildBody(d),
+ "parameter_values": buildCreateTemplateParametersBodyParam(d),
+ }
+ return bodyParams
+}
+
+func buildCreateParameterTemplateDatastoreChildBody(d *schema.ResourceData) map[string]interface{} {
+ datastoreEngine := d.Get("engine_version").(string)
+ if datastoreEngine == "" {
+ return nil
+ }
+ params := map[string]interface{}{
+ "engine_version": utils.ValueIgnoreEmpty(datastoreEngine),
+ "instance_mode": utils.ValueIgnoreEmpty(d.Get("instance_mode")),
+ }
+ return params
+}
+
+func copyParameterTemplate(d *schema.ResourceData, client *golangsdk.ServiceClient) (string, error) {
+ httpUrl := "v3/{project_id}/configurations/{config_id}/copy"
+ createPath := client.Endpoint + httpUrl
+ createPath = strings.ReplaceAll(createPath, "{project_id}", client.ProjectID)
+ createPath = strings.ReplaceAll(createPath, "{config_id}", d.Get("source_configuration_id").(string))
+
+ createOpt := golangsdk.RequestOpts{
+ KeepResponseBody: true,
+ }
+ createOpt.JSONBody = utils.RemoveNil(buildCopyParameterTemplateBodyParams(d))
+ createResp, err := client.Request("POST", createPath, &createOpt)
+ if err != nil {
+ return "", fmt.Errorf("error creating GaussDB OpenGauss parameter template: %s", err)
+ }
+
+ createRespBody, err := utils.FlattenResponse(createResp)
+ if err != nil {
+ return "", err
+ }
+
+ id := utils.PathSearch("config_id", createRespBody, "").(string)
+ if id == "" {
+ return "", fmt.Errorf("error creating GaussDB OpenGauss parameter template: config_id is not found in API response")
+ }
+ return id, nil
+}
+
+func buildCreateTemplateParametersBodyParam(d *schema.ResourceData) map[string]string {
+ rawParameters := d.Get("parameters").(*schema.Set)
+ if rawParameters.Len() == 0 {
+ return nil
+ }
+ rst := make(map[string]string)
+ for _, v := range rawParameters.List() {
+ if raw, ok := v.(map[string]interface{}); ok {
+ rst[raw["name"].(string)] = raw["value"].(string)
+ }
+ }
+ return rst
+}
+
+func buildCopyParameterTemplateBodyParams(d *schema.ResourceData) map[string]interface{} {
+ bodyParams := map[string]interface{}{
+ "name": d.Get("name"),
+ "description": utils.ValueIgnoreEmpty(d.Get("description")),
+ }
+ return bodyParams
+}
+
+func resourceOpenGaussParameterTemplateRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
+ cfg := meta.(*config.Config)
+ region := cfg.GetRegion(d)
+
+ var mErr *multierror.Error
+
+ var (
+ httpUrl = "v3/{project_id}/configurations/{config_id}"
+ product = "opengauss"
+ )
+ client, err := cfg.NewServiceClient(product, region)
+ if err != nil {
+ return diag.Errorf("error creating GaussDB client: %s", err)
+ }
+
+ getPath := client.Endpoint + httpUrl
+ getPath = strings.ReplaceAll(getPath, "{project_id}", client.ProjectID)
+ getPath = strings.ReplaceAll(getPath, "{config_id}", d.Id())
+
+ getOpt := golangsdk.RequestOpts{
+ KeepResponseBody: true,
+ }
+ getResp, err := client.Request("GET", getPath, &getOpt)
+
+ if err != nil {
+ return common.CheckDeletedDiag(d, err, "error retrieving GaussDB OpenGauss parameter template")
+ }
+
+ getRespBody, err := utils.FlattenResponse(getResp)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ mErr = multierror.Append(
+ mErr,
+ d.Set("region", region),
+ d.Set("name", utils.PathSearch("name", getRespBody, nil)),
+ d.Set("description", utils.PathSearch("description", getRespBody, nil)),
+ d.Set("engine_version", utils.PathSearch("engine_version", getRespBody, nil)),
+ d.Set("instance_mode", utils.PathSearch("instance_mode", getRespBody, nil)),
+ d.Set("created_at", utils.PathSearch("created_at", getRespBody, nil)),
+ d.Set("updated_at", utils.PathSearch("updated_at", getRespBody, nil)),
+ d.Set("parameters", flattenGaussDBOpenGaussResponseBodyParameters(d, getRespBody)),
+ )
+
+ return diag.FromErr(mErr.ErrorOrNil())
+}
+
+func flattenGaussDBOpenGaussResponseBodyParameters(d *schema.ResourceData, resp interface{}) []interface{} {
+ if resp == nil {
+ return nil
+ }
+ paramsMap := buildParamsMap(d)
+ curJson := utils.PathSearch("configuration_parameters", resp, make([]interface{}, 0))
+ curArray := curJson.([]interface{})
+ rst := make([]interface{}, 0, len(curArray))
+ for _, v := range curArray {
+ paramName := utils.PathSearch("name", v, "").(string)
+ if !paramsMap[paramName] {
+ continue
+ }
+ rst = append(rst, map[string]interface{}{
+ "name": paramName,
+ "value": utils.PathSearch("value", v, nil),
+ "need_restart": utils.PathSearch("need_restart", v, nil),
+ "readonly": utils.PathSearch("readonly", v, nil),
+ "value_range": utils.PathSearch("value_range", v, nil),
+ "data_type": utils.PathSearch("data_type", v, nil),
+ "description": utils.PathSearch("description", v, nil),
+ })
+ }
+ return rst
+}
+
+func buildParamsMap(d *schema.ResourceData) map[string]bool {
+ params := d.Get("parameters").(*schema.Set).List()
+ paramsMap := make(map[string]bool)
+ for _, param := range params {
+ if v, ok := param.(map[string]interface{}); ok {
+ paramsMap[v["name"].(string)] = true
+ }
+ }
+ return paramsMap
+}
+
+func resourceOpenGaussParameterTemplateDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
+ cfg := meta.(*config.Config)
+ region := cfg.GetRegion(d)
+
+ var (
+ httpUrl = "v3/{project_id}/configurations/{config_id}"
+ product = "opengauss"
+ )
+ client, err := cfg.NewServiceClient(product, region)
+ if err != nil {
+ return diag.Errorf("error creating GaussDB client: %s", err)
+ }
+
+ deletePath := client.Endpoint + httpUrl
+ deletePath = strings.ReplaceAll(deletePath, "{project_id}", client.ProjectID)
+ deletePath = strings.ReplaceAll(deletePath, "{config_id}", d.Id())
+
+ deleteGOpt := golangsdk.RequestOpts{
+ KeepResponseBody: true,
+ }
+ _, err = client.Request("DELETE", deletePath,
+ &deleteGOpt)
+ if err != nil {
+ return common.CheckDeletedDiag(d, err, "error deleting GaussDB OpenGauss parameter template")
+ }
+
+ return nil
+}