Skip to content

Commit

Permalink
Merge pull request #271 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bvargasre authored Jun 27, 2024
2 parents 5ce155a + 2fa3fd8 commit b2629b3
Show file tree
Hide file tree
Showing 196 changed files with 326 additions and 274 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.33-beta (June 26, 2024)
BUGFIXES:
* Resource `pnp_devoce` pagination bug fixed. #254
* Resource `reserve_ip_subpool` import bug fix. #265
* Resource `discovery` pagination bug fixed. #267

## 1.1.32-beta (June 13, 2024)
BUGFIXES:
* Data source `device_details` fixed. Change `timestamp` attribute from `string` to `int`.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=hashicorp.com
NAMESPACE=edu
NAME=dnacenter
BINARY=terraform-provider-${NAME}
VERSION=1.1.32-beta
VERSION=1.1.33-beta
OS_ARCH=darwin_arm64
# Change to OS_ARCH=darwin_arm64 or your current architecture
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The following table shows the supported versions.
| 2.2.3.3 | 0.3.0-beta |
| 2.2.3.3 | 0.3.0 |
| 2.3.3.0 | 1.0.19-beta |
| 2.3.5.3 | 1.1.32-beta |
| 2.3.5.3 | 1.1.33-beta |

If your SDK, Terraform provider is older please consider updating it first.

