diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d7e334e..8af00e65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.8.1 (unreleased) + +- Enhance handling of DNS split profile assignments by adding checks for empty responses and refining matching logic for assignment IDs during updates - Issue #131. +- Add undocumented `ipv6_prefix_assignments[].disabled` attribute to `meraki_appliance_single_vlan` resource. + ## 1.8.0 - Add `high_speed_enabled` attribute to `meraki_switch_port` resources and data sources diff --git a/docs/data-sources/appliance_single_lan.md b/docs/data-sources/appliance_single_lan.md index 09a864a0..85b3a247 100644 --- a/docs/data-sources/appliance_single_lan.md +++ b/docs/data-sources/appliance_single_lan.md @@ -40,6 +40,7 @@ data "meraki_appliance_single_lan" "example" { Read-Only: - `autonomous` (Boolean) Auto assign a /64 prefix from the origin to the VLAN +- `disabled` (Boolean) Disable IPv6 on VLAN. - `origin_interfaces` (List of String) Interfaces associated with the prefix - `origin_type` (String) Type of the origin - `static_appliance_ip6` (String) Manual configuration of the IPv6 Appliance IP diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 8d4ecfc7..0f51ab2c 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -1,12 +1,17 @@ ---- -subcategory: "Guides" -page_title: "Changelog" -description: |- - Changelog ---- - -# Changelog - +--- +subcategory: "Guides" +page_title: "Changelog" +description: |- + Changelog +--- + +# Changelog + +## 1.8.1 (unreleased) + +- Enhance handling of DNS split profile assignments by adding checks for empty responses and refining matching logic for assignment IDs during updates - Issue #131. +- Add undocumented `ipv6_prefix_assignments[].disabled` attribute to `meraki_appliance_single_vlan` resource. + ## 1.8.0 - Add `high_speed_enabled` attribute to `meraki_switch_port` resources and data sources @@ -333,4 +338,4 @@ description: |- ## 0.1.0 - Initial release - + diff --git a/docs/resources/appliance_single_lan.md b/docs/resources/appliance_single_lan.md index 36a1296e..fff833cb 100644 --- a/docs/resources/appliance_single_lan.md +++ b/docs/resources/appliance_single_lan.md @@ -47,6 +47,7 @@ resource "meraki_appliance_single_lan" "example" { Optional: - `autonomous` (Boolean) Auto assign a /64 prefix from the origin to the VLAN +- `disabled` (Boolean) Disable IPv6 on VLAN. - `origin_interfaces` (List of String) Interfaces associated with the prefix - `origin_type` (String) Type of the origin - Choices: `independent`, `internet` diff --git a/gen/definitions/appliance_dns_split_profile_assignments.yaml b/gen/definitions/appliance_dns_split_profile_assignments.yaml index 02b87836..c170708c 100644 --- a/gen/definitions/appliance_dns_split_profile_assignments.yaml +++ b/gen/definitions/appliance_dns_split_profile_assignments.yaml @@ -7,6 +7,8 @@ no_update: false no_delete: false no_import: true no_read: false +get_in_create_context: true +read_path_method: getAssignmentsPath doc_category: Appliances test_tags: [APPLIANCE_DNS_SPLIT_PROFILE_ASSIGNMENTS] test_variables: [test_org, test_network] @@ -34,12 +36,14 @@ attributes: description: ID of the network example: N_123456 test_value: meraki_network.test.id + id: true - model_name: id type: String data_path: [profile] mandatory: true description: ID of the profile example: "1234" + id: true test_value: meraki_appliance_dns_split_profile.test.id test_prerequisites: | data "meraki_organization" "test" { diff --git a/gen/definitions/appliance_single_lan.yaml b/gen/definitions/appliance_single_lan.yaml index dcc44eb1..8d065eac 100644 --- a/gen/definitions/appliance_single_lan.yaml +++ b/gen/definitions/appliance_single_lan.yaml @@ -39,6 +39,10 @@ attributes: type: Bool description: Auto assign a /64 prefix from the origin to the VLAN example: "false" + - model_name: disabled + type: Bool + description: Disable IPv6 on VLAN. + example: "false" - model_name: staticApplianceIp6 type: String description: Manual configuration of the IPv6 Appliance IP diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index 0854fa14..2e1e8732 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -14,6 +14,8 @@ no_delete: bool(required=False) # Set to true if the DELETE request is not suppo no_import: bool(required=False) # Set to true if the resource does not support importing no_read: bool(required=False) # Set to true if the resource does not support reading (GET) post_and_put: bool(required=False) # Set to true if the resource should issue another PUT request after a POST request +get_in_create_context: bool(required=False) # Set to true if the resource should issue a GET request after create to retrieve computed values +read_path_method: str(required=False) # Method name to use for Read() path (e.g., "getAssignmentsPath", "getGetPath"). If not specified, uses "getPath()" data_source_name_query: bool(required=False) # Set to true if the data source supports name queries minimum_version: str(required=False) # Define a minimum supported version ds_description: str(required=False) # Define a data source description diff --git a/gen/templates/resource.go b/gen/templates/resource.go index d5930831..0600ca19 100644 --- a/gen/templates/resource.go +++ b/gen/templates/resource.go @@ -437,7 +437,21 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C {{- else}} plan.Id = types.StringValue(res.Get("{{.IdName}}").String()) {{- end}} + + {{- if .GetInCreateContext}} + {{- if .ReadPathMethod}} + resGet, errGet := r.client.Get(plan.{{.ReadPathMethod}}()) + {{- else}} + resGet, errGet := r.client.Get(plan.getPath()) + {{- end}} + if errGet != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", errGet, resGet.String())) + return + } + plan.fromBodyUnknowns(ctx, resGet) + {{- else}} plan.fromBodyUnknowns(ctx, res) + {{- end}} {{- if .PostAndPut}} res, err = r.client.Put(plan.getPath() + "/" + url.QueryEscape(plan.Id.ValueString()), body) diff --git a/gen/yamlconfig/main.go b/gen/yamlconfig/main.go index 2a7d04c4..d360ccc6 100644 --- a/gen/yamlconfig/main.go +++ b/gen/yamlconfig/main.go @@ -27,9 +27,11 @@ type YamlConfig struct { GetFromAll bool `yaml:"get_from_all,omitempty"` NoUpdate bool `yaml:"no_update,omitempty"` NoDelete bool `yaml:"no_delete,omitempty"` + GetInCreateContext bool `yaml:"get_in_create_context,omitempty"` NoImport bool `yaml:"no_import,omitempty"` NoRead bool `yaml:"no_read,omitempty"` PostAndPut bool `yaml:"post_and_put,omitempty"` + ReadPathMethod string `yaml:"read_path_method,omitempty"` IdName string `yaml:"id_name,omitempty"` EarlyAccess bool `yaml:"early_access,omitempty"` DataSourceNameQuery bool `yaml:"data_source_name_query,omitempty"` @@ -66,6 +68,7 @@ type YamlConfigP struct { NoImport *bool `yaml:"no_import,omitempty"` NoRead *bool `yaml:"no_read,omitempty"` PostAndPut *bool `yaml:"post_and_put,omitempty"` + ReadPathMethod *string `yaml:"read_path_method,omitempty"` IdName *string `yaml:"id_name,omitempty"` EarlyAccess *bool `yaml:"early_access,omitempty"` DataSourceNameQuery *bool `yaml:"data_source_name_query,omitempty"` @@ -732,6 +735,9 @@ func MergeYamlConfig(existing *YamlConfigP, new *YamlConfigP) *YamlConfigP { if existing.PostAndPut != nil { new.PostAndPut = existing.PostAndPut } + if existing.ReadPathMethod != nil { + new.ReadPathMethod = existing.ReadPathMethod + } if existing.IdName != nil { new.IdName = existing.IdName } diff --git a/internal/provider/data_source_meraki_appliance_single_lan.go b/internal/provider/data_source_meraki_appliance_single_lan.go index 5536d307..f3ae8962 100644 --- a/internal/provider/data_source_meraki_appliance_single_lan.go +++ b/internal/provider/data_source_meraki_appliance_single_lan.go @@ -87,6 +87,10 @@ func (d *ApplianceSingleLANDataSource) Schema(ctx context.Context, req datasourc MarkdownDescription: "Auto assign a /64 prefix from the origin to the VLAN", Computed: true, }, + "disabled": schema.BoolAttribute{ + MarkdownDescription: "Disable IPv6 on VLAN.", + Computed: true, + }, "static_appliance_ip6": schema.StringAttribute{ MarkdownDescription: "Manual configuration of the IPv6 Appliance IP", Computed: true, diff --git a/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go b/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go index f676fad9..7caa9b90 100644 --- a/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go +++ b/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go @@ -141,8 +141,8 @@ func (data *ApplianceDNSSplitProfileAssignments) fromBody(ctx context.Context, r // "managed" elements, instead of all elements. func (data *ApplianceDNSSplitProfileAssignments) fromBodyPartial(ctx context.Context, res meraki.Res) { for i := 0; i < len(data.Items); i++ { - keys := [...]string{"assignmentId", "network.id", "profile.id"} - keyValues := [...]string{data.Items[i].AssignmentId.ValueString(), data.Items[i].NetworkId.ValueString(), data.Items[i].ProfileId.ValueString()} + keys := [...]string{"network.id", "profile.id"} + keyValues := [...]string{data.Items[i].NetworkId.ValueString(), data.Items[i].ProfileId.ValueString()} parent := &data data := (*parent).Items[i] @@ -203,8 +203,8 @@ func (data *ApplianceDNSSplitProfileAssignments) fromBodyPartial(ctx context.Con // Known values are not changed (usual for Computed attributes with UseStateForUnknown or with Default). func (data *ApplianceDNSSplitProfileAssignments) fromBodyUnknowns(ctx context.Context, res meraki.Res) { for i := 0; i < len(data.Items); i++ { - keys := [...]string{"assignmentId", "network.id", "profile.id"} - keyValues := [...]string{data.Items[i].AssignmentId.ValueString(), data.Items[i].NetworkId.ValueString(), data.Items[i].ProfileId.ValueString()} + keys := [...]string{"network.id", "profile.id"} + keyValues := [...]string{data.Items[i].NetworkId.ValueString(), data.Items[i].ProfileId.ValueString()} parent := &data data := (*parent).Items[i] diff --git a/internal/provider/model_meraki_appliance_single_lan.go b/internal/provider/model_meraki_appliance_single_lan.go index 1adc92db..75050a21 100644 --- a/internal/provider/model_meraki_appliance_single_lan.go +++ b/internal/provider/model_meraki_appliance_single_lan.go @@ -47,6 +47,7 @@ type ApplianceSingleLAN struct { type ApplianceSingleLANIpv6PrefixAssignments struct { Autonomous types.Bool `tfsdk:"autonomous"` + Disabled types.Bool `tfsdk:"disabled"` StaticApplianceIp6 types.String `tfsdk:"static_appliance_ip6"` StaticPrefix types.String `tfsdk:"static_prefix"` OriginType types.String `tfsdk:"origin_type"` @@ -83,6 +84,9 @@ func (data ApplianceSingleLAN) toBody(ctx context.Context, state ApplianceSingle if !item.Autonomous.IsNull() { itemBody, _ = sjson.Set(itemBody, "autonomous", item.Autonomous.ValueBool()) } + if !item.Disabled.IsNull() { + itemBody, _ = sjson.Set(itemBody, "disabled", item.Disabled.ValueBool()) + } if !item.StaticApplianceIp6.IsNull() { itemBody, _ = sjson.Set(itemBody, "staticApplianceIp6", item.StaticApplianceIp6.ValueString()) } @@ -136,6 +140,11 @@ func (data *ApplianceSingleLAN) fromBody(ctx context.Context, res meraki.Res) { } else { data.Autonomous = types.BoolNull() } + if value := res.Get("disabled"); value.Exists() && value.Value() != nil { + data.Disabled = types.BoolValue(value.Bool()) + } else { + data.Disabled = types.BoolNull() + } if value := res.Get("staticApplianceIp6"); value.Exists() && value.Value() != nil { data.StaticApplianceIp6 = types.StringValue(value.String()) } else { @@ -208,6 +217,11 @@ func (data *ApplianceSingleLAN) fromBodyPartial(ctx context.Context, res meraki. } else { data.Autonomous = types.BoolNull() } + if value := res.Get("disabled"); value.Exists() && !data.Disabled.IsNull() { + data.Disabled = types.BoolValue(value.Bool()) + } else { + data.Disabled = types.BoolNull() + } if value := res.Get("staticApplianceIp6"); value.Exists() && !data.StaticApplianceIp6.IsNull() { data.StaticApplianceIp6 = types.StringValue(value.String()) } else { diff --git a/internal/provider/resource_meraki_appliance_dns_split_profile_assignments.go b/internal/provider/resource_meraki_appliance_dns_split_profile_assignments.go index badab597..f1d21e36 100644 --- a/internal/provider/resource_meraki_appliance_dns_split_profile_assignments.go +++ b/internal/provider/resource_meraki_appliance_dns_split_profile_assignments.go @@ -131,7 +131,12 @@ func (r *ApplianceDNSSplitProfileAssignmentsResource) Create(ctx context.Context return } plan.Id = plan.OrganizationId - plan.fromBodyUnknowns(ctx, res) + resGet, errGet := r.client.Get(plan.getAssignmentsPath()) + if errGet != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", errGet, resGet.String())) + return + } + plan.fromBodyUnknowns(ctx, resGet) tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_single_lan.go b/internal/provider/resource_meraki_appliance_single_lan.go index 17d80ef5..3b5abdd7 100644 --- a/internal/provider/resource_meraki_appliance_single_lan.go +++ b/internal/provider/resource_meraki_appliance_single_lan.go @@ -99,6 +99,10 @@ func (r *ApplianceSingleLANResource) Schema(ctx context.Context, req resource.Sc MarkdownDescription: helpers.NewAttributeDescription("Auto assign a /64 prefix from the origin to the VLAN").String, Optional: true, }, + "disabled": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Disable IPv6 on VLAN.").String, + Optional: true, + }, "static_appliance_ip6": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Manual configuration of the IPv6 Appliance IP").String, Optional: true, diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 8d4ecfc7..0f51ab2c 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -1,12 +1,17 @@ ---- -subcategory: "Guides" -page_title: "Changelog" -description: |- - Changelog ---- - -# Changelog - +--- +subcategory: "Guides" +page_title: "Changelog" +description: |- + Changelog +--- + +# Changelog + +## 1.8.1 (unreleased) + +- Enhance handling of DNS split profile assignments by adding checks for empty responses and refining matching logic for assignment IDs during updates - Issue #131. +- Add undocumented `ipv6_prefix_assignments[].disabled` attribute to `meraki_appliance_single_vlan` resource. + ## 1.8.0 - Add `high_speed_enabled` attribute to `meraki_switch_port` resources and data sources @@ -333,4 +338,4 @@ description: |- ## 0.1.0 - Initial release - +