Skip to content

Commit

Permalink
Merge pull request #81 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bvargasre authored Apr 22, 2024
2 parents bbb37bf + a71c6da commit e999911
Show file tree
Hide file tree
Showing 43 changed files with 1,814 additions and 138 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.0.26] - 2024-04-22
- Functions were modified to be called recursively in case of Status Unauthorized.


## [5.0.25] - 2024-02-13
- `EndTime` attribute change to `*int` in `ResponseTaskGetTaskTreeResponse`.
- `StartTime` attribute change to `*int` in `ResponseTaskGetTaskTreeResponse`.
Expand Down Expand Up @@ -615,4 +619,5 @@ Services removed on Cisco DNA Center 2.3.3.0's API:
[5.0.23]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.22...v5.0.23
[5.0.24]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.23...v5.0.24
[5.0.25]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.24...v5.0.25
[Unreleased]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.25...main
[5.0.26]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.25...v5.0.26
[Unreleased]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.26...main
2 changes: 1 addition & 1 deletion sdk/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func NewClientNoAuth() (*Client, error) {
retry = true
}
}
return r.StatusCode() == http.StatusTooManyRequests || r.StatusCode() == http.StatusUnauthorized || retry
return r.StatusCode() == http.StatusTooManyRequests || retry
},
)
c.common.client.
Expand Down
77 changes: 77 additions & 0 deletions sdk/application_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dnac

import (
"fmt"
"net/http"
"strings"

"github.com/go-resty/resty/v2"
Expand Down Expand Up @@ -842,6 +843,9 @@ func (s *ApplicationPolicyService) GetApplicationPolicy(GetApplicationPolicyQuer
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationPolicy(GetApplicationPolicyQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetApplicationPolicy")
}

Expand Down Expand Up @@ -873,6 +877,9 @@ func (s *ApplicationPolicyService) GetApplicationPolicyDefault() (*ResponseAppli
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationPolicyDefault()
}
return nil, response, fmt.Errorf("error with operation GetApplicationPolicyDefault")
}

Expand Down Expand Up @@ -907,6 +914,9 @@ func (s *ApplicationPolicyService) GetApplicationPolicyQueuingProfile(GetApplica
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationPolicyQueuingProfile(GetApplicationPolicyQueuingProfileQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetApplicationPolicyQueuingProfile")
}

Expand Down Expand Up @@ -938,6 +948,9 @@ func (s *ApplicationPolicyService) GetApplicationPolicyQueuingProfileCount() (*R
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationPolicyQueuingProfileCount()
}
return nil, response, fmt.Errorf("error with operation GetApplicationPolicyQueuingProfileCount")
}

Expand Down Expand Up @@ -972,6 +985,9 @@ func (s *ApplicationPolicyService) GetApplicationSets(GetApplicationSetsQueryPar
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationSets(GetApplicationSetsQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetApplicationSets")
}

Expand Down Expand Up @@ -1003,6 +1019,9 @@ func (s *ApplicationPolicyService) GetApplicationSetsCount() (*ResponseApplicati
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationSetsCount()
}
return nil, response, fmt.Errorf("error with operation GetApplicationSetsCount")
}

Expand Down Expand Up @@ -1037,6 +1056,9 @@ func (s *ApplicationPolicyService) GetApplications(GetApplicationsQueryParams *G
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplications(GetApplicationsQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetApplications")
}

Expand Down Expand Up @@ -1068,6 +1090,9 @@ func (s *ApplicationPolicyService) GetApplicationsCount() (*ResponseApplicationP
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetApplicationsCount()
}
return nil, response, fmt.Errorf("error with operation GetApplicationsCount")
}

Expand Down Expand Up @@ -1102,6 +1127,9 @@ func (s *ApplicationPolicyService) GetQosDeviceInterfaceInfo(GetQosDeviceInterfa
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetQosDeviceInterfaceInfo(GetQosDeviceInterfaceInfoQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetQosDeviceInterfaceInfo")
}

Expand Down Expand Up @@ -1133,6 +1161,9 @@ func (s *ApplicationPolicyService) GetQosDeviceInterfaceInfoCount() (*ResponseAp
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetQosDeviceInterfaceInfoCount()
}
return nil, response, fmt.Errorf("error with operation GetQosDeviceInterfaceInfoCount")
}

Expand Down Expand Up @@ -1165,6 +1196,11 @@ func (s *ApplicationPolicyService) ApplicationPolicyIntent(requestApplicationPol
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.ApplicationPolicyIntent(requestApplicationPolicyApplicationPolicyIntent)
}

return nil, response, fmt.Errorf("error with operation ApplicationPolicyIntent")
}

