Skip to content

Commit

Permalink
Merge pull request #10 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
Develop v1.0.1-beta
  • Loading branch information
fmunozmiranda authored Nov 12, 2024
2 parents e3c04f9 + bbd4e15 commit f4a3cb0
Show file tree
Hide file tree
Showing 1,235 changed files with 35,415 additions and 17,655 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
## 1.0.1-beta (November 12, 2024)
FEATURES:
* General Version Selection Behavior added. More info detailed in README.md.
* **New Data Source:** `data_source_analytics_anc_policies`
* **New Data Source:** `data_source_analytics_dictionaries`
* **New Data Source:** `data_source_analytics_endpoints`
* **New Data Source:** `data_source_analytics_endpoints_count`
* **New Data Source:** `data_source_analytics_profiling_rules`
* **New Data Source:** `data_source_analytics_profiling_rules_count`
* **New Data Source:** `data_source_analytics_tasks`
* **New Data Source:** `data_source_disasterrecovery_system_operationstatus`
* **New Data Source:** `data_source_disasterrecovery_system_status`
* **New Data Source:** `data_source_endpoint_analytics_profiling_rules`
* **New Data Source:** `data_source_profiling_rules_count`
* **New Data Source:** `data_source_security_rogue_wireless_containment_status`
* **New Data Source:** `data_source_security_threats_level`
* **New Data Source:** `data_source_security_threats_rogue_allowed_list`
* **New Data Source:** `data_source_security_threats_rogue_allowed_list_count`
* **New Data Source:** `data_source_security_threats_type`
* **New Data Source:** `data_source_tags_interfaces_members_associations`
* **New Data Source:** `data_source_tags_interfaces_members_associations_count`
* **New Data Source:** `data_source_tags_network_devices_members_associations`
* **New Data Source:** `data_source_tags_network_devices_members_associations_count`
* **New Data Source:** `data_source_threat_detail`
* **New Data Source:** `data_source_threat_detail_count`
* **New Data Source:** `data_source_threat_summary`
* **New Resource:** `resource_analytics_cmdb_endpoints`
* **New Resource:** `resource_analytics_endpoints`
* **New Resource:** `resource_analytics_endpoints_anc_policy_delete`
* **New Resource:** `resource_analytics_endpoints_anc_policy_update`
* **New Resource:** `resource_analytics_profiling_rules`
* **New Resource:** `resource_analytics_profiling_rules_bulk`
* **New Resource:** `resource_endpoint_analytics_profiling_rules`
* **New Resource:** `resource_network_device_user_defined_field_delete`
* **New Resource:** `resource_network_device_user_defined_field_update`
* **New Resource:** `resource_profiling_rules_in_bulk_create`
* **New Resource:** `resource_security_rogue_additional_details`
* **New Resource:** `resource_security_rogue_additional_details_count`
* **New Resource:** `resource_security_rogue_wireless_containment_start`
* **New Resource:** `resource_security_rogue_wireless_containment_stop`
* **New Resource:** `resource_security_threats_details`
* **New Resource:** `resource_security_threats_details_count`
* **New Resource:** `resource_security_threats_rogue_allowed_list`
* **New Resource:** `resource_security_threats_summary`
* **New Resource:** `resource_tags_interfaces_members_associations_query`
* **New Resource:** `resource_tags_network_devices_members_associations_query`

## 1.0.0-beta (September 13, 2024)
IMPROVEMENTS:
* The provider has been updated with Catalyst Center API version `2.3.7.6`
Expand Down
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,89 @@ In the [docs directory](./docs/) you can find the documentation source for this

