From d7998d28e4b20853e999a81ddcb49042e73f578b Mon Sep 17 00:00:00 2001
From: Kuba Mazurkiewicz <132581633+kuba-mazurkiewicz@users.noreply.github.com>
Date: Tue, 15 Oct 2024 08:16:29 +0200
Subject: [PATCH 1/2] Fix issue #125 (#130)
---
CHANGELOG.md | 4 ++++
docs/guides/changelog.md | 4 ++++
gen/definitions/ip_pool.yaml | 1 +
gen/templates/resource.go | 3 +++
internal/provider/data_source_catalystcenter_ip_pool.go | 3 ++-
internal/provider/resource_catalystcenter_ip_pool.go | 2 ++
internal/provider/resource_catalystcenter_network_profile.go | 1 +
templates/guides/changelog.md.tmpl | 4 ++++
8 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c6470b79..8f57ecc7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.13 (unreleased)
+
+- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)
+
## 0.1.12
- Change default timeout for asynchronous operations to 60 seconds and introduce provider attribute `max_timeout` to set a custom timeout
diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md
index 2c62a893..74c5edb6 100644
--- a/docs/guides/changelog.md
+++ b/docs/guides/changelog.md
@@ -7,6 +7,10 @@ description: |-
# Changelog
+## 0.1.13 (unreleased)
+
+- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)
+
## 0.1.12
- Change default timeout for asynchronous operations to 60 seconds and introduce provider attribute `max_timeout` to set a custom timeout
diff --git a/gen/definitions/ip_pool.yaml b/gen/definitions/ip_pool.yaml
index c4f651f3..59e06ec0 100644
--- a/gen/definitions/ip_pool.yaml
+++ b/gen/definitions/ip_pool.yaml
@@ -3,6 +3,7 @@ name: IP Pool
rest_endpoint: /api/v2/ippool
get_requires_id: true
id_from_query_path: response
+get_extra_query_params: "?limit=1000"
doc_category: Network Settings
attributes:
- model_name: ipPoolName
diff --git a/gen/templates/resource.go b/gen/templates/resource.go
index ecbc78a4..50300567 100644
--- a/gen/templates/resource.go
+++ b/gen/templates/resource.go
@@ -451,6 +451,9 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C
params += {{$queryParams}}
{{- end}}
{{- end}}
+ {{- if .GetExtraQueryParams}}
+ params += "{{.GetExtraQueryParams}}"
+ {{- end}}
res, err = r.client.Get({{if .GetRestEndpoint}}"{{.GetRestEndpoint}}"{{else}}plan.getPath(){{end}} + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
diff --git a/internal/provider/data_source_catalystcenter_ip_pool.go b/internal/provider/data_source_catalystcenter_ip_pool.go
index 534d0413..63f0c0be 100644
--- a/internal/provider/data_source_catalystcenter_ip_pool.go
+++ b/internal/provider/data_source_catalystcenter_ip_pool.go
@@ -133,7 +133,7 @@ func (d *IPPoolDataSource) Read(ctx context.Context, req datasource.ReadRequest,
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
if config.Id.IsNull() && !config.Name.IsNull() {
- res, err := d.client.Get(config.getPath())
+ res, err := d.client.Get(config.getPath() + "?limit=1000")
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve objects, got error: %s", err))
return
@@ -157,6 +157,7 @@ func (d *IPPoolDataSource) Read(ctx context.Context, req datasource.ReadRequest,
params := ""
params += "/" + url.QueryEscape(config.Id.ValueString())
+ params += "?limit=1000"
res, err := d.client.Get(config.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
diff --git a/internal/provider/resource_catalystcenter_ip_pool.go b/internal/provider/resource_catalystcenter_ip_pool.go
index e1a79b51..27baa644 100644
--- a/internal/provider/resource_catalystcenter_ip_pool.go
+++ b/internal/provider/resource_catalystcenter_ip_pool.go
@@ -152,6 +152,7 @@ func (r *IPPoolResource) Create(ctx context.Context, req resource.CreateRequest,
return
}
params = ""
+ params += "?limit=1000"
res, err = r.client.Get(plan.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
@@ -182,6 +183,7 @@ func (r *IPPoolResource) Read(ctx context.Context, req resource.ReadRequest, res
params := ""
params += "/" + url.QueryEscape(state.Id.ValueString())
+ params += "?limit=1000"
res, err := r.client.Get(state.getPath() + params)
if err != nil && strings.Contains(err.Error(), "StatusCode 404") {
resp.State.RemoveResource(ctx)
diff --git a/internal/provider/resource_catalystcenter_network_profile.go b/internal/provider/resource_catalystcenter_network_profile.go
index cc653afa..64141bdd 100644
--- a/internal/provider/resource_catalystcenter_network_profile.go
+++ b/internal/provider/resource_catalystcenter_network_profile.go
@@ -148,6 +148,7 @@ func (r *NetworkProfileResource) Create(ctx context.Context, req resource.Create
return
}
params = ""
+ params += "?populated=true"
res, err = r.client.Get(plan.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl
index 2c62a893..74c5edb6 100644
--- a/templates/guides/changelog.md.tmpl
+++ b/templates/guides/changelog.md.tmpl
@@ -7,6 +7,10 @@ description: |-
# Changelog
+## 0.1.13 (unreleased)
+
+- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)
+
## 0.1.12
- Change default timeout for asynchronous operations to 60 seconds and introduce provider attribute `max_timeout` to set a custom timeout
From f4035c669eaef83e9d391daaeeacba078c44392f Mon Sep 17 00:00:00 2001
From: Kuba Mazurkiewicz <132581633+kuba-mazurkiewicz@users.noreply.github.com>
Date: Tue, 15 Oct 2024 08:21:02 +0200
Subject: [PATCH 2/2] Add composite template support (#133)
---
CHANGELOG.md | 1 +
docs/data-sources/template.md | 14 ++
docs/guides/changelog.md | 21 +--
docs/resources/template.md | 19 +++
.../catalystcenter_template/resource.tf | 1 +
gen/definitions/template.yaml | 36 ++++
.../data_source_catalystcenter_template.go | 32 ++++
...ata_source_catalystcenter_template_test.go | 2 +
.../provider/model_catalystcenter_template.go | 155 ++++++++++++++++--
.../resource_catalystcenter_template.go | 35 ++++
.../resource_catalystcenter_template_test.go | 2 +
templates/guides/changelog.md.tmpl | 21 +--
12 files changed, 308 insertions(+), 31 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f57ecc7..7783cecd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 0.1.13 (unreleased)
+- Add composite templates support to `catalystcenter_template` resource
- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)
## 0.1.12
diff --git a/docs/data-sources/template.md b/docs/data-sources/template.md
index 4b1371f4..01db410f 100644
--- a/docs/data-sources/template.md
+++ b/docs/data-sources/template.md
@@ -33,6 +33,8 @@ data "catalystcenter_template" "example" {
### Read-Only
+- `composite` (Boolean) Is it composite template
+- `containing_templates` (Attributes List) Containing templates for composite template (see [below for nested schema](#nestedatt--containing_templates))
- `description` (String) Description
- `device_types` (Attributes List) List of device types (see [below for nested schema](#nestedatt--device_types))
- `language` (String) Language of the template
@@ -42,6 +44,18 @@ data "catalystcenter_template" "example" {
- `template_content` (String) Template content
- `template_params` (Attributes List) List of template parameters (see [below for nested schema](#nestedatt--template_params))
+
+### Nested Schema for `containing_templates`
+
+Read-Only:
+
+- `composite` (Boolean) Is it composite template
+- `id` (String) ID of the template
+- `language` (String) Language of the template
+- `name` (String) Name of the template
+- `project_name` (String) Project name
+
+
### Nested Schema for `device_types`
diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md
index 74c5edb6..31f3a27c 100644
--- a/docs/guides/changelog.md
+++ b/docs/guides/changelog.md
@@ -1,14 +1,15 @@
----
-subcategory: "Guides"
-page_title: "Changelog"
-description: |-
- Changelog
----
-
-# Changelog
-
+---
+subcategory: "Guides"
+page_title: "Changelog"
+description: |-
+ Changelog
+---
+
+# Changelog
+
## 0.1.13 (unreleased)
+- Add composite templates support to `catalystcenter_template` resource
- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)
## 0.1.12
@@ -124,4 +125,4 @@ description: |-
## 0.1.0
- Initial release
-
+
diff --git a/docs/resources/template.md b/docs/resources/template.md
index b295279e..7fed1e89 100644
--- a/docs/resources/template.md
+++ b/docs/resources/template.md
@@ -44,6 +44,7 @@ resource "catalystcenter_template" "example" {
selection_values = { host1 = "host1" }
}
]
+ composite = false
}
```
@@ -61,6 +62,8 @@ resource "catalystcenter_template" "example" {
### Optional
+- `composite` (Boolean) Is it composite template
+- `containing_templates` (Attributes List) Containing templates for composite template (see [below for nested schema](#nestedatt--containing_templates))
- `description` (String) Description
- `software_variant` (String) Software variant
- `software_version` (String) Software version
@@ -84,6 +87,22 @@ Optional:
- `product_type` (String) Product type
+
+### Nested Schema for `containing_templates`
+
+Required:
+
+- `id` (String) ID of the template
+- `language` (String) Language of the template
+ - Choices: `JINJA`, `VELOCITY`
+- `name` (String) Name of the template
+- `project_name` (String) Project name
+
+Optional:
+
+- `composite` (Boolean) Is it composite template
+
+
### Nested Schema for `template_params`
diff --git a/examples/resources/catalystcenter_template/resource.tf b/examples/resources/catalystcenter_template/resource.tf
index 700f4087..18fcc4ea 100644
--- a/examples/resources/catalystcenter_template/resource.tf
+++ b/examples/resources/catalystcenter_template/resource.tf
@@ -29,4 +29,5 @@ resource "catalystcenter_template" "example" {
selection_values = { host1 = "host1" }
}
]
+ composite = false
}
diff --git a/gen/definitions/template.yaml b/gen/definitions/template.yaml
index d6f093db..3f867501 100644
--- a/gen/definitions/template.yaml
+++ b/gen/definitions/template.yaml
@@ -156,6 +156,42 @@ attributes:
type: Map
description: Selection values
example: "{host1 = \"host1\"}"
+ - model_name: composite
+ type: Bool
+ description: Is it composite template
+ example: false
+ - model_name: containingTemplates
+ type: List
+ description: Containing templates for composite template
+ exclude_test: true
+ attributes:
+ - model_name: name
+ type: String
+ mandatory: true
+ description: Name of the template
+ example: CompositeTemplate1
+ - model_name: id
+ id: true
+ type: String
+ description: ID of the template
+ example: 12345678-1234-1234-1234-123456789012
+ - model_name: projectName
+ type: String
+ mandatory: true
+ description: Project name
+ example: Project1
+ - model_name: language
+ type: String
+ enum_values:
+ - JINJA
+ - VELOCITY
+ mandatory: true
+ description: Language of the template
+ example: JINJA
+ - model_name: composite
+ type: Bool
+ description: Is it composite template
+ example: false
test_prerequisites: |
resource "catalystcenter_project" "test" {
name = "Project1"
diff --git a/internal/provider/data_source_catalystcenter_template.go b/internal/provider/data_source_catalystcenter_template.go
index 4de53685..c40f869c 100644
--- a/internal/provider/data_source_catalystcenter_template.go
+++ b/internal/provider/data_source_catalystcenter_template.go
@@ -197,6 +197,38 @@ func (d *TemplateDataSource) Schema(ctx context.Context, req datasource.SchemaRe
},
},
},
+ "composite": schema.BoolAttribute{
+ MarkdownDescription: "Is it composite template",
+ Computed: true,
+ },
+ "containing_templates": schema.ListNestedAttribute{
+ MarkdownDescription: "Containing templates for composite template",
+ Computed: true,
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "name": schema.StringAttribute{
+ MarkdownDescription: "Name of the template",
+ Computed: true,
+ },
+ "id": schema.StringAttribute{
+ MarkdownDescription: "ID of the template",
+ Computed: true,
+ },
+ "project_name": schema.StringAttribute{
+ MarkdownDescription: "Project name",
+ Computed: true,
+ },
+ "language": schema.StringAttribute{
+ MarkdownDescription: "Language of the template",
+ Computed: true,
+ },
+ "composite": schema.BoolAttribute{
+ MarkdownDescription: "Is it composite template",
+ Computed: true,
+ },
+ },
+ },
+ },
},
}
}
diff --git a/internal/provider/data_source_catalystcenter_template_test.go b/internal/provider/data_source_catalystcenter_template_test.go
index 6b0ef1f4..bb6108de 100644
--- a/internal/provider/data_source_catalystcenter_template_test.go
+++ b/internal/provider/data_source_catalystcenter_template_test.go
@@ -49,6 +49,7 @@ func TestAccDataSourceCcTemplate(t *testing.T) {
checks = append(checks, resource.TestCheckResourceAttr("data.catalystcenter_template.test", "template_params.0.parameter_name", "hostname"))
checks = append(checks, resource.TestCheckResourceAttr("data.catalystcenter_template.test", "template_params.0.required", "false"))
checks = append(checks, resource.TestCheckResourceAttr("data.catalystcenter_template.test", "template_params.0.selection_type", "SINGLE_SELECT"))
+ checks = append(checks, resource.TestCheckResourceAttr("data.catalystcenter_template.test", "composite", "false"))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
@@ -102,6 +103,7 @@ func testAccDataSourceCcTemplateConfig() string {
config += ` selection_type = "SINGLE_SELECT"` + "\n"
config += ` selection_values = {host1 = "host1"}` + "\n"
config += ` }]` + "\n"
+ config += ` composite = false` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/model_catalystcenter_template.go b/internal/provider/model_catalystcenter_template.go
index 70ef189b..744f5c7c 100644
--- a/internal/provider/model_catalystcenter_template.go
+++ b/internal/provider/model_catalystcenter_template.go
@@ -34,17 +34,19 @@ import (
// Section below is generated&owned by "gen/generator.go". //template:begin types
type Template struct {
- Id types.String `tfsdk:"id"`
- ProjectId types.String `tfsdk:"project_id"`
- Name types.String `tfsdk:"name"`
- Description types.String `tfsdk:"description"`
- DeviceTypes []TemplateDeviceTypes `tfsdk:"device_types"`
- Language types.String `tfsdk:"language"`
- SoftwareType types.String `tfsdk:"software_type"`
- SoftwareVariant types.String `tfsdk:"software_variant"`
- SoftwareVersion types.String `tfsdk:"software_version"`
- TemplateContent types.String `tfsdk:"template_content"`
- TemplateParams []TemplateTemplateParams `tfsdk:"template_params"`
+ Id types.String `tfsdk:"id"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Name types.String `tfsdk:"name"`
+ Description types.String `tfsdk:"description"`
+ DeviceTypes []TemplateDeviceTypes `tfsdk:"device_types"`
+ Language types.String `tfsdk:"language"`
+ SoftwareType types.String `tfsdk:"software_type"`
+ SoftwareVariant types.String `tfsdk:"software_variant"`
+ SoftwareVersion types.String `tfsdk:"software_version"`
+ TemplateContent types.String `tfsdk:"template_content"`
+ TemplateParams []TemplateTemplateParams `tfsdk:"template_params"`
+ Composite types.Bool `tfsdk:"composite"`
+ ContainingTemplates []TemplateContainingTemplates `tfsdk:"containing_templates"`
}
type TemplateDeviceTypes struct {
@@ -70,6 +72,14 @@ type TemplateTemplateParams struct {
SelectionValues types.Map `tfsdk:"selection_values"`
}
+type TemplateContainingTemplates struct {
+ Name types.String `tfsdk:"name"`
+ Id types.String `tfsdk:"id"`
+ ProjectName types.String `tfsdk:"project_name"`
+ Language types.String `tfsdk:"language"`
+ Composite types.Bool `tfsdk:"composite"`
+}
+
type TemplateTemplateParamsRanges struct {
MaxValue types.Int64 `tfsdk:"max_value"`
MinValue types.Int64 `tfsdk:"min_value"`
@@ -201,6 +211,31 @@ func (data Template) toBody(ctx context.Context, state Template) string {
body, _ = sjson.SetRaw(body, "templateParams.-1", itemBody)
}
}
+ if !data.Composite.IsNull() {
+ body, _ = sjson.Set(body, "composite", data.Composite.ValueBool())
+ }
+ if len(data.ContainingTemplates) > 0 {
+ body, _ = sjson.Set(body, "containingTemplates", []interface{}{})
+ for _, item := range data.ContainingTemplates {
+ itemBody := ""
+ if !item.Name.IsNull() {
+ itemBody, _ = sjson.Set(itemBody, "name", item.Name.ValueString())
+ }
+ if !item.Id.IsNull() {
+ itemBody, _ = sjson.Set(itemBody, "id", item.Id.ValueString())
+ }
+ if !item.ProjectName.IsNull() {
+ itemBody, _ = sjson.Set(itemBody, "projectName", item.ProjectName.ValueString())
+ }
+ if !item.Language.IsNull() {
+ itemBody, _ = sjson.Set(itemBody, "language", item.Language.ValueString())
+ }
+ if !item.Composite.IsNull() {
+ itemBody, _ = sjson.Set(itemBody, "composite", item.Composite.ValueBool())
+ }
+ body, _ = sjson.SetRaw(body, "containingTemplates.-1", itemBody)
+ }
+ }
return body
}
@@ -357,6 +392,44 @@ func (data *Template) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
+ if value := res.Get("composite"); value.Exists() {
+ data.Composite = types.BoolValue(value.Bool())
+ } else {
+ data.Composite = types.BoolNull()
+ }
+ if value := res.Get("containingTemplates"); value.Exists() && len(value.Array()) > 0 {
+ data.ContainingTemplates = make([]TemplateContainingTemplates, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateContainingTemplates{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ } else {
+ item.Name = types.StringNull()
+ }
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ } else {
+ item.Id = types.StringNull()
+ }
+ if cValue := v.Get("projectName"); cValue.Exists() {
+ item.ProjectName = types.StringValue(cValue.String())
+ } else {
+ item.ProjectName = types.StringNull()
+ }
+ if cValue := v.Get("language"); cValue.Exists() {
+ item.Language = types.StringValue(cValue.String())
+ } else {
+ item.Language = types.StringNull()
+ }
+ if cValue := v.Get("composite"); cValue.Exists() {
+ item.Composite = types.BoolValue(cValue.Bool())
+ } else {
+ item.Composite = types.BoolNull()
+ }
+ data.ContainingTemplates = append(data.ContainingTemplates, item)
+ return true
+ })
+ }
}
// End of section. //template:end fromBody
@@ -560,6 +633,60 @@ func (data *Template) updateFromBody(ctx context.Context, res gjson.Result) {
data.TemplateParams[i].SelectionValues = types.MapNull(types.StringType)
}
}
+ if value := res.Get("composite"); value.Exists() && !data.Composite.IsNull() {
+ data.Composite = types.BoolValue(value.Bool())
+ } else {
+ data.Composite = types.BoolNull()
+ }
+ for i := range data.ContainingTemplates {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.ContainingTemplates[i].Id.ValueString()}
+
+ var r gjson.Result
+ res.Get("containingTemplates").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.ContainingTemplates[i].Name.IsNull() {
+ data.ContainingTemplates[i].Name = types.StringValue(value.String())
+ } else {
+ data.ContainingTemplates[i].Name = types.StringNull()
+ }
+ if value := r.Get("id"); value.Exists() && !data.ContainingTemplates[i].Id.IsNull() {
+ data.ContainingTemplates[i].Id = types.StringValue(value.String())
+ } else {
+ data.ContainingTemplates[i].Id = types.StringNull()
+ }
+ if value := r.Get("projectName"); value.Exists() && !data.ContainingTemplates[i].ProjectName.IsNull() {
+ data.ContainingTemplates[i].ProjectName = types.StringValue(value.String())
+ } else {
+ data.ContainingTemplates[i].ProjectName = types.StringNull()
+ }
+ if value := r.Get("language"); value.Exists() && !data.ContainingTemplates[i].Language.IsNull() {
+ data.ContainingTemplates[i].Language = types.StringValue(value.String())
+ } else {
+ data.ContainingTemplates[i].Language = types.StringNull()
+ }
+ if value := r.Get("composite"); value.Exists() && !data.ContainingTemplates[i].Composite.IsNull() {
+ data.ContainingTemplates[i].Composite = types.BoolValue(value.Bool())
+ } else {
+ data.ContainingTemplates[i].Composite = types.BoolNull()
+ }
+ }
}
// End of section. //template:end updateFromBody
@@ -593,6 +720,12 @@ func (data *Template) isNull(ctx context.Context, res gjson.Result) bool {
if len(data.TemplateParams) > 0 {
return false
}
+ if !data.Composite.IsNull() {
+ return false
+ }
+ if len(data.ContainingTemplates) > 0 {
+ return false
+ }
return true
}
diff --git a/internal/provider/resource_catalystcenter_template.go b/internal/provider/resource_catalystcenter_template.go
index bbd36028..3fe06d1f 100644
--- a/internal/provider/resource_catalystcenter_template.go
+++ b/internal/provider/resource_catalystcenter_template.go
@@ -213,6 +213,41 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques
},
},
},
+ "composite": schema.BoolAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("Is it composite template").String,
+ Optional: true,
+ },
+ "containing_templates": schema.ListNestedAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("Containing templates for composite template").String,
+ Optional: true,
+ NestedObject: schema.NestedAttributeObject{
+ Attributes: map[string]schema.Attribute{
+ "name": schema.StringAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("Name of the template").String,
+ Required: true,
+ },
+ "id": schema.StringAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("ID of the template").String,
+ Required: true,
+ },
+ "project_name": schema.StringAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("Project name").String,
+ Required: true,
+ },
+ "language": schema.StringAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("Language of the template").AddStringEnumDescription("JINJA", "VELOCITY").String,
+ Required: true,
+ Validators: []validator.String{
+ stringvalidator.OneOf("JINJA", "VELOCITY"),
+ },
+ },
+ "composite": schema.BoolAttribute{
+ MarkdownDescription: helpers.NewAttributeDescription("Is it composite template").String,
+ Optional: true,
+ },
+ },
+ },
+ },
},
}
}
diff --git a/internal/provider/resource_catalystcenter_template_test.go b/internal/provider/resource_catalystcenter_template_test.go
index c8e9b3d6..d62bbaf0 100644
--- a/internal/provider/resource_catalystcenter_template_test.go
+++ b/internal/provider/resource_catalystcenter_template_test.go
@@ -50,6 +50,7 @@ func TestAccCcTemplate(t *testing.T) {
checks = append(checks, resource.TestCheckResourceAttr("catalystcenter_template.test", "template_params.0.parameter_name", "hostname"))
checks = append(checks, resource.TestCheckResourceAttr("catalystcenter_template.test", "template_params.0.required", "false"))
checks = append(checks, resource.TestCheckResourceAttr("catalystcenter_template.test", "template_params.0.selection_type", "SINGLE_SELECT"))
+ checks = append(checks, resource.TestCheckResourceAttr("catalystcenter_template.test", "composite", "false"))
var steps []resource.TestStep
if os.Getenv("SKIP_MINIMUM_TEST") == "" {
@@ -126,6 +127,7 @@ func testAccCcTemplateConfig_all() string {
config += ` selection_type = "SINGLE_SELECT"` + "\n"
config += ` selection_values = {host1 = "host1"}` + "\n"
config += ` }]` + "\n"
+ config += ` composite = false` + "\n"
config += `}` + "\n"
return config
}
diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl
index 74c5edb6..31f3a27c 100644
--- a/templates/guides/changelog.md.tmpl
+++ b/templates/guides/changelog.md.tmpl
@@ -1,14 +1,15 @@
----
-subcategory: "Guides"
-page_title: "Changelog"
-description: |-
- Changelog
----
-
-# Changelog
-
+---
+subcategory: "Guides"
+page_title: "Changelog"
+description: |-
+ Changelog
+---
+
+# Changelog
+
## 0.1.13 (unreleased)
+- Add composite templates support to `catalystcenter_template` resource
- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)
## 0.1.12
@@ -124,4 +125,4 @@ description: |-
## 0.1.0
- Initial release
-
+