Skip to content

Commit

Permalink
## [6.0.0] - 2024-11-14
Browse files Browse the repository at this point in the history
### Added
New services for Cisco Catalyst Center 2.3.7.6's API:
- CiscoTrustedCertificates *CiscoTrustedCertificatesService
- AIEndpointAnalytics      *AIEndpointAnalyticsService
  • Loading branch information
fmunozmiranda committed Nov 14, 2024
1 parent ba4eaa9 commit ac7891b
Show file tree
Hide file tree
Showing 48 changed files with 4,277 additions and 2,898 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
New services for Cisco Catalyst Center 2.3.7.6's API:
- CiscoTrustedCertificates *CiscoTrustedCertificatesService
- AIEndpointAnalytics *AIEndpointAnalyticsService

## [5.0.32] - 2024-08-06
### Added
Expand Down
2 changes: 1 addition & 1 deletion examples/configuration_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func main() {
// return
// }

resp, _, err := client.ConfigurationTemplates.GetProjectsDetails(&dnac.GetProjectsDetailsQueryParams{
resp, _, err := client.ConfigurationTemplates.GetProjectsDetailsV2(&dnac.GetProjectsDetailsV2QueryParams{
Name: "Onboarding Configuration",
})

Expand Down
2 changes: 1 addition & 1 deletion examples/devices/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
}

fmt.Println("Getting device count")
devicesCount, _, err := Client.Devices.GetDeviceCount2(nil)
devicesCount, _, err := Client.Devices.GetDeviceConfigCount()
if err != nil {
fmt.Println(err)
}
Expand Down
1,099 changes: 1,099 additions & 0 deletions sdk/ai_endpoint_analytics.go

Large diffs are not rendered by default.

61 changes: 46 additions & 15 deletions sdk/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const DNAC_PASSWORD = "DNAC_PASSWORD"
const DNAC_DEBUG = "DNAC_DEBUG"
const DNAC_SSL_VERIFY = "DNAC_SSL_VERIFY"
const DNAC_WAIT_TIME = "DNAC_WAIT_TIME"
const VERSION = "2.3.5.3"
const USER_AGENT = "go-cisco-dnacsdk/" + VERSION

var VERSION = "2.3.7.6.1"
var DNAC_USER_STRING = "DNAC_USER_STRING"
var USER_AGENT = "go-cisco-dnacentersdk/" + VERSION

type FileDownload struct {
FileName string
Expand All @@ -43,8 +45,11 @@ type Client struct {

// API Services
Authentication *AuthenticationService
AuthenticationManagement *AuthenticationManagementService
AIEndpointAnalytics *AIEndpointAnalyticsService
ApplicationPolicy *ApplicationPolicyService
Applications *ApplicationsService
CiscoTrustedCertificates *CiscoTrustedCertificatesService
Clients *ClientsService
CommandRunner *CommandRunnerService
Compliance *ComplianceService
Expand All @@ -53,8 +58,9 @@ type Client struct {
DeviceOnboardingPnp *DeviceOnboardingPnpService
DeviceReplacement *DeviceReplacementService
Devices *DevicesService
DisasterRecovery *DisasterRecoveryService
Discovery *DiscoveryService
Eox *EoxService
EoX *EoXService
EventManagement *EventManagementService
FabricWireless *FabricWirelessService
File *FileService
Expand Down Expand Up @@ -82,8 +88,6 @@ type Client struct {
Users *UsersService
Wireless *WirelessService
CustomCall *CustomCallService
CiscoDnaCenterSystem *CiscoDnaCenterSystemService
CiscoTrustedCertificates *CiscoTrustedCertificatesService
}

type service struct {
Expand Down Expand Up @@ -116,10 +120,15 @@ func NewClient() (*Client, error) {
}

// NewClientWithOptions is the client with options passed with parameters
func NewClientWithOptions(baseURL string, username string, password string, debug string, sslVerify string, waitTimeToManyRequest *int) (*Client, error) {
func NewClientWithOptions(baseURL string, username string, password string, debug string, sslVerify string, waitTimeToManyRequest *int, userString ...string) (*Client, error) {
var err error

err = SetOptions(baseURL, username, password, debug, sslVerify, waitTimeToManyRequest)
var user string
if len(userString) > 0 {
user = "-" + userString[0]
}

err = SetOptions(baseURL, username, password, debug, sslVerify, waitTimeToManyRequest, user)
if err != nil {
return nil, err
}
Expand All @@ -128,7 +137,7 @@ func NewClientWithOptions(baseURL string, username string, password string, debu
}

// SetOptions sets the environment variables
func SetOptions(baseURL string, username string, password string, debug string, sslVerify string, waitTimeToManyRequest *int) error {
func SetOptions(baseURL string, username string, password string, debug string, sslVerify string, waitTimeToManyRequest *int, userString string) error {
var err error
err = os.Setenv(DNAC_BASE_URL, baseURL)
if err != nil {
Expand All @@ -150,6 +159,10 @@ func SetOptions(baseURL string, username string, password string, debug string,
if err != nil {
return err
}
err = os.Setenv(DNAC_USER_STRING, userString)
if err != nil {
return err
}
if waitTimeToManyRequest != nil {
err = os.Setenv(DNAC_WAIT_TIME, strconv.Itoa(*waitTimeToManyRequest))
if err != nil {
Expand All @@ -164,12 +177,17 @@ func SetOptions(baseURL string, username string, password string, debug string,
return nil
}

func GetUserAgent() string {
return USER_AGENT + os.Getenv(DNAC_USER_STRING)
}

// NewClientNoAuth returns the client object without trying to authenticate
func NewClientNoAuth() (*Client, error) {
var err error

client := resty.New()
client.SetHeader("User-Agent", USER_AGENT)

client.SetHeader("User-Agent", GetUserAgent())
c := &Client{}
c.common.client = client
waitTimeToManyRequest := 0
Expand All @@ -186,6 +204,7 @@ func NewClientNoAuth() (*Client, error) {
} else {
err = fmt.Errorf("enviroment variable %s was not defined", DNAC_BASE_URL)
}

if os.Getenv(DNAC_WAIT_TIME) != "" {
waitTimeToManyRequest, err = strconv.Atoi(os.Getenv(DNAC_WAIT_TIME))
if err != nil {
Expand All @@ -194,14 +213,15 @@ func NewClientNoAuth() (*Client, error) {
} else {
waitTimeToManyRequest = 1
}

c.common.client.AddRetryCondition(
// RetryConditionFunc type is for retry condition function
// input: non-nil Response OR request execution error
func(r *resty.Response, err error) bool {
retry := false
if r.StatusCode() == http.StatusUnauthorized {
cl := resty.New()
cl.SetHeader("User-Agent", USER_AGENT)
cl.SetHeader("User-Agent", GetUserAgent())

username := os.Getenv("DNAC_USERNAME")
password := os.Getenv("DNAC_PASSWORD")
Expand Down Expand Up @@ -244,13 +264,16 @@ func NewClientNoAuth() (*Client, error) {
// MaxWaitTime can be overridden as well.
// Default is 2 seconds.
SetRetryMaxWaitTime(time.Duration(waitTimeToManyRequest+1) * time.Minute)

if err != nil {
return nil, err
}

c.Authentication = (*AuthenticationService)(&c.common)
c.AIEndpointAnalytics = (*AIEndpointAnalyticsService)(&c.common)
c.ApplicationPolicy = (*ApplicationPolicyService)(&c.common)
c.Applications = (*ApplicationsService)(&c.common)
c.CiscoTrustedCertificates = (*CiscoTrustedCertificatesService)(&c.common)
c.Clients = (*ClientsService)(&c.common)
c.CommandRunner = (*CommandRunnerService)(&c.common)
c.Compliance = (*ComplianceService)(&c.common)
Expand All @@ -259,8 +282,9 @@ func NewClientNoAuth() (*Client, error) {
c.DeviceOnboardingPnp = (*DeviceOnboardingPnpService)(&c.common)
c.DeviceReplacement = (*DeviceReplacementService)(&c.common)
c.Devices = (*DevicesService)(&c.common)
c.DisasterRecovery = (*DisasterRecoveryService)(&c.common)
c.Discovery = (*DiscoveryService)(&c.common)
c.Eox = (*EoxService)(&c.common)
c.EoX = (*EoXService)(&c.common)
c.EventManagement = (*EventManagementService)(&c.common)
c.FabricWireless = (*FabricWirelessService)(&c.common)
c.File = (*FileService)(&c.common)
Expand Down Expand Up @@ -293,10 +317,17 @@ func NewClientNoAuth() (*Client, error) {
}

// NewClientWithOptionsNoAuth returns the client object without trying to authenticate and sets environment variables
func NewClientWithOptionsNoAuth(baseURL string, username string, password string, debug string, sslVerify string, waitTimeToManyRequest *int) (*Client, error) {
func NewClientWithOptionsNoAuth(baseURL string, username string, password string, debug string, sslVerify string, waitTimeToManyRequest *int, userString ...string) (*Client, error) {
var err error

err = SetOptions(baseURL, username, password, debug, sslVerify, waitTimeToManyRequest)
var user string
if len(userString) > 0 {
user = "-" + userString[0]
} else {
user = ""
}

err = SetOptions(baseURL, username, password, debug, sslVerify, waitTimeToManyRequest, user)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -341,11 +372,11 @@ func (s *Client) AuthClient() error {

// RestyClient returns the resty.Client used by the sdk
func (s *Client) RestyClient() *resty.Client {
s.common.client.SetHeader("User-Agent", USER_AGENT)
s.common.client.SetHeader("User-Agent", GetUserAgent())
return s.common.client
}

func (s *Client) SetDNACWaitTimeToManyRequest(waitTimeToManyRequest int) error {
func (s *Client) SetCatalystWaitTimeToManyRequest(waitTimeToManyRequest int) error {

err := os.Setenv(DNAC_WAIT_TIME, strconv.Itoa(waitTimeToManyRequest))
if err != nil {
Expand Down
Loading

0 comments on commit ac7891b

Please sign in to comment.