You can find the documentation online for the previously released versions at [Terraform Registry - Cisco Catalyst Center provider](https://registry.terraform.io/providers/cisco-en-programmability/catalystcenter/latest/docs).


# Automatic Version Management for Resources and DataSources
In this Terraform provider, version management is handled dynamically for **all resources** and **datasources**. The version of a resource or datasource is automatically selected based on the available versions in the environment, allowing users to either use a default version or specify a particular version when needed. Below is an explanation of how this automatic version selection works for both resources and datasources.

## General Version Selection Behavior
For all resources and datasources, the behavior follows these general rules:

1. **If multiple versions of a resource or datasource exist (e.g., `resource_v1`, `resource_v2`)**:
* By **default**, the **oldest** available version will be selected. That is, if both `resource_v1` and `resource_v2` are available, the provider will automatically select `v1` unless explicitly specified otherwise.
* If a user wants to use the latest version (e.g., `v2`), they need to specify it explicitly in the configuration.

2. **If only one version of a resource or datasource exists (e.g., only `resource_v1`)**:
* **The resource or datasource will automatically be used in that version**, without needing to specify the version suffix in the configuration.

3. **If only the latest version is available (e.g., only `resource_v2` and not `resource_v1`)**:
* The resource or datasource will automatically refer to the **latest available version**, i.e., `resource_v2`.


## Example Usage with Resources
### Case 1: Both `resource_v1` and `resource_v2` are available
If both `resource_v1` and `resource_v2` are available in your environment, the provider will select `resource_v1` by default. If you want to use `resource_v2`, you can specify it explicitly:

```hcl
# Using version 1 (default)
resource "resource" "default" {
# This resource will refer to `resource_v1` by default
}
# Explicitly using version 2
resource "resource_v2" "default" {
# This resource will refer to `resource_v2`
}
```
### Case 2: Only resource\_v1 exists
If only resource\_v1 is available in your environment, there is no need to specify the version, as the provider will automatically use that version:

```hcl
resource "resource" "default" {
# This resource will refer to `resource_v1` since it's the only version available
}
```
### Case 3: Only resource\_v2 exists
If only resource\_v2 is available in your environment, the provider will automatically refer to that version, since resource\_v1 is not available:

```hcl
resource "resource" "default" {
# This resource will refer to `resource_v2` since `resource_v1` is not available
}
```
## Example Usage with DataSources
The same version selection logic applies to datasources. Below is how version management works for datasources:

### Case 1: Both datasource\_v1 and datasource\_v2 are available
```hcl
# Using version 1 (default)
data "datasource" "default" {
# This datasource will refer to `datasource_v1` by default
}
# Explicitly using version 2
data "datasource_v2" "default" {
# This datasource will refer to `datasource_v2`
}
```
### Case 2: Only datasource\_v1 exists
```hcl
data "datasource" "default" {
# This datasource will refer to `datasource_v1` since it's the only version available
}
```
### Case 3: Only datasource\_v2 exists
```hcl
data "datasource" "default" {
# This datasource will refer to `datasource_v2` since `datasource_v1` is not available
}
```

# Contributing

Ongoing development efforts and contributions to this provider are tracked as issues in this repository.
Expand Down
2 changes: 1 addition & 1 deletion catalystcenter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Unable to create Cisco Catalyst Center client",
Summary: "Unable to create Cisco DNA Center client",
Detail: err.Error(),
})
return nil, diags
Expand Down
23 changes: 1 addition & 22 deletions catalystcenter/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package catalystcenter
import (
"encoding/json"
"fmt"
"log"
"strconv"
)

Expand Down Expand Up @@ -92,22 +91,6 @@ 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{})
if !ok {
Expand Down Expand Up @@ -136,11 +119,7 @@ func interfaceToSliceInt(v interface{}) *[]int {
}

func interfaceToString(v interface{}) string {
if v == nil {
return ""
} else {
return fmt.Sprint(v)
}
return fmt.Sprint(v)
}

func responseInterfaceToSliceString(v interface{}) []string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,27 @@ func dataSourceAccesspointConfigurationDetailsByTaskIDRead(ctx context.Context,

selectedMethod := 1
if selectedMethod == 1 {
log.Printf("[DEBUG] Selected method: GetAccessPointConfigurationTaskResult")
log.Printf("[DEBUG] Selected method: GetAccessPointConfigurationTaskResultV1")
vvTaskID := vTaskID.(string)

response1, restyResp1, err := client.Wireless.GetAccessPointConfigurationTaskResult(vvTaskID)
response1, restyResp1, err := client.Wireless.GetAccessPointConfigurationTaskResultV1(vvTaskID)

if err != nil || response1 == nil {
if restyResp1 != nil {
log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String())
}
diags = append(diags, diagErrorWithAlt(
"Failure when executing 2 GetAccessPointConfigurationTaskResult", err,
"Failure at GetAccessPointConfigurationTaskResult, unexpected response", ""))
"Failure when executing 2 GetAccessPointConfigurationTaskResultV1", err,
"Failure at GetAccessPointConfigurationTaskResultV1, unexpected response", ""))
return diags
}

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

vItems1 := flattenWirelessGetAccessPointConfigurationTaskResultItems(response1)
vItems1 := flattenWirelessGetAccessPointConfigurationTaskResultV1Items(response1)
if err := d.Set("items", vItems1); err != nil {
diags = append(diags, diagError(
"Failure when setting GetAccessPointConfigurationTaskResult response",
"Failure when setting GetAccessPointConfigurationTaskResultV1 response",
err))
return diags
}
Expand All @@ -224,43 +224,43 @@ func dataSourceAccesspointConfigurationDetailsByTaskIDRead(ctx context.Context,
return diags
}

