Skip to content

Commit

Permalink
Merge pull request #272 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
## 1.2.0-beta (September 5, 2024)
  • Loading branch information
fmunozmiranda authored Nov 14, 2024
2 parents b2629b3 + 76ec5af commit 41d70d7
Show file tree
Hide file tree
Showing 1,841 changed files with 169,625 additions and 34,627 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ A clear and concise description of what you expected to happen.
Please provide an screenshot of the successful API call with cuRL, Postman, etc.

**Environment (please complete the following information):**
* Cisco DNA Center version and patch:
* Cisco Catalyst Center version and patch:
* Terraform version:
* Cisco DNA Center provider version:
* Cisco Catalyst Center provider version:
* OS Version:

**Additional context**
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ vendor/
*.log

# Shell
.sh
.sh

env.sh
288 changes: 281 additions & 7 deletions CHANGELOG.md

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# terraform-provider-dnacenter

terraform-provider-dnacenter is a Terraform Provider for [Cisco DNA Center](https://developer.cisco.com/docs/dna-center/)
terraform-provider-dnacenter is a Terraform Provider for [Cisco Catalyst Center](https://developer.cisco.com/docs/dna-center/)

## Requirements

Expand All @@ -10,22 +10,23 @@ terraform-provider-dnacenter is a Terraform Provider for [Cisco DNA Center](http

## Introduction

The terraform-provider-dnacenter provides a Terraform provider for managing and automating your Cisco DNA Center environment. It consists of a set of resources and data-sources for performing tasks related to DNA Center.
The terraform-provider-dnacenter provides a Terraform provider for managing and automating your Cisco Catalyst Center environment. It consists of a set of resources and data-sources for performing tasks related to Catalyst Center.

This collection has been tested and supports Cisco DNA Center 2.3.5.3.
This collection has been tested and supports Cisco Catalyst Center 2.3.5.3.

Other versions of this collection have support for previous Cisco DNA Center versions. The recommended versions are listed below on the [Compatibility matrix](#compatibility-matrix).
Other versions of this collection have support for previous Cisco Catalyst Center versions. The recommended versions are listed below on the [Compatibility matrix](#compatibility-matrix).

## Compatibility matrix
The following table shows the supported versions.

| Cisco DNA Center version | Terraform "dnacenter" provider version |
| Cisco Catalyst Center version | Terraform "dnacenter" provider version |
|--------------------------|----------------------------------------|
| 2.1.1 | 0.0.4 |
| 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.33-beta |
| 2.3.7.6 | 1.2.0-beta |

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

Expand Down Expand Up @@ -71,17 +72,17 @@ terraform {
}
}
# Configure provider with your Cisco DNA Center SDK credentials
# Configure provider with your Cisco Catalyst Center SDK credentials
provider "dnacenter" {
# Cisco DNA Center user name
# Cisco Catalyst Center user name
username = "admin"
# it can be set using the environment variable DNAC_BASE_URL
# Cisco DNA Center password
# Cisco Catalyst Center password
password = "admin123"
# it can be set using the environment variable DNAC_USERNAME
# Cisco DNA Center base URL, FQDN or IP
# Cisco Catalyst Center base URL, FQDN or IP
base_url = "https://172.168.196.2"
# it can be set using the environment variable DNAC_PASSWORD
Expand Down Expand Up @@ -151,19 +152,19 @@ $ make testacc

In the [docs directory](./docs/) you can find the documentation source for this 1.0.19-beta version.

You can find the documentation online for the previously released versions at [Terraform Registry - Cisco DNA Center provider](https://registry.terraform.io/providers/cisco-en-programmability/dnacenter/latest/docs).
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/dnacenter/latest/docs).

# Contributing

Ongoing development efforts and contributions to this provider are tracked as issues in this repository.

We welcome community contributions to this project. If you find problems, need an enhancement or need a new data-source or resource, please open an issue or create a PR against the [Terraform Provider for Cisco DNA Center repository](https://github.com/cisco-en-programmability/terraform-provider-dnacenter/issues).
We welcome community contributions to this project. If you find problems, need an enhancement or need a new data-source or resource, please open an issue or create a PR against the [Terraform Provider for Cisco Catalyst Center repository](https://github.com/cisco-en-programmability/terraform-provider-dnacenter/issues).

# Change log

All notable changes to this project will be documented in the [CHANGELOG](./CHANGELOG.md) file.

The development team may make additional changes as the library evolves with the Cisco DNA Center.
The development team may make additional changes as the library evolves with the Cisco Catalyst Center.

**NOTE**: Consider reviewing the Changelog to review the new features of the 1.0.19-beta version.

Expand Down
6 changes: 3 additions & 3 deletions dnacenter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package dnacenter
import (
"context"

dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v5/sdk"
dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v6/sdk"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

// Config is the configuration structure used to instantiate a
// new Cisco DNA Center client.
// new Cisco Catalyst Center client.
type Config struct {
BaseURL string
Username string
Expand All @@ -19,7 +19,7 @@ type Config struct {
SSLVerify string
}

// NewClient returns a new Cisco DNA Center client.
// NewClient returns a new Cisco Catalyst Center client.
func (c *Config) NewClient() (*dnacentersdkgo.Client, error) {
client, err := dnacentersdkgo.NewClientWithOptions(c.BaseURL,
c.Username, c.Password,
Expand Down
25 changes: 1 addition & 24 deletions dnacenter/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dnacenter
import (
"encoding/json"
"fmt"
"log"
"strconv"
)

Expand Down Expand Up @@ -92,27 +91,9 @@ 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{}
Expand All @@ -138,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 @@ -5,7 +5,7 @@ import (

"log"

dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v5/sdk"
dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v6/sdk"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -202,7 +202,7 @@ func dataSourceAccesspointConfigurationDetailsByTaskIDRead(ctx context.Context,
log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String())
}
diags = append(diags, diagErrorWithAlt(
"Failure when executing GetAccessPointConfigurationTaskResult", err,
"Failure when executing 2 GetAccessPointConfigurationTaskResult", err,
"Failure at GetAccessPointConfigurationTaskResult, unexpected response", ""))
return diags
}
Expand Down
92 changes: 92 additions & 0 deletions dnacenter/data_source_analytics_anc_policies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package dnacenter

import (
"context"

"log"

dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v6/sdk"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAnalyticsAncPolicies() *schema.Resource {
return &schema.Resource{
Description: `It performs read operation on AI Endpoint Analytics.
- Fetches the list of ANC policies available in ISE.
`,

ReadContext: dataSourceAnalyticsAncPoliciesRead,
Schema: map[string]*schema.Schema{

"items": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{

"name": &schema.Schema{
Description: `Name of the ANC policy.
`,
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}

func dataSourceAnalyticsAncPoliciesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*dnacentersdkgo.Client)

var diags diag.Diagnostics

selectedMethod := 1
if selectedMethod == 1 {
log.Printf("[DEBUG] Selected method: GetAncPolicies")

response1, restyResp1, err := client.AIEndpointAnalytics.GetAncPolicies()

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 GetAncPolicies", err,
"Failure at GetAncPolicies, unexpected response", ""))
return diags
}

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

vItems1 := flattenAIEndpointAnalyticsGetAncPoliciesItems(response1)
if err := d.Set("items", vItems1); err != nil {
diags = append(diags, diagError(
"Failure when setting GetAncPolicies response",
err))
return diags
}

d.SetId(getUnixTimeString())
return diags

}
return diags
}

func flattenAIEndpointAnalyticsGetAncPoliciesItems(items *dnacentersdkgo.ResponseAIEndpointAnalyticsGetAncPolicies) []map[string]interface{} {
if items == nil {
return nil
}
var respItems []map[string]interface{}
for _, item := range *items {
respItem := make(map[string]interface{})
respItem["name"] = item.Name
respItems = append(respItems, respItem)
}
return respItems
}
Loading

0 comments on commit 41d70d7

Please sign in to comment.