diff --git a/dnacenter/convert.go b/dnacenter/convert.go index c204b4d7..47cee980 100644 --- a/dnacenter/convert.go +++ b/dnacenter/convert.go @@ -3,6 +3,7 @@ package dnacenter import ( "encoding/json" "fmt" + "log" "strconv" ) @@ -91,9 +92,27 @@ func getResourceItem(item interface{}) *map[string]interface{} { return &vvItem } +func sliceInterfaceToSliceString(v []interface{}) []string { + newValue := []string{} + for _, v2 := range v { + value, ok := v2.([]interface{}) + if !ok { + log.Print("sliceInterfaceToSliceString: Nil") + return nil + } + + for _, i := range value { + newValue = append(newValue, interfaceToString(i)) + } + } + return newValue +} + func interfaceToSliceString(v interface{}) []string { value, ok := v.([]interface{}) + log.Printf("interfaceToSliceString interface: %s", responseInterfaceToSliceString(v)) if !ok { + log.Print("interfaceToSliceString: Nil") return nil } newValue := []string{} diff --git a/dnacenter/data_source_reserve_ip_subpool.go b/dnacenter/data_source_reserve_ip_subpool.go index 898f46ea..586c6914 100644 --- a/dnacenter/data_source_reserve_ip_subpool.go +++ b/dnacenter/data_source_reserve_ip_subpool.go @@ -332,7 +332,7 @@ func flattenNetworkSettingsGetReserveIPSubpoolParameters(items *dnacentersdkgo.R respItem["ipv6_address_space"] = boolPtrToString(items.IPv6AddressSpace) respItem["ipv4_global_pool"] = items.IPv4GlobalPool respItem["ipv4_prefix"] = boolPtrToString(items.IPv4Prefix) - respItem["ipv4_prefix_length"] = interfaceToIntPtr(items.IPv4PrefixLength) + respItem["ipv4_prefix_length"] = items.IPv4PrefixLength respItem["ipv4_subnet"] = items.IPv4Subnet respItem["ipv4_gate_way"] = items.IPv4GateWay respItem["ipv4_dhcp_servers"] = items.IPv4DhcpServers @@ -352,6 +352,30 @@ func flattenNetworkSettingsGetReserveIPSubpoolParameters(items *dnacentersdkgo.R return respItems } +func flattenNetworkSettingsGetReserveIPSubpoolParametersDhcpServers(items []string) []interface{} { + if items == nil { + return nil + } + var respItems []interface{} + for _, item := range items { + respItem := item + respItems = append(respItems, responseInterfaceToString(respItem)) + } + return respItems +} + +func flattenNetworkSettingsGetReserveIPSubpoolParametersDnsServers(items []string) []interface{} { + if items == nil { + return nil + } + var respItems []interface{} + for _, item := range items { + respItem := item + respItems = append(respItems, responseInterfaceToString(respItem)) + } + return respItems +} + func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPools(items *[]dnacentersdkgo.ResponseNetworkSettingsGetReserveIPSubpoolResponseIPPools) []map[string]interface{} { if items == nil { return nil @@ -384,12 +408,12 @@ func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPools(items *[]dnacentersdk return respItems } -func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPoolsDhcpServerIPs(items *[]dnacentersdkgo.ResponseNetworkSettingsGetReserveIPSubpoolResponseIPPoolsDhcpServerIPs) []interface{} { +func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPoolsDhcpServerIPs(items []string) []interface{} { if items == nil { return nil } var respItems []interface{} - for _, item := range *items { + for _, item := range items { respItem := item respItems = append(respItems, responseInterfaceToString(respItem)) } @@ -406,12 +430,12 @@ func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPoolsClientOptions(item *dn } -func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPoolsDNSServerIPs(items *[]dnacentersdkgo.ResponseNetworkSettingsGetReserveIPSubpoolResponseIPPoolsDNSServerIPs) []interface{} { +func flattenNetworkSettingsGetReserveIPSubpoolItemsIPPoolsDNSServerIPs(items []string) []interface{} { if items == nil { return nil } var respItems []interface{} - for _, item := range *items { + for _, item := range items { respItem := item respItems = append(respItems, responseInterfaceToString(respItem)) } diff --git a/dnacenter/resource_reserve_ip_subpool.go b/dnacenter/resource_reserve_ip_subpool.go index a684c0c0..65da0693 100644 --- a/dnacenter/resource_reserve_ip_subpool.go +++ b/dnacenter/resource_reserve_ip_subpool.go @@ -538,6 +538,7 @@ func resourceReserveIPSubpoolRead(ctx context.Context, d *schema.ResourceData, m return diags } request1 := expandRequestReserveIPSubpoolReserveIPSubpool(ctx, "parameters.0", d) + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) updatedParameters := updateReserveIpPoolParameters(request1, response1) vParameters := flattenNetworkSettingsGetReserveIPSubpoolParameters(updatedParameters) @@ -869,22 +870,26 @@ func searchNetworkSettingsGetReserveIPSubpool(m interface{}, queryParams dnacent } func updateReserveIpPoolParameters(request *dnacentersdkgo.RequestNetworkSettingsReserveIPSubpool, response *dnacentersdkgo.ResponseNetworkSettingsGetReserveIPSubpoolResponse) *dnacentersdkgo.RequestNetworkSettingsReserveIPSubpool { + log.Printf("IPPOOLREQUEST %s", responseInterfaceToString(request)) for _, v := range *response.IPPools { - // log.Printf("IPPOOL %s", responseInterfaceToString(v)) + log.Printf("IPPOOL %s", responseInterfaceToString(v)) + log.Printf("IPPOOL Dhcp %s", responseInterfaceToString(v.DhcpServerIPs)) if v.IPv6 != nil && *v.IPv6 { if v.IPPoolName == request.Name { request.Name = v.IPPoolName - request.IPv6DhcpServers = interfaceToSliceString(v.DhcpServerIPs) - request.IPv6DNSServers = interfaceToSliceString(v.DNSServerIPs) + request.IPv6DhcpServers = v.DhcpServerIPs + request.IPv6DNSServers = v.DNSServerIPs } // request.SLAacSupport = } else { if v.IPPoolName == request.Name { request.Name = v.IPPoolName - request.IPv4DhcpServers = interfaceToSliceString(v.DhcpServerIPs) - request.IPv4DNSServers = interfaceToSliceString(v.DNSServerIPs) + request.IPv4DhcpServers = v.DhcpServerIPs + request.IPv4DNSServers = v.DNSServerIPs } } } + + log.Printf("IPPOOLREQUEST %s", responseInterfaceToString(request)) return request } diff --git a/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf b/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf index 81c6c0ad..86c234cf 100644 --- a/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf +++ b/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf @@ -19,24 +19,22 @@ resource "dnacenter_reserve_ip_subpool" "example" { ipv4_global_pool = "10.0.0.0" //id = "string" - # ipv4_dhcp_servers = [] - # ipv4_dns_servers = [] - ipv4_gate_way = "10.0.0.1" + ipv4_dhcp_servers = ["abc.def.ghi.jkl"] + ipv4_dns_servers = ["abc.def.ghi.jkl"] + ipv4_gate_way = "abc.def.ghi.jkl" ipv4_prefix_length = 27 ipv4_subnet = "17" # ipv4_total_host = 2 # ipv6_address_space = "false" - ipv6_dhcp_servers = [ - "2004:192:3::40" - ] - # ipv6_dns_servers = [] - # ipv6_gate_way = "string2" - # ipv6_global_pool = "string" + ipv6_dhcp_servers = ["abc.def.ghi.jkl2"] + ipv6_dns_servers = ["abc.def.ghi.jkl"] + ipv6_gate_way = "abc.def.ghi.jkl" + ipv6_global_pool = "10.0.0.1" # ipv6_prefix = "false" - # ipv6_prefix_length = 1 - # ipv6_subnet = "2" + ipv6_prefix_length = 10 + ipv6_subnet = "2" # ipv6_total_host = 2 - name = "80net_nyc" + name = "devhf_SVG_medtek_vlan855" site_id = "4e1fb72d-4896-49d7-aa98-57b64d93ce0a" /*slaac_support = "false" type = "string"*/ diff --git a/examples/samples/resources/dnacenter_wireless_profile/resource.tf b/examples/samples/resources/dnacenter_wireless_profile/resource.tf index 937b73d1..5539a07a 100644 --- a/examples/samples/resources/dnacenter_wireless_profile/resource.tf +++ b/examples/samples/resources/dnacenter_wireless_profile/resource.tf @@ -33,16 +33,6 @@ resource "dnacenter_wireless_profile" "example" { interface_name = "management" name = "BTest22" type = "string" - } - ssid_details { - enable_fabric = "true" - flex_connect { - enable_flex_connect = "false" - local_to_vlan = 0 - } - interface_name = "management" - name = "new2" - type = "eduroam" } ssid_details { enable_fabric = "true" @@ -54,7 +44,7 @@ resource "dnacenter_wireless_profile" "example" { name = "ATest222" type = "eduroam" } - ssid_details { + ssid_details { enable_fabric = "true" flex_connect { enable_flex_connect = "false" @@ -62,9 +52,8 @@ resource "dnacenter_wireless_profile" "example" { } interface_name = "management" name = "new" - type = "eduroam" + type = "string" } - } } } diff --git a/go.mod b/go.mod index 9609eddf..85077df5 100644 --- a/go.mod +++ b/go.mod @@ -76,6 +76,6 @@ require ( ) require ( - github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.18 + github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.20 github.com/mattn/go-isatty v0.0.19 // indirect ) diff --git a/go.sum b/go.sum index e359f447..8fdd88c2 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.18 h1:J/6QK10VJd/T2jd44blLwu6zP/vgN+EdpQ9aZSTfiNc= -github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.18/go.mod h1:4Km+JuiyL/LsNRvO4dMWUSUVbnNBRmbwzJMU1oUbn0E= +github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.20 h1:6TGimRLXTSWi40QaALp0+P+CU95AKMd1REZ35bBUBaA= +github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.20/go.mod h1:4Km+JuiyL/LsNRvO4dMWUSUVbnNBRmbwzJMU1oUbn0E= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=