func flattenWirelessGetAccessPointConfigurationTaskResultItems(items *catalystcentersdkgo.ResponseWirelessGetAccessPointConfigurationTaskResult) []map[string]interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1Items(items *catalystcentersdkgo.ResponseWirelessGetAccessPointConfigurationTaskResultV1) []map[string]interface{} {
if items == nil {
return nil
}
var respItems []map[string]interface{}
for _, item := range *items {
respItem := make(map[string]interface{})
respItem["instance_uuid"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceUUID(item.InstanceUUID)
respItem["instance_uuid"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceUUID(item.InstanceUUID)
respItem["instance_id"] = item.InstanceID
respItem["auth_entity_id"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsAuthEntityID(item.AuthEntityID)
respItem["auth_entity_id"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsAuthEntityID(item.AuthEntityID)
respItem["display_name"] = item.DisplayName
respItem["auth_entity_class"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsAuthEntityClass(item.AuthEntityClass)
respItem["auth_entity_class"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsAuthEntityClass(item.AuthEntityClass)
respItem["instance_tenant_id"] = item.InstanceTenantID
respItem["ordered_list_oeindex"] = item.OrderedListOEIndex
respItem["ordered_list_oeassoc_name"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsOrderedListOEAssocName(item.OrderedListOEAssocName)
respItem["ordered_list_oeassoc_name"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsOrderedListOEAssocName(item.OrderedListOEAssocName)
respItem["creation_order_index"] = item.CreationOrderIndex
respItem["is_being_changed"] = boolPtrToString(item.IsBeingChanged)
respItem["deploy_pending"] = item.DeployPending
respItem["instance_created_on"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceCreatedOn(item.InstanceCreatedOn)
respItem["instance_updated_on"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceUpdatedOn(item.InstanceUpdatedOn)
respItem["change_log_list"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsChangeLogList(item.ChangeLogList)
respItem["instance_origin"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceOrigin(item.InstanceOrigin)
respItem["lazy_loaded_entities"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsLazyLoadedEntities(item.LazyLoadedEntities)
respItem["instance_created_on"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceCreatedOn(item.InstanceCreatedOn)
respItem["instance_updated_on"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceUpdatedOn(item.InstanceUpdatedOn)
respItem["change_log_list"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsChangeLogList(item.ChangeLogList)
respItem["instance_origin"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceOrigin(item.InstanceOrigin)
respItem["lazy_loaded_entities"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsLazyLoadedEntities(item.LazyLoadedEntities)
respItem["instance_version"] = item.InstanceVersion
respItem["ap_name"] = item.ApName
respItem["controller_name"] = item.ControllerName
respItem["location_heirarchy"] = item.LocationHeirarchy
respItem["mac_address"] = item.MacAddress
respItem["status"] = item.Status
respItem["status_details"] = item.StatusDetails
respItem["internal_key"] = flattenWirelessGetAccessPointConfigurationTaskResultItemsInternalKey(item.InternalKey)
respItem["internal_key"] = flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInternalKey(item.InternalKey)
respItems = append(respItems, respItem)
}
return respItems
}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceUUID(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultInstanceUUID) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceUUID(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1InstanceUUID) interface{} {
if item == nil {
return nil
}
Expand All @@ -270,7 +270,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceUUID(item

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsAuthEntityID(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultAuthEntityID) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsAuthEntityID(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1AuthEntityID) interface{} {
if item == nil {
return nil
}
Expand All @@ -280,7 +280,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsAuthEntityID(item

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsAuthEntityClass(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultAuthEntityClass) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsAuthEntityClass(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1AuthEntityClass) interface{} {
if item == nil {
return nil
}
Expand All @@ -290,7 +290,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsAuthEntityClass(it

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsOrderedListOEAssocName(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultOrderedListOEAssocName) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsOrderedListOEAssocName(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1OrderedListOEAssocName) interface{} {
if item == nil {
return nil
}
Expand All @@ -300,7 +300,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsOrderedListOEAssoc

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceCreatedOn(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultInstanceCreatedOn) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceCreatedOn(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1InstanceCreatedOn) interface{} {
if item == nil {
return nil
}
Expand All @@ -310,7 +310,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceCreatedOn(

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceUpdatedOn(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultInstanceUpdatedOn) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceUpdatedOn(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1InstanceUpdatedOn) interface{} {
if item == nil {
return nil
}
Expand All @@ -320,7 +320,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceUpdatedOn(

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsChangeLogList(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultChangeLogList) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsChangeLogList(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1ChangeLogList) interface{} {
if item == nil {
return nil
}
Expand All @@ -330,7 +330,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsChangeLogList(item

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceOrigin(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultInstanceOrigin) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInstanceOrigin(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1InstanceOrigin) interface{} {
if item == nil {
return nil
}
Expand All @@ -340,7 +340,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsInstanceOrigin(ite

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsLazyLoadedEntities(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultLazyLoadedEntities) interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsLazyLoadedEntities(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1LazyLoadedEntities) interface{} {
if item == nil {
return nil
}
Expand All @@ -350,7 +350,7 @@ func flattenWirelessGetAccessPointConfigurationTaskResultItemsLazyLoadedEntities

}

func flattenWirelessGetAccessPointConfigurationTaskResultItemsInternalKey(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultInternalKey) []map[string]interface{} {
func flattenWirelessGetAccessPointConfigurationTaskResultV1ItemsInternalKey(item *catalystcentersdkgo.ResponseItemWirelessGetAccessPointConfigurationTaskResultV1InternalKey) []map[string]interface{} {
if item == nil {
return nil
}
Expand Down
Loading

0 comments on commit f4a3cb0

Please sign in to comment.