Skip to content

Commit dfe78c8

Browse files
committed
Testing Terraform provider.
- Resource tested: * Area * Floor * Building * ConfigurationTemplate - DS Tested: * App Policy * Applications * Site * TemplateProject
1 parent 8c6373b commit dfe78c8

File tree

15 files changed

+116
-44
lines changed

15 files changed

+116
-44
lines changed

dnacenter/data_source_applications_count.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func dataSourceApplicationsCount() *schema.Resource {
3030

3131
"response": &schema.Schema{
3232
Description: `Response`,
33-
Type: schema.TypeString,
33+
Type: schema.TypeFloat,
3434
Computed: true,
3535
},
3636

dnacenter/data_source_site.go

Lines changed: 90 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,43 @@ func flattenSitesGetSiteItems(items *[]dnacentersdkgo.ResponseSitesGetSiteRespon
179179
respItem := make(map[string]interface{})
180180
respItem["parent_id"] = item.ParentID
181181
respItem["name"] = item.Name
182-
respItem["additional_info"] = item.AdditionalInfo
182+
respItem["additional_info"] = flattenSitesGetSiteItemsAdditionalInfo(item.AdditionalInfo, nil)
183+
respItem["site_hierarchy"] = item.SiteHierarchy
184+
respItem["site_name_hierarchy"] = item.SiteNameHierarchy
185+
respItem["instance_tenant_id"] = item.InstanceTenantID
186+
respItem["id"] = item.ID
187+
respItems = append(respItems, respItem)
188+
}
189+
return respItems
190+
}
191+
func flattenSitesGetFloorItems(items *[]dnacentersdkgo.ResponseSitesGetFloorResponse) []map[string]interface{} {
192+
if items == nil {
193+
return nil
194+
}
195+
var respItems []map[string]interface{}
196+
for _, item := range *items {
197+
respItem := make(map[string]interface{})
198+
respItem["parent_id"] = item.ParentID
199+
respItem["name"] = item.Name
200+
respItem["additional_info"] = flattenSitesGetFloorItemsAdditionalInfo(item.AdditionalInfo)
201+
respItem["site_hierarchy"] = item.SiteHierarchy
202+
respItem["site_name_hierarchy"] = item.SiteNameHierarchy
203+
respItem["instance_tenant_id"] = item.InstanceTenantID
204+
respItem["id"] = item.ID
205+
respItems = append(respItems, respItem)
206+
}
207+
return respItems
208+
}
209+
func flattenSitesGetAreaItems(items *[]dnacentersdkgo.ResponseSitesGetAreaResponse) []map[string]interface{} {
210+
if items == nil {
211+
return nil
212+
}
213+
var respItems []map[string]interface{}
214+
for _, item := range *items {
215+
respItem := make(map[string]interface{})
216+
respItem["parent_id"] = item.ParentID
217+
respItem["name"] = item.Name
218+
respItem["additional_info"] = flattenSitesGetAreaItemsAdditionalInfo(item.AdditionalInfo, nil)
183219
respItem["site_hierarchy"] = item.SiteHierarchy
184220
respItem["site_name_hierarchy"] = item.SiteNameHierarchy
185221
respItem["instance_tenant_id"] = item.InstanceTenantID
@@ -343,22 +379,39 @@ func flattenSitesGetAreaParams(items *[]dnacentersdkgo.ResponseSitesGetAreaRespo
343379

344380
}
345381

346-
/*
347-
func flattenSitesGetSiteItem(item *dnacentersdkgo.ResponseSitesGetSiteResponse) []map[string]interface{} {
348-
if item == nil {
349-
return nil
350-
}
382+
func flattenSitesGetSiteItemsAdditionalInfo(items []dnacentersdkgo.ResponseSitesGetSiteResponseAdditionalInfo, parameters []interface{}) []map[string]interface{} {
351383
var respItems []map[string]interface{}
352-
353-
respItem := make(map[string]interface{})
354-
respItem["parent_id"] = item.ParentID
355-
respItem["name"] = item.Name
356-
respItem["additional_info"] = flattenSitesGetSiteItemsAdditionalInfo(item.AdditionalInfo)
357-
358-
respItems = append(respItems, respItem)
359-
384+
var parentName string
385+
if parameters != nil {
386+
parentName = getParametersOfLastUpdatedBuilding(parameters, "parent_name", "building")
387+
} else {
388+
parentName = ""
389+
}
390+
for _, item := range items {
391+
respItem := make(map[string]interface{})
392+
respItem["name_space"] = item.Namespace
393+
respItem["attributes"] = []map[string]interface{}{
394+
{
395+
"country": item.Attributes.Country,
396+
"address": item.Attributes.Address,
397+
"latitude": item.Attributes.Latitude,
398+
"addressinheritedfrom": item.Attributes.AddressInheritedFrom,
399+
"type": item.Attributes.Type,
400+
"longitude": item.Attributes.Longitude,
401+
"offsetx": item.Attributes.OffsetX,
402+
"offsety": item.Attributes.OffsetY,
403+
"length": item.Attributes.Length,
404+
"width": item.Attributes.Width,
405+
"height": item.Attributes.Height,
406+
"rfmodel": item.Attributes.RfModel,
407+
"floorindex": item.Attributes.FloorIndex,
408+
"parent_name": parentName,
409+
},
410+
}
411+
respItems = append(respItems, respItem)
412+
}
360413
return respItems
361-
}*/
414+
}
362415

363416
func flattenSitesGetFloorItemsAdditionalInfo(items []dnacentersdkgo.ResponseSitesGetFloorResponseAdditionalInfo) []map[string]interface{} {
364417
var respItems []map[string]interface{}
@@ -405,6 +458,28 @@ func flattenSitesGetAreaItemsAdditionalInfo(items []dnacentersdkgo.ResponseSites
405458
return respItems
406459
}
407460

461+
func flattenSitesGetSiteItemsAdditionalInfoAtributes(item *dnacentersdkgo.ResponseSitesGetSiteResponseAdditionalInfoAttributes) map[string]interface{} {
462+
if item == nil {
463+
return nil
464+
}
465+
respItem := make(map[string]interface{})
466+
respItem["country"] = item.Country
467+
respItem["address"] = item.Address
468+
respItem["latitude"] = item.Latitude
469+
respItem["addressInheritedFrom"] = item.AddressInheritedFrom
470+
respItem["type"] = item.Longitude
471+
respItem["offsetX"] = item.OffsetX
472+
respItem["offsetY"] = item.OffsetY
473+
respItem["length"] = item.Length
474+
respItem["width"] = item.Width
475+
respItem["height"] = item.Height
476+
respItem["rfModel"] = item.RfModel
477+
respItem["rfModel"] = item.RfModel
478+
respItem["floorIndex"] = item.FloorIndex
479+
480+
return respItem
481+
}
482+
408483
func getParametersOfLastUpdatedBuilding(parameters []interface{}, searchValue string, typeSite string) string {
409484
for _, param := range parameters {
410485
paramData, ok := param.(map[string]interface{})

dnacenter/resource_area.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func resourceAreaRead(ctx context.Context, d *schema.ResourceData, m interface{}
328328
return diags
329329
}
330330
parameters := d.Get("parameters").([]interface{})
331-
vItem1 := flattenSitesGetAreaParams(response1.Response, parameters)
331+
vItem1 := flattenSitesGetAreaItems(response1.Response)
332332
log.Printf("[DEBUG] response flatten sent => %v", responseInterfaceToString(vItem1))
333333
if err := d.Set("item", vItem1); err != nil {
334334
diags = append(diags, diagError(

dnacenter/resource_building.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func resourceBuildingRead(ctx context.Context, d *schema.ResourceData, m interfa
396396
return diags
397397
}
398398
parameters := d.Get("parameters").([]interface{})
399-
vItem1 := flattenSitesGetSiteParams(response1.Response, parameters)
399+
vItem1 := flattenSitesGetSiteItems(response1.Response)
400400
log.Printf("[DEBUG] response flatten sent => %v", responseInterfaceToString(vItem1))
401401
if err := d.Set("item", vItem1); err != nil {
402402
diags = append(diags, diagError(

dnacenter/resource_floor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func resourceFloorRead(ctx context.Context, d *schema.ResourceData, m interface{
376376
return diags
377377
}
378378
parameters := d.Get("parameters").([]interface{})
379-
vItem1 := flattenSitesGetFloorParams(response1.Response, parameters)
379+
vItem1 := flattenSitesGetFloorItems(response1.Response)
380380
log.Printf("[DEBUG] response flatten sent => %v", responseInterfaceToString(vItem1))
381381
if err := d.Set("item", vItem1); err != nil {
382382
diags = append(diags, diagError(

examples/samples/data-sources/dnacenter_app_policy/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
dnacenter = {
4-
version = "1.1.33-beta"
4+
version = "1.1.34-beta"
55
source = "hashicorp.com/edu/dnacenter"
66
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
77
}
@@ -10,7 +10,7 @@ terraform {
1010

1111
data "dnacenter_app_policy" "example" {
1212
provider = dnacenter
13-
# policy_scope = "draft_WiredTest"
13+
policy_scope = "draft_WiredTest"
1414
}
1515

1616
output "dnacenter_app_policy_example" {

examples/samples/data-sources/dnacenter_applications/data-source.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ provider "dnacenter" {
1414
data "dnacenter_applications" "example" {
1515
provider = dnacenter
1616
# limit = 1
17-
# name = "intrinsa"
17+
name = "intrinsa"
1818
# offset = 1
1919
}
2020

examples/samples/data-sources/dnacenter_building/data-source.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
dnacenter = {
4-
version = "1.1.33-beta"
4+
version = "1.1.34-beta"
55
source = "hashicorp.com/edu/dnacenter"
66
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
77
}
@@ -16,6 +16,6 @@ data "dnacenter_building" "example" {
1616
# type = "string"
1717
}
1818

19-
output "dnacenter_building_example" {
20-
value = data.dnacenter_building.example.items
21-
}
19+
# output "dnacenter_building_example" {
20+
# value = data.dnacenter_building.example.items
21+
# }

examples/samples/data-sources/dnacenter_client_health/data-source.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
data "dnacenter_client_health" "example" {
33
provider = dnacenter
4-
timestamp = "string"
4+
# timestamp = "string"
55
}
66

77
output "dnacenter_client_health_example" {

examples/samples/data-sources/dnacenter_configuration_template_project/data-source.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
dnacenter = {
4-
version = "1.1.33-beta"
4+
version = "1.1.34-beta"
55
source = "hashicorp.com/edu/dnacenter"
66
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
77
}

0 commit comments

Comments
 (0)