Expand Down Expand Up @@ -1197,6 +1233,11 @@ func (s *ApplicationPolicyService) CreateApplicationPolicyQueuingProfile(request
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.CreateApplicationPolicyQueuingProfile(requestApplicationPolicyCreateApplicationPolicyQueuingProfile)
}

return nil, response, fmt.Errorf("error with operation CreateApplicationPolicyQueuingProfile")
}

Expand Down Expand Up @@ -1229,6 +1270,11 @@ func (s *ApplicationPolicyService) CreateApplicationSet(requestApplicationPolicy
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.CreateApplicationSet(requestApplicationPolicyCreateApplicationSet)
}

return nil, response, fmt.Errorf("error with operation CreateApplicationSet")
}

Expand Down Expand Up @@ -1261,6 +1307,11 @@ func (s *ApplicationPolicyService) CreateApplication(requestApplicationPolicyCre
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.CreateApplication(requestApplicationPolicyCreateApplication)
}

return nil, response, fmt.Errorf("error with operation CreateApplication")
}

Expand Down Expand Up @@ -1293,6 +1344,11 @@ func (s *ApplicationPolicyService) CreateQosDeviceInterfaceInfo(requestApplicati
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.CreateQosDeviceInterfaceInfo(requestApplicationPolicyCreateQosDeviceInterfaceInfo)
}

return nil, response, fmt.Errorf("error with operation CreateQosDeviceInterfaceInfo")
}

Expand Down Expand Up @@ -1323,6 +1379,9 @@ func (s *ApplicationPolicyService) UpdateApplicationPolicyQueuingProfile(request
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.UpdateApplicationPolicyQueuingProfile(requestApplicationPolicyUpdateApplicationPolicyQueuingProfile)
}
return nil, response, fmt.Errorf("error with operation UpdateApplicationPolicyQueuingProfile")
}

Expand Down Expand Up @@ -1353,6 +1412,9 @@ func (s *ApplicationPolicyService) EditApplication(requestApplicationPolicyEditA
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.EditApplication(requestApplicationPolicyEditApplication)
}
return nil, response, fmt.Errorf("error with operation EditApplication")
}

Expand Down Expand Up @@ -1383,6 +1445,9 @@ func (s *ApplicationPolicyService) UpdateQosDeviceInterfaceInfo(requestApplicati
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.UpdateQosDeviceInterfaceInfo(requestApplicationPolicyUpdateQosDeviceInterfaceInfo)
}
return nil, response, fmt.Errorf("error with operation UpdateQosDeviceInterfaceInfo")
}

Expand Down Expand Up @@ -1418,6 +1483,9 @@ func (s *ApplicationPolicyService) DeleteApplicationPolicyQueuingProfile(id stri
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.DeleteApplicationPolicyQueuingProfile(id)
}
return nil, response, fmt.Errorf("error with operation DeleteApplicationPolicyQueuingProfile")
}

Expand Down Expand Up @@ -1453,6 +1521,9 @@ func (s *ApplicationPolicyService) DeleteApplicationSet(DeleteApplicationSetQuer
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.DeleteApplicationSet(DeleteApplicationSetQueryParams)
}
return nil, response, fmt.Errorf("error with operation DeleteApplicationSet")
}

Expand Down Expand Up @@ -1488,6 +1559,9 @@ func (s *ApplicationPolicyService) DeleteApplication(DeleteApplicationQueryParam
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.DeleteApplication(DeleteApplicationQueryParams)
}
return nil, response, fmt.Errorf("error with operation DeleteApplication")
}

