diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ed8b8..8cd0d12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. @@ -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 diff --git a/sdk/api_client.go b/sdk/api_client.go index 955509d..569a0ad 100644 --- a/sdk/api_client.go +++ b/sdk/api_client.go @@ -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. diff --git a/sdk/application_policy.go b/sdk/application_policy.go index 043a19e..63e392c 100644 --- a/sdk/application_policy.go +++ b/sdk/application_policy.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } @@ -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") } diff --git a/sdk/applications.go b/sdk/applications.go index 02e0db3..88e050d 100644 --- a/sdk/applications.go +++ b/sdk/applications.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -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") } diff --git a/sdk/cisco_dna_center_system.go b/sdk/cisco_dna_center_system.go index d0cdc13..25c4d0c 100644 --- a/sdk/cisco_dna_center_system.go +++ b/sdk/cisco_dna_center_system.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" ) @@ -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") } diff --git a/sdk/clients.go b/sdk/clients.go index b9c87f0..d9d923f 100644 --- a/sdk/clients.go +++ b/sdk/clients.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -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") } @@ -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") } @@ -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") } @@ -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") } diff --git a/sdk/command_runner.go b/sdk/command_runner.go index e815a9b..27a834d 100644 --- a/sdk/command_runner.go +++ b/sdk/command_runner.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" ) @@ -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") } @@ -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") } diff --git a/sdk/compliance.go b/sdk/compliance.go index aa8f5d6..bd323e5 100644 --- a/sdk/compliance.go +++ b/sdk/compliance.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -173,6 +174,9 @@ func (s *ComplianceService) GetComplianceStatus(GetComplianceStatusQueryParams * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetComplianceStatus(GetComplianceStatusQueryParams) + } return nil, response, fmt.Errorf("error with operation GetComplianceStatus") } @@ -207,6 +211,9 @@ func (s *ComplianceService) GetComplianceStatusCount(GetComplianceStatusCountQue } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetComplianceStatusCount(GetComplianceStatusCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetComplianceStatusCount") } @@ -241,6 +248,9 @@ func (s *ComplianceService) GetComplianceDetail(GetComplianceDetailQueryParams * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetComplianceDetail(GetComplianceDetailQueryParams) + } return nil, response, fmt.Errorf("error with operation GetComplianceDetail") } @@ -275,6 +285,9 @@ func (s *ComplianceService) GetComplianceDetailCount(GetComplianceDetailCountQue } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetComplianceDetailCount(GetComplianceDetailCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetComplianceDetailCount") } @@ -308,6 +321,9 @@ func (s *ComplianceService) DeviceComplianceStatus(deviceUUID string) (*Response } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeviceComplianceStatus(deviceUUID) + } return nil, response, fmt.Errorf("error with operation DeviceComplianceStatus") } @@ -344,6 +360,9 @@ func (s *ComplianceService) ComplianceDetailsOfDevice(deviceUUID string, Complia } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ComplianceDetailsOfDevice(deviceUUID, ComplianceDetailsOfDeviceQueryParams) + } return nil, response, fmt.Errorf("error with operation ComplianceDetailsOfDevice") } @@ -376,6 +395,11 @@ func (s *ComplianceService) RunCompliance(requestComplianceRunCompliance *Reques } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.RunCompliance(requestComplianceRunCompliance) + } + return nil, response, fmt.Errorf("error with operation RunCompliance") } diff --git a/sdk/configuration_archive.go b/sdk/configuration_archive.go index a6af27c..28e6524 100644 --- a/sdk/configuration_archive.go +++ b/sdk/configuration_archive.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" ) @@ -45,6 +46,9 @@ func (s *ConfigurationArchiveService) ExportDeviceConfigurations(requestConfigur } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ExportDeviceConfigurations(requestConfigurationArchiveExportDeviceConfigurations) + } return nil, response, fmt.Errorf("error with operation ExportDeviceConfigurations") } diff --git a/sdk/configuration_templates.go b/sdk/configuration_templates.go index 63f2bb7..bce88f3 100644 --- a/sdk/configuration_templates.go +++ b/sdk/configuration_templates.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -1798,6 +1799,9 @@ func (s *ConfigurationTemplatesService) GetsAListOfProjects(GetsAListOfProjectsQ } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetsAListOfProjects(GetsAListOfProjectsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetsAListOfProjects") } @@ -1832,6 +1836,9 @@ func (s *ConfigurationTemplatesService) GetsTheDetailsOfAGivenProject(projectID } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetsTheDetailsOfAGivenProject(projectID) + } return nil, response, fmt.Errorf("error with operation GetsTheDetailsOfAGivenProject") } @@ -1866,6 +1873,9 @@ func (s *ConfigurationTemplatesService) GetsTheTemplatesAvailable(GetsTheTemplat } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetsTheTemplatesAvailable(GetsTheTemplatesAvailableQueryParams) + } return nil, response, fmt.Errorf("error with operation GetsTheTemplatesAvailable") } @@ -1900,6 +1910,9 @@ func (s *ConfigurationTemplatesService) StatusOfTemplateDeployment(deploymentID } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.StatusOfTemplateDeployment(deploymentID) + } return nil, response, fmt.Errorf("error with operation StatusOfTemplateDeployment") } @@ -1934,6 +1947,9 @@ func (s *ConfigurationTemplatesService) GetsAllTheVersionsOfAGivenTemplate(templ } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetsAllTheVersionsOfAGivenTemplate(templateID) + } return nil, response, fmt.Errorf("error with operation GetsAllTheVersionsOfAGivenTemplate") } @@ -1971,6 +1987,9 @@ func (s *ConfigurationTemplatesService) GetsDetailsOfAGivenTemplate(templateID s } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetsDetailsOfAGivenTemplate(templateID, GetsDetailsOfAGivenTemplateQueryParams) + } return nil, response, fmt.Errorf("error with operation GetsDetailsOfAGivenTemplate") } @@ -2005,6 +2024,9 @@ func (s *ConfigurationTemplatesService) GetProjectsDetails(GetProjectsDetailsQue } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetProjectsDetails(GetProjectsDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetProjectsDetails") } @@ -2039,6 +2061,9 @@ func (s *ConfigurationTemplatesService) GetTemplatesDetails(GetTemplatesDetailsQ } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTemplatesDetails(GetTemplatesDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTemplatesDetails") } @@ -2082,6 +2107,11 @@ func (s *ConfigurationTemplatesService) CreatesACloneOfTheGivenTemplate(name str } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreatesACloneOfTheGivenTemplate(name, templateID, projectID, CreatesACloneOfTheGivenTemplateQueryParams) + } + return nil, response, fmt.Errorf("error with operation CreatesACloneOfTheGivenTemplate") } @@ -2114,6 +2144,11 @@ func (s *ConfigurationTemplatesService) CreateProject(requestConfigurationTempla } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateProject(requestConfigurationTemplatesCreateProject) + } + return nil, response, fmt.Errorf("error with operation CreateProject") } @@ -2149,6 +2184,11 @@ func (s *ConfigurationTemplatesService) ImportsTheProjectsProvided(ImportsThePro } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ImportsTheProjectsProvided(ImportsTheProjectsProvidedQueryParams) + } + return nil, response, fmt.Errorf("error with operation ImportsTheProjectsProvided") } @@ -2181,6 +2221,11 @@ func (s *ConfigurationTemplatesService) ExportsTheProjectsForAGivenCriteria(requ } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ExportsTheProjectsForAGivenCriteria(requestConfigurationTemplatesExportsTheProjectsForAGivenCriteria) + } + return nil, response, fmt.Errorf("error with operation ExportsTheProjectsForAGivenCriteria") } @@ -2219,6 +2264,11 @@ func (s *ConfigurationTemplatesService) ImportsTheTemplatesProvided(projectName } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ImportsTheTemplatesProvided(projectName, requestConfigurationTemplatesImportsTheTemplatesProvided, ImportsTheTemplatesProvidedQueryParams) + } + return nil, response, fmt.Errorf("error with operation ImportsTheTemplatesProvided") } @@ -2254,6 +2304,11 @@ func (s *ConfigurationTemplatesService) CreateTemplate(projectID string, request } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateTemplate(projectID, requestConfigurationTemplatesCreateTemplate) + } + return nil, response, fmt.Errorf("error with operation CreateTemplate") } @@ -2286,6 +2341,11 @@ func (s *ConfigurationTemplatesService) DeployTemplate(requestConfigurationTempl } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.DeployTemplate(requestConfigurationTemplatesDeployTemplate) + } + return nil, response, fmt.Errorf("error with operation DeployTemplate") } @@ -2318,6 +2378,11 @@ func (s *ConfigurationTemplatesService) ExportsTheTemplatesForAGivenCriteria(req } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ExportsTheTemplatesForAGivenCriteria(requestConfigurationTemplatesExportsTheTemplatesForAGivenCriteria) + } + return nil, response, fmt.Errorf("error with operation ExportsTheTemplatesForAGivenCriteria") } @@ -2350,6 +2415,11 @@ func (s *ConfigurationTemplatesService) VersionTemplate(requestConfigurationTemp } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.VersionTemplate(requestConfigurationTemplatesVersionTemplate) + } + return nil, response, fmt.Errorf("error with operation VersionTemplate") } @@ -2382,6 +2452,11 @@ func (s *ConfigurationTemplatesService) DeployTemplateV2(requestConfigurationTem } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.DeployTemplateV2(requestConfigurationTemplatesDeployTemplateV2) + } + return nil, response, fmt.Errorf("error with operation DeployTemplateV2") } @@ -2412,6 +2487,9 @@ func (s *ConfigurationTemplatesService) UpdateProject(requestConfigurationTempla } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateProject(requestConfigurationTemplatesUpdateProject) + } return nil, response, fmt.Errorf("error with operation UpdateProject") } @@ -2442,6 +2520,9 @@ func (s *ConfigurationTemplatesService) UpdateTemplate(requestConfigurationTempl } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateTemplate(requestConfigurationTemplatesUpdateTemplate) + } return nil, response, fmt.Errorf("error with operation UpdateTemplate") } @@ -2472,6 +2553,9 @@ func (s *ConfigurationTemplatesService) PreviewTemplate(requestConfigurationTemp } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.PreviewTemplate(requestConfigurationTemplatesPreviewTemplate) + } return nil, response, fmt.Errorf("error with operation PreviewTemplate") } @@ -2507,6 +2591,9 @@ func (s *ConfigurationTemplatesService) DeletesTheProject(projectID string) (*Re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeletesTheProject(projectID) + } return nil, response, fmt.Errorf("error with operation DeletesTheProject") } @@ -2542,6 +2629,9 @@ func (s *ConfigurationTemplatesService) DeletesTheTemplate(templateID string) (* } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeletesTheTemplate(templateID) + } return nil, response, fmt.Errorf("error with operation DeletesTheTemplate") } diff --git a/sdk/custom_call.go b/sdk/custom_call.go index 4c1af2e..b4fdd8c 100644 --- a/sdk/custom_call.go +++ b/sdk/custom_call.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" ) @@ -26,6 +27,9 @@ func (s *CustomCallService) GetCustomCall(ResourcePath string, QueryParms *map[s } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetCustomCall(ResourcePath, QueryParms) + } return response, fmt.Errorf("error with custom operation %s", ResourcePath) } diff --git a/sdk/device_onboarding_pnp.go b/sdk/device_onboarding_pnp.go index 16f1df3..762f316 100644 --- a/sdk/device_onboarding_pnp.go +++ b/sdk/device_onboarding_pnp.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -3914,6 +3915,9 @@ func (s *DeviceOnboardingPnpService) GetDeviceList2(GetDeviceList2QueryParams *G } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceList2(GetDeviceList2QueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceList2") } @@ -3948,6 +3952,9 @@ func (s *DeviceOnboardingPnpService) GetDeviceCount(GetDeviceCountQueryParams *G } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceCount(GetDeviceCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceCount") } @@ -3982,6 +3989,9 @@ func (s *DeviceOnboardingPnpService) GetDeviceHistory(GetDeviceHistoryQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceHistory(GetDeviceHistoryQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceHistory") } @@ -4019,6 +4029,9 @@ func (s *DeviceOnboardingPnpService) GetSyncResultForVirtualAccount(domain strin } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSyncResultForVirtualAccount(domain, name) + } return nil, response, fmt.Errorf("error with operation GetSyncResultForVirtualAccount") } @@ -4052,6 +4065,9 @@ func (s *DeviceOnboardingPnpService) GetDeviceByID(id string) (*ResponseDeviceOn } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceByID(id) + } return nil, response, fmt.Errorf("error with operation GetDeviceById") } @@ -4083,6 +4099,9 @@ func (s *DeviceOnboardingPnpService) GetPnpGlobalSettings() (*ResponseDeviceOnbo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPnpGlobalSettings() + } return nil, response, fmt.Errorf("error with operation GetPnpGlobalSettings") } @@ -4114,6 +4133,9 @@ func (s *DeviceOnboardingPnpService) GetSmartAccountList() (*ResponseDeviceOnboa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSmartAccountList() + } return nil, response, fmt.Errorf("error with operation GetSmartAccountList") } @@ -4148,6 +4170,9 @@ func (s *DeviceOnboardingPnpService) GetVirtualAccountList(domain string) (*Resp } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetVirtualAccountList(domain) + } return nil, response, fmt.Errorf("error with operation GetVirtualAccountList") } @@ -4182,6 +4207,9 @@ func (s *DeviceOnboardingPnpService) GetWorkflows(GetWorkflowsQueryParams *GetWo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetWorkflows(GetWorkflowsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetWorkflows") } @@ -4216,6 +4244,9 @@ func (s *DeviceOnboardingPnpService) GetWorkflowCount(GetWorkflowCountQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetWorkflowCount(GetWorkflowCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetWorkflowCount") } @@ -4249,6 +4280,9 @@ func (s *DeviceOnboardingPnpService) GetWorkflowByID(id string) (*ResponseDevice } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetWorkflowByID(id) + } return nil, response, fmt.Errorf("error with operation GetWorkflowById") } @@ -4281,6 +4315,11 @@ func (s *DeviceOnboardingPnpService) AddDevice(requestDeviceOnboardingPnpAddDevi } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddDevice(requestDeviceOnboardingPnpAddDevice) + } + return nil, response, fmt.Errorf("error with operation AddDevice") } @@ -4313,6 +4352,11 @@ func (s *DeviceOnboardingPnpService) ClaimDevice(requestDeviceOnboardingPnpClaim } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ClaimDevice(requestDeviceOnboardingPnpClaimDevice) + } + return nil, response, fmt.Errorf("error with operation ClaimDevice") } @@ -4345,6 +4389,11 @@ func (s *DeviceOnboardingPnpService) ImportDevicesInBulk(requestDeviceOnboarding } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ImportDevicesInBulk(requestDeviceOnboardingPnpImportDevicesInBulk) + } + return nil, response, fmt.Errorf("error with operation ImportDevicesInBulk") } @@ -4377,6 +4426,11 @@ func (s *DeviceOnboardingPnpService) ResetDevice(requestDeviceOnboardingPnpReset } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ResetDevice(requestDeviceOnboardingPnpResetDevice) + } + return nil, response, fmt.Errorf("error with operation ResetDevice") } @@ -4413,6 +4467,11 @@ func (s *DeviceOnboardingPnpService) ClaimADeviceToASite(requestDeviceOnboarding } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ClaimADeviceToASite(requestDeviceOnboardingPnpClaimADeviceToASite) + } + return nil, response, fmt.Errorf("error with operation ClaimADeviceToASite") } @@ -4445,6 +4504,11 @@ func (s *DeviceOnboardingPnpService) PreviewConfig(requestDeviceOnboardingPnpPre } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.PreviewConfig(requestDeviceOnboardingPnpPreviewConfig) + } + return nil, response, fmt.Errorf("error with operation PreviewConfig") } @@ -4477,6 +4541,11 @@ func (s *DeviceOnboardingPnpService) UnClaimDevice(requestDeviceOnboardingPnpUnC } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.UnClaimDevice(requestDeviceOnboardingPnpUnClaimDevice) + } + return nil, response, fmt.Errorf("error with operation UnClaimDevice") } @@ -4509,6 +4578,11 @@ func (s *DeviceOnboardingPnpService) SyncVirtualAccountDevices(requestDeviceOnbo } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.SyncVirtualAccountDevices(requestDeviceOnboardingPnpSyncVirtualAccountDevices) + } + return nil, response, fmt.Errorf("error with operation SyncVirtualAccountDevices") } @@ -4541,6 +4615,11 @@ func (s *DeviceOnboardingPnpService) AddVirtualAccount(requestDeviceOnboardingPn } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddVirtualAccount(requestDeviceOnboardingPnpAddVirtualAccount) + } + return nil, response, fmt.Errorf("error with operation AddVirtualAccount") } @@ -4573,6 +4652,11 @@ func (s *DeviceOnboardingPnpService) AddAWorkflow(requestDeviceOnboardingPnpAddA } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddAWorkflow(requestDeviceOnboardingPnpAddAWorkflow) + } + return nil, response, fmt.Errorf("error with operation AddAWorkflow") } @@ -4605,6 +4689,9 @@ func (s *DeviceOnboardingPnpService) UpdateDevice(id string, requestDeviceOnboar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateDevice(id, requestDeviceOnboardingPnpUpdateDevice) + } return nil, response, fmt.Errorf("error with operation UpdateDevice") } @@ -4635,6 +4722,9 @@ func (s *DeviceOnboardingPnpService) UpdatePnpGlobalSettings(requestDeviceOnboar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdatePnpGlobalSettings(requestDeviceOnboardingPnpUpdatePnPGlobalSettings) + } return nil, response, fmt.Errorf("error with operation UpdatePnpGlobalSettings") } @@ -4665,6 +4755,9 @@ func (s *DeviceOnboardingPnpService) UpdatePnpServerProfile(requestDeviceOnboard } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdatePnpServerProfile(requestDeviceOnboardingPnpUpdatePnPServerProfile) + } return nil, response, fmt.Errorf("error with operation UpdatePnpServerProfile") } @@ -4697,6 +4790,9 @@ func (s *DeviceOnboardingPnpService) UpdateWorkflow(id string, requestDeviceOnbo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateWorkflow(id, requestDeviceOnboardingPnpUpdateWorkflow) + } return nil, response, fmt.Errorf("error with operation UpdateWorkflow") } @@ -4731,6 +4827,9 @@ func (s *DeviceOnboardingPnpService) DeleteDeviceByIDFromPnp(id string) (*Respon } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDeviceByIDFromPnp(id) + } return nil, response, fmt.Errorf("error with operation DeleteDeviceByIdFromPnp") } @@ -4766,6 +4865,9 @@ func (s *DeviceOnboardingPnpService) DeregisterVirtualAccount(DeregisterVirtualA } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeregisterVirtualAccount(DeregisterVirtualAccountQueryParams) + } return nil, response, fmt.Errorf("error with operation DeregisterVirtualAccount") } @@ -4800,6 +4902,9 @@ func (s *DeviceOnboardingPnpService) DeleteWorkflowByID(id string) (*ResponseDev } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteWorkflowByID(id) + } return nil, response, fmt.Errorf("error with operation DeleteWorkflowById") } diff --git a/sdk/device_replacement.go b/sdk/device_replacement.go index 7806886..2b24c6b 100644 --- a/sdk/device_replacement.go +++ b/sdk/device_replacement.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -139,6 +140,9 @@ func (s *DeviceReplacementService) ReturnListOfReplacementDevicesWithReplacement } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ReturnListOfReplacementDevicesWithReplacementDetails(ReturnListOfReplacementDevicesWithReplacementDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation ReturnListOfReplacementDevicesWithReplacementDetails") } @@ -173,6 +177,9 @@ func (s *DeviceReplacementService) ReturnReplacementDevicesCount(ReturnReplaceme } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ReturnReplacementDevicesCount(ReturnReplacementDevicesCountQueryParams) + } return nil, response, fmt.Errorf("error with operation ReturnReplacementDevicesCount") } @@ -205,6 +212,11 @@ func (s *DeviceReplacementService) MarkDeviceForReplacement(requestDeviceReplace } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.MarkDeviceForReplacement(requestDeviceReplacementMarkDeviceForReplacement) + } + return nil, response, fmt.Errorf("error with operation MarkDeviceForReplacement") } @@ -237,6 +249,11 @@ func (s *DeviceReplacementService) DeployDeviceReplacementWorkflow(requestDevice } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.DeployDeviceReplacementWorkflow(requestDeviceReplacementDeployDeviceReplacementWorkflow) + } + return nil, response, fmt.Errorf("error with operation DeployDeviceReplacementWorkflow") } @@ -267,6 +284,9 @@ func (s *DeviceReplacementService) UnmarkDeviceForReplacement(requestDeviceRepla } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UnmarkDeviceForReplacement(requestDeviceReplacementUnMarkDeviceForReplacement) + } return nil, response, fmt.Errorf("error with operation UnmarkDeviceForReplacement") } diff --git a/sdk/devices.go b/sdk/devices.go index 54de45f..e25f874 100644 --- a/sdk/devices.go +++ b/sdk/devices.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -1729,6 +1730,9 @@ func (s *DevicesService) GetPlannedAccessPointsForBuilding(buildingID string, Ge } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPlannedAccessPointsForBuilding(buildingID, GetPlannedAccessPointsForBuildingQueryParams) + } return nil, response, fmt.Errorf("error with operation GetPlannedAccessPointsForBuilding") } @@ -1763,6 +1767,9 @@ func (s *DevicesService) GetDeviceDetail(GetDeviceDetailQueryParams *GetDeviceDe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceDetail(GetDeviceDetailQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceDetail") } @@ -1811,6 +1818,9 @@ func (s *DevicesService) GetDeviceEnrichmentDetails(GetDeviceEnrichmentDetailsHe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceEnrichmentDetails(GetDeviceEnrichmentDetailsHeaderParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceEnrichmentDetails") } @@ -1845,6 +1855,9 @@ func (s *DevicesService) Devices(DevicesQueryParams *DevicesQueryParams) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.Devices(DevicesQueryParams) + } return nil, response, fmt.Errorf("error with operation Devices") } @@ -1882,6 +1895,9 @@ func (s *DevicesService) GetPlannedAccessPointsForFloor(floorID string, GetPlann } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPlannedAccessPointsForFloor(floorID, GetPlannedAccessPointsForFloorQueryParams) + } return nil, response, fmt.Errorf("error with operation GetPlannedAccessPointsForFloor") } @@ -1916,6 +1932,9 @@ func (s *DevicesService) GetAllInterfaces(GetAllInterfacesQueryParams *GetAllInt } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAllInterfaces(GetAllInterfacesQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAllInterfaces") } @@ -1947,6 +1966,9 @@ func (s *DevicesService) GetDeviceInterfaceCount() (*ResponseDevicesGetDeviceInt } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceInterfaceCount() + } return nil, response, fmt.Errorf("error with operation GetDeviceInterfaceCount") } @@ -1981,6 +2003,9 @@ func (s *DevicesService) GetInterfaceByIP(ipAddress string) (*ResponseDevicesGet } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetInterfaceByIP(ipAddress) + } return nil, response, fmt.Errorf("error with operation GetInterfaceByIp") } @@ -1994,7 +2019,7 @@ func (s *DevicesService) GetInterfaceByIP(ipAddress string) (*ResponseDevicesGet -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-i-s-i-s-interfaces +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-isis-interfaces */ func (s *DevicesService) GetIsisInterfaces() (*ResponseDevicesGetIsisInterfaces, *resty.Response, error) { path := "/dna/intent/api/v1/interface/isis" @@ -2012,6 +2037,9 @@ func (s *DevicesService) GetIsisInterfaces() (*ResponseDevicesGetIsisInterfaces, } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetIsisInterfaces() + } return nil, response, fmt.Errorf("error with operation GetIsisInterfaces") } @@ -2046,6 +2074,9 @@ func (s *DevicesService) GetInterfaceInfoByID(deviceID string) (*ResponseDevices } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetInterfaceInfoByID(deviceID) + } return nil, response, fmt.Errorf("error with operation GetInterfaceInfoById") } @@ -2080,6 +2111,9 @@ func (s *DevicesService) GetDeviceInterfaceCount2(deviceID string) (*ResponseDev } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceInterfaceCount2(deviceID) + } return nil, response, fmt.Errorf("error with operation GetDeviceInterfaceCount2") } @@ -2117,6 +2151,9 @@ func (s *DevicesService) GetInterfaceDetailsByDeviceIDAndInterfaceName(deviceID } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetInterfaceDetailsByDeviceIDAndInterfaceName(deviceID, GetInterfaceDetailsByDeviceIdAndInterfaceNameQueryParams) + } return nil, response, fmt.Errorf("error with operation GetInterfaceDetailsByDeviceIdAndInterfaceName") } @@ -2157,6 +2194,9 @@ func (s *DevicesService) GetDeviceInterfacesBySpecifiedRange(deviceID string, st } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceInterfacesBySpecifiedRange(deviceID, startIndex, recordsToReturn) + } return nil, response, fmt.Errorf("error with operation GetDeviceInterfacesBySpecifiedRange") } @@ -2170,7 +2210,7 @@ func (s *DevicesService) GetDeviceInterfacesBySpecifiedRange(deviceID string, st -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-o-s-p-f-interfaces +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-ospf-interfaces */ func (s *DevicesService) GetOspfInterfaces() (*ResponseDevicesGetOspfInterfaces, *resty.Response, error) { path := "/dna/intent/api/v1/interface/ospf" @@ -2188,6 +2228,9 @@ func (s *DevicesService) GetOspfInterfaces() (*ResponseDevicesGetOspfInterfaces, } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetOspfInterfaces() + } return nil, response, fmt.Errorf("error with operation GetOspfInterfaces") } @@ -2222,6 +2265,9 @@ func (s *DevicesService) GetInterfaceByID(id string) (*ResponseDevicesGetInterfa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetInterfaceByID(id) + } return nil, response, fmt.Errorf("error with operation GetInterfaceById") } @@ -2256,6 +2302,9 @@ func (s *DevicesService) LegitOperationsForInterface(interfaceUUID string) (*Res } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LegitOperationsForInterface(interfaceUUID) + } return nil, response, fmt.Errorf("error with operation LegitOperationsForInterface") } @@ -2291,6 +2340,9 @@ func (s *DevicesService) GetDeviceList(GetDeviceListQueryParams *GetDeviceListQu } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceList(GetDeviceListQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceList") } @@ -2325,6 +2377,9 @@ func (s *DevicesService) GetDeviceValuesThatMatchFullyOrPartiallyAnAttribute(Get } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceValuesThatMatchFullyOrPartiallyAnAttribute(GetDeviceValuesThatMatchFullyOrPartiallyAnAttributeQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceValuesThatMatchFullyOrPartiallyAnAttribute") } @@ -2356,6 +2411,9 @@ func (s *DevicesService) GetPollingIntervalForAllDevices() (*ResponseDevicesGetP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPollingIntervalForAllDevices() + } return nil, response, fmt.Errorf("error with operation GetPollingIntervalForAllDevices") } @@ -2387,6 +2445,9 @@ func (s *DevicesService) GetDeviceConfigForAllDevices() (*ResponseDevicesGetDevi } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceConfigForAllDevices() + } return nil, response, fmt.Errorf("error with operation GetDeviceConfigForAllDevices") } @@ -2418,6 +2479,9 @@ func (s *DevicesService) GetDeviceConfigCount() (*ResponseDevicesGetDeviceConfig } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceConfigCount() + } return nil, response, fmt.Errorf("error with operation GetDeviceConfigCount") } @@ -2449,6 +2513,9 @@ func (s *DevicesService) GetDeviceCount2() (*ResponseDevicesGetDeviceCount2, *re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceCount2() + } return nil, response, fmt.Errorf("error with operation GetDeviceCount2") } @@ -2483,6 +2550,9 @@ func (s *DevicesService) GetFunctionalCapabilityForDevices(GetFunctionalCapabili } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetFunctionalCapabilityForDevices(GetFunctionalCapabilityForDevicesQueryParams) + } return nil, response, fmt.Errorf("error with operation GetFunctionalCapabilityForDevices") } @@ -2517,6 +2587,9 @@ func (s *DevicesService) GetFunctionalCapabilityByID(id string) (*ResponseDevice } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetFunctionalCapabilityByID(id) + } return nil, response, fmt.Errorf("error with operation GetFunctionalCapabilityById") } @@ -2525,7 +2598,7 @@ func (s *DevicesService) GetFunctionalCapabilityByID(id string) (*ResponseDevice } -//InventoryInsightDeviceLinkMismatchApI Inventory Insight Device Link Mismatch API - 5792-59d8-4208-8190 +//InventoryInsightDeviceLinkMismatchAPI Inventory Insight Device Link Mismatch API - 5792-59d8-4208-8190 /* Find all devices with link mismatch (speed / vlan) @@ -2534,7 +2607,7 @@ func (s *DevicesService) GetFunctionalCapabilityByID(id string) (*ResponseDevice Documentation Link: https://developer.cisco.com/docs/dna-center/#!inventory-insight-device-link-mismatch-api */ -func (s *DevicesService) InventoryInsightDeviceLinkMismatchApI(siteID string, InventoryInsightDeviceLinkMismatchAPIQueryParams *InventoryInsightDeviceLinkMismatchApIQueryParams) (*ResponseDevicesInventoryInsightDeviceLinkMismatchApI, *resty.Response, error) { +func (s *DevicesService) InventoryInsightDeviceLinkMismatchAPI(siteID string, InventoryInsightDeviceLinkMismatchAPIQueryParams *InventoryInsightDeviceLinkMismatchApIQueryParams) (*ResponseDevicesInventoryInsightDeviceLinkMismatchApI, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/insight/{siteId}/device-link" path = strings.Replace(path, "{siteId}", fmt.Sprintf("%v", siteID), -1) @@ -2553,7 +2626,10 @@ func (s *DevicesService) InventoryInsightDeviceLinkMismatchApI(siteID string, In } if response.IsError() { - return nil, response, fmt.Errorf("error with operation InventoryInsightDeviceLinkMismatchApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.InventoryInsightDeviceLinkMismatchAPI(siteID, InventoryInsightDeviceLinkMismatchAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation InventoryInsightDeviceLinkMismatchApi") } result := response.Result().(*ResponseDevicesInventoryInsightDeviceLinkMismatchApI) @@ -2561,16 +2637,16 @@ func (s *DevicesService) InventoryInsightDeviceLinkMismatchApI(siteID string, In } -//ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DES Returns devices added to Cisco DNA center with snmp v3 DES. - afba-7a69-4d38-8de1 +//ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3Des Returns devices added to Cisco DNA center with snmp v3 DES. - afba-7a69-4d38-8de1 /* Returns devices added to Cisco DNA center with snmp v3 DES, where siteId is mandatory & accepts offset, limit, sortby, order which are optional. @param siteID siteId path parameter. @param ReturnsDevicesAddedToCiscoDNACenterWithSnmpV3DESQueryParams Filtering parameter -Documentation Link: https://developer.cisco.com/docs/dna-center/#!returns-devices-added-to-cisco-d-n-a-center-with-snmp-v3-des +Documentation Link: https://developer.cisco.com/docs/dna-center/#!returns-devices-added-to-cisco-dna-center-with-snmp-v3-des */ -func (s *DevicesService) ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DES(siteID string, ReturnsDevicesAddedToCiscoDNACenterWithSnmpV3DESQueryParams *ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DESQueryParams) (*ResponseDevicesReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DES, *resty.Response, error) { +func (s *DevicesService) ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3Des(siteID string, ReturnsDevicesAddedToCiscoDNACenterWithSnmpV3DESQueryParams *ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DESQueryParams) (*ResponseDevicesReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DES, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/insight/{siteId}/insecure-connection" path = strings.Replace(path, "{siteId}", fmt.Sprintf("%v", siteID), -1) @@ -2589,7 +2665,10 @@ func (s *DevicesService) ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DES(siteID } if response.IsError() { - return nil, response, fmt.Errorf("error with operation ReturnsDevicesAddedToCiscoDnaCenterWithSnmpV3DES") + if response.StatusCode() == http.StatusUnauthorized { + return s.ReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3Des(siteID, ReturnsDevicesAddedToCiscoDNACenterWithSnmpV3DESQueryParams) + } + return nil, response, fmt.Errorf("error with operation ReturnsDevicesAddedToCiscoDnaCenterWithSnmpV3Des") } result := response.Result().(*ResponseDevicesReturnsDevicesAddedToCiscoDnaCenterWithSNMPV3DES) @@ -2623,6 +2702,9 @@ func (s *DevicesService) GetNetworkDeviceByIP(ipAddress string) (*ResponseDevice } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNetworkDeviceByIP(ipAddress) + } return nil, response, fmt.Errorf("error with operation GetNetworkDeviceByIp") } @@ -2657,6 +2739,9 @@ func (s *DevicesService) GetModules(GetModulesQueryParams *GetModulesQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetModules(GetModulesQueryParams) + } return nil, response, fmt.Errorf("error with operation GetModules") } @@ -2691,6 +2776,9 @@ func (s *DevicesService) GetModuleCount(GetModuleCountQueryParams *GetModuleCoun } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetModuleCount(GetModuleCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetModuleCount") } @@ -2725,6 +2813,9 @@ func (s *DevicesService) GetModuleInfoByID(id string) (*ResponseDevicesGetModule } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetModuleInfoByID(id) + } return nil, response, fmt.Errorf("error with operation GetModuleInfoById") } @@ -2759,6 +2850,9 @@ func (s *DevicesService) GetDeviceBySerialNumber(serialNumber string) (*Response } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceBySerialNumber(serialNumber) + } return nil, response, fmt.Errorf("error with operation GetDeviceBySerialNumber") } @@ -2793,6 +2887,9 @@ func (s *DevicesService) GetDevicesRegisteredForWsaNotification(GetDevicesRegist } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDevicesRegisteredForWsaNotification(GetDevicesRegisteredForWSANotificationQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDevicesRegisteredForWsaNotification") } @@ -2827,6 +2924,9 @@ func (s *DevicesService) GetAllUserDefinedFields(GetAllUserDefinedFieldsQueryPar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAllUserDefinedFields(GetAllUserDefinedFieldsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAllUserDefinedFields") } @@ -2861,6 +2961,9 @@ func (s *DevicesService) GetChassisDetailsForDevice(deviceID string) (*ResponseD } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetChassisDetailsForDevice(deviceID) + } return nil, response, fmt.Errorf("error with operation GetChassisDetailsForDevice") } @@ -2895,6 +2998,9 @@ func (s *DevicesService) GetStackDetailsForDevice(deviceID string) (*ResponseDev } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetStackDetailsForDevice(deviceID) + } return nil, response, fmt.Errorf("error with operation GetStackDetailsForDevice") } @@ -2931,6 +3037,9 @@ func (s *DevicesService) ReturnPowerSupplyFanDetailsForTheGivenDevice(deviceUUID } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ReturnPowerSupplyFanDetailsForTheGivenDevice(deviceUUID, ReturnPowerSupplyFanDetailsForTheGivenDeviceQueryParams) + } return nil, response, fmt.Errorf("error with operation ReturnPowerSupplyFanDetailsForTheGivenDevice") } @@ -2947,7 +3056,7 @@ func (s *DevicesService) ReturnPowerSupplyFanDetailsForTheGivenDevice(deviceUUID @param ReturnsPOEInterfaceDetailsForTheDeviceQueryParams Filtering parameter -Documentation Link: https://developer.cisco.com/docs/dna-center/#!returns-p-o-e-interface-details-for-the-device +Documentation Link: https://developer.cisco.com/docs/dna-center/#!returns-poe-interface-details-for-the-device */ func (s *DevicesService) ReturnsPoeInterfaceDetailsForTheDevice(deviceUUID string, ReturnsPOEInterfaceDetailsForTheDeviceQueryParams *ReturnsPoeInterfaceDetailsForTheDeviceQueryParams) (*ResponseDevicesReturnsPoeInterfaceDetailsForTheDevice, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/{deviceUuid}/interface/poe-detail" @@ -2968,6 +3077,9 @@ func (s *DevicesService) ReturnsPoeInterfaceDetailsForTheDevice(deviceUUID strin } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ReturnsPoeInterfaceDetailsForTheDevice(deviceUUID, ReturnsPOEInterfaceDetailsForTheDeviceQueryParams) + } return nil, response, fmt.Errorf("error with operation ReturnsPoeInterfaceDetailsForTheDevice") } @@ -3005,6 +3117,9 @@ func (s *DevicesService) GetConnectedDeviceDetail(deviceUUID string, interfaceUU } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetConnectedDeviceDetail(deviceUUID, interfaceUUID) + } return nil, response, fmt.Errorf("error with operation GetConnectedDeviceDetail") } @@ -3039,6 +3154,9 @@ func (s *DevicesService) GetLinecardDetails(deviceUUID string) (*ResponseDevices } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetLinecardDetails(deviceUUID) + } return nil, response, fmt.Errorf("error with operation GetLinecardDetails") } @@ -3054,7 +3172,7 @@ func (s *DevicesService) GetLinecardDetails(deviceUUID string) (*ResponseDevices @param deviceUUID deviceUuid path parameter. uuid of the device -Documentation Link: https://developer.cisco.com/docs/dna-center/#!p-o-e-details +Documentation Link: https://developer.cisco.com/docs/dna-center/#!poe-details */ func (s *DevicesService) PoeDetails(deviceUUID string) (*ResponseDevicesPoeDetails, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/{deviceUuid}/poe" @@ -3073,6 +3191,9 @@ func (s *DevicesService) PoeDetails(deviceUUID string) (*ResponseDevicesPoeDetai } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.PoeDetails(deviceUUID) + } return nil, response, fmt.Errorf("error with operation PoeDetails") } @@ -3107,6 +3228,9 @@ func (s *DevicesService) GetSupervisorCardDetail(deviceUUID string) (*ResponseDe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSupervisorCardDetail(deviceUUID) + } return nil, response, fmt.Errorf("error with operation GetSupervisorCardDetail") } @@ -3141,6 +3265,9 @@ func (s *DevicesService) GetDeviceByID(id string) (*ResponseDevicesGetDeviceByID } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceByID(id) + } return nil, response, fmt.Errorf("error with operation GetDeviceById") } @@ -3175,6 +3302,9 @@ func (s *DevicesService) GetDeviceSummary(id string) (*ResponseDevicesGetDeviceS } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceSummary(id) + } return nil, response, fmt.Errorf("error with operation GetDeviceSummary") } @@ -3209,6 +3339,9 @@ func (s *DevicesService) GetPollingIntervalByID(id string) (*ResponseDevicesGetP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPollingIntervalByID(id) + } return nil, response, fmt.Errorf("error with operation GetPollingIntervalById") } @@ -3242,6 +3375,9 @@ func (s *DevicesService) GetOrganizationListForMeraki(id string) (*ResponseDevic } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetOrganizationListForMeraki(id) + } return nil, response, fmt.Errorf("error with operation GetOrganizationListForMeraki") } @@ -3257,7 +3393,7 @@ func (s *DevicesService) GetOrganizationListForMeraki(id string) (*ResponseDevic @param id id path parameter. @param GetDeviceInterfaceVLANsQueryParams Filtering parameter -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-device-interface-v-lans +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-device-interface-vlans */ func (s *DevicesService) GetDeviceInterfaceVLANs(id string, GetDeviceInterfaceVLANsQueryParams *GetDeviceInterfaceVLANsQueryParams) (*ResponseDevicesGetDeviceInterfaceVLANs, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/{id}/vlan" @@ -3278,6 +3414,9 @@ func (s *DevicesService) GetDeviceInterfaceVLANs(id string, GetDeviceInterfaceVL } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceInterfaceVLANs(id, GetDeviceInterfaceVLANsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceInterfaceVlans") } @@ -3312,6 +3451,9 @@ func (s *DevicesService) GetWirelessLanControllerDetailsByID(id string) (*Respon } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetWirelessLanControllerDetailsByID(id) + } return nil, response, fmt.Errorf("error with operation GetWirelessLanControllerDetailsById") } @@ -3345,6 +3487,9 @@ func (s *DevicesService) GetDeviceConfigByID(networkDeviceID string) (*ResponseD } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceConfigByID(networkDeviceID) + } return nil, response, fmt.Errorf("error with operation GetDeviceConfigById") } @@ -3382,6 +3527,9 @@ func (s *DevicesService) GetNetworkDeviceByPaginationRange(startIndex int, recor } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNetworkDeviceByPaginationRange(startIndex, recordsToReturn) + } return nil, response, fmt.Errorf("error with operation GetNetworkDeviceByPaginationRange") } @@ -3420,6 +3568,11 @@ func (s *DevicesService) ClearMacAddressTable(interfaceUUID string, requestDevic } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ClearMacAddressTable(interfaceUUID, requestDevicesClearMacAddressTable, ClearMacAddressTableQueryParams) + } + return nil, response, fmt.Errorf("error with operation ClearMacAddressTable") } @@ -3452,6 +3605,11 @@ func (s *DevicesService) AddDevice2(requestDevicesAddDevice2 *RequestDevicesAddD } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddDevice2(requestDevicesAddDevice2) + } + return nil, response, fmt.Errorf("error with operation AddDevice2") } @@ -3484,6 +3642,11 @@ func (s *DevicesService) ExportDeviceList(requestDevicesExportDeviceList *Reques } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ExportDeviceList(requestDevicesExportDeviceList) + } + return nil, response, fmt.Errorf("error with operation ExportDeviceList") } @@ -3516,6 +3679,11 @@ func (s *DevicesService) CreateUserDefinedField(requestDevicesCreateUserDefinedF } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateUserDefinedField(requestDevicesCreateUserDefinedField) + } + return nil, response, fmt.Errorf("error with operation CreateUserDefinedField") } @@ -3552,6 +3720,9 @@ func (s *DevicesService) UpdateInterfaceDetails(interfaceUUID string, requestDev } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateInterfaceDetails(interfaceUUID, requestDevicesUpdateInterfaceDetails, UpdateInterfaceDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation UpdateInterfaceDetails") } @@ -3582,6 +3753,9 @@ func (s *DevicesService) SyncDevices2(requestDevicesSyncDevices2 *RequestDevices } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.SyncDevices2(requestDevicesSyncDevices2) + } return nil, response, fmt.Errorf("error with operation SyncDevices2") } @@ -3612,6 +3786,9 @@ func (s *DevicesService) UpdateDeviceRole(requestDevicesUpdateDeviceRole *Reques } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateDeviceRole(requestDevicesUpdateDeviceRole) + } return nil, response, fmt.Errorf("error with operation UpdateDeviceRole") } @@ -3645,6 +3822,9 @@ func (s *DevicesService) SyncDevices(requestDevicesSyncDevices *RequestDevicesSy } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.SyncDevices(requestDevicesSyncDevices, SyncDevicesQueryParams) + } return nil, response, fmt.Errorf("error with operation SyncDevices") } @@ -3678,6 +3858,9 @@ func (s *DevicesService) UpdateUserDefinedField(id string, requestDevicesUpdateU } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateUserDefinedField(id, requestDevicesUpdateUserDefinedField) + } return nil, response, fmt.Errorf("error with operation UpdateUserDefinedField") } @@ -3711,6 +3894,9 @@ func (s *DevicesService) AddUserDefinedFieldToDevice(deviceID string, requestDev } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.AddUserDefinedFieldToDevice(deviceID, requestDevicesAddUserDefinedFieldToDevice) + } return nil, response, fmt.Errorf("error with operation AddUserDefinedFieldToDevice") } @@ -3746,6 +3932,9 @@ func (s *DevicesService) DeleteUserDefinedField(id string) (*ResponseDevicesDele } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteUserDefinedField(id) + } return nil, response, fmt.Errorf("error with operation DeleteUserDefinedField") } @@ -3784,6 +3973,9 @@ func (s *DevicesService) RemoveUserDefinedFieldFromDevice(deviceID string, Remov } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RemoveUserDefinedFieldFromDevice(deviceID, RemoveUserDefinedFieldFromDeviceQueryParams) + } return nil, response, fmt.Errorf("error with operation RemoveUserDefinedFieldFromDevice") } @@ -3822,6 +4014,9 @@ func (s *DevicesService) DeleteDeviceByID(id string, DeleteDeviceByIdQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDeviceByID(id, DeleteDeviceByIdQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteDeviceById") } diff --git a/sdk/discovery.go b/sdk/discovery.go index b444738..5844c60 100644 --- a/sdk/discovery.go +++ b/sdk/discovery.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -1037,6 +1038,9 @@ func (s *DiscoveryService) GetCountOfAllDiscoveryJobs() (*ResponseDiscoveryGetCo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetCountOfAllDiscoveryJobs() + } return nil, response, fmt.Errorf("error with operation GetCountOfAllDiscoveryJobs") } @@ -1071,6 +1075,9 @@ func (s *DiscoveryService) GetDiscoveryJobsByIP(GetDiscoveryJobsByIPQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDiscoveryJobsByIP(GetDiscoveryJobsByIPQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDiscoveryJobsByIp") } @@ -1105,6 +1112,9 @@ func (s *DiscoveryService) GetDiscoveryByID(id string) (*ResponseDiscoveryGetDis } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDiscoveryByID(id) + } return nil, response, fmt.Errorf("error with operation GetDiscoveryById") } @@ -1142,6 +1152,9 @@ func (s *DiscoveryService) GetListOfDiscoveriesByDiscoveryID(id string, GetListO } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetListOfDiscoveriesByDiscoveryID(id, GetListOfDiscoveriesByDiscoveryIdQueryParams) + } return nil, response, fmt.Errorf("error with operation GetListOfDiscoveriesByDiscoveryId") } @@ -1179,6 +1192,9 @@ func (s *DiscoveryService) GetDiscoveredNetworkDevicesByDiscoveryID(id string, G } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDiscoveredNetworkDevicesByDiscoveryID(id, GetDiscoveredNetworkDevicesByDiscoveryIdQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDiscoveredNetworkDevicesByDiscoveryId") } @@ -1216,6 +1232,9 @@ func (s *DiscoveryService) GetDevicesDiscoveredByID(id string, GetDevicesDiscove } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDevicesDiscoveredByID(id, GetDevicesDiscoveredByIdQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDevicesDiscoveredById") } @@ -1259,6 +1278,9 @@ func (s *DiscoveryService) GetDiscoveredDevicesByRange(id string, startIndex int } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDiscoveredDevicesByRange(id, startIndex, recordsToReturn, GetDiscoveredDevicesByRangeQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDiscoveredDevicesByRange") } @@ -1296,6 +1318,9 @@ func (s *DiscoveryService) GetNetworkDevicesFromDiscovery(id string, GetNetworkD } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNetworkDevicesFromDiscovery(id, GetNetworkDevicesFromDiscoveryQueryParams) + } return nil, response, fmt.Errorf("error with operation GetNetworkDevicesFromDiscovery") } @@ -1333,6 +1358,9 @@ func (s *DiscoveryService) GetDiscoveriesByRange(startIndex int, recordsToReturn } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDiscoveriesByRange(startIndex, recordsToReturn) + } return nil, response, fmt.Errorf("error with operation GetDiscoveriesByRange") } @@ -1367,6 +1395,9 @@ func (s *DiscoveryService) GetGlobalCredentials(GetGlobalCredentialsQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetGlobalCredentials(GetGlobalCredentialsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetGlobalCredentials") } @@ -1401,6 +1432,9 @@ func (s *DiscoveryService) GetCredentialSubTypeByCredentialID(id string) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetCredentialSubTypeByCredentialID(id) + } return nil, response, fmt.Errorf("error with operation GetCredentialSubTypeByCredentialId") } @@ -1414,7 +1448,7 @@ func (s *DiscoveryService) GetCredentialSubTypeByCredentialID(id string) (*Respo -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-s-n-m-p-properties +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-snmp-properties */ func (s *DiscoveryService) GetSNMPProperties() (*ResponseDiscoveryGetSNMPProperties, *resty.Response, error) { path := "/dna/intent/api/v1/snmp-property" @@ -1432,6 +1466,9 @@ func (s *DiscoveryService) GetSNMPProperties() (*ResponseDiscoveryGetSNMPPropert } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSNMPProperties() + } return nil, response, fmt.Errorf("error with operation GetSnmpProperties") } @@ -1463,6 +1500,9 @@ func (s *DiscoveryService) GetAllGlobalCredentialsV2() (*ResponseDiscoveryGetAll } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAllGlobalCredentialsV2() + } return nil, response, fmt.Errorf("error with operation GetAllGlobalCredentialsV2") } @@ -1495,6 +1535,11 @@ func (s *DiscoveryService) StartDiscovery(requestDiscoveryStartDiscovery *Reques } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.StartDiscovery(requestDiscoveryStartDiscovery) + } + return nil, response, fmt.Errorf("error with operation StartDiscovery") } @@ -1508,7 +1553,7 @@ func (s *DiscoveryService) StartDiscovery(requestDiscoveryStartDiscovery *Reques -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-c-l-i-credentials +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-cli-credentials */ func (s *DiscoveryService) CreateCliCredentials(requestDiscoveryCreateCLICredentials *RequestDiscoveryCreateCliCredentials) (*ResponseDiscoveryCreateCliCredentials, *resty.Response, error) { path := "/dna/intent/api/v1/global-credential/cli" @@ -1527,6 +1572,11 @@ func (s *DiscoveryService) CreateCliCredentials(requestDiscoveryCreateCLICredent } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateCliCredentials(requestDiscoveryCreateCLICredentials) + } + return nil, response, fmt.Errorf("error with operation CreateCliCredentials") } @@ -1559,6 +1609,11 @@ func (s *DiscoveryService) CreateHTTPReadCredentials(requestDiscoveryCreateHTTPR } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateHTTPReadCredentials(requestDiscoveryCreateHTTPReadCredentials) + } + return nil, response, fmt.Errorf("error with operation CreateHttpReadCredentials") } @@ -1591,6 +1646,11 @@ func (s *DiscoveryService) CreateHTTPWriteCredentials(requestDiscoveryCreateHTTP } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateHTTPWriteCredentials(requestDiscoveryCreateHTTPWriteCredentials) + } + return nil, response, fmt.Errorf("error with operation CreateHttpWriteCredentials") } @@ -1623,6 +1683,11 @@ func (s *DiscoveryService) CreateNetconfCredentials(requestDiscoveryCreateNetcon } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateNetconfCredentials(requestDiscoveryCreateNetconfCredentials) + } + return nil, response, fmt.Errorf("error with operation CreateNetconfCredentials") } @@ -1636,7 +1701,7 @@ func (s *DiscoveryService) CreateNetconfCredentials(requestDiscoveryCreateNetcon -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-s-n-m-p-read-community +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-snmp-read-community */ func (s *DiscoveryService) CreateSNMPReadCommunity(requestDiscoveryCreateSNMPReadCommunity *RequestDiscoveryCreateSNMPReadCommunity) (*ResponseDiscoveryCreateSNMPReadCommunity, *resty.Response, error) { path := "/dna/intent/api/v1/global-credential/snmpv2-read-community" @@ -1655,6 +1720,11 @@ func (s *DiscoveryService) CreateSNMPReadCommunity(requestDiscoveryCreateSNMPRea } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSNMPReadCommunity(requestDiscoveryCreateSNMPReadCommunity) + } + return nil, response, fmt.Errorf("error with operation CreateSnmpReadCommunity") } @@ -1668,7 +1738,7 @@ func (s *DiscoveryService) CreateSNMPReadCommunity(requestDiscoveryCreateSNMPRea -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-s-n-m-p-write-community +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-snmp-write-community */ func (s *DiscoveryService) CreateSNMPWriteCommunity(requestDiscoveryCreateSNMPWriteCommunity *RequestDiscoveryCreateSNMPWriteCommunity) (*ResponseDiscoveryCreateSNMPWriteCommunity, *resty.Response, error) { path := "/dna/intent/api/v1/global-credential/snmpv2-write-community" @@ -1687,6 +1757,11 @@ func (s *DiscoveryService) CreateSNMPWriteCommunity(requestDiscoveryCreateSNMPWr } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSNMPWriteCommunity(requestDiscoveryCreateSNMPWriteCommunity) + } + return nil, response, fmt.Errorf("error with operation CreateSnmpWriteCommunity") } @@ -1700,7 +1775,7 @@ func (s *DiscoveryService) CreateSNMPWriteCommunity(requestDiscoveryCreateSNMPWr -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-s-n-m-pv3-credentials +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-snmpv3-credentials */ func (s *DiscoveryService) CreateSNMPv3Credentials(requestDiscoveryCreateSNMPv3Credentials *RequestDiscoveryCreateSNMPv3Credentials) (*ResponseDiscoveryCreateSNMPv3Credentials, *resty.Response, error) { path := "/dna/intent/api/v1/global-credential/snmpv3" @@ -1719,6 +1794,11 @@ func (s *DiscoveryService) CreateSNMPv3Credentials(requestDiscoveryCreateSNMPv3C } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSNMPv3Credentials(requestDiscoveryCreateSNMPv3Credentials) + } + return nil, response, fmt.Errorf("error with operation CreateSnmpv3Credentials") } @@ -1732,7 +1812,7 @@ func (s *DiscoveryService) CreateSNMPv3Credentials(requestDiscoveryCreateSNMPv3C -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-update-s-n-m-p-properties +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-update-snmp-properties */ func (s *DiscoveryService) CreateUpdateSNMPProperties(requestDiscoveryCreateUpdateSNMPProperties *RequestDiscoveryCreateUpdateSNMPProperties) (*ResponseDiscoveryCreateUpdateSNMPProperties, *resty.Response, error) { path := "/dna/intent/api/v1/snmp-property" @@ -1751,6 +1831,11 @@ func (s *DiscoveryService) CreateUpdateSNMPProperties(requestDiscoveryCreateUpda } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateUpdateSNMPProperties(requestDiscoveryCreateUpdateSNMPProperties) + } + return nil, response, fmt.Errorf("error with operation CreateUpdateSnmpProperties") } @@ -1783,6 +1868,11 @@ func (s *DiscoveryService) CreateGlobalCredentialsV2(requestDiscoveryCreateGloba } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateGlobalCredentialsV2(requestDiscoveryCreateGlobalCredentialsV2) + } + return nil, response, fmt.Errorf("error with operation CreateGlobalCredentialsV2") } @@ -1813,6 +1903,9 @@ func (s *DiscoveryService) UpdatesAnExistingDiscoveryBySpecifiedID(requestDiscov } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdatesAnExistingDiscoveryBySpecifiedID(requestDiscoveryUpdatesAnExistingDiscoveryBySpecifiedId) + } return nil, response, fmt.Errorf("error with operation UpdatesAnExistingDiscoveryBySpecifiedId") } @@ -1843,6 +1936,9 @@ func (s *DiscoveryService) UpdateCliCredentials(requestDiscoveryUpdateCLICredent } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateCliCredentials(requestDiscoveryUpdateCLICredentials) + } return nil, response, fmt.Errorf("error with operation UpdateCliCredentials") } @@ -1873,6 +1969,9 @@ func (s *DiscoveryService) UpdateHTTPReadCredential(requestDiscoveryUpdateHTTPRe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateHTTPReadCredential(requestDiscoveryUpdateHTTPReadCredential) + } return nil, response, fmt.Errorf("error with operation UpdateHttpReadCredential") } @@ -1903,6 +2002,9 @@ func (s *DiscoveryService) UpdateHTTPWriteCredentials(requestDiscoveryUpdateHTTP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateHTTPWriteCredentials(requestDiscoveryUpdateHTTPWriteCredentials) + } return nil, response, fmt.Errorf("error with operation UpdateHttpWriteCredentials") } @@ -1933,6 +2035,9 @@ func (s *DiscoveryService) UpdateNetconfCredentials(requestDiscoveryUpdateNetcon } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateNetconfCredentials(requestDiscoveryUpdateNetconfCredentials) + } return nil, response, fmt.Errorf("error with operation UpdateNetconfCredentials") } @@ -1963,6 +2068,9 @@ func (s *DiscoveryService) UpdateSNMPReadCommunity(requestDiscoveryUpdateSNMPRea } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSNMPReadCommunity(requestDiscoveryUpdateSNMPReadCommunity) + } return nil, response, fmt.Errorf("error with operation UpdateSnmpReadCommunity") } @@ -1993,6 +2101,9 @@ func (s *DiscoveryService) UpdateSNMPWriteCommunity(requestDiscoveryUpdateSNMPWr } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSNMPWriteCommunity(requestDiscoveryUpdateSNMPWriteCommunity) + } return nil, response, fmt.Errorf("error with operation UpdateSnmpWriteCommunity") } @@ -2023,6 +2134,9 @@ func (s *DiscoveryService) UpdateSNMPv3Credentials(requestDiscoveryUpdateSNMPv3C } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSNMPv3Credentials(requestDiscoveryUpdateSNMPv3Credentials) + } return nil, response, fmt.Errorf("error with operation UpdateSnmpv3Credentials") } @@ -2056,6 +2170,9 @@ func (s *DiscoveryService) UpdateGlobalCredentials(globalCredentialID string, re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateGlobalCredentials(globalCredentialID, requestDiscoveryUpdateGlobalCredentials) + } return nil, response, fmt.Errorf("error with operation UpdateGlobalCredentials") } @@ -2086,6 +2203,9 @@ func (s *DiscoveryService) UpdateGlobalCredentialsV2(requestDiscoveryUpdateGloba } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateGlobalCredentialsV2(requestDiscoveryUpdateGlobalCredentialsV2) + } return nil, response, fmt.Errorf("error with operation UpdateGlobalCredentialsV2") } @@ -2118,6 +2238,9 @@ func (s *DiscoveryService) DeleteAllDiscovery() (*ResponseDiscoveryDeleteAllDisc } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteAllDiscovery() + } return nil, response, fmt.Errorf("error with operation DeleteAllDiscovery") } @@ -2153,6 +2276,9 @@ func (s *DiscoveryService) DeleteDiscoveryByID(id string) (*ResponseDiscoveryDel } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDiscoveryByID(id) + } return nil, response, fmt.Errorf("error with operation DeleteDiscoveryById") } @@ -2191,6 +2317,9 @@ func (s *DiscoveryService) DeleteDiscoveryBySpecifiedRange(startIndex int, recor } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDiscoveryBySpecifiedRange(startIndex, recordsToDelete) + } return nil, response, fmt.Errorf("error with operation DeleteDiscoveryBySpecifiedRange") } @@ -2226,6 +2355,9 @@ func (s *DiscoveryService) DeleteGlobalCredentialsByID(globalCredentialID string } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteGlobalCredentialsByID(globalCredentialID) + } return nil, response, fmt.Errorf("error with operation DeleteGlobalCredentialsById") } @@ -2261,6 +2393,9 @@ func (s *DiscoveryService) DeleteGlobalCredentialV2(id string) (*ResponseDiscove } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteGlobalCredentialV2(id) + } return nil, response, fmt.Errorf("error with operation DeleteGlobalCredentialV2") } diff --git a/sdk/eox.go b/sdk/eox.go index b5840d5..782cfeb 100644 --- a/sdk/eox.go +++ b/sdk/eox.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -72,7 +73,7 @@ type ResponseEoXGetEoXSummaryResponse struct { Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-eo-x-status-for-all-devices */ -func (s *EoXService) GetEoXStatusForAllDevices() (*ResponseEoXGetEoXStatusForAllDevices, *resty.Response, error) { +func (s *EoXService) GetEoxStatusForAllDevices() (*ResponseEoXGetEoXStatusForAllDevices, *resty.Response, error) { path := "/dna/intent/api/v1/eox-status/device" response, err := s.client.R(). @@ -88,7 +89,10 @@ func (s *EoXService) GetEoXStatusForAllDevices() (*ResponseEoXGetEoXStatusForAll } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetEoXStatusForAllDevices") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEoxStatusForAllDevices() + } + return nil, response, fmt.Errorf("error with operation GetEoxStatusForAllDevices") } result := response.Result().(*ResponseEoXGetEoXStatusForAllDevices) @@ -96,16 +100,16 @@ func (s *EoXService) GetEoXStatusForAllDevices() (*ResponseEoXGetEoXStatusForAll } -//GetEoXDetailsPerDevice Get EoX Details Per Device - dc80-099e-4d59-986d +//GetEoxDetailsPerDevice Get EoX Details Per Device - dc80-099e-4d59-986d /* Retrieves EoX details for a device @param deviceID deviceId path parameter. Device instance UUID -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-eo-x-details-per-device +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-eox-details-per-device */ -func (s *EoXService) GetEoXDetailsPerDevice(deviceID string) (*ResponseEoXGetEoXDetailsPerDevice, *resty.Response, error) { +func (s *EoXService) GetEoxDetailsPerDevice(deviceID string) (*ResponseEoXGetEoXDetailsPerDevice, *resty.Response, error) { path := "/dna/intent/api/v1/eox-status/device/{deviceId}" path = strings.Replace(path, "{deviceId}", fmt.Sprintf("%v", deviceID), -1) @@ -122,7 +126,10 @@ func (s *EoXService) GetEoXDetailsPerDevice(deviceID string) (*ResponseEoXGetEoX } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetEoXDetailsPerDevice") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEoxDetailsPerDevice(deviceID) + } + return nil, response, fmt.Errorf("error with operation GetEoxDetailsPerDevice") } result := response.Result().(*ResponseEoXGetEoXDetailsPerDevice) @@ -130,14 +137,14 @@ func (s *EoXService) GetEoXDetailsPerDevice(deviceID string) (*ResponseEoXGetEoX } -//GetEoXSummary Get EoX Summary - f0b2-7a23-4fea-96fc +//GetEoxSummary Get EoX Summary - f0b2-7a23-4fea-96fc /* Retrieves EoX summary for all devices in the network -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-eo-x-summary +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-eox-summary */ -func (s *EoXService) GetEoXSummary() (*ResponseEoXGetEoXSummary, *resty.Response, error) { +func (s *EoXService) GetEoxSummary() (*ResponseEoXGetEoXSummary, *resty.Response, error) { path := "/dna/intent/api/v1/eox-status/summary" response, err := s.client.R(). @@ -153,7 +160,10 @@ func (s *EoXService) GetEoXSummary() (*ResponseEoXGetEoXSummary, *resty.Response } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetEoXSummary") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEoxSummary() + } + return nil, response, fmt.Errorf("error with operation GetEoxSummary") } result := response.Result().(*ResponseEoXGetEoXSummary) diff --git a/sdk/event_management.go b/sdk/event_management.go index b974a56..c848893 100644 --- a/sdk/event_management.go +++ b/sdk/event_management.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -1156,6 +1157,9 @@ func (s *EventManagementService) GetAuditLogParentRecords(GetAuditLogParentRecor } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAuditLogParentRecords(GetAuditLogParentRecordsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAuditLogParentRecords") } @@ -1190,6 +1194,9 @@ func (s *EventManagementService) GetAuditLogSummary(GetAuditLogSummaryQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAuditLogSummary(GetAuditLogSummaryQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAuditLogSummary") } @@ -1224,6 +1231,9 @@ func (s *EventManagementService) GetAuditLogRecords(GetAuditLogRecordsQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAuditLogRecords(GetAuditLogRecordsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAuditLogRecords") } @@ -1258,6 +1268,9 @@ func (s *EventManagementService) GetStatusAPIForEvents(executionID string) (*Res } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetStatusAPIForEvents(executionID) + } return nil, response, fmt.Errorf("error with operation GetStatusApiForEvents") } @@ -1289,6 +1302,9 @@ func (s *EventManagementService) GetEmailDestination() (*ResponseEventManagement } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEmailDestination() + } return nil, response, fmt.Errorf("error with operation GetEmailDestination") } @@ -1323,6 +1339,9 @@ func (s *EventManagementService) GetNotifications(GetNotificationsQueryParams *G } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNotifications(GetNotificationsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetNotifications") } @@ -1357,6 +1376,9 @@ func (s *EventManagementService) CountOfNotifications(CountOfNotificationsQueryP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CountOfNotifications(CountOfNotificationsQueryParams) + } return nil, response, fmt.Errorf("error with operation CountOfNotifications") } @@ -1371,7 +1393,7 @@ func (s *EventManagementService) CountOfNotifications(CountOfNotificationsQueryP @param GetSNMPDestinationQueryParams Filtering parameter -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-s-n-m-p-destination +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-snmp-destination */ func (s *EventManagementService) GetSNMPDestination(GetSNMPDestinationQueryParams *GetSNMPDestinationQueryParams) (*ResponseEventManagementGetSNMPDestination, *resty.Response, error) { path := "/dna/intent/api/v1/event/snmp-config" @@ -1391,6 +1413,9 @@ func (s *EventManagementService) GetSNMPDestination(GetSNMPDestinationQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSNMPDestination(GetSNMPDestinationQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSnmpDestination") } @@ -1425,6 +1450,9 @@ func (s *EventManagementService) GetEventSubscriptions(GetEventSubscriptionsQuer } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEventSubscriptions(GetEventSubscriptionsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEventSubscriptions") } @@ -1459,6 +1487,9 @@ func (s *EventManagementService) GetEmailSubscriptionDetails(GetEmailSubscriptio } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEmailSubscriptionDetails(GetEmailSubscriptionDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEmailSubscriptionDetails") } @@ -1493,6 +1524,9 @@ func (s *EventManagementService) GetRestWebhookSubscriptionDetails(GetRestWebhoo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetRestWebhookSubscriptionDetails(GetRestWebhookSubscriptionDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetRestWebhookSubscriptionDetails") } @@ -1527,6 +1561,9 @@ func (s *EventManagementService) GetSyslogSubscriptionDetails(GetSyslogSubscript } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSyslogSubscriptionDetails(GetSyslogSubscriptionDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSyslogSubscriptionDetails") } @@ -1561,6 +1598,9 @@ func (s *EventManagementService) CountOfEventSubscriptions(CountOfEventSubscript } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CountOfEventSubscriptions(CountOfEventSubscriptionsQueryParams) + } return nil, response, fmt.Errorf("error with operation CountOfEventSubscriptions") } @@ -1595,6 +1635,9 @@ func (s *EventManagementService) GetEmailEventSubscriptions(GetEmailEventSubscri } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEmailEventSubscriptions(GetEmailEventSubscriptionsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEmailEventSubscriptions") } @@ -1629,6 +1672,9 @@ func (s *EventManagementService) GetRestWebhookEventSubscriptions(GetRestWebhook } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetRestWebhookEventSubscriptions(GetRestWebhookEventSubscriptionsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetRestWebhookEventSubscriptions") } @@ -1663,6 +1709,9 @@ func (s *EventManagementService) GetSyslogEventSubscriptions(GetSyslogEventSubsc } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSyslogEventSubscriptions(GetSyslogEventSubscriptionsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSyslogEventSubscriptions") } @@ -1697,6 +1746,9 @@ func (s *EventManagementService) GetSyslogDestination(GetSyslogDestinationQueryP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSyslogDestination(GetSyslogDestinationQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSyslogDestination") } @@ -1731,6 +1783,9 @@ func (s *EventManagementService) GetWebhookDestination(GetWebhookDestinationQuer } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetWebhookDestination(GetWebhookDestinationQueryParams) + } return nil, response, fmt.Errorf("error with operation GetWebhookDestination") } @@ -1765,6 +1820,9 @@ func (s *EventManagementService) GetEvents(GetEventsQueryParams *GetEventsQueryP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEvents(GetEventsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEvents") } @@ -1799,6 +1857,9 @@ func (s *EventManagementService) CountOfEvents(CountOfEventsQueryParams *CountOf } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CountOfEvents(CountOfEventsQueryParams) + } return nil, response, fmt.Errorf("error with operation CountOfEvents") } @@ -1833,6 +1894,9 @@ func (s *EventManagementService) GetEventArtifacts(GetEventArtifactsQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEventArtifacts(GetEventArtifactsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEventArtifacts") } @@ -1864,6 +1928,9 @@ func (s *EventManagementService) EventArtifactCount() (*ResponseEventManagementE } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.EventArtifactCount() + } return nil, response, fmt.Errorf("error with operation EventArtifactCount") } @@ -1895,6 +1962,9 @@ func (s *EventManagementService) GetConnectorTypes() (*ResponseEventManagementGe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetConnectorTypes() + } return nil, response, fmt.Errorf("error with operation GetConnectorTypes") } @@ -1927,6 +1997,11 @@ func (s *EventManagementService) CreateEmailDestination(requestEventManagementCr } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateEmailDestination(requestEventManagementCreateEmailDestination) + } + return nil, response, fmt.Errorf("error with operation CreateEmailDestination") } @@ -1959,6 +2034,11 @@ func (s *EventManagementService) CreateEventSubscriptions(requestEventManagement } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateEventSubscriptions(requestEventManagementCreateEventSubscriptions) + } + return nil, response, fmt.Errorf("error with operation CreateEventSubscriptions") } @@ -1991,6 +2071,11 @@ func (s *EventManagementService) CreateEmailEventSubscription(requestEventManage } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateEmailEventSubscription(requestEventManagementCreateEmailEventSubscription) + } + return nil, response, fmt.Errorf("error with operation CreateEmailEventSubscription") } @@ -2023,6 +2108,11 @@ func (s *EventManagementService) CreateRestWebhookEventSubscription(requestEvent } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateRestWebhookEventSubscription(requestEventManagementCreateRestWebhookEventSubscription) + } + return nil, response, fmt.Errorf("error with operation CreateRestWebhookEventSubscription") } @@ -2055,6 +2145,11 @@ func (s *EventManagementService) CreateSyslogEventSubscription(requestEventManag } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSyslogEventSubscription(requestEventManagementCreateSyslogEventSubscription) + } + return nil, response, fmt.Errorf("error with operation CreateSyslogEventSubscription") } @@ -2087,6 +2182,11 @@ func (s *EventManagementService) CreateSyslogDestination(requestEventManagementC } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSyslogDestination(requestEventManagementCreateSyslogDestination) + } + return nil, response, fmt.Errorf("error with operation CreateSyslogDestination") } @@ -2119,6 +2219,11 @@ func (s *EventManagementService) CreateWebhookDestination(requestEventManagement } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateWebhookDestination(requestEventManagementCreateWebhookDestination) + } + return nil, response, fmt.Errorf("error with operation CreateWebhookDestination") } @@ -2149,6 +2254,9 @@ func (s *EventManagementService) UpdateEmailDestination(requestEventManagementUp } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateEmailDestination(requestEventManagementUpdateEmailDestination) + } return nil, response, fmt.Errorf("error with operation UpdateEmailDestination") } @@ -2179,6 +2287,9 @@ func (s *EventManagementService) UpdateEventSubscriptions(requestEventManagement } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateEventSubscriptions(requestEventManagementUpdateEventSubscriptions) + } return nil, response, fmt.Errorf("error with operation UpdateEventSubscriptions") } @@ -2209,6 +2320,9 @@ func (s *EventManagementService) UpdateEmailEventSubscription(requestEventManage } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateEmailEventSubscription(requestEventManagementUpdateEmailEventSubscription) + } return nil, response, fmt.Errorf("error with operation UpdateEmailEventSubscription") } @@ -2239,6 +2353,9 @@ func (s *EventManagementService) UpdateRestWebhookEventSubscription(requestEvent } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateRestWebhookEventSubscription(requestEventManagementUpdateRestWebhookEventSubscription) + } return nil, response, fmt.Errorf("error with operation UpdateRestWebhookEventSubscription") } @@ -2269,6 +2386,9 @@ func (s *EventManagementService) UpdateSyslogEventSubscription(requestEventManag } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSyslogEventSubscription(requestEventManagementUpdateSyslogEventSubscription) + } return nil, response, fmt.Errorf("error with operation UpdateSyslogEventSubscription") } @@ -2299,6 +2419,9 @@ func (s *EventManagementService) UpdateSyslogDestination(requestEventManagementU } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSyslogDestination(requestEventManagementUpdateSyslogDestination) + } return nil, response, fmt.Errorf("error with operation UpdateSyslogDestination") } @@ -2329,6 +2452,9 @@ func (s *EventManagementService) UpdateWebhookDestination(requestEventManagement } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateWebhookDestination(requestEventManagementUpdateWebhookDestination) + } return nil, response, fmt.Errorf("error with operation UpdateWebhookDestination") } @@ -2364,6 +2490,9 @@ func (s *EventManagementService) DeleteEventSubscriptions(DeleteEventSubscriptio } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteEventSubscriptions(DeleteEventSubscriptionsQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteEventSubscriptions") } diff --git a/sdk/fabric_wireless.go b/sdk/fabric_wireless.go index ee17cf2..956d3fc 100644 --- a/sdk/fabric_wireless.go +++ b/sdk/fabric_wireless.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -94,6 +95,9 @@ func (s *FabricWirelessService) GetSSIDToIPPoolMapping(GetSSIDToIPPoolMappingQue } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSSIDToIPPoolMapping(GetSSIDToIPPoolMappingQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSsidToIpPoolMapping") } @@ -139,6 +143,11 @@ func (s *FabricWirelessService) AddSSIDToIPPoolMapping(requestFabricWirelessAddS } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddSSIDToIPPoolMapping(requestFabricWirelessAddSSIDToIPPoolMapping, AddSSIDToIPPoolMappingHeaderParams) + } + return nil, response, fmt.Errorf("error with operation AddSsidToIpPoolMapping") } @@ -171,6 +180,11 @@ func (s *FabricWirelessService) AddWLCToFabricDomain(requestFabricWirelessAddWLC } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddWLCToFabricDomain(requestFabricWirelessAddWLCToFabricDomain) + } + return nil, response, fmt.Errorf("error with operation AddWLCToFabricDomain") } @@ -201,6 +215,9 @@ func (s *FabricWirelessService) UpdateSSIDToIPPoolMapping(requestFabricWirelessU } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSSIDToIPPoolMapping(requestFabricWirelessUpdateSSIDToIPPoolMapping) + } return nil, response, fmt.Errorf("error with operation UpdateSsidToIpPoolMapping") } @@ -249,6 +266,9 @@ func (s *FabricWirelessService) RemoveWLCFromFabricDomain(RemoveWLCFromFabricDom } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RemoveWLCFromFabricDomain(RemoveWLCFromFabricDomainHeaderParams, RemoveWLCFromFabricDomainQueryParams) + } return nil, response, fmt.Errorf("error with operation RemoveWLCFromFabricDomain") } diff --git a/sdk/file.go b/sdk/file.go index 11d7084..b59cc9c 100644 --- a/sdk/file.go +++ b/sdk/file.go @@ -3,6 +3,7 @@ package dnac import ( "fmt" "io" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -64,6 +65,9 @@ func (s *FileService) GetListOfAvailableNamespaces() (*ResponseFileGetListOfAvai } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetListOfAvailableNamespaces() + } return nil, response, fmt.Errorf("error with operation GetListOfAvailableNamespaces") } @@ -98,6 +102,9 @@ func (s *FileService) GetListOfFiles(nameSpace string) (*ResponseFileGetListOfFi } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetListOfFiles(nameSpace) + } return nil, response, fmt.Errorf("error with operation GetListOfFiles") } @@ -131,6 +138,9 @@ func (s *FileService) DownloadAFileByFileID(fileID string) (FileDownload, *resty } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DownloadAFileByFileID(fileID) + } return fdownload, response, fmt.Errorf("error with operation ExportTrustedCertificate") } @@ -177,6 +187,11 @@ func (s *FileService) UploadFile(nameSpace string, UploadFileMultipartFields *Up } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.UploadFile(nameSpace, UploadFileMultipartFields) + } + return nil, response, fmt.Errorf("error with operation UploadFile") } diff --git a/sdk/health_and_performance.go b/sdk/health_and_performance.go index 99d8fcd..efbb079 100644 --- a/sdk/health_and_performance.go +++ b/sdk/health_and_performance.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -116,7 +117,7 @@ type ResponseHealthAndPerformanceSystemPerformanceHistoricalAPIKpisData map[stri Documentation Link: https://developer.cisco.com/docs/dna-center/#!system-health-api */ -func (s *HealthAndPerformanceService) SystemHealthApI(SystemHealthAPIQueryParams *SystemHealthApIQueryParams) (*ResponseHealthAndPerformanceSystemHealthApI, *resty.Response, error) { +func (s *HealthAndPerformanceService) SystemHealthAPI(SystemHealthAPIQueryParams *SystemHealthApIQueryParams) (*ResponseHealthAndPerformanceSystemHealthApI, *resty.Response, error) { path := "/dna/intent/api/v1/diagnostics/system/health" queryString, _ := query.Values(SystemHealthAPIQueryParams) @@ -134,7 +135,10 @@ func (s *HealthAndPerformanceService) SystemHealthApI(SystemHealthAPIQueryParams } if response.IsError() { - return nil, response, fmt.Errorf("error with operation SystemHealthApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.SystemHealthAPI(SystemHealthAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation SystemHealthApi") } result := response.Result().(*ResponseHealthAndPerformanceSystemHealthApI) @@ -142,7 +146,7 @@ func (s *HealthAndPerformanceService) SystemHealthApI(SystemHealthAPIQueryParams } -//SystemHealthCountApI System Health Count API - 5289-0891-4729-8714 +//SystemHealthCountAPI System Health Count API - 5289-0891-4729-8714 /* This API gives the count of the latest system events @@ -150,7 +154,7 @@ func (s *HealthAndPerformanceService) SystemHealthApI(SystemHealthAPIQueryParams Documentation Link: https://developer.cisco.com/docs/dna-center/#!system-health-count-api */ -func (s *HealthAndPerformanceService) SystemHealthCountApI(SystemHealthCountAPIQueryParams *SystemHealthCountApIQueryParams) (*ResponseHealthAndPerformanceSystemHealthCountApI, *resty.Response, error) { +func (s *HealthAndPerformanceService) SystemHealthCountAPI(SystemHealthCountAPIQueryParams *SystemHealthCountApIQueryParams) (*ResponseHealthAndPerformanceSystemHealthCountApI, *resty.Response, error) { path := "/dna/intent/api/v1/diagnostics/system/health/count" queryString, _ := query.Values(SystemHealthCountAPIQueryParams) @@ -168,7 +172,10 @@ func (s *HealthAndPerformanceService) SystemHealthCountApI(SystemHealthCountAPIQ } if response.IsError() { - return nil, response, fmt.Errorf("error with operation SystemHealthCountApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.SystemHealthCountAPI(SystemHealthCountAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation SystemHealthCountApi") } result := response.Result().(*ResponseHealthAndPerformanceSystemHealthCountApI) @@ -176,7 +183,7 @@ func (s *HealthAndPerformanceService) SystemHealthCountApI(SystemHealthCountAPIQ } -//SystemPerformanceApI System Performance API - f2a9-5b4d-48eb-a4f8 +//SystemPerformanceAPI System Performance API - f2a9-5b4d-48eb-a4f8 /* This API gives the aggregated performance indicators. The data can be retrieved for the last 3 months. @@ -184,7 +191,7 @@ func (s *HealthAndPerformanceService) SystemHealthCountApI(SystemHealthCountAPIQ Documentation Link: https://developer.cisco.com/docs/dna-center/#!system-performance-api */ -func (s *HealthAndPerformanceService) SystemPerformanceApI(SystemPerformanceAPIQueryParams *SystemPerformanceApIQueryParams) (*ResponseHealthAndPerformanceSystemPerformanceApI, *resty.Response, error) { +func (s *HealthAndPerformanceService) SystemPerformanceAPI(SystemPerformanceAPIQueryParams *SystemPerformanceApIQueryParams) (*ResponseHealthAndPerformanceSystemPerformanceApI, *resty.Response, error) { path := "/dna/intent/api/v1/diagnostics/system/performance" queryString, _ := query.Values(SystemPerformanceAPIQueryParams) @@ -202,7 +209,10 @@ func (s *HealthAndPerformanceService) SystemPerformanceApI(SystemPerformanceAPIQ } if response.IsError() { - return nil, response, fmt.Errorf("error with operation SystemPerformanceApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.SystemPerformanceAPI(SystemPerformanceAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation SystemPerformanceApi") } result := response.Result().(*ResponseHealthAndPerformanceSystemPerformanceApI) @@ -210,7 +220,7 @@ func (s *HealthAndPerformanceService) SystemPerformanceApI(SystemPerformanceAPIQ } -//SystemPerformanceHistoricalApI System Performance Historical API - 879b-ea1e-4389-83d7 +//SystemPerformanceHistoricalAPI System Performance Historical API - 879b-ea1e-4389-83d7 /* This API retrieves the historical performance indicators . The data can be retrieved for the last 3 months. @@ -218,7 +228,7 @@ func (s *HealthAndPerformanceService) SystemPerformanceApI(SystemPerformanceAPIQ Documentation Link: https://developer.cisco.com/docs/dna-center/#!system-performance-historical-api */ -func (s *HealthAndPerformanceService) SystemPerformanceHistoricalApI(SystemPerformanceHistoricalAPIQueryParams *SystemPerformanceHistoricalApIQueryParams) (*ResponseHealthAndPerformanceSystemPerformanceHistoricalApI, *resty.Response, error) { +func (s *HealthAndPerformanceService) SystemPerformanceHistoricalAPI(SystemPerformanceHistoricalAPIQueryParams *SystemPerformanceHistoricalApIQueryParams) (*ResponseHealthAndPerformanceSystemPerformanceHistoricalApI, *resty.Response, error) { path := "/dna/intent/api/v1/diagnostics/system/performance/history" queryString, _ := query.Values(SystemPerformanceHistoricalAPIQueryParams) @@ -236,7 +246,10 @@ func (s *HealthAndPerformanceService) SystemPerformanceHistoricalApI(SystemPerfo } if response.IsError() { - return nil, response, fmt.Errorf("error with operation SystemPerformanceHistoricalApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.SystemPerformanceHistoricalAPI(SystemPerformanceHistoricalAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation SystemPerformanceHistoricalApi") } result := response.Result().(*ResponseHealthAndPerformanceSystemPerformanceHistoricalApI) diff --git a/sdk/issues.go b/sdk/issues.go index 31f66eb..8413c72 100644 --- a/sdk/issues.go +++ b/sdk/issues.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -126,6 +127,9 @@ func (s *IssuesService) GetIssueEnrichmentDetails(GetIssueEnrichmentDetailsHeade } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetIssueEnrichmentDetails(GetIssueEnrichmentDetailsHeaderParams) + } return nil, response, fmt.Errorf("error with operation GetIssueEnrichmentDetails") } @@ -160,6 +164,9 @@ func (s *IssuesService) Issues(IssuesQueryParams *IssuesQueryParams) (*ResponseI } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.Issues(IssuesQueryParams) + } return nil, response, fmt.Errorf("error with operation Issues") } @@ -193,6 +200,11 @@ func (s *IssuesService) ExecuteSuggestedActionsCommands(requestIssuesExecuteSugg } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ExecuteSuggestedActionsCommands(requestIssuesExecuteSuggestedActionsCommands) + } + return nil, response, fmt.Errorf("error with operation ExecuteSuggestedActionsCommands") } diff --git a/sdk/itsm.go b/sdk/itsm.go index 4646c1f..45d4d50 100644 --- a/sdk/itsm.go +++ b/sdk/itsm.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -85,6 +86,9 @@ func (s *ItsmService) GetCmdbSyncStatus(GetCMDBSyncStatusQueryParams *GetCmdbSyn } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetCmdbSyncStatus(GetCMDBSyncStatusQueryParams) + } return nil, response, fmt.Errorf("error with operation GetCmdbSyncStatus") } @@ -119,6 +123,9 @@ func (s *ItsmService) GetFailedItsmEvents(GetFailedITSMEventsQueryParams *GetFai } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetFailedItsmEvents(GetFailedITSMEventsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetFailedItsmEvents") } @@ -151,6 +158,11 @@ func (s *ItsmService) RetryIntegrationEvents(requestItsmRetryIntegrationEvents * } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.RetryIntegrationEvents(requestItsmRetryIntegrationEvents) + } + return nil, response, fmt.Errorf("error with operation RetryIntegrationEvents") } diff --git a/sdk/itsm_integration.go b/sdk/itsm_integration.go index 976c835..1ffd55b 100644 --- a/sdk/itsm_integration.go +++ b/sdk/itsm_integration.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -150,6 +151,9 @@ func (s *ItsmIntegrationService) GetItsmIntegrationSettingByID(instanceID string } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetItsmIntegrationSettingByID(instanceID) + } return nil, response, fmt.Errorf("error with operation GetItsmIntegrationSettingById") } @@ -181,6 +185,9 @@ func (s *ItsmIntegrationService) GetAllItsmIntegrationSettings() (*ResponseItsmI } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAllItsmIntegrationSettings() + } return nil, response, fmt.Errorf("error with operation GetAllItsmIntegrationSettings") } @@ -213,6 +220,11 @@ func (s *ItsmIntegrationService) CreateItsmIntegrationSetting(requestItsmIntegra } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateItsmIntegrationSetting(requestItsmIntegrationCreateITSMIntegrationSetting) + } + return nil, response, fmt.Errorf("error with operation CreateItsmIntegrationSetting") } @@ -246,6 +258,9 @@ func (s *ItsmIntegrationService) UpdateItsmIntegrationSetting(instanceID string, } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateItsmIntegrationSetting(instanceID, requestItsmIntegrationUpdateITSMIntegrationSetting) + } return nil, response, fmt.Errorf("error with operation UpdateItsmIntegrationSetting") } @@ -280,6 +295,9 @@ func (s *ItsmIntegrationService) DeleteItsmIntegrationSetting(instanceID string) } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteItsmIntegrationSetting(instanceID) + } return response, fmt.Errorf("error with operation DeleteItsmIntegrationSetting") } diff --git a/sdk/lan_automation.go b/sdk/lan_automation.go index eff729a..ef6dee7 100644 --- a/sdk/lan_automation.go +++ b/sdk/lan_automation.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -193,6 +194,9 @@ func (s *LanAutomationService) LanAutomationSessionCount() (*ResponseLanAutomati } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationSessionCount() + } return nil, response, fmt.Errorf("error with operation LanAutomationSessionCount") } @@ -227,6 +231,9 @@ func (s *LanAutomationService) LanAutomationLog(LANAutomationLogQueryParams *Lan } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationLog(LANAutomationLogQueryParams) + } return nil, response, fmt.Errorf("error with operation LanAutomationLog") } @@ -261,6 +268,9 @@ func (s *LanAutomationService) LanAutomationLogByID(id string) (*ResponseLanAuto } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationLogByID(id) + } return nil, response, fmt.Errorf("error with operation LanAutomationLogById") } @@ -301,6 +311,9 @@ func (s *LanAutomationService) LanAutomationLogsForIndividualDevices(id string, } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationLogsForIndividualDevices(id, serialNumber, LANAutomationLogsForIndividualDevicesQueryParams) + } return nil, response, fmt.Errorf("error with operation LanAutomationLogsForIndividualDevices") } @@ -332,6 +345,9 @@ func (s *LanAutomationService) LanAutomationActiveSessions() (*ResponseLanAutoma } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationActiveSessions() + } return nil, response, fmt.Errorf("error with operation LanAutomationActiveSessions") } @@ -366,6 +382,9 @@ func (s *LanAutomationService) LanAutomationStatus(LANAutomationStatusQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationStatus(LANAutomationStatusQueryParams) + } return nil, response, fmt.Errorf("error with operation LanAutomationStatus") } @@ -400,6 +419,9 @@ func (s *LanAutomationService) LanAutomationStatusByID(id string) (*ResponseLanA } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationStatusByID(id) + } return nil, response, fmt.Errorf("error with operation LanAutomationStatusById") } @@ -432,6 +454,11 @@ func (s *LanAutomationService) LanAutomationStart(requestLanAutomationLANAutomat } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationStart(requestLanAutomationLANAutomationStart) + } + return nil, response, fmt.Errorf("error with operation LanAutomationStart") } @@ -467,6 +494,9 @@ func (s *LanAutomationService) LanAutomationStop(id string) (*ResponseLanAutomat } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LanAutomationStop(id) + } return nil, response, fmt.Errorf("error with operation LanAutomationStop") } diff --git a/sdk/licenses.go b/sdk/licenses.go index 0a7a051..618bddb 100644 --- a/sdk/licenses.go +++ b/sdk/licenses.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -260,6 +261,9 @@ func (s *LicensesService) DeviceCountDetails2(DeviceCountDetails2QueryParams *De } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeviceCountDetails2(DeviceCountDetails2QueryParams) + } return nil, response, fmt.Errorf("error with operation DeviceCountDetails2") } @@ -294,6 +298,9 @@ func (s *LicensesService) DeviceLicenseSummary2(DeviceLicenseSummary2QueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeviceLicenseSummary2(DeviceLicenseSummary2QueryParams) + } return nil, response, fmt.Errorf("error with operation DeviceLicenseSummary2") } @@ -328,6 +335,9 @@ func (s *LicensesService) DeviceLicenseDetails2(deviceuuid string) (*ResponseLic } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeviceLicenseDetails2(deviceuuid) + } return nil, response, fmt.Errorf("error with operation DeviceLicenseDetails2") } @@ -362,6 +372,9 @@ func (s *LicensesService) VirtualAccountDetails2(smartaccountTypeID string) (*Re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.VirtualAccountDetails2(smartaccountTypeID) + } return nil, response, fmt.Errorf("error with operation VirtualAccountDetails2") } @@ -393,6 +406,9 @@ func (s *LicensesService) SmartAccountDetails() (*ResponseLicensesSmartAccountDe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.SmartAccountDetails() + } return nil, response, fmt.Errorf("error with operation SmartAccountDetails") } @@ -433,6 +449,9 @@ func (s *LicensesService) LicenseTermDetails2(smartaccountTypeID string, virtual } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LicenseTermDetails2(smartaccountTypeID, virtualaccountname, LicenseTermDetails2QueryParams) + } return nil, response, fmt.Errorf("error with operation LicenseTermDetails2") } @@ -473,6 +492,9 @@ func (s *LicensesService) LicenseUsageDetails2(smartaccountTypeID string, virtua } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.LicenseUsageDetails2(smartaccountTypeID, virtualaccountname, LicenseUsageDetails2QueryParams) + } return nil, response, fmt.Errorf("error with operation LicenseUsageDetails2") } @@ -511,6 +533,11 @@ func (s *LicensesService) ChangeVirtualAccount2(smartaccountTypeID string, virtu } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ChangeVirtualAccount2(smartaccountTypeID, virtualaccountname, requestLicensesChangeVirtualAccount2) + } + return nil, response, fmt.Errorf("error with operation ChangeVirtualAccount2") } @@ -541,6 +568,9 @@ func (s *LicensesService) DeviceDeregistration2(requestLicensesDeviceDeregistrat } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeviceDeregistration2(requestLicensesDeviceDeregistration2) + } return nil, response, fmt.Errorf("error with operation DeviceDeregistration2") } @@ -574,6 +604,9 @@ func (s *LicensesService) DeviceRegistration2(virtualaccountname string, request } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeviceRegistration2(virtualaccountname, requestLicensesDeviceRegistration2) + } return nil, response, fmt.Errorf("error with operation DeviceRegistration2") } diff --git a/sdk/network_settings.go b/sdk/network_settings.go index 4d4a074..a715408 100644 --- a/sdk/network_settings.go +++ b/sdk/network_settings.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -849,6 +850,9 @@ func (s *NetworkSettingsService) GetDeviceCredentialDetails(GetDeviceCredentialD } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceCredentialDetails(GetDeviceCredentialDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceCredentialDetails") } @@ -883,6 +887,9 @@ func (s *NetworkSettingsService) GetGlobalPool(GetGlobalPoolQueryParams *GetGlob } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetGlobalPool(GetGlobalPoolQueryParams) + } return nil, response, fmt.Errorf("error with operation GetGlobalPool") } @@ -917,6 +924,9 @@ func (s *NetworkSettingsService) GetNetwork(GetNetworkQueryParams *GetNetworkQue } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNetwork(GetNetworkQueryParams) + } return nil, response, fmt.Errorf("error with operation GetNetwork") } @@ -951,6 +961,9 @@ func (s *NetworkSettingsService) GetReserveIPSubpool(GetReserveIPSubpoolQueryPar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetReserveIPSubpool(GetReserveIPSubpoolQueryParams) + } return nil, response, fmt.Errorf("error with operation GetReserveIpSubpool") } @@ -982,6 +995,9 @@ func (s *NetworkSettingsService) GetServiceProviderDetails() (*ResponseNetworkSe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetServiceProviderDetails() + } return nil, response, fmt.Errorf("error with operation GetServiceProviderDetails") } @@ -1016,6 +1032,9 @@ func (s *NetworkSettingsService) GetNetworkV2(GetNetworkV2QueryParams *GetNetwor } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNetworkV2(GetNetworkV2QueryParams) + } return nil, response, fmt.Errorf("error with operation GetNetworkV2") } @@ -1047,6 +1066,9 @@ func (s *NetworkSettingsService) GetServiceProviderDetailsV2() (*ResponseNetwork } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetServiceProviderDetailsV2() + } return nil, response, fmt.Errorf("error with operation GetServiceProviderDetailsV2") } @@ -1095,6 +1117,11 @@ func (s *NetworkSettingsService) AssignDeviceCredentialToSite(siteID string, req } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AssignDeviceCredentialToSite(siteID, requestNetworkSettingsAssignDeviceCredentialToSite, AssignDeviceCredentialToSiteHeaderParams) + } + return nil, response, fmt.Errorf("error with operation AssignDeviceCredentialToSite") } @@ -1127,6 +1154,11 @@ func (s *NetworkSettingsService) CreateDeviceCredentials(requestNetworkSettingsC } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateDeviceCredentials(requestNetworkSettingsCreateDeviceCredentials) + } + return nil, response, fmt.Errorf("error with operation CreateDeviceCredentials") } @@ -1159,6 +1191,11 @@ func (s *NetworkSettingsService) CreateGlobalPool(requestNetworkSettingsCreateGl } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateGlobalPool(requestNetworkSettingsCreateGlobalPool) + } + return nil, response, fmt.Errorf("error with operation CreateGlobalPool") } @@ -1207,6 +1244,11 @@ func (s *NetworkSettingsService) CreateNetwork(siteID string, requestNetworkSett } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateNetwork(siteID, requestNetworkSettingsCreateNetwork, CreateNetworkHeaderParams) + } + return nil, response, fmt.Errorf("error with operation CreateNetwork") } @@ -1242,6 +1284,11 @@ func (s *NetworkSettingsService) ReserveIPSubpool(siteID string, requestNetworkS } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ReserveIPSubpool(siteID, requestNetworkSettingsReserveIPSubpool) + } + return nil, response, fmt.Errorf("error with operation ReserveIpSubpool") } @@ -1255,7 +1302,7 @@ func (s *NetworkSettingsService) ReserveIPSubpool(siteID string, requestNetworkS -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-s-p-profile +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-sp-profile */ func (s *NetworkSettingsService) CreateSpProfile(requestNetworkSettingsCreateSPProfile *RequestNetworkSettingsCreateSpProfile) (*ResponseNetworkSettingsCreateSpProfile, *resty.Response, error) { path := "/dna/intent/api/v1/service-provider" @@ -1274,6 +1321,11 @@ func (s *NetworkSettingsService) CreateSpProfile(requestNetworkSettingsCreateSPP } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSpProfile(requestNetworkSettingsCreateSPProfile) + } + return nil, response, fmt.Errorf("error with operation CreateSpProfile") } @@ -1309,6 +1361,11 @@ func (s *NetworkSettingsService) AssignDeviceCredentialToSiteV2(siteID string, r } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AssignDeviceCredentialToSiteV2(siteID, requestNetworkSettingsAssignDeviceCredentialToSiteV2) + } + return nil, response, fmt.Errorf("error with operation AssignDeviceCredentialToSiteV2") } @@ -1344,6 +1401,11 @@ func (s *NetworkSettingsService) CreateNetworkV2(siteID string, requestNetworkSe } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateNetworkV2(siteID, requestNetworkSettingsCreateNetworkV2) + } + return nil, response, fmt.Errorf("error with operation CreateNetworkV2") } @@ -1357,7 +1419,7 @@ func (s *NetworkSettingsService) CreateNetworkV2(siteID string, requestNetworkSe -Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-s-p-profile-v2 +Documentation Link: https://developer.cisco.com/docs/dna-center/#!create-sp-profile-v2 */ func (s *NetworkSettingsService) CreateSpProfileV2(requestNetworkSettingsCreateSPProfileV2 *RequestNetworkSettingsCreateSpProfileV2) (*ResponseNetworkSettingsCreateSpProfileV2, *resty.Response, error) { path := "/dna/intent/api/v2/service-provider" @@ -1376,6 +1438,11 @@ func (s *NetworkSettingsService) CreateSpProfileV2(requestNetworkSettingsCreateS } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSpProfileV2(requestNetworkSettingsCreateSPProfileV2) + } + return nil, response, fmt.Errorf("error with operation CreateSpProfileV2") } @@ -1406,6 +1473,9 @@ func (s *NetworkSettingsService) UpdateDeviceCredentials(requestNetworkSettingsU } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateDeviceCredentials(requestNetworkSettingsUpdateDeviceCredentials) + } return nil, response, fmt.Errorf("error with operation UpdateDeviceCredentials") } @@ -1436,6 +1506,9 @@ func (s *NetworkSettingsService) UpdateGlobalPool(requestNetworkSettingsUpdateGl } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateGlobalPool(requestNetworkSettingsUpdateGlobalPool) + } return nil, response, fmt.Errorf("error with operation UpdateGlobalPool") } @@ -1469,6 +1542,9 @@ func (s *NetworkSettingsService) UpdateNetwork(siteID string, requestNetworkSett } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateNetwork(siteID, requestNetworkSettingsUpdateNetwork) + } return nil, response, fmt.Errorf("error with operation UpdateNetwork") } @@ -1505,6 +1581,9 @@ func (s *NetworkSettingsService) UpdateReserveIPSubpool(siteID string, requestNe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateReserveIPSubpool(siteID, requestNetworkSettingsUpdateReserveIPSubpool, UpdateReserveIPSubpoolQueryParams) + } return nil, response, fmt.Errorf("error with operation UpdateReserveIpSubpool") } @@ -1535,6 +1614,9 @@ func (s *NetworkSettingsService) UpdateSpProfile(requestNetworkSettingsUpdateSPP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSpProfile(requestNetworkSettingsUpdateSPProfile) + } return nil, response, fmt.Errorf("error with operation UpdateSpProfile") } @@ -1568,6 +1650,9 @@ func (s *NetworkSettingsService) UpdateNetworkV2(siteID string, requestNetworkSe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateNetworkV2(siteID, requestNetworkSettingsUpdateNetworkV2) + } return nil, response, fmt.Errorf("error with operation UpdateNetworkV2") } @@ -1598,6 +1683,9 @@ func (s *NetworkSettingsService) UpdateSpProfileV2(requestNetworkSettingsUpdateS } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSpProfileV2(requestNetworkSettingsUpdateSPProfileV2) + } return nil, response, fmt.Errorf("error with operation UpdateSpProfileV2") } @@ -1633,6 +1721,9 @@ func (s *NetworkSettingsService) DeleteDeviceCredential(id string) (*ResponseNet } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDeviceCredential(id) + } return nil, response, fmt.Errorf("error with operation DeleteDeviceCredential") } @@ -1668,6 +1759,9 @@ func (s *NetworkSettingsService) DeleteGlobalIPPool(id string) (*ResponseNetwork } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteGlobalIPPool(id) + } return nil, response, fmt.Errorf("error with operation DeleteGlobalIpPool") } @@ -1703,6 +1797,9 @@ func (s *NetworkSettingsService) ReleaseReserveIPSubpool(id string) (*ResponseNe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ReleaseReserveIPSubpool(id) + } return nil, response, fmt.Errorf("error with operation ReleaseReserveIpSubpool") } @@ -1718,7 +1815,7 @@ func (s *NetworkSettingsService) ReleaseReserveIPSubpool(id string) (*ResponseNe @param spProfileName spProfileName path parameter. sp profile name -Documentation Link: https://developer.cisco.com/docs/dna-center/#!delete-s-p-profile +Documentation Link: https://developer.cisco.com/docs/dna-center/#!delete-sp-profile */ func (s *NetworkSettingsService) DeleteSpProfile(spProfileName string) (*ResponseNetworkSettingsDeleteSpProfile, *resty.Response, error) { //spProfileName string @@ -1738,6 +1835,9 @@ func (s *NetworkSettingsService) DeleteSpProfile(spProfileName string) (*Respons } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteSpProfile(spProfileName) + } return nil, response, fmt.Errorf("error with operation DeleteSpProfile") } @@ -1753,7 +1853,7 @@ func (s *NetworkSettingsService) DeleteSpProfile(spProfileName string) (*Respons @param spProfileName spProfileName path parameter. sp profile name -Documentation Link: https://developer.cisco.com/docs/dna-center/#!delete-s-p-profile-v2 +Documentation Link: https://developer.cisco.com/docs/dna-center/#!delete-sp-profile-v2 */ func (s *NetworkSettingsService) DeleteSpProfileV2(spProfileName string) (*ResponseNetworkSettingsDeleteSpProfileV2, *resty.Response, error) { //spProfileName string @@ -1773,6 +1873,9 @@ func (s *NetworkSettingsService) DeleteSpProfileV2(spProfileName string) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteSpProfileV2(spProfileName) + } return nil, response, fmt.Errorf("error with operation DeleteSpProfileV2") } diff --git a/sdk/path_trace.go b/sdk/path_trace.go index fe57148..5570e91 100644 --- a/sdk/path_trace.go +++ b/sdk/path_trace.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -952,6 +953,9 @@ func (s *PathTraceService) RetrivesAllPreviousPathtracesSummary(RetrivesAllPrevi } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RetrivesAllPreviousPathtracesSummary(RetrivesAllPreviousPathtracesSummaryQueryParams) + } return nil, response, fmt.Errorf("error with operation RetrivesAllPreviousPathtracesSummary") } @@ -986,6 +990,9 @@ func (s *PathTraceService) RetrievesPreviousPathtrace(flowAnalysisID string) (*R } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RetrievesPreviousPathtrace(flowAnalysisID) + } return nil, response, fmt.Errorf("error with operation RetrievesPreviousPathtrace") } @@ -1018,6 +1025,11 @@ func (s *PathTraceService) InitiateANewPathtrace(requestPathTraceInitiateANewPat } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.InitiateANewPathtrace(requestPathTraceInitiateANewPathtrace) + } + return nil, response, fmt.Errorf("error with operation InitiateANewPathtrace") } @@ -1053,6 +1065,9 @@ func (s *PathTraceService) DeletesPathtraceByID(flowAnalysisID string) (*Respons } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeletesPathtraceByID(flowAnalysisID) + } return nil, response, fmt.Errorf("error with operation DeletesPathtraceById") } diff --git a/sdk/platform.go b/sdk/platform.go index 85ca9d5..6a9956d 100644 --- a/sdk/platform.go +++ b/sdk/platform.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" ) @@ -106,6 +107,9 @@ func (s *PlatformService) CiscoDnaCenterPackagesSummary() (*ResponsePlatformCisc } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CiscoDnaCenterPackagesSummary() + } return nil, response, fmt.Errorf("error with operation CiscoDnaCenterPackagesSummary") } @@ -119,7 +123,7 @@ func (s *PlatformService) CiscoDnaCenterPackagesSummary() (*ResponsePlatformCisc -Documentation Link: https://developer.cisco.com/docs/dna-center/#!cisco-d-n-a-center-release-summary +Documentation Link: https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-release-summary */ func (s *PlatformService) CiscoDnaCenterReleaseSummary() (*ResponsePlatformCiscoDnaCenterReleaseSummary, *resty.Response, error) { path := "/dna/intent/api/v1/dnac-release" @@ -137,6 +141,9 @@ func (s *PlatformService) CiscoDnaCenterReleaseSummary() (*ResponsePlatformCisco } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CiscoDnaCenterReleaseSummary() + } return nil, response, fmt.Errorf("error with operation CiscoDnaCenterReleaseSummary") } @@ -150,7 +157,7 @@ func (s *PlatformService) CiscoDnaCenterReleaseSummary() (*ResponsePlatformCisco -Documentation Link: https://developer.cisco.com/docs/dna-center/#!cisco-d-n-a-center-nodes-configuration-summary +Documentation Link: https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-nodes-configuration-summary */ func (s *PlatformService) CiscoDnaCenterNodesConfigurationSummary() (*ResponsePlatformCiscoDnaCenterNodesConfigurationSummary, *resty.Response, error) { path := "/dna/intent/api/v1/nodes-config" @@ -168,6 +175,9 @@ func (s *PlatformService) CiscoDnaCenterNodesConfigurationSummary() (*ResponsePl } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CiscoDnaCenterNodesConfigurationSummary() + } return nil, response, fmt.Errorf("error with operation CiscoDnaCenterNodesConfigurationSummary") } diff --git a/sdk/policy.go b/sdk/policy.go index b52b588..179819a 100644 --- a/sdk/policy.go +++ b/sdk/policy.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -241,6 +242,9 @@ func (s *PolicyService) GetListOfProfilingRules(GetListOfProfilingRulesQueryPara } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetListOfProfilingRules(GetListOfProfilingRulesQueryParams) + } return nil, response, fmt.Errorf("error with operation GetListOfProfilingRules") } @@ -273,6 +277,9 @@ func (s *PolicyService) GetCountOfProfilingRules(GetCountOfProfilingRulesQueryPa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetCountOfProfilingRules(GetCountOfProfilingRulesQueryParams) + } return nil, response, fmt.Errorf("error with operation GetCountOfProfilingRules") } @@ -305,6 +312,9 @@ func (s *PolicyService) GetDetailsOfASingleProfilingRule(ruleID string) (*Respon } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDetailsOfASingleProfilingRule(ruleID) + } return nil, response, fmt.Errorf("error with operation GetDetailsOfASingleProfilingRule") } @@ -335,6 +345,9 @@ func (s *PolicyService) CreateAProfilingRule(requestPolicyCreateAProfilingRule * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateAProfilingRule(requestPolicyCreateAProfilingRule) + } return nil, response, fmt.Errorf("error with operation CreateAProfilingRule") } @@ -367,6 +380,9 @@ func (s *PolicyService) ImportProfilingRulesInBulk(requestPolicyImportProfilingR } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ImportProfilingRulesInBulk(requestPolicyImportProfilingRulesInBulk) + } return response, fmt.Errorf("error with operation ImportProfilingRulesInBulk") } @@ -398,6 +414,9 @@ func (s *PolicyService) UpdateAnExistingProfilingRule(ruleID string, requestPoli } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateAnExistingProfilingRule(ruleID, requestPolicyUpdateAnExistingProfilingRule) + } return response, fmt.Errorf("error with operation UpdateAnExistingProfilingRule") } @@ -428,6 +447,9 @@ func (s *PolicyService) DeleteAnExistingProfilingRule(ruleID string) (*resty.Res } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteAnExistingProfilingRule(ruleID) + } return response, fmt.Errorf("error with operation DeleteAnExistingProfilingRule") } diff --git a/sdk/reports.go b/sdk/reports.go index 4fe7ccc..19943c4 100644 --- a/sdk/reports.go +++ b/sdk/reports.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -366,6 +367,9 @@ func (s *ReportsService) GetListOfScheduledReports(GetListOfScheduledReportsQuer } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetListOfScheduledReports(GetListOfScheduledReportsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetListOfScheduledReports") } @@ -400,6 +404,9 @@ func (s *ReportsService) GetAScheduledReport(reportID string) (*ResponseReportsG } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAScheduledReport(reportID) + } return nil, response, fmt.Errorf("error with operation GetAScheduledReport") } @@ -434,6 +441,9 @@ func (s *ReportsService) GetAllExecutionDetailsForAGivenReport(reportID string) } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAllExecutionDetailsForAGivenReport(reportID) + } return nil, response, fmt.Errorf("error with operation GetAllExecutionDetailsForAGivenReport") } @@ -470,6 +480,9 @@ func (s *ReportsService) DownloadReportContent(reportID string, executionID stri } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DownloadReportContent(reportID, executionID) + } return fdownload, response, fmt.Errorf("error with operation ExportTrustedCertificate") } @@ -505,6 +518,9 @@ func (s *ReportsService) GetAllViewGroups() (*ResponseReportsGetAllViewGroups, * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAllViewGroups() + } return nil, response, fmt.Errorf("error with operation GetAllViewGroups") } @@ -539,6 +555,9 @@ func (s *ReportsService) GetViewsForAGivenViewGroup(viewGroupID string) (*Respon } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetViewsForAGivenViewGroup(viewGroupID) + } return nil, response, fmt.Errorf("error with operation GetViewsForAGivenViewGroup") } @@ -576,6 +595,9 @@ func (s *ReportsService) GetViewDetailsForAGivenViewGroupView(viewGroupID string } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetViewDetailsForAGivenViewGroupView(viewGroupID, viewID) + } return nil, response, fmt.Errorf("error with operation GetViewDetailsForAGivenViewGroupView") } @@ -608,6 +630,11 @@ func (s *ReportsService) CreateOrScheduleAReport(requestReportsCreateOrScheduleA } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateOrScheduleAReport(requestReportsCreateOrScheduleAReport) + } + return nil, response, fmt.Errorf("error with operation CreateOrScheduleAReport") } @@ -643,6 +670,9 @@ func (s *ReportsService) DeleteAScheduledReport(reportID string) (*ResponseRepor } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteAScheduledReport(reportID) + } return nil, response, fmt.Errorf("error with operation DeleteAScheduledReport") } diff --git a/sdk/sda.go b/sdk/sda.go index d16f21b..0b748a9 100644 --- a/sdk/sda.go +++ b/sdk/sda.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -841,20 +842,13 @@ func (s *SdaService) GetDefaultAuthenticationProfileFromSdaFabric(GetDefaultAuth } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDefaultAuthenticationProfileFromSdaFabric(GetDefaultAuthenticationProfileFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDefaultAuthenticationProfileFromSdaFabric") } result := response.Result().(*ResponseSdaGetDefaultAuthenticationProfileFromSdaFabric) - - // REVIEW: Custom code is needed to address different types (bool vs string) - // To follow the expected documentation, it converts the string responses to nil. - // Hopefully, actual API behavior could do this soon, so we could change it to a pointer to a bool instead to reflect the three states - if result != nil { - if result.WakeOnLan == "" { - result.WakeOnLan = nil - } - } - return result, response, err } @@ -885,6 +879,9 @@ func (s *SdaService) GetBorderDeviceDetailFromSdaFabric(GetBorderDeviceDetailFro } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetBorderDeviceDetailFromSdaFabric(GetBorderDeviceDetailFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetBorderDeviceDetailFromSdaFabric") } @@ -919,6 +916,9 @@ func (s *SdaService) GetControlPlaneDeviceFromSdaFabric(GetControlPlaneDeviceFro } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetControlPlaneDeviceFromSdaFabric(GetControlPlaneDeviceFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetControlPlaneDeviceFromSdaFabric") } @@ -953,6 +953,9 @@ func (s *SdaService) GetDeviceInfoFromSdaFabric(GetDeviceInfoFromSDAFabricQueryP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceInfoFromSdaFabric(GetDeviceInfoFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceInfoFromSdaFabric") } @@ -987,6 +990,9 @@ func (s *SdaService) GetDeviceRoleInSdaFabric(GetDeviceRoleInSDAFabricQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceRoleInSdaFabric(GetDeviceRoleInSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceRoleInSdaFabric") } @@ -1021,6 +1027,9 @@ func (s *SdaService) GetEdgeDeviceFromSdaFabric(GetEdgeDeviceFromSDAFabricQueryP } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEdgeDeviceFromSdaFabric(GetEdgeDeviceFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEdgeDeviceFromSdaFabric") } @@ -1055,6 +1064,9 @@ func (s *SdaService) GetSiteFromSdaFabric(GetSiteFromSDAFabricQueryParams *GetSi } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSiteFromSdaFabric(GetSiteFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSiteFromSdaFabric") } @@ -1089,6 +1101,9 @@ func (s *SdaService) GetPortAssignmentForAccessPointInSdaFabric(GetPortAssignmen } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPortAssignmentForAccessPointInSdaFabric(GetPortAssignmentForAccessPointInSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetPortAssignmentForAccessPointInSdaFabric") } @@ -1123,6 +1138,9 @@ func (s *SdaService) GetPortAssignmentForUserDeviceInSdaFabric(GetPortAssignment } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPortAssignmentForUserDeviceInSdaFabric(GetPortAssignmentForUserDeviceInSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetPortAssignmentForUserDeviceInSdaFabric") } @@ -1157,6 +1175,9 @@ func (s *SdaService) GetMulticastDetailsFromSdaFabric(GetMulticastDetailsFromSDA } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetMulticastDetailsFromSdaFabric(GetMulticastDetailsFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetMulticastDetailsFromSdaFabric") } @@ -1191,6 +1212,9 @@ func (s *SdaService) GetProvisionedWiredDevice(GetProvisionedWiredDeviceQueryPar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetProvisionedWiredDevice(GetProvisionedWiredDeviceQueryParams) + } return nil, response, fmt.Errorf("error with operation GetProvisionedWiredDevice") } @@ -1225,6 +1249,9 @@ func (s *SdaService) GetTransitPeerNetworkInfo(GetTransitPeerNetworkInfoQueryPar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTransitPeerNetworkInfo(GetTransitPeerNetworkInfoQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTransitPeerNetworkInfo") } @@ -1239,7 +1266,7 @@ func (s *SdaService) GetTransitPeerNetworkInfo(GetTransitPeerNetworkInfoQueryPar @param GetVNFromSDAFabricQueryParams Filtering parameter -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-v-n-from-sda-fabric +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-vn-from-sda-fabric */ func (s *SdaService) GetVnFromSdaFabric(GetVNFromSDAFabricQueryParams *GetVnFromSdaFabricQueryParams) (*ResponseSdaGetVnFromSdaFabric, *resty.Response, error) { path := "/dna/intent/api/v1/business/sda/virtual-network" @@ -1259,6 +1286,9 @@ func (s *SdaService) GetVnFromSdaFabric(GetVNFromSDAFabricQueryParams *GetVnFrom } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetVnFromSdaFabric(GetVNFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation GetVnFromSdaFabric") } @@ -1293,6 +1323,9 @@ func (s *SdaService) GetVirtualNetworkSummary(GetVirtualNetworkSummaryQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetVirtualNetworkSummary(GetVirtualNetworkSummaryQueryParams) + } return nil, response, fmt.Errorf("error with operation GetVirtualNetworkSummary") } @@ -1327,6 +1360,9 @@ func (s *SdaService) GetIPPoolFromSdaVirtualNetwork(GetIPPoolFromSDAVirtualNetwo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetIPPoolFromSdaVirtualNetwork(GetIPPoolFromSDAVirtualNetworkQueryParams) + } return nil, response, fmt.Errorf("error with operation GetIpPoolFromSdaVirtualNetwork") } @@ -1361,6 +1397,9 @@ func (s *SdaService) GetVirtualNetworkWithScalableGroups(GetVirtualNetworkWithSc } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetVirtualNetworkWithScalableGroups(GetVirtualNetworkWithScalableGroupsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetVirtualNetworkWithScalableGroups") } @@ -1393,6 +1432,11 @@ func (s *SdaService) AddDefaultAuthenticationTemplateInSdaFabric(requestSdaAddDe } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddDefaultAuthenticationTemplateInSdaFabric(requestSdaAddDefaultAuthenticationTemplateInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddDefaultAuthenticationTemplateInSdaFabric") } @@ -1425,6 +1469,11 @@ func (s *SdaService) AddBorderDeviceInSdaFabric(requestSdaAddBorderDeviceInSDAFa } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddBorderDeviceInSdaFabric(requestSdaAddBorderDeviceInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddBorderDeviceInSdaFabric") } @@ -1457,6 +1506,11 @@ func (s *SdaService) AddControlPlaneDeviceInSdaFabric(requestSdaAddControlPlaneD } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddControlPlaneDeviceInSdaFabric(requestSdaAddControlPlaneDeviceInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddControlPlaneDeviceInSdaFabric") } @@ -1489,6 +1543,11 @@ func (s *SdaService) AddEdgeDeviceInSdaFabric(requestSdaAddEdgeDeviceInSDAFabric } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddEdgeDeviceInSdaFabric(requestSdaAddEdgeDeviceInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddEdgeDeviceInSdaFabric") } @@ -1521,6 +1580,11 @@ func (s *SdaService) AddSiteInSdaFabric(requestSdaAddSiteInSDAFabric *RequestSda } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddSiteInSdaFabric(requestSdaAddSiteInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddSiteInSdaFabric") } @@ -1553,6 +1617,11 @@ func (s *SdaService) AddPortAssignmentForAccessPointInSdaFabric(requestSdaAddPor } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddPortAssignmentForAccessPointInSdaFabric(requestSdaAddPortAssignmentForAccessPointInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddPortAssignmentForAccessPointInSdaFabric") } @@ -1585,6 +1654,11 @@ func (s *SdaService) AddPortAssignmentForUserDeviceInSdaFabric(requestSdaAddPort } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddPortAssignmentForUserDeviceInSdaFabric(requestSdaAddPortAssignmentForUserDeviceInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddPortAssignmentForUserDeviceInSdaFabric") } @@ -1617,6 +1691,11 @@ func (s *SdaService) AddMulticastInSdaFabric(requestSdaAddMulticastInSDAFabric * } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddMulticastInSdaFabric(requestSdaAddMulticastInSDAFabric) + } + return nil, response, fmt.Errorf("error with operation AddMulticastInSdaFabric") } @@ -1649,6 +1728,11 @@ func (s *SdaService) ProvisionWiredDevice(requestSdaProvisionWiredDevice *Reques } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ProvisionWiredDevice(requestSdaProvisionWiredDevice) + } + return nil, response, fmt.Errorf("error with operation ProvisionWiredDevice") } @@ -1681,6 +1765,11 @@ func (s *SdaService) AddTransitPeerNetwork(requestSdaAddTransitPeerNetwork *Requ } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddTransitPeerNetwork(requestSdaAddTransitPeerNetwork) + } + return nil, response, fmt.Errorf("error with operation AddTransitPeerNetwork") } @@ -1694,7 +1783,7 @@ func (s *SdaService) AddTransitPeerNetwork(requestSdaAddTransitPeerNetwork *Requ -Documentation Link: https://developer.cisco.com/docs/dna-center/#!add-v-n-in-fabric +Documentation Link: https://developer.cisco.com/docs/dna-center/#!add-vn-in-fabric */ func (s *SdaService) AddVnInFabric(requestSdaAddVNInFabric *RequestSdaAddVnInFabric) (*ResponseSdaAddVnInFabric, *resty.Response, error) { path := "/dna/intent/api/v1/business/sda/virtual-network" @@ -1713,6 +1802,11 @@ func (s *SdaService) AddVnInFabric(requestSdaAddVNInFabric *RequestSdaAddVnInFab } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddVnInFabric(requestSdaAddVNInFabric) + } + return nil, response, fmt.Errorf("error with operation AddVnInFabric") } @@ -1745,6 +1839,11 @@ func (s *SdaService) AddIPPoolInSdaVirtualNetwork(requestSdaAddIPPoolInSDAVirtua } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddIPPoolInSdaVirtualNetwork(requestSdaAddIPPoolInSDAVirtualNetwork) + } + return nil, response, fmt.Errorf("error with operation AddIpPoolInSdaVirtualNetwork") } @@ -1777,6 +1876,11 @@ func (s *SdaService) AddVirtualNetworkWithScalableGroups(requestSdaAddVirtualNet } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddVirtualNetworkWithScalableGroups(requestSdaAddVirtualNetworkWithScalableGroups) + } + return nil, response, fmt.Errorf("error with operation AddVirtualNetworkWithScalableGroups") } @@ -1807,6 +1911,9 @@ func (s *SdaService) UpdateDefaultAuthenticationProfileInSdaFabric(requestSdaUpd } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateDefaultAuthenticationProfileInSdaFabric(requestSdaUpdateDefaultAuthenticationProfileInSDAFabric) + } return nil, response, fmt.Errorf("error with operation UpdateDefaultAuthenticationProfileInSdaFabric") } @@ -1837,6 +1944,9 @@ func (s *SdaService) ReProvisionWiredDevice(requestSdaReProvisionWiredDevice *Re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ReProvisionWiredDevice(requestSdaReProvisionWiredDevice) + } return nil, response, fmt.Errorf("error with operation ReProvisionWiredDevice") } @@ -1867,6 +1977,9 @@ func (s *SdaService) UpdateVirtualNetworkWithScalableGroups(requestSdaUpdateVirt } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateVirtualNetworkWithScalableGroups(requestSdaUpdateVirtualNetworkWithScalableGroups) + } return nil, response, fmt.Errorf("error with operation UpdateVirtualNetworkWithScalableGroups") } @@ -1902,6 +2015,9 @@ func (s *SdaService) DeleteDefaultAuthenticationProfileFromSdaFabric(DeleteDefau } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDefaultAuthenticationProfileFromSdaFabric(DeleteDefaultAuthenticationProfileFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteDefaultAuthenticationProfileFromSdaFabric") } @@ -1937,6 +2053,9 @@ func (s *SdaService) DeleteBorderDeviceFromSdaFabric(DeleteBorderDeviceFromSDAFa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteBorderDeviceFromSdaFabric(DeleteBorderDeviceFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteBorderDeviceFromSdaFabric") } @@ -1972,6 +2091,9 @@ func (s *SdaService) DeleteControlPlaneDeviceInSdaFabric(DeleteControlPlaneDevic } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteControlPlaneDeviceInSdaFabric(DeleteControlPlaneDeviceInSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteControlPlaneDeviceInSdaFabric") } @@ -2007,6 +2129,9 @@ func (s *SdaService) DeleteEdgeDeviceFromSdaFabric(DeleteEdgeDeviceFromSDAFabric } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteEdgeDeviceFromSdaFabric(DeleteEdgeDeviceFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteEdgeDeviceFromSdaFabric") } @@ -2042,6 +2167,9 @@ func (s *SdaService) DeleteSiteFromSdaFabric(DeleteSiteFromSDAFabricQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteSiteFromSdaFabric(DeleteSiteFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteSiteFromSdaFabric") } @@ -2077,6 +2205,9 @@ func (s *SdaService) DeletePortAssignmentForAccessPointInSdaFabric(DeletePortAss } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeletePortAssignmentForAccessPointInSdaFabric(DeletePortAssignmentForAccessPointInSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeletePortAssignmentForAccessPointInSdaFabric") } @@ -2112,6 +2243,9 @@ func (s *SdaService) DeletePortAssignmentForUserDeviceInSdaFabric(DeletePortAssi } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeletePortAssignmentForUserDeviceInSdaFabric(DeletePortAssignmentForUserDeviceInSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeletePortAssignmentForUserDeviceInSdaFabric") } @@ -2147,6 +2281,9 @@ func (s *SdaService) DeleteMulticastFromSdaFabric(DeleteMulticastFromSDAFabricQu } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteMulticastFromSdaFabric(DeleteMulticastFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteMulticastFromSdaFabric") } @@ -2182,6 +2319,9 @@ func (s *SdaService) DeleteProvisionedWiredDevice(DeleteProvisionedWiredDeviceQu } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteProvisionedWiredDevice(DeleteProvisionedWiredDeviceQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteProvisionedWiredDevice") } @@ -2217,6 +2357,9 @@ func (s *SdaService) DeleteTransitPeerNetwork(DeleteTransitPeerNetworkQueryParam } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteTransitPeerNetwork(DeleteTransitPeerNetworkQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteTransitPeerNetwork") } @@ -2231,7 +2374,7 @@ func (s *SdaService) DeleteTransitPeerNetwork(DeleteTransitPeerNetworkQueryParam @param DeleteVNFromSDAFabricQueryParams Filtering parameter -Documentation Link: https://developer.cisco.com/docs/dna-center/#!delete-v-n-from-sda-fabric +Documentation Link: https://developer.cisco.com/docs/dna-center/#!delete-vn-from-sda-fabric */ func (s *SdaService) DeleteVnFromSdaFabric(DeleteVNFromSDAFabricQueryParams *DeleteVnFromSdaFabricQueryParams) (*ResponseSdaDeleteVnFromSdaFabric, *resty.Response, error) { //DeleteVNFromSDAFabricQueryParams *DeleteVnFromSdaFabricQueryParams @@ -2252,6 +2395,9 @@ func (s *SdaService) DeleteVnFromSdaFabric(DeleteVNFromSDAFabricQueryParams *Del } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteVnFromSdaFabric(DeleteVNFromSDAFabricQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteVnFromSdaFabric") } @@ -2287,6 +2433,9 @@ func (s *SdaService) DeleteIPPoolFromSdaVirtualNetwork(DeleteIPPoolFromSDAVirtua } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteIPPoolFromSdaVirtualNetwork(DeleteIPPoolFromSDAVirtualNetworkQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteIpPoolFromSdaVirtualNetwork") } @@ -2322,6 +2471,9 @@ func (s *SdaService) DeleteVirtualNetworkWithScalableGroups(DeleteVirtualNetwork } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteVirtualNetworkWithScalableGroups(DeleteVirtualNetworkWithScalableGroupsQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteVirtualNetworkWithScalableGroups") } diff --git a/sdk/security_advisories.go b/sdk/security_advisories.go index 5e42bd5..684b160 100644 --- a/sdk/security_advisories.go +++ b/sdk/security_advisories.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -117,6 +118,9 @@ func (s *SecurityAdvisoriesService) GetAdvisoriesList() (*ResponseSecurityAdviso } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAdvisoriesList() + } return nil, response, fmt.Errorf("error with operation GetAdvisoriesList") } @@ -148,6 +152,9 @@ func (s *SecurityAdvisoriesService) GetAdvisoriesSummary() (*ResponseSecurityAdv } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAdvisoriesSummary() + } return nil, response, fmt.Errorf("error with operation GetAdvisoriesSummary") } @@ -182,6 +189,9 @@ func (s *SecurityAdvisoriesService) GetDevicesPerAdvisory(advisoryID string) (*R } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDevicesPerAdvisory(advisoryID) + } return nil, response, fmt.Errorf("error with operation GetDevicesPerAdvisory") } @@ -216,6 +226,9 @@ func (s *SecurityAdvisoriesService) GetAdvisoryIDsPerDevice(deviceID string) (*R } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAdvisoryIDsPerDevice(deviceID) + } return nil, response, fmt.Errorf("error with operation GetAdvisoryIdsPerDevice") } @@ -250,6 +263,9 @@ func (s *SecurityAdvisoriesService) GetAdvisoriesPerDevice(deviceID string) (*Re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAdvisoriesPerDevice(deviceID) + } return nil, response, fmt.Errorf("error with operation GetAdvisoriesPerDevice") } diff --git a/sdk/sensors.go b/sdk/sensors.go index 1b86d3e..7e0e734 100644 --- a/sdk/sensors.go +++ b/sdk/sensors.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -551,6 +552,9 @@ func (s *SensorsService) Sensors(SensorsQueryParams *SensorsQueryParams) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.Sensors(SensorsQueryParams) + } return nil, response, fmt.Errorf("error with operation Sensors") } @@ -583,6 +587,11 @@ func (s *SensorsService) CreateSensorTestTemplate(requestSensorsCreateSensorTest } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSensorTestTemplate(requestSensorsCreateSensorTestTemplate) + } + return nil, response, fmt.Errorf("error with operation CreateSensorTestTemplate") } @@ -613,6 +622,9 @@ func (s *SensorsService) EditSensorTestTemplate(requestSensorsEditSensorTestTemp } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.EditSensorTestTemplate(requestSensorsEditSensorTestTemplate) + } return nil, response, fmt.Errorf("error with operation EditSensorTestTemplate") } @@ -642,6 +654,9 @@ func (s *SensorsService) RunNowSensorTest(requestSensorsRunNowSensorTest *Reques } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RunNowSensorTest(requestSensorsRunNowSensorTest) + } return response, fmt.Errorf("error with operation RunNowSensorTest") } @@ -671,6 +686,9 @@ func (s *SensorsService) DuplicateSensorTestTemplate(requestSensorsDuplicateSens } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DuplicateSensorTestTemplate(requestSensorsDuplicateSensorTestTemplate) + } return nil, response, fmt.Errorf("error with operation DuplicateSensorTestTemplate") } @@ -706,6 +724,9 @@ func (s *SensorsService) DeleteSensorTest(DeleteSensorTestQueryParams *DeleteSen } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteSensorTest(DeleteSensorTestQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteSensorTest") } diff --git a/sdk/site_design.go b/sdk/site_design.go index dd2e916..faf5730 100644 --- a/sdk/site_design.go +++ b/sdk/site_design.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -448,6 +449,9 @@ func (s *SiteDesignService) GetDeviceDetailsByIP(GetDeviceDetailsByIPQueryParams } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceDetailsByIP(GetDeviceDetailsByIPQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDeviceDetailsByIp") } @@ -485,6 +489,9 @@ func (s *SiteDesignService) GetNfvProfile(id string, GetNFVProfileQueryParams *G } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetNfvProfile(id, GetNFVProfileQueryParams) + } return nil, response, fmt.Errorf("error with operation GetNfvProfile") } @@ -538,6 +545,11 @@ func (s *SiteDesignService) ProvisionNfv(requestSiteDesignProvisionNFV *RequestS } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ProvisionNfv(requestSiteDesignProvisionNFV, ProvisionNFVHeaderParams) + } + return nil, response, fmt.Errorf("error with operation ProvisionNfv") } @@ -575,6 +587,11 @@ func (s *SiteDesignService) Associate(networkProfileID string, siteID string) (* } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.Associate(networkProfileID, siteID) + } + return nil, response, fmt.Errorf("error with operation Associate") } @@ -628,6 +645,11 @@ func (s *SiteDesignService) NfvProvisioningDetail(requestSiteDesignNFVProvisioni } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.NfvProvisioningDetail(requestSiteDesignNFVProvisioningDetail, NFVProvisioningDetailHeaderParams) + } + return nil, response, fmt.Errorf("error with operation NfvProvisioningDetail") } @@ -660,6 +682,11 @@ func (s *SiteDesignService) CreateNfvProfile(requestSiteDesignCreateNFVProfile * } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateNfvProfile(requestSiteDesignCreateNFVProfile) + } + return nil, response, fmt.Errorf("error with operation CreateNfvProfile") } @@ -696,6 +723,9 @@ func (s *SiteDesignService) UpdateNfvProfile(id string, requestSiteDesignUpdateN } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateNfvProfile(id, requestSiteDesignUpdateNFVProfile, UpdateNFVProfileQueryParams) + } return nil, response, fmt.Errorf("error with operation UpdateNfvProfile") } @@ -734,6 +764,9 @@ func (s *SiteDesignService) Disassociate(networkProfileID string, siteID string) } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.Disassociate(networkProfileID, siteID) + } return nil, response, fmt.Errorf("error with operation Disassociate") } @@ -772,6 +805,9 @@ func (s *SiteDesignService) DeleteNfvProfile(id string, DeleteNFVProfileQueryPar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteNfvProfile(id, DeleteNFVProfileQueryParams) + } return nil, response, fmt.Errorf("error with operation DeleteNfvProfile") } diff --git a/sdk/sites.go b/sdk/sites.go index 237af27..df25dc4 100644 --- a/sdk/sites.go +++ b/sdk/sites.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -389,6 +390,9 @@ func (s *SitesService) GetMembership(siteID string, GetMembershipQueryParams *Ge } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetMembership(siteID, GetMembershipQueryParams) + } return nil, response, fmt.Errorf("error with operation GetMembership") } @@ -423,6 +427,9 @@ func (s *SitesService) GetSite(GetSiteQueryParams *GetSiteQueryParams) (*Respons } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSite(GetSiteQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSite") } @@ -431,58 +438,6 @@ func (s *SitesService) GetSite(GetSiteQueryParams *GetSiteQueryParams) (*Respons } -func (s *SitesService) GetFloor(GetSiteQueryParams *GetSiteQueryParams) (*ResponseSitesGetFloor, *resty.Response, error) { - path := "/dna/intent/api/v1/site" - - queryString, _ := query.Values(GetSiteQueryParams) - - response, err := s.client.R(). - SetHeader("Content-Type", "application/json"). - SetHeader("Accept", "application/json"). - SetQueryString(queryString.Encode()).SetResult(&ResponseSitesGetFloor{}). - SetError(&Error). - Get(path) - - if err != nil { - return nil, nil, err - - } - - if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetSite") - } - - result := response.Result().(*ResponseSitesGetFloor) - return result, response, err - -} - -func (s *SitesService) GetArea(GetSiteQueryParams *GetSiteQueryParams) (*ResponseSitesGetArea, *resty.Response, error) { - path := "/dna/intent/api/v1/site" - - queryString, _ := query.Values(GetSiteQueryParams) - - response, err := s.client.R(). - SetHeader("Content-Type", "application/json"). - SetHeader("Accept", "application/json"). - SetQueryString(queryString.Encode()).SetResult(&ResponseSitesGetArea{}). - SetError(&Error). - Get(path) - - if err != nil { - return nil, nil, err - - } - - if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetSite") - } - - result := response.Result().(*ResponseSitesGetArea) - return result, response, err - -} - //GetSiteHealth Get Site Health - 15b7-aa0c-4dda-8e85 /* Returns Overall Health information for all sites @@ -509,6 +464,9 @@ func (s *SitesService) GetSiteHealth(GetSiteHealthQueryParams *GetSiteHealthQuer } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSiteHealth(GetSiteHealthQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSiteHealth") } @@ -543,6 +501,9 @@ func (s *SitesService) GetSiteCount(GetSiteCountQueryParams *GetSiteCountQueryPa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSiteCount(GetSiteCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSiteCount") } @@ -599,6 +560,11 @@ func (s *SitesService) AssignDevicesToSite(siteID string, requestSitesAssignDevi } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AssignDevicesToSite(siteID, requestSitesAssignDevicesToSite, AssignDevicesToSiteHeaderParams) + } + return nil, response, fmt.Errorf("error with operation AssignDevicesToSite") } @@ -652,6 +618,11 @@ func (s *SitesService) CreateSite(requestSitesCreateSite *RequestSitesCreateSite } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateSite(requestSitesCreateSite, CreateSiteHeaderParams) + } + return nil, response, fmt.Errorf("error with operation CreateSite") } @@ -706,6 +677,9 @@ func (s *SitesService) UpdateSite(siteID string, requestSitesUpdateSite *Request } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateSite(siteID, requestSitesUpdateSite, UpdateSiteHeaderParams) + } return nil, response, fmt.Errorf("error with operation UpdateSite") } @@ -741,6 +715,9 @@ func (s *SitesService) DeleteSite(siteID string) (*ResponseSitesDeleteSite, *res } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteSite(siteID) + } return nil, response, fmt.Errorf("error with operation DeleteSite") } @@ -748,3 +725,61 @@ func (s *SitesService) DeleteSite(siteID string) (*ResponseSitesDeleteSite, *res return result, response, err } + +func (s *SitesService) GetFloor(GetSiteQueryParams *GetSiteQueryParams) (*ResponseSitesGetFloor, *resty.Response, error) { + path := "/dna/intent/api/v1/site" + + queryString, _ := query.Values(GetSiteQueryParams) + + response, err := s.client.R(). + SetHeader("Content-Type", "application/json"). + SetHeader("Accept", "application/json"). + SetQueryString(queryString.Encode()).SetResult(&ResponseSitesGetFloor{}). + SetError(&Error). + Get(path) + + if err != nil { + return nil, nil, err + + } + + if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetFloor(GetSiteQueryParams) + } + return nil, response, fmt.Errorf("error with operation GetSite") + } + + result := response.Result().(*ResponseSitesGetFloor) + return result, response, err + +} + +func (s *SitesService) GetArea(GetSiteQueryParams *GetSiteQueryParams) (*ResponseSitesGetArea, *resty.Response, error) { + path := "/dna/intent/api/v1/site" + + queryString, _ := query.Values(GetSiteQueryParams) + + response, err := s.client.R(). + SetHeader("Content-Type", "application/json"). + SetHeader("Accept", "application/json"). + SetQueryString(queryString.Encode()).SetResult(&ResponseSitesGetArea{}). + SetError(&Error). + Get(path) + + if err != nil { + return nil, nil, err + + } + + if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetArea(GetSiteQueryParams) + } + return nil, response, fmt.Errorf("error with operation GetSite") + } + + result := response.Result().(*ResponseSitesGetArea) + return result, response, err + +} diff --git a/sdk/software_image_management_swim.go b/sdk/software_image_management_swim.go index 9afc915..938d3b1 100644 --- a/sdk/software_image_management_swim.go +++ b/sdk/software_image_management_swim.go @@ -3,6 +3,7 @@ package dnac import ( "fmt" "io" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -222,6 +223,9 @@ func (s *SoftwareImageManagementSwimService) GetSoftwareImageDetails(GetSoftware } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSoftwareImageDetails(GetSoftwareImageDetailsQueryParams) + } return nil, response, fmt.Errorf("error with operation GetSoftwareImageDetails") } @@ -253,6 +257,9 @@ func (s *SoftwareImageManagementSwimService) GetDeviceFamilyIDentifiers() (*Resp } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDeviceFamilyIDentifiers() + } return nil, response, fmt.Errorf("error with operation GetDeviceFamilyIdentifiers") } @@ -296,6 +303,9 @@ func (s *SoftwareImageManagementSwimService) GetGoldenTagStatusOfAnImage(siteID } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetGoldenTagStatusOfAnImage(siteID, deviceFamilyIDentifier, deviceRole, imageID) + } return nil, response, fmt.Errorf("error with operation GetGoldenTagStatusOfAnImage") } @@ -348,6 +358,11 @@ func (s *SoftwareImageManagementSwimService) TriggerSoftwareImageActivation(requ } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.TriggerSoftwareImageActivation(requestSoftwareImageManagementSwimTriggerSoftwareImageActivation, TriggerSoftwareImageActivationHeaderParams, TriggerSoftwareImageActivationQueryParams) + } + return nil, response, fmt.Errorf("error with operation TriggerSoftwareImageActivation") } @@ -380,6 +395,11 @@ func (s *SoftwareImageManagementSwimService) TriggerSoftwareImageDistribution(re } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.TriggerSoftwareImageDistribution(requestSoftwareImageManagementSwimTriggerSoftwareImageDistribution) + } + return nil, response, fmt.Errorf("error with operation TriggerSoftwareImageDistribution") } @@ -412,6 +432,11 @@ func (s *SoftwareImageManagementSwimService) TagAsGoldenImage(requestSoftwareIma } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.TagAsGoldenImage(requestSoftwareImageManagementSwimTagAsGoldenImage) + } + return nil, response, fmt.Errorf("error with operation TagAsGoldenImage") } @@ -455,6 +480,11 @@ func (s *SoftwareImageManagementSwimService) ImportLocalSoftwareImage(ImportLoca } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ImportLocalSoftwareImage(ImportLocalSoftwareImageQueryParams, ImportLocalSoftwareImageMultipartFields) + } + return nil, response, fmt.Errorf("error with operation ImportLocalSoftwareImage") } @@ -490,6 +520,11 @@ func (s *SoftwareImageManagementSwimService) ImportSoftwareImageViaURL(requestSo } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ImportSoftwareImageViaURL(requestSoftwareImageManagementSwimImportSoftwareImageViaURL, ImportSoftwareImageViaURLQueryParams) + } + return nil, response, fmt.Errorf("error with operation ImportSoftwareImageViaUrl") } @@ -534,6 +569,9 @@ func (s *SoftwareImageManagementSwimService) RemoveGoldenTagForImage(siteID stri } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RemoveGoldenTagForImage(siteID, deviceFamilyIDentifier, deviceRole, imageID) + } return nil, response, fmt.Errorf("error with operation RemoveGoldenTagForImage") } diff --git a/sdk/system_settings.go b/sdk/system_settings.go index 66f2a74..c2a730c 100644 --- a/sdk/system_settings.go +++ b/sdk/system_settings.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -110,6 +111,9 @@ func (s *SystemSettingsService) GetAuthenticationAndPolicyServers(GetAuthenticat } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAuthenticationAndPolicyServers(GetAuthenticationAndPolicyServersQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAuthenticationAndPolicyServers") } @@ -118,14 +122,14 @@ func (s *SystemSettingsService) GetAuthenticationAndPolicyServers(GetAuthenticat } -//CustomPromptSupportGetAPI Custom-prompt support GET API - 2aa8-f90e-4ebb-a629 +//CustomPromptSupportGETAPI Custom-prompt support GET API - 2aa8-f90e-4ebb-a629 /* Returns supported custom prompts by Cisco DNA Center -Documentation Link: https://developer.cisco.com/docs/dna-center/#!custom-prompt-support-get-api +Documentation Link: https://developer.cisco.com/docs/dna-center/#!custom-prompt-support-g-e-t-api */ -func (s *SystemSettingsService) CustomPromptSupportGetAPI() (*ResponseSystemSettingsCustomPromptSupportGetAPI, *resty.Response, error) { +func (s *SystemSettingsService) CustomPromptSupportGETAPI() (*ResponseSystemSettingsCustomPromptSupportGetAPI, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/custom-prompt" response, err := s.client.R(). @@ -141,7 +145,10 @@ func (s *SystemSettingsService) CustomPromptSupportGetAPI() (*ResponseSystemSett } if response.IsError() { - return nil, response, fmt.Errorf("error with operation CustomPromptSupportGetApi") + if response.StatusCode() == http.StatusUnauthorized { + return s.CustomPromptSupportGETAPI() + } + return nil, response, fmt.Errorf("error with operation CustomPromptSupportGETApi") } result := response.Result().(*ResponseSystemSettingsCustomPromptSupportGetAPI) @@ -149,14 +156,14 @@ func (s *SystemSettingsService) CustomPromptSupportGetAPI() (*ResponseSystemSett } -//CustomPromptPostAPI Custom Prompt POST API - f4b9-1a8a-4718-aa97 +//CustomPromptPOSTAPI Custom Prompt POST API - f4b9-1a8a-4718-aa97 /* Save custom prompt added by user in Cisco DNA Center. API will always override the existing prompts. User should provide all the custom prompt in case of any update Documentation Link: https://developer.cisco.com/docs/dna-center/#!custom-prompt-p-o-s-t-api */ -func (s *SystemSettingsService) CustomPromptPostAPI(requestSystemSettingsCustomPromptPOSTAPI *RequestSystemSettingsCustomPromptPostAPI) (*ResponseSystemSettingsCustomPromptPostAPI, *resty.Response, error) { +func (s *SystemSettingsService) CustomPromptPOSTAPI(requestSystemSettingsCustomPromptPOSTAPI *RequestSystemSettingsCustomPromptPostAPI) (*ResponseSystemSettingsCustomPromptPostAPI, *resty.Response, error) { path := "/dna/intent/api/v1/network-device/custom-prompt" response, err := s.client.R(). @@ -173,7 +180,12 @@ func (s *SystemSettingsService) CustomPromptPostAPI(requestSystemSettingsCustomP } if response.IsError() { - return nil, response, fmt.Errorf("error with operation CustomPromptPostApi") + + if response.StatusCode() == http.StatusUnauthorized { + return s.CustomPromptPOSTAPI(requestSystemSettingsCustomPromptPOSTAPI) + } + + return nil, response, fmt.Errorf("error with operation CustomPromptPOSTApi") } result := response.Result().(*ResponseSystemSettingsCustomPromptPostAPI) diff --git a/sdk/tag.go b/sdk/tag.go index 542f164..a8ef772 100644 --- a/sdk/tag.go +++ b/sdk/tag.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -249,6 +250,9 @@ func (s *TagService) GetTag(GetTagQueryParams *GetTagQueryParams) (*ResponseTagG } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTag(GetTagQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTag") } @@ -283,6 +287,9 @@ func (s *TagService) GetTagCount(GetTagCountQueryParams *GetTagCountQueryParams) } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTagCount(GetTagCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTagCount") } @@ -314,6 +321,9 @@ func (s *TagService) GetTagResourceTypes() (*ResponseTagGetTagResourceTypes, *re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTagResourceTypes() + } return nil, response, fmt.Errorf("error with operation GetTagResourceTypes") } @@ -348,6 +358,9 @@ func (s *TagService) GetTagByID(id string) (*ResponseTagGetTagByID, *resty.Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTagByID(id) + } return nil, response, fmt.Errorf("error with operation GetTagById") } @@ -385,6 +398,9 @@ func (s *TagService) GetTagMembersByID(id string, GetTagMembersByIdQueryParams * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTagMembersByID(id, GetTagMembersByIdQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTagMembersById") } @@ -422,6 +438,9 @@ func (s *TagService) GetTagMemberCount(id string, GetTagMemberCountQueryParams * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTagMemberCount(id, GetTagMemberCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTagMemberCount") } @@ -454,6 +473,11 @@ func (s *TagService) CreateTag(requestTagCreateTag *RequestTagCreateTag) (*Respo } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateTag(requestTagCreateTag) + } + return nil, response, fmt.Errorf("error with operation CreateTag") } @@ -489,6 +513,11 @@ func (s *TagService) AddMembersToTheTag(id string, requestTagAddMembersToTheTag } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddMembersToTheTag(id, requestTagAddMembersToTheTag) + } + return nil, response, fmt.Errorf("error with operation AddMembersToTheTag") } @@ -519,6 +548,9 @@ func (s *TagService) UpdateTag(requestTagUpdateTag *RequestTagUpdateTag) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateTag(requestTagUpdateTag) + } return nil, response, fmt.Errorf("error with operation UpdateTag") } @@ -549,6 +581,9 @@ func (s *TagService) UpdatesTagMembership(requestTagUpdatesTagMembership *Reques } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdatesTagMembership(requestTagUpdatesTagMembership) + } return nil, response, fmt.Errorf("error with operation UpdatesTagMembership") } @@ -584,6 +619,9 @@ func (s *TagService) DeleteTag(id string) (*ResponseTagDeleteTag, *resty.Respons } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteTag(id) + } return nil, response, fmt.Errorf("error with operation DeleteTag") } @@ -622,6 +660,9 @@ func (s *TagService) RemoveTagMember(id string, memberID string) (*ResponseTagRe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RemoveTagMember(id, memberID) + } return nil, response, fmt.Errorf("error with operation RemoveTagMember") } diff --git a/sdk/task.go b/sdk/task.go index 0f9e111..8805075 100644 --- a/sdk/task.go +++ b/sdk/task.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -184,6 +185,9 @@ func (s *TaskService) GetBusinessAPIExecutionDetails(executionID string) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetBusinessAPIExecutionDetails(executionID) + } return nil, response, fmt.Errorf("error with operation GetBusinessApiExecutionDetails") } @@ -218,6 +222,9 @@ func (s *TaskService) GetTasks(GetTasksQueryParams *GetTasksQueryParams) (*Respo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTasks(GetTasksQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTasks") } @@ -252,6 +259,9 @@ func (s *TaskService) GetTaskCount(GetTaskCountQueryParams *GetTaskCountQueryPar } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTaskCount(GetTaskCountQueryParams) + } return nil, response, fmt.Errorf("error with operation GetTaskCount") } @@ -291,6 +301,9 @@ func (s *TaskService) GetTaskByOperationID(operationID string, offset int, limit } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTaskByOperationID(operationID, offset, limit) + } return nil, response, fmt.Errorf("error with operation GetTaskByOperationId") } @@ -325,6 +338,9 @@ func (s *TaskService) GetTaskByID(taskID string) (*ResponseTaskGetTaskByID, *res } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTaskByID(taskID) + } return nil, response, fmt.Errorf("error with operation GetTaskById") } @@ -359,6 +375,9 @@ func (s *TaskService) GetTaskTree(taskID string) (*ResponseTaskGetTaskTree, *res } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTaskTree(taskID) + } return nil, response, fmt.Errorf("error with operation GetTaskTree") } diff --git a/sdk/topology.go b/sdk/topology.go index f676f7e..9847b5b 100644 --- a/sdk/topology.go +++ b/sdk/topology.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -299,6 +300,9 @@ func (s *TopologyService) GetOverallNetworkHealth(GetOverallNetworkHealthQueryPa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetOverallNetworkHealth(GetOverallNetworkHealthQueryParams) + } return nil, response, fmt.Errorf("error with operation GetOverallNetworkHealth") } @@ -333,6 +337,9 @@ func (s *TopologyService) GetTopologyDetails(vlanID string) (*ResponseTopologyGe } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetTopologyDetails(vlanID) + } return nil, response, fmt.Errorf("error with operation GetTopologyDetails") } @@ -367,6 +374,9 @@ func (s *TopologyService) GetL3TopologyDetails(topologyType string) (*ResponseTo } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetL3TopologyDetails(topologyType) + } return nil, response, fmt.Errorf("error with operation GetL3TopologyDetails") } @@ -401,6 +411,9 @@ func (s *TopologyService) GetPhysicalTopology(GetPhysicalTopologyQueryParams *Ge } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPhysicalTopology(GetPhysicalTopologyQueryParams) + } return nil, response, fmt.Errorf("error with operation GetPhysicalTopology") } @@ -432,6 +445,9 @@ func (s *TopologyService) GetSiteTopology() (*ResponseTopologyGetSiteTopology, * } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetSiteTopology() + } return nil, response, fmt.Errorf("error with operation GetSiteTopology") } @@ -445,7 +461,7 @@ func (s *TopologyService) GetSiteTopology() (*ResponseTopologyGetSiteTopology, * -Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-v-lan-details +Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-vlan-details */ func (s *TopologyService) GetVLANDetails() (*ResponseTopologyGetVLANDetails, *resty.Response, error) { path := "/dna/intent/api/v1/topology/vlan/vlan-names" @@ -463,6 +479,9 @@ func (s *TopologyService) GetVLANDetails() (*ResponseTopologyGetVLANDetails, *re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetVLANDetails() + } return nil, response, fmt.Errorf("error with operation GetVlanDetails") } diff --git a/sdk/user_and_roles.go b/sdk/user_and_roles.go index dcff93b..bc89900 100644 --- a/sdk/user_and_roles.go +++ b/sdk/user_and_roles.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" @@ -125,7 +126,7 @@ type RequestUserandRolesUpdateUserApI struct { Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-permissions-api */ -func (s *UserandRolesService) GetPermissionsApI() (*ResponseUserandRolesGetPermissionsApI, *resty.Response, error) { +func (s *UserandRolesService) GetPermissionsAPI() (*ResponseUserandRolesGetPermissionsApI, *resty.Response, error) { path := "/dna/system/api/v1/role/permissions" response, err := s.client.R(). @@ -141,7 +142,10 @@ func (s *UserandRolesService) GetPermissionsApI() (*ResponseUserandRolesGetPermi } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetPermissionsApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetPermissionsAPI() + } + return nil, response, fmt.Errorf("error with operation GetPermissionsApi") } result := response.Result().(*ResponseUserandRolesGetPermissionsApI) @@ -149,7 +153,7 @@ func (s *UserandRolesService) GetPermissionsApI() (*ResponseUserandRolesGetPermi } -//GetRolesApI Get roles API - 7c86-da3f-4b08-8593 +//GetRolesAPI Get roles API - 7c86-da3f-4b08-8593 /* Get all roles for the Cisco DNA Center system @@ -157,7 +161,7 @@ func (s *UserandRolesService) GetPermissionsApI() (*ResponseUserandRolesGetPermi Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-roles-api */ -func (s *UserandRolesService) GetRolesApI(GetRolesAPIHeaderParams *GetRolesApIHeaderParams) (*ResponseUserandRolesGetRolesApI, *resty.Response, error) { +func (s *UserandRolesService) GetRolesAPI(GetRolesAPIHeaderParams *GetRolesApIHeaderParams) (*ResponseUserandRolesGetRolesApI, *resty.Response, error) { path := "/dna/system/api/v1/roles" var response *resty.Response @@ -185,7 +189,10 @@ func (s *UserandRolesService) GetRolesApI(GetRolesAPIHeaderParams *GetRolesApIHe } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetRolesApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetRolesAPI(GetRolesAPIHeaderParams) + } + return nil, response, fmt.Errorf("error with operation GetRolesApi") } result := response.Result().(*ResponseUserandRolesGetRolesApI) @@ -193,7 +200,7 @@ func (s *UserandRolesService) GetRolesApI(GetRolesAPIHeaderParams *GetRolesApIHe } -//GetUsersApI Get users API - 918c-89fa-4a98-a528 +//GetUsersAPI Get users API - 918c-89fa-4a98-a528 /* Get all users for the Cisco DNA Center system @@ -201,7 +208,7 @@ func (s *UserandRolesService) GetRolesApI(GetRolesAPIHeaderParams *GetRolesApIHe Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-users-api */ -func (s *UserandRolesService) GetUsersApI(GetUsersAPIQueryParams *GetUsersApIQueryParams) (*ResponseUserandRolesGetUsersApI, *resty.Response, error) { +func (s *UserandRolesService) GetUsersAPI(GetUsersAPIQueryParams *GetUsersApIQueryParams) (*ResponseUserandRolesGetUsersApI, *resty.Response, error) { path := "/dna/system/api/v1/user" queryString, _ := query.Values(GetUsersAPIQueryParams) @@ -219,7 +226,10 @@ func (s *UserandRolesService) GetUsersApI(GetUsersAPIQueryParams *GetUsersApIQue } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetUsersApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetUsersAPI(GetUsersAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation GetUsersApi") } result := response.Result().(*ResponseUserandRolesGetUsersApI) @@ -227,7 +237,7 @@ func (s *UserandRolesService) GetUsersApI(GetUsersAPIQueryParams *GetUsersApIQue } -//GetExternalAuthenticationServersApI Get external authentication servers API - 9dbd-0b01-4758-bde4 +//GetExternalAuthenticationServersAPI Get external authentication servers API - 9dbd-0b01-4758-bde4 /* Get external users authentication servers @@ -235,7 +245,7 @@ func (s *UserandRolesService) GetUsersApI(GetUsersAPIQueryParams *GetUsersApIQue Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-external-authentication-servers-api */ -func (s *UserandRolesService) GetExternalAuthenticationServersApI(GetExternalAuthenticationServersAPIQueryParams *GetExternalAuthenticationServersApIQueryParams) (*ResponseUserandRolesGetExternalAuthenticationServersApI, *resty.Response, error) { +func (s *UserandRolesService) GetExternalAuthenticationServersAPI(GetExternalAuthenticationServersAPIQueryParams *GetExternalAuthenticationServersApIQueryParams) (*ResponseUserandRolesGetExternalAuthenticationServersApI, *resty.Response, error) { path := "/dna/system/api/v1/users/external-servers" queryString, _ := query.Values(GetExternalAuthenticationServersAPIQueryParams) @@ -253,7 +263,10 @@ func (s *UserandRolesService) GetExternalAuthenticationServersApI(GetExternalAut } if response.IsError() { - return nil, response, fmt.Errorf("error with operation GetExternalAuthenticationServersApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.GetExternalAuthenticationServersAPI(GetExternalAuthenticationServersAPIQueryParams) + } + return nil, response, fmt.Errorf("error with operation GetExternalAuthenticationServersApi") } result := response.Result().(*ResponseUserandRolesGetExternalAuthenticationServersApI) @@ -261,14 +274,14 @@ func (s *UserandRolesService) GetExternalAuthenticationServersApI(GetExternalAut } -//AddUserApI Add user API - 6c9a-09c4-4a39-9e2b +//AddUserAPI Add user API - 6c9a-09c4-4a39-9e2b /* Add a new user for Cisco DNA Center system Documentation Link: https://developer.cisco.com/docs/dna-center/#!add-user-api */ -func (s *UserandRolesService) AddUserApI(requestUserandRolesAddUserAPI *RequestUserandRolesAddUserApI) (*ResponseUserandRolesAddUserApI, *resty.Response, error) { +func (s *UserandRolesService) AddUserAPI(requestUserandRolesAddUserAPI *RequestUserandRolesAddUserApI) (*ResponseUserandRolesAddUserApI, *resty.Response, error) { path := "/dna/system/api/v1/user" response, err := s.client.R(). @@ -285,7 +298,12 @@ func (s *UserandRolesService) AddUserApI(requestUserandRolesAddUserAPI *RequestU } if response.IsError() { - return nil, response, fmt.Errorf("error with operation AddUserApI") + + if response.StatusCode() == http.StatusUnauthorized { + return s.AddUserAPI(requestUserandRolesAddUserAPI) + } + + return nil, response, fmt.Errorf("error with operation AddUserApi") } result := response.Result().(*ResponseUserandRolesAddUserApI) @@ -293,12 +311,12 @@ func (s *UserandRolesService) AddUserApI(requestUserandRolesAddUserAPI *RequestU } -//UpdateUserApI Update user API - f596-6adc-492b-a2ff +//UpdateUserAPI Update user API - f596-6adc-492b-a2ff /* Update a user for Cisco DNA Center system */ -func (s *UserandRolesService) UpdateUserApI(requestUserandRolesUpdateUserAPI *RequestUserandRolesUpdateUserApI) (*ResponseUserandRolesUpdateUserApI, *resty.Response, error) { +func (s *UserandRolesService) UpdateUserAPI(requestUserandRolesUpdateUserAPI *RequestUserandRolesUpdateUserApI) (*ResponseUserandRolesUpdateUserApI, *resty.Response, error) { path := "/dna/system/api/v1/user" response, err := s.client.R(). @@ -315,7 +333,10 @@ func (s *UserandRolesService) UpdateUserApI(requestUserandRolesUpdateUserAPI *Re } if response.IsError() { - return nil, response, fmt.Errorf("error with operation UpdateUserApI") + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateUserAPI(requestUserandRolesUpdateUserAPI) + } + return nil, response, fmt.Errorf("error with operation UpdateUserApi") } result := response.Result().(*ResponseUserandRolesUpdateUserApI) diff --git a/sdk/users.go b/sdk/users.go index 612f27a..12921f2 100644 --- a/sdk/users.go +++ b/sdk/users.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "github.com/go-resty/resty/v2" ) @@ -200,6 +201,9 @@ func (s *UsersService) GetUserEnrichmentDetails(GetUserEnrichmentDetailsHeaderPa } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetUserEnrichmentDetails(GetUserEnrichmentDetailsHeaderParams) + } return nil, response, fmt.Errorf("error with operation GetUserEnrichmentDetails") } diff --git a/sdk/wireless.go b/sdk/wireless.go index 1083123..bf45332 100644 --- a/sdk/wireless.go +++ b/sdk/wireless.go @@ -2,6 +2,7 @@ package dnac import ( "fmt" + "net/http" "strings" "github.com/go-resty/resty/v2" @@ -809,6 +810,9 @@ func (s *WirelessService) SensorTestResults(SensorTestResultsQueryParams *Sensor } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.SensorTestResults(SensorTestResultsQueryParams) + } return nil, response, fmt.Errorf("error with operation SensorTestResults") } @@ -843,6 +847,9 @@ func (s *WirelessService) GetAccessPointRebootTaskResult(GetAccessPointRebootTas } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAccessPointRebootTaskResult(GetAccessPointRebootTaskResultQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAccessPointRebootTaskResult") } @@ -877,6 +884,9 @@ func (s *WirelessService) GetEnterpriseSSID(GetEnterpriseSSIDQueryParams *GetEnt } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetEnterpriseSSID(GetEnterpriseSSIDQueryParams) + } return nil, response, fmt.Errorf("error with operation GetEnterpriseSsid") } @@ -911,6 +921,9 @@ func (s *WirelessService) GetAccessPointConfigurationTaskResult(taskTypeID strin } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAccessPointConfigurationTaskResult(taskTypeID) + } return nil, response, fmt.Errorf("error with operation GetAccessPointConfigurationTaskResult") } @@ -945,6 +958,9 @@ func (s *WirelessService) GetAccessPointConfiguration(GetAccessPointConfiguratio } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetAccessPointConfiguration(GetAccessPointConfigurationQueryParams) + } return nil, response, fmt.Errorf("error with operation GetAccessPointConfiguration") } @@ -979,6 +995,9 @@ func (s *WirelessService) GetDynamicInterface(GetDynamicInterfaceQueryParams *Ge } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetDynamicInterface(GetDynamicInterfaceQueryParams) + } return nil, response, fmt.Errorf("error with operation GetDynamicInterface") } @@ -1013,6 +1032,9 @@ func (s *WirelessService) GetWirelessProfile(GetWirelessProfileQueryParams *GetW } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.GetWirelessProfile(GetWirelessProfileQueryParams) + } return nil, response, fmt.Errorf("error with operation GetWirelessProfile") } @@ -1047,6 +1069,9 @@ func (s *WirelessService) RetrieveRfProfiles(RetrieveRFProfilesQueryParams *Retr } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.RetrieveRfProfiles(RetrieveRFProfilesQueryParams) + } return nil, response, fmt.Errorf("error with operation RetrieveRfProfiles") } @@ -1092,6 +1117,11 @@ func (s *WirelessService) CreateAndProvisionSSID(requestWirelessCreateAndProvisi } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateAndProvisionSSID(requestWirelessCreateAndProvisionSSID, CreateAndProvisionSSIDHeaderParams) + } + return nil, response, fmt.Errorf("error with operation CreateAndProvisionSsid") } @@ -1124,6 +1154,11 @@ func (s *WirelessService) RebootAccessPoints(requestWirelessRebootAccessPoints * } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.RebootAccessPoints(requestWirelessRebootAccessPoints) + } + return nil, response, fmt.Errorf("error with operation RebootAccessPoints") } @@ -1156,6 +1191,11 @@ func (s *WirelessService) CreateEnterpriseSSID(requestWirelessCreateEnterpriseSS } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateEnterpriseSSID(requestWirelessCreateEnterpriseSSID) + } + return nil, response, fmt.Errorf("error with operation CreateEnterpriseSsid") } @@ -1188,6 +1228,11 @@ func (s *WirelessService) ConfigureAccessPoints(requestWirelessConfigureAccessPo } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ConfigureAccessPoints(requestWirelessConfigureAccessPoints) + } + return nil, response, fmt.Errorf("error with operation ConfigureAccessPoints") } @@ -1233,6 +1278,11 @@ func (s *WirelessService) ApProvision(requestWirelessAPProvision *RequestWireles } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.ApProvision(requestWirelessAPProvision, APProvisionHeaderParams) + } + return nil, response, fmt.Errorf("error with operation ApProvision") } @@ -1282,6 +1332,11 @@ func (s *WirelessService) CreateUpdateDynamicInterface(requestWirelessCreateUpda } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateUpdateDynamicInterface(requestWirelessCreateUpdateDynamicInterface, CreateUpdateDynamicInterfaceHeaderParams) + } + return nil, response, fmt.Errorf("error with operation CreateUpdateDynamicInterface") } @@ -1314,6 +1369,11 @@ func (s *WirelessService) CreateWirelessProfile(requestWirelessCreateWirelessPro } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateWirelessProfile(requestWirelessCreateWirelessProfile) + } + return nil, response, fmt.Errorf("error with operation CreateWirelessProfile") } @@ -1346,6 +1406,11 @@ func (s *WirelessService) Provision(requestWirelessProvision *RequestWirelessPro } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.Provision(requestWirelessProvision) + } + return nil, response, fmt.Errorf("error with operation Provision") } @@ -1378,6 +1443,11 @@ func (s *WirelessService) PSKOverride(requestWirelessPSKOverride *RequestWireles } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.PSKOverride(requestWirelessPSKOverride) + } + return nil, response, fmt.Errorf("error with operation PSKOverride") } @@ -1410,6 +1480,11 @@ func (s *WirelessService) CreateOrUpdateRfProfile(requestWirelessCreateOrUpdateR } if response.IsError() { + + if response.StatusCode() == http.StatusUnauthorized { + return s.CreateOrUpdateRfProfile(requestWirelessCreateOrUpdateRFProfile) + } + return nil, response, fmt.Errorf("error with operation CreateOrUpdateRfProfile") } @@ -1440,6 +1515,9 @@ func (s *WirelessService) UpdateEnterpriseSSID(requestWirelessUpdateEnterpriseSS } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateEnterpriseSSID(requestWirelessUpdateEnterpriseSSID) + } return nil, response, fmt.Errorf("error with operation UpdateEnterpriseSsid") } @@ -1470,6 +1548,9 @@ func (s *WirelessService) UpdateWirelessProfile(requestWirelessUpdateWirelessPro } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.UpdateWirelessProfile(requestWirelessUpdateWirelessProfile) + } return nil, response, fmt.Errorf("error with operation UpdateWirelessProfile") } @@ -1513,6 +1594,9 @@ func (s *WirelessService) ProvisionUpdate(requestWirelessProvisionUpdate *Reques } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.ProvisionUpdate(requestWirelessProvisionUpdate, ProvisionUpdateHeaderParams) + } return nil, response, fmt.Errorf("error with operation ProvisionUpdate") } @@ -1562,6 +1646,9 @@ func (s *WirelessService) DeleteSSIDAndProvisionItToDevices(ssidName string, man } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteSSIDAndProvisionItToDevices(ssidName, managedAPLocations, DeleteSSIDAndProvisionItToDevicesHeaderParams) + } return nil, response, fmt.Errorf("error with operation DeleteSsidAndProvisionItToDevices") } @@ -1597,6 +1684,9 @@ func (s *WirelessService) DeleteEnterpriseSSID(ssidName string) (*ResponseWirele } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteEnterpriseSSID(ssidName) + } return nil, response, fmt.Errorf("error with operation DeleteEnterpriseSsid") } @@ -1632,6 +1722,9 @@ func (s *WirelessService) DeleteWirelessProfile(wirelessProfileName string) (*Re } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteWirelessProfile(wirelessProfileName) + } return nil, response, fmt.Errorf("error with operation DeleteWirelessProfile") } @@ -1683,6 +1776,9 @@ func (s *WirelessService) DeleteDynamicInterface(interfaceName string, DeleteDyn } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteDynamicInterface(interfaceName, DeleteDynamicInterfaceHeaderParams) + } return response, fmt.Errorf("error with operation DeleteDynamicInterface") } @@ -1717,6 +1813,9 @@ func (s *WirelessService) DeleteRfProfiles(rfProfileName string) (*ResponseWirel } if response.IsError() { + if response.StatusCode() == http.StatusUnauthorized { + return s.DeleteRfProfiles(rfProfileName) + } return nil, response, fmt.Errorf("error with operation DeleteRfProfiles") }