Expand Down Expand Up @@ -66,7 +66,7 @@ terraform {
required_providers {
dnacenter = {
source = "cisco-en-programmability/dnacenter"
version = "1.1.32-beta"
version = "1.1.33-beta"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dnacenter/data_source_network_device_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func dataSourceNetworkDeviceCountRead(ctx context.Context, d *schema.ResourceDat
}

d.SetId(getUnixTimeString())
return diags

vItemID2 := flattenDevicesGetDeviceCount2ItemID(response2)
if err := d.Set("item_id", vItemID2); err != nil {
diags = append(diags, diagError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func dataSourceNetworkDeviceInventoryInsightLinkMismatchRead(ctx context.Context
return diags
}

func flattenDevicesInventoryInsightDeviceLinkMismatchApIItems(items *[]dnacentersdkgo.ResponseDevicesInventoryInsightDeviceLinkMismatchAPIResponse) []map[string]interface{} {
func flattenDevicesInventoryInsightDeviceLinkMismatchApIItems(items *[]dnacentersdkgo.ResponseDevicesInventoryInsightDeviceLinkMismatchApIResponse) []map[string]interface{} {
if items == nil {
return nil
}
Expand Down
68 changes: 35 additions & 33 deletions dnacenter/data_source_templates_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ func dataSourceTemplatesDetailsRead(ctx context.Context, d *schema.ResourceData,

log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1))

vItem1 := flattenConfigurationTemplatesGetTemplatesDetailsItem(response1)
vItem1 := flattenConfigurationTemplatesGetTemplatesDetailsItem(&response1.Response)
if err := d.Set("item", vItem1); err != nil {
diags = append(diags, diagError(
"Failure when setting GetTemplatesDetails response",
Expand All @@ -1418,42 +1418,44 @@ func dataSourceTemplatesDetailsRead(ctx context.Context, d *schema.ResourceData,
return diags
}

func flattenConfigurationTemplatesGetTemplatesDetailsItem(item *dnacentersdkgo.ResponseConfigurationTemplatesGetTemplatesDetails) []map[string]interface{} {
func flattenConfigurationTemplatesGetTemplatesDetailsItem(item *[]dnacentersdkgo.ResponseConfigurationTemplatesGetTemplatesDetailsResponse) []map[string]interface{} {
if item == nil {
return nil
}
respItem := make(map[string]interface{})
respItem["author"] = item.Author
respItem["composite"] = boolPtrToString(item.Composite)
respItem["containing_templates"] = flattenConfigurationTemplatesGetTemplatesDetailsItemContainingTemplates(item.ContainingTemplates)
respItem["create_time"] = item.CreateTime
respItem["custom_params_order"] = boolPtrToString(item.CustomParamsOrder)
respItem["description"] = item.Description
respItem["device_types"] = flattenConfigurationTemplatesGetTemplatesDetailsItemDeviceTypes(item.DeviceTypes)
respItem["failure_policy"] = item.FailurePolicy
respItem["id"] = item.ID
respItem["language"] = item.Language
respItem["last_update_time"] = item.LastUpdateTime
respItem["latest_version_time"] = item.LatestVersionTime
respItem["name"] = item.Name
respItem["parent_template_id"] = item.ParentTemplateID
respItem["project_associated"] = boolPtrToString(item.ProjectAssociated)
respItem["project_id"] = item.ProjectID
respItem["project_name"] = item.ProjectName
respItem["rollback_template_content"] = item.RollbackTemplateContent
respItem["rollback_template_params"] = flattenConfigurationTemplatesGetTemplatesDetailsItemRollbackTemplateParams(item.RollbackTemplateParams)
respItem["software_type"] = item.SoftwareType
respItem["software_variant"] = item.SoftwareVariant
respItem["software_version"] = item.SoftwareVersion
respItem["tags"] = flattenConfigurationTemplatesGetTemplatesDetailsItemTags(item.Tags)
respItem["template_content"] = item.TemplateContent
respItem["template_params"] = flattenConfigurationTemplatesGetTemplatesDetailsItemTemplateParams(item.TemplateParams)
respItem["validation_errors"] = flattenConfigurationTemplatesGetTemplatesDetailsItemValidationErrors(item.ValidationErrors)
respItem["version"] = item.Version
respItem["versions_info"] = flattenConfigurationTemplatesGetTemplatesDetailsItemVersionsInfo(item.VersionsInfo)
return []map[string]interface{}{
respItem,
var respItems []map[string]interface{}
for _, item := range *item {
respItem := make(map[string]interface{})
respItem["author"] = item.Author
respItem["composite"] = boolPtrToString(item.Composite)
respItem["containing_templates"] = flattenConfigurationTemplatesGetTemplatesDetailsItemContainingTemplates(item.ContainingTemplates)
respItem["create_time"] = item.CreateTime
respItem["custom_params_order"] = boolPtrToString(item.CustomParamsOrder)
respItem["description"] = item.Description
respItem["device_types"] = flattenConfigurationTemplatesGetTemplatesDetailsItemDeviceTypes(item.DeviceTypes)
respItem["failure_policy"] = item.FailurePolicy
respItem["id"] = item.ID
respItem["language"] = item.Language
respItem["last_update_time"] = item.LastUpdateTime
respItem["latest_version_time"] = item.LatestVersionTime
respItem["name"] = item.Name
respItem["parent_template_id"] = item.ParentTemplateID
respItem["project_associated"] = boolPtrToString(item.ProjectAssociated)
respItem["project_id"] = item.ProjectID
respItem["project_name"] = item.ProjectName
respItem["rollback_template_content"] = item.RollbackTemplateContent
respItem["rollback_template_params"] = flattenConfigurationTemplatesGetTemplatesDetailsItemRollbackTemplateParams(item.RollbackTemplateParams)
respItem["software_type"] = item.SoftwareType
respItem["software_variant"] = item.SoftwareVariant
respItem["software_version"] = item.SoftwareVersion
respItem["tags"] = flattenConfigurationTemplatesGetTemplatesDetailsItemTags(item.Tags)
respItem["template_content"] = item.TemplateContent
respItem["template_params"] = flattenConfigurationTemplatesGetTemplatesDetailsItemTemplateParams(item.TemplateParams)
respItem["validation_errors"] = flattenConfigurationTemplatesGetTemplatesDetailsItemValidationErrors(item.ValidationErrors)
respItem["version"] = item.Version
respItem["versions_info"] = flattenConfigurationTemplatesGetTemplatesDetailsItemVersionsInfo(item.VersionsInfo)
respItems = append(respItems, respItem)
}
return respItems
}

func flattenConfigurationTemplatesGetTemplatesDetailsItemContainingTemplates(items *[]dnacentersdkgo.ResponseConfigurationTemplatesGetTemplatesDetailsContainingTemplates) []map[string]interface{} {
Expand Down
33 changes: 24 additions & 9 deletions dnacenter/resource_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -1379,17 +1379,29 @@ func searchDiscovery(m interface{}, vName string) (*dnacentersdkgo.ResponseDisco
client := m.(*dnacentersdkgo.Client)
var err error
var foundItem *dnacentersdkgo.ResponseDiscoveryGetDiscoveriesByRangeResponse
if vName != "" {
totalDiscovery, _, err := client.Discovery.GetCountOfAllDiscoveryJobs()
if err != nil || totalDiscovery == nil {
return foundItem, err
}
if vName == "" {
return foundItem, err
}
totalDiscovery, _, err := client.Discovery.GetCountOfAllDiscoveryJobs()
if err != nil || totalDiscovery == nil {
return foundItem, err
}
if totalDiscovery.Response == nil || *totalDiscovery.Response < 1 {
return foundItem, err
}

if err != nil || totalDiscovery.Response == nil || *totalDiscovery.Response < 1 {
return foundItem, err
totalRecords := *totalDiscovery.Response
const recordsToReturn = 500
startIndex := 1
for {
if totalRecords <= 0 {
break
}

response, _, err := client.Discovery.GetDiscoveriesByRange(1, *totalDiscovery.Response)
records := recordsToReturn
if totalRecords < recordsToReturn {
records = totalRecords
}
response, _, err := client.Discovery.GetDiscoveriesByRange(startIndex, records)
if err != nil || response == nil {
return foundItem, err
}
Expand All @@ -1399,6 +1411,9 @@ func searchDiscovery(m interface{}, vName string) (*dnacentersdkgo.ResponseDisco
return &item, err
}
}

totalRecords -= records
startIndex += records
}
return foundItem, err
}
34 changes: 21 additions & 13 deletions dnacenter/resource_pnp_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -2958,12 +2958,15 @@ func resourcePnpDeviceCreate(ctx context.Context, d *schema.ResourceData, m inte
if _, ok := d.GetOk("parameters.0.device_info.0"); ok {
if v, ok := d.GetOk("parameters.0.device_info.0.name"); ok {
vName = interfaceToString(v)
} else if v, ok := d.GetOk("parameters.0.device_info.0.serial_number"); ok {
vName = interfaceToString(v)
}
}
}
}
var vvName string
vvName = vName
log.Printf("[DEBUG] vName: %s", vName)
log.Printf("[DEBUG] vID: %s", vID)
vvName := vName
vvID := interfaceToString(vID)
if okID && vvID != "" {
getResponse2, _, err := client.DeviceOnboardingPnp.GetDeviceByID(vvID)
Expand Down Expand Up @@ -6173,19 +6176,24 @@ func searchDeviceOnboardingPnpGetDeviceList2(m interface{}, queryParams dnacente
client := m.(*dnacentersdkgo.Client)
var err error
var foundItem *dnacentersdkgo.ResponseItemDeviceOnboardingPnpGetDeviceList2
nResponse, _, err := client.DeviceOnboardingPnp.GetDeviceList2(nil)
if nResponse == nil || err != nil {
return foundItem, err
}
maxPageSize := len(*nResponse)
for _, item := range *nResponse {
if item.DeviceInfo != nil && vName == item.DeviceInfo.Name {
foundItem = &item
queryParams.Offset = 0
for {
log.Println("[DEBUG] INSIDE THE LOOP")
nResponse, _, err := client.DeviceOnboardingPnp.GetDeviceList2(&queryParams)
if err != nil {
return foundItem, err
}
if nResponse == nil || len(*nResponse) == 0 {
break
}
for _, item := range *nResponse {
if item.DeviceInfo != nil && vName == item.DeviceInfo.Name {
foundItem = &item
return foundItem, err
}
}
queryParams.Offset += len(*nResponse)
queryParams.Limit = len(*nResponse)
}
queryParams.Limit = maxPageSize
queryParams.Offset = maxPageSize
nResponse, _, err = client.DeviceOnboardingPnp.GetDeviceList2(&queryParams)
return foundItem, err
}
4 changes: 3 additions & 1 deletion dnacenter/resource_reserve_ip_subpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ func searchNetworkSettingsGetReserveIPSubpool(m interface{}, queryParams dnacent

func updateReserveIpPoolParameters(request *dnacentersdkgo.RequestNetworkSettingsReserveIPSubpool, response *dnacentersdkgo.ResponseNetworkSettingsGetReserveIPSubpoolResponse) *dnacentersdkgo.RequestNetworkSettingsReserveIPSubpool {
log.Printf("IPPOOLREQUEST %s", responseInterfaceToString(request))
if request == nil {
request = &dnacentersdkgo.RequestNetworkSettingsReserveIPSubpool{}
}
for _, v := range *response.IPPools {
log.Printf("IPPOOL %s", responseInterfaceToString(v))
log.Printf("IPPOOL Dhcp %s", responseInterfaceToString(v.DhcpServerIPs))
Expand All @@ -894,7 +897,6 @@ func updateReserveIpPoolParameters(request *dnacentersdkgo.RequestNetworkSetting
request.IPv6DhcpServers = v.DhcpServerIPs
request.IPv6DNSServers = v.DNSServerIPs
}
// request.SLAacSupport =
} else {
if v.IPPoolName == request.Name {
request.Name = v.IPPoolName
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/dnacenter_network_v2/resource.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
2 changes: 1 addition & 1 deletion examples/samples/data-sources/dnacenter_app_policy/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.32-beta"
version = "1.1.33-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Loading

0 comments on commit b2629b3

Please sign in to comment.