Skip to content

Commit

Permalink
Merge pull request #49 from meraki/develop
Browse files Browse the repository at this point in the history
## [4.0.1] - 2025-01-20
  • Loading branch information
fmunozmiranda authored Feb 7, 2025
2 parents 7e4e5a7 + f19e904 commit a3b3d19
Show file tree
Hide file tree
Showing 20 changed files with 5,716 additions and 694 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.0.1] - 2025-01-20
### Added
- **Support for fetching all items with `perpage=-1`**
A new feature has been added to the endpoint where if the `perpage` parameter is set to `-1`, it will return all available items for that endpoint. This eliminates the need for multiple paginated requests when retrieving the full set of data.

**Behavior:**
- When `perpage` is set to `-1`, all items will be returned.
- For positive values of `perpage`, the traditional pagination logic will be applied.

**Benefits:**
- Simplifies fetching all data in a single request.
- Reduces the need for multiple API calls to retrieve the full dataset.


## [4.0.0] - 2025-01-20
### Changed
- dashboard-api-go supports now v1.53.0 of Meraki Dashboard API.
Expand Down Expand Up @@ -1413,4 +1427,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[3.0.8]: https://github.com/meraki/dashboard-api-go/compare/v3.0.7...3.0.8
[3.0.9]: https://github.com/meraki/dashboard-api-go/compare/v3.0.8...3.0.9
[4.0.0]: https://github.com/meraki/dashboard-api-go/compare/v3.0.10...4.0.0
[Unreleased]: https://github.com/meraki/dashboard-api-go/compare/v4.0.0...main
[4.0.1]: https://github.com/meraki/dashboard-api-go/compare/v4.0.0...4.0.1
[Unreleased]: https://github.com/meraki/dashboard-api-go/compare/v4.0.1...main
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,48 @@ nResponse, _, err := client.Administered.GetAdministeredIDentitiesMe()
}
```

### Fetch All Items of an Endpoint with Pagination

- **Support for fetching all items with `perpage=-1`**
A new feature has been introduced to the API endpoints, enabling clients to fetch all available items in a single request by setting the `perpage` parameter to `-1`. This enhancement allows you to retrieve the full dataset without needing to make multiple paginated requests.

### Behavior

- When `perpage` is set to `-1`, the server will return **all available items** for that endpoint, bypassing the pagination logic.
- If a positive integer is passed for `perpage`, the endpoint will continue using traditional pagination and return only the number of items specified by `perpage`.

### Example Usage
```go
func main() {
var err error
fmt.Println("Authenticating")
client, err = meraki.NewClient()
if err != nil {
fmt.Println(err)
return
}

nResponse, _, err := client.Organizations.GetOrganizationDevices("828099381482762270", &meraki.GetOrganizationDevicesQueryParams{
PerPage: -1,
TagsFilterType: "withAnyTags",
})
if err != nil {
fmt.Println(err)
return
}
if nResponse != nil {
fmt.Println("\n <Count>: ", len(*nResponse))
fmt.Printf("%v", *nResponse)
return
}

fmt.Println("There's no data on response")
```
#### Fetch All Items
To retrieve all items from the endpoint, set the `perpage` parameter to `-1`:
### Using environment variables
The client can be configured with the following environment variables:
Expand Down
30 changes: 30 additions & 0 deletions examples/429_Test/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"

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

var client *meraki.Client

func main() {
var err error
fmt.Println("Authenticating")
client, err = meraki.NewClient()
if err != nil {
fmt.Println(err)
return
}

nResponse, _, err := client.Organizations.GetOrganizations(nil)
if err != nil {
fmt.Println(err)
return
}
if nResponse != nil {
fmt.Println(nResponse)
return
}
fmt.Println("There's no data on response")
}
60 changes: 60 additions & 0 deletions examples/GetAllTests/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package main

import (
"fmt"

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

var client *meraki.Client

func main() {
var err error
fmt.Println("Authenticating")
client, err = meraki.NewClient()
if err != nil {
fmt.Println(err)
return
}

nResponse, _, err := client.Organizations.GetOrganizationDevices("828099381482762270", &meraki.GetOrganizationDevicesQueryParams{
PerPage: -1,
TagsFilterType: "withAnyTags",
})
// nResponse, _, err := client.Organizations.GetOrganizationAssuranceAlertsOverviewByNetwork("828099381482762270", &meraki.GetOrganizationAssuranceAlertsOverviewByNetworkQueryParams{
// PerPage: -1,
// })
// nResponse, _, err := client.Devices.GetOrganizationWirelessControllerDevicesInterfacesL2StatusesChangeHistoryByDevice("828099381482762270", &meraki.GetOrganizationWirelessControllerDevicesInterfacesL2StatusesChangeHistoryByDeviceQueryParams{
// PerPage: -1,
// })

// nResponse, _, err := client.Switch.GetOrganizationSwitchPortsClientsOverviewByDevice("828099381482762270", &meraki.GetOrganizationSwitchPortsClientsOverviewByDeviceQueryParams{
// PerPage: -1,
// })
// nResponse, _, err := client.Switch.GetOrganizationSwitchPortsTopologyDiscoveryByDevice("828099381482762270", &meraki.GetOrganizationSwitchPortsTopologyDiscoveryByDeviceQueryParams{
// PerPage: -1,
// })

// nResponse, _, err := client.WirelessController.GetOrganizationWirelessControllerAvailabilitiesChangeHistory("828099381482762270", &meraki.GetOrganizationWirelessControllerAvailabilitiesChangeHistoryQueryParams{
// PerPage: -1,
// })
// nResponse, _, err := client.WirelessController.GetOrganizationWirelessControllerDevicesInterfacesL3StatusesChangeHistoryByDevice("828099381482762270", &meraki.GetOrganizationWirelessControllerDevicesInterfacesL3StatusesChangeHistoryByDeviceQueryParams{
// PerPage: -1,
// })

// nResponse, _, err := client.Wireless.GetOrganizationWirelessAirMarshalRules("828099381482762270", &meraki.GetOrganizationWirelessAirMarshalRulesQueryParams{
// PerPage: -1,
// })

if err != nil {
fmt.Println(err)
return
}
if nResponse != nil {
fmt.Println("\n Cantidad: ", len(*nResponse))
fmt.Printf("%v", *nResponse)
return
}

fmt.Println("There's no data on response")
}
36 changes: 36 additions & 0 deletions examples/GetAllTests2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"fmt"

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

var client *meraki.Client

func main() {
var err error
fmt.Println("Authenticating")
client, err = meraki.NewClient()
if err != nil {
fmt.Println(err)
return
}

nResponse, _, err := client.Networks.GetNetworkClientsApplicationUsage("L_828099381482771185", &meraki.GetNetworkClientsApplicationUsageQueryParams{
PerPage: -1,
Clients: "4c:c8:a1:0b:01:58",
})

if err != nil {
fmt.Println(err)
return
}
if nResponse != nil {
fmt.Println("\n Cantidad: ", len(*nResponse))
fmt.Printf("%v", *nResponse)
return
}

fmt.Println("There's no data on response")
}
2 changes: 2 additions & 0 deletions sdk/administered.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ResponseAdministeredGenerateAdministeredIDentitiesMeAPIKeys struct {
*/

func (s *AdministeredService) GetAdministeredIDentitiesMe() (*ResponseAdministeredGetAdministeredIDentitiesMe, *resty.Response, error) {
path := "/api/v1/administered/identities/me"
s.rateLimiterBucket.Wait(1)
Expand Down Expand Up @@ -79,6 +80,7 @@ func (s *AdministeredService) GetAdministeredIDentitiesMe() (*ResponseAdminister
*/

func (s *AdministeredService) GetAdministeredIDentitiesMeAPIKeys() (*ResponseAdministeredGetAdministeredIDentitiesMeAPIKeys, *resty.Response, error) {
path := "/api/v1/administered/identities/me/api/keys"
s.rateLimiterBucket.Wait(1)
Expand Down
Loading

0 comments on commit a3b3d19

Please sign in to comment.