Skip to content

Commit e8aec13

Browse files
authored
Merge pull request #87 from cisco-en-programmability/develop
chore: Set User-Agent header in API client
2 parents bb9bb15 + 0b4d0ae commit e8aec13

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [5.0.32] - 2024-08-06
10+
### Added
11+
- Set User-Agent header in API client
12+
913
## [5.0.31] - 2024-07-17
1014
### Changed
1115
- Method `SetDNACWaitTimeToManyRequest` update for update wait time from minutes to seconds.
@@ -642,4 +646,5 @@ Services removed on Cisco DNA Center 2.3.3.0's API:
642646
[5.0.29]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.28...v5.0.29
643647
[5.0.30]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.29...v5.0.30
644648
[5.0.31]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.30...v5.0.31
645-
[Unreleased]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.31...main
649+
[5.0.32]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.31...v5.0.32
650+
[Unreleased]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.32...main

sdk/api_client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const DNAC_PASSWORD = "DNAC_PASSWORD"
2424
const DNAC_DEBUG = "DNAC_DEBUG"
2525
const DNAC_SSL_VERIFY = "DNAC_SSL_VERIFY"
2626
const DNAC_WAIT_TIME = "DNAC_WAIT_TIME"
27+
const VERSION = "2.3.5.3"
28+
const USER_AGENT = "go-cisco-dnacsdk/" + VERSION
2729

2830
type FileDownload struct {
2931
FileName string
@@ -167,6 +169,7 @@ func NewClientNoAuth() (*Client, error) {
167169
var err error
168170

169171
client := resty.New()
172+
client.SetHeader("User-Agent", USER_AGENT)
170173
c := &Client{}
171174
c.common.client = client
172175
waitTimeToManyRequest := 0
@@ -198,6 +201,7 @@ func NewClientNoAuth() (*Client, error) {
198201
retry := false
199202
if r.StatusCode() == http.StatusUnauthorized {
200203
cl := resty.New()
204+
cl.SetHeader("User-Agent", USER_AGENT)
201205

202206
username := os.Getenv("DNAC_USERNAME")
203207
password := os.Getenv("DNAC_PASSWORD")
@@ -339,6 +343,7 @@ func (s *Client) AuthClient() error {
339343

340344
// RestyClient returns the resty.Client used by the sdk
341345
func (s *Client) RestyClient() *resty.Client {
346+
s.common.client.SetHeader("User-Agent", USER_AGENT)
342347
return s.common.client
343348
}
344349

0 commit comments

Comments
 (0)