Expand Down Expand Up @@ -1523,6 +1597,9 @@ func (s *ApplicationPolicyService) DeleteQosDeviceInterfaceInfo(id string) (*Res
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.DeleteQosDeviceInterfaceInfo(id)
}
return nil, response, fmt.Errorf("error with operation DeleteQosDeviceInterfaceInfo")
}

Expand Down
4 changes: 4 additions & 0 deletions sdk/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dnac

import (
"fmt"
"net/http"

"github.com/go-resty/resty/v2"
"github.com/google/go-querystring/query"
Expand Down Expand Up @@ -92,6 +93,9 @@ func (s *ApplicationsService) Applications(ApplicationsQueryParams *Applications
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.Applications(ApplicationsQueryParams)
}
return nil, response, fmt.Errorf("error with operation Applications")
}

Expand Down
6 changes: 6 additions & 0 deletions sdk/cisco_dna_center_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dnac

import (
"fmt"
"net/http"

"github.com/go-resty/resty/v2"
)
Expand Down Expand Up @@ -45,6 +46,11 @@ func (s *CiscoDnaCenterSystemService) AuthorizeDevice(requestCiscoDnaCenterSyste
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.AuthorizeDevice(requestCiscoDnaCenterSystemAuthorizeDevice)
}

return nil, response, fmt.Errorf("error with operation AuthorizeDevice")
}

Expand Down
13 changes: 13 additions & 0 deletions sdk/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dnac

import (
"fmt"
"net/http"

"github.com/go-resty/resty/v2"
"github.com/google/go-querystring/query"
Expand Down Expand Up @@ -449,6 +450,9 @@ func (s *ClientsService) GetClientDetail(GetClientDetailQueryParams *GetClientDe
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetClientDetail(GetClientDetailQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetClientDetail")
}

Expand Down Expand Up @@ -501,6 +505,9 @@ func (s *ClientsService) GetClientEnrichmentDetails(GetClientEnrichmentDetailsHe
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetClientEnrichmentDetails(GetClientEnrichmentDetailsHeaderParams)
}
return nil, response, fmt.Errorf("error with operation GetClientEnrichmentDetails")
}

Expand Down Expand Up @@ -535,6 +542,9 @@ func (s *ClientsService) GetOverallClientHealth(GetOverallClientHealthQueryParam
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetOverallClientHealth(GetOverallClientHealthQueryParams)
}
return nil, response, fmt.Errorf("error with operation GetOverallClientHealth")
}

Expand Down Expand Up @@ -569,6 +579,9 @@ func (s *ClientsService) ClientProximity(ClientProximityQueryParams *ClientProxi
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.ClientProximity(ClientProximityQueryParams)
}
return nil, response, fmt.Errorf("error with operation ClientProximity")
}

Expand Down
9 changes: 9 additions & 0 deletions sdk/command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dnac

import (
"fmt"
"net/http"

"github.com/go-resty/resty/v2"
)
Expand Down Expand Up @@ -51,6 +52,9 @@ func (s *CommandRunnerService) GetAllKeywordsOfCliSAcceptedByCommandRunner() (*R
}

if response.IsError() {
if response.StatusCode() == http.StatusUnauthorized {
return s.GetAllKeywordsOfCliSAcceptedByCommandRunner()
}
return nil, response, fmt.Errorf("error with operation GetAllKeywordsOfCliSAcceptedByCommandRunner")
}

Expand Down Expand Up @@ -83,6 +87,11 @@ func (s *CommandRunnerService) RunReadOnlyCommandsOnDevicesToGetTheirRealTimeCon
}

if response.IsError() {

if response.StatusCode() == http.StatusUnauthorized {
return s.RunReadOnlyCommandsOnDevicesToGetTheirRealTimeConfiguration(requestCommandRunnerRunReadOnlyCommandsOnDevicesToGetTheirRealTimeConfiguration)
}

return nil, response, fmt.Errorf("error with operation RunReadOnlyCommandsOnDevicesToGetTheirRealTimeConfiguration")
}

Expand Down
Loading

0 comments on commit e999911

Please sign in to comment.