@@ -24,8 +24,10 @@ const DNAC_PASSWORD = "DNAC_PASSWORD"
2424const DNAC_DEBUG = "DNAC_DEBUG"
2525const DNAC_SSL_VERIFY = "DNAC_SSL_VERIFY"
2626const DNAC_WAIT_TIME = "DNAC_WAIT_TIME"
27- const VERSION = "2.3.5.3"
28- const USER_AGENT = "go-cisco-dnacsdk/" + VERSION
27+
28+ var VERSION = "2.3.7.6.1"
29+ var DNAC_USER_STRING = "DNAC_USER_STRING"
30+ var USER_AGENT = "go-cisco-dnacentersdk/" + VERSION
2931
3032type FileDownload struct {
3133 FileName string
@@ -43,8 +45,11 @@ type Client struct {
4345
4446 // API Services
4547 Authentication * AuthenticationService
48+ AuthenticationManagement * AuthenticationManagementService
49+ AIEndpointAnalytics * AIEndpointAnalyticsService
4650 ApplicationPolicy * ApplicationPolicyService
4751 Applications * ApplicationsService
52+ CiscoTrustedCertificates * CiscoTrustedCertificatesService
4853 Clients * ClientsService
4954 CommandRunner * CommandRunnerService
5055 Compliance * ComplianceService
@@ -53,8 +58,9 @@ type Client struct {
5358 DeviceOnboardingPnp * DeviceOnboardingPnpService
5459 DeviceReplacement * DeviceReplacementService
5560 Devices * DevicesService
61+ DisasterRecovery * DisasterRecoveryService
5662 Discovery * DiscoveryService
57- Eox * EoxService
63+ EoX * EoXService
5864 EventManagement * EventManagementService
5965 FabricWireless * FabricWirelessService
6066 File * FileService
@@ -82,8 +88,6 @@ type Client struct {
8288 Users * UsersService
8389 Wireless * WirelessService
8490 CustomCall * CustomCallService
85- CiscoDnaCenterSystem * CiscoDnaCenterSystemService
86- CiscoTrustedCertificates * CiscoTrustedCertificatesService
8791}
8892
8993type service struct {
@@ -116,10 +120,15 @@ func NewClient() (*Client, error) {
116120}
117121
118122// NewClientWithOptions is the client with options passed with parameters
119- func NewClientWithOptions (baseURL string , username string , password string , debug string , sslVerify string , waitTimeToManyRequest * int ) (* Client , error ) {
123+ func NewClientWithOptions (baseURL string , username string , password string , debug string , sslVerify string , waitTimeToManyRequest * int , userString ... string ) (* Client , error ) {
120124 var err error
121125
122- err = SetOptions (baseURL , username , password , debug , sslVerify , waitTimeToManyRequest )
126+ var user string
127+ if len (userString ) > 0 {
128+ user = "-" + userString [0 ]
129+ }
130+
131+ err = SetOptions (baseURL , username , password , debug , sslVerify , waitTimeToManyRequest , user )
123132 if err != nil {
124133 return nil , err
125134 }
@@ -128,7 +137,7 @@ func NewClientWithOptions(baseURL string, username string, password string, debu
128137}
129138
130139// SetOptions sets the environment variables
131- func SetOptions (baseURL string , username string , password string , debug string , sslVerify string , waitTimeToManyRequest * int ) error {
140+ func SetOptions (baseURL string , username string , password string , debug string , sslVerify string , waitTimeToManyRequest * int , userString string ) error {
132141 var err error
133142 err = os .Setenv (DNAC_BASE_URL , baseURL )
134143 if err != nil {
@@ -150,6 +159,10 @@ func SetOptions(baseURL string, username string, password string, debug string,
150159 if err != nil {
151160 return err
152161 }
162+ err = os .Setenv (DNAC_USER_STRING , userString )
163+ if err != nil {
164+ return err
165+ }
153166 if waitTimeToManyRequest != nil {
154167 err = os .Setenv (DNAC_WAIT_TIME , strconv .Itoa (* waitTimeToManyRequest ))
155168 if err != nil {
@@ -164,12 +177,17 @@ func SetOptions(baseURL string, username string, password string, debug string,
164177 return nil
165178}
166179
180+ func GetUserAgent () string {
181+ return USER_AGENT + os .Getenv (DNAC_USER_STRING )
182+ }
183+
167184// NewClientNoAuth returns the client object without trying to authenticate
168185func NewClientNoAuth () (* Client , error ) {
169186 var err error
170187
171188 client := resty .New ()
172- client .SetHeader ("User-Agent" , USER_AGENT )
189+
190+ client .SetHeader ("User-Agent" , GetUserAgent ())
173191 c := & Client {}
174192 c .common .client = client
175193 waitTimeToManyRequest := 0
@@ -186,6 +204,7 @@ func NewClientNoAuth() (*Client, error) {
186204 } else {
187205 err = fmt .Errorf ("enviroment variable %s was not defined" , DNAC_BASE_URL )
188206 }
207+
189208 if os .Getenv (DNAC_WAIT_TIME ) != "" {
190209 waitTimeToManyRequest , err = strconv .Atoi (os .Getenv (DNAC_WAIT_TIME ))
191210 if err != nil {
@@ -194,14 +213,15 @@ func NewClientNoAuth() (*Client, error) {
194213 } else {
195214 waitTimeToManyRequest = 1
196215 }
216+
197217 c .common .client .AddRetryCondition (
198218 // RetryConditionFunc type is for retry condition function
199219 // input: non-nil Response OR request execution error
200220 func (r * resty.Response , err error ) bool {
201221 retry := false
202222 if r .StatusCode () == http .StatusUnauthorized {
203223 cl := resty .New ()
204- cl .SetHeader ("User-Agent" , USER_AGENT )
224+ cl .SetHeader ("User-Agent" , GetUserAgent () )
205225
206226 username := os .Getenv ("DNAC_USERNAME" )
207227 password := os .Getenv ("DNAC_PASSWORD" )
@@ -244,13 +264,16 @@ func NewClientNoAuth() (*Client, error) {
244264 // MaxWaitTime can be overridden as well.
245265 // Default is 2 seconds.
246266 SetRetryMaxWaitTime (time .Duration (waitTimeToManyRequest + 1 ) * time .Minute )
267+
247268 if err != nil {
248269 return nil , err
249270 }
250271
251272 c .Authentication = (* AuthenticationService )(& c .common )
273+ c .AIEndpointAnalytics = (* AIEndpointAnalyticsService )(& c .common )
252274 c .ApplicationPolicy = (* ApplicationPolicyService )(& c .common )
253275 c .Applications = (* ApplicationsService )(& c .common )
276+ c .CiscoTrustedCertificates = (* CiscoTrustedCertificatesService )(& c .common )
254277 c .Clients = (* ClientsService )(& c .common )
255278 c .CommandRunner = (* CommandRunnerService )(& c .common )
256279 c .Compliance = (* ComplianceService )(& c .common )
@@ -259,8 +282,9 @@ func NewClientNoAuth() (*Client, error) {
259282 c .DeviceOnboardingPnp = (* DeviceOnboardingPnpService )(& c .common )
260283 c .DeviceReplacement = (* DeviceReplacementService )(& c .common )
261284 c .Devices = (* DevicesService )(& c .common )
285+ c .DisasterRecovery = (* DisasterRecoveryService )(& c .common )
262286 c .Discovery = (* DiscoveryService )(& c .common )
263- c .Eox = (* EoxService )(& c .common )
287+ c .EoX = (* EoXService )(& c .common )
264288 c .EventManagement = (* EventManagementService )(& c .common )
265289 c .FabricWireless = (* FabricWirelessService )(& c .common )
266290 c .File = (* FileService )(& c .common )
@@ -293,10 +317,17 @@ func NewClientNoAuth() (*Client, error) {
293317}
294318
295319// NewClientWithOptionsNoAuth returns the client object without trying to authenticate and sets environment variables
296- func NewClientWithOptionsNoAuth (baseURL string , username string , password string , debug string , sslVerify string , waitTimeToManyRequest * int ) (* Client , error ) {
320+ func NewClientWithOptionsNoAuth (baseURL string , username string , password string , debug string , sslVerify string , waitTimeToManyRequest * int , userString ... string ) (* Client , error ) {
297321 var err error
298322
299- err = SetOptions (baseURL , username , password , debug , sslVerify , waitTimeToManyRequest )
323+ var user string
324+ if len (userString ) > 0 {
325+ user = "-" + userString [0 ]
326+ } else {
327+ user = ""
328+ }
329+
330+ err = SetOptions (baseURL , username , password , debug , sslVerify , waitTimeToManyRequest , user )
300331 if err != nil {
301332 return nil , err
302333 }
@@ -341,11 +372,11 @@ func (s *Client) AuthClient() error {
341372
342373// RestyClient returns the resty.Client used by the sdk
343374func (s * Client ) RestyClient () * resty.Client {
344- s .common .client .SetHeader ("User-Agent" , USER_AGENT )
375+ s .common .client .SetHeader ("User-Agent" , GetUserAgent () )
345376 return s .common .client
346377}
347378
348- func (s * Client ) SetDNACWaitTimeToManyRequest (waitTimeToManyRequest int ) error {
379+ func (s * Client ) SetCatalystWaitTimeToManyRequest (waitTimeToManyRequest int ) error {
349380
350381 err := os .Setenv (DNAC_WAIT_TIME , strconv .Itoa (waitTimeToManyRequest ))
351382 if err != nil {
0 commit comments