Skip to content

Commit

Permalink
Revert "New main branch SDK doesn't use the intended user agent strin…
Browse files Browse the repository at this point in the history
…g format #21"

This reverts commit 2d468ea.
  • Loading branch information
fmunozmiranda committed Mar 14, 2024
1 parent a7821ca commit d514075
Show file tree
Hide file tree
Showing 22 changed files with 572 additions and 1,355 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ assignees: ''
**Prerequisites**
* [ ] Have you tested the operation in the API directly?
* [ ] Do you have the latest SDK version?
* [ ] Review [compability matrix](https://github.com/meraki/dashboard-api-go?tab=readme-ov-file#compatibility-matrix)
* [ ] Review [compability matrix](https://github.com/cisco-en-programmability/dnacenter-go-sdk/tree/main#compatibility-matrix)

**Describe the bug**
A clear and concise description of what the bug is.
Expand All @@ -22,7 +22,7 @@ A clear and concise description of what you expected to happen.
Please provide an screenshot of the successful API call with cuRL, Postman, etc.

**Environment (please complete the following information):**
* Cisco Dasboard Meraki Version and patch:
* Cisco DNA Center Version and patch:
* Go Version:
* SDK version:
* OS Version:
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ The client could be generated with the following parameters:
- `baseURL`: The base URL, FQDN or IP, of the MERAKI instance.
- `dashboardApiKey`: The meraki_key for access to API.
- `debug`: Boolean to enable debugging
- `customUserAgent`: Set Custom user agent, if is nil, default is: (golang/*)
- `requestPerSecond`: Set request per second allowed for client, if is nil, default is: (10)
- `sslVerify`: Boolean to enable or disable SSL certificate verification.

```go
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"MERAKI_KEY",
"true", nil,nil)
"true", "false")
nResponse, _, err := client.Administered.GetAdministeredIDentitiesMe()
if err != nil {
fmt.Println(err)
Expand All @@ -49,10 +48,10 @@ The client can be configured with the following environment variables:
- `MERAKI_BASE_URL`: The base URL, FQDN or IP, of the MERAKI instance.
- `MERAKI_DASHBOARD_API_KEY`: The meraki_key for access to API.
- `MERAKI_DEBUG`: Boolean to enable debugging
- `MERAKI_USER_AGENT`: Custom user agent can be set. Default (golang/*)
- `MERAKI_SSL_VERIFY`: Boolean to enable or disable SSL certificate verification.

```go
Client, err = meraki.NewClient(nil)
Client, err = meraki.NewClient()
devicesCount, _, err := Client.Devices.GetDeviceCount()
```

Expand All @@ -61,12 +60,9 @@ devicesCount, _, err := Client.Devices.GetDeviceCount()
Here is an example of how we can generate a client, get a device count and then a list of devices filtering them using query params.

```go

requestPerSecond := 5
custom_user_agent := "customUA"
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"APIKEY",
"true", &custom_user_agent, &requestPerSecond)
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"Meraki_key",
"true", "false")
if err != nil {
fmt.Println(err)
return
Expand Down
22 changes: 8 additions & 14 deletions examples/administered/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,42 @@ package main

import (
"fmt"
"os"

meraki "github.com/meraki/dashboard-api-go/v2/sdk"
)

// Client is Dasboard Meraki API client
// Client is DNA Center API client
var client *meraki.Client

func main() {
var err error
fmt.Println("Authenticating")
requestPerSecond := 5
custom_user_agent := "customUA"
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"12f2eb53588c75e28d89e108a05ea0c2487b08cf",
"true", &custom_user_agent, &requestPerSecond)
"true", "false")
if err != nil {
fmt.Println(err)
return
}

nResponse, _, err := client.Administered.GetAdministeredIDentitiesMe()
if err != nil {

os.Exit(1)
fmt.Println(err)
return
}
if nResponse != nil {
fmt.Println(nResponse)

return
}
nResponse2, _, err := client.Organizations.GetOrganization("828099381482762270")
if err != nil {

os.Exit(1)
nResponse2, _, err := client.Administered.GetAdministeredIDentitiesMe()
if err != nil {
fmt.Println(err)
return
}
if nResponse2 != nil {
fmt.Println(nResponse2)

fmt.Println(nResponse)
return
}

fmt.Println("There's no data on response")
}
2 changes: 1 addition & 1 deletion examples/networks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {
fmt.Println("Authenticating")
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"12f2eb53588c75e28d89e108a05ea0c2487b08cf",
"true", nil, nil)
"true", "false")
if err != nil {
fmt.Println(err)
return
Expand Down
2 changes: 1 addition & 1 deletion examples/organizations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {
fmt.Println("Authenticating")
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"12f2eb53588c75e28d89e108a05ea0c2487b08cf",
"true", nil, nil)
"true", "false")
if err != nil {
fmt.Println(err)
return
Expand Down
2 changes: 1 addition & 1 deletion examples/testPagination/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func main() {
fmt.Println("Authenticating")
client, err = meraki.NewClientWithOptions("https://api.meraki.com/",
"12f2eb53588c75e28d89e108a05ea0c2487b08cf",
"false", nil, nil)
"false", "false")
if err != nil {
fmt.Println(err)
return
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ go 1.21.5
require (
github.com/go-resty/resty/v2 v2.11.0
github.com/google/go-querystring v1.1.0
github.com/juju/ratelimit v1.0.2
)

require (
golang.org/x/net v0.17.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
require golang.org/x/net v0.17.0 // indirect
9 changes: 0 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/juju/ratelimit v1.0.2 h1:sRxmtRiajbvrcLQT7S+JbqU0ntsb9W2yhSdNN8tWfaI=
github.com/juju/ratelimit v1.0.2/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand Down Expand Up @@ -54,5 +47,3 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
6 changes: 3 additions & 3 deletions sdk/administered.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ type ResponseAdministeredGetAdministeredIDentitiesMeAuthenticationTwoFactor stru
/* Returns the identity of the current user.
*/
Documentation Link: https://developer.cisco.com/docs/dna-center/#!get-administered-identities-me
*/
func (s *AdministeredService) GetAdministeredIDentitiesMe() (*ResponseAdministeredGetAdministeredIDentitiesMe, *resty.Response, error) {
path := "/api/v1/administered/identities/me"
s.rateLimiterBucket.Wait(1)

response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
Expand Down
Loading

0 comments on commit d514075

Please sign in to comment.