Skip to content

Commit 90fe99c

Browse files
committed
feat: new pagination logic
1 parent 67e04e1 commit 90fe99c

File tree

71 files changed

+404
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+404
-298
lines changed

.github/workflows/release-please.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
steps:
1717
- uses: googleapis/[email protected]
1818
with:
19-
release-type: simple
20-
token: ${{ secrets.RELEASE_PLEASE_PAT }}
19+
release-type: go
20+
token: ${{ secrets.RELEASE_PLEASE_PAT }}

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## [2.0.1](https://github.com/deploymenttheory/go-api-sdk-jamfpro/compare/v2.0.0...v2.0.1) (2025-04-17)
4+
5+
6+
### Bug Fixes
7+
8+
* release please to release type go ([af961b5](https://github.com/deploymenttheory/go-api-sdk-jamfpro/commit/af961b5cb3de7c9df1ec53b1dcf60aecfbae00f9))
9+
10+
## [2.0.0](https://github.com/deploymenttheory/go-api-sdk-jamfpro/compare/v1.27.1...v2.0.0) (2025-04-17)
11+
12+
13+
### ⚠ BREAKING CHANGES
14+
15+
* Pagination func filter passing refactored ([#760](https://github.com/deploymenttheory/go-api-sdk-jamfpro/issues/760))
16+
17+
### Features
18+
19+
* Pagination func filter passing refactored ([#760](https://github.com/deploymenttheory/go-api-sdk-jamfpro/issues/760)) ([5199c4e](https://github.com/deploymenttheory/go-api-sdk-jamfpro/commit/5199c4e81489c30b8da64849d29fec5919b80a9f))
20+
321
## [1.27.1](https://github.com/deploymenttheory/go-api-sdk-jamfpro/compare/v1.27.0...v1.27.1) (2025-04-14)
422

523

docs/url_queries.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Querying the Jamf Pro API with RSQL
2+
3+
Jamf Pro's **Jamf Pro API (v1+)** supports querying resources using **RSQL filters** via HTTP requests. This guide explains how to construct API queries using URLs with RSQL in Go.
4+
5+
6+
## 📘 Basic URL Format
7+
8+
Jamf Pro API endpoints follow this pattern:
9+
10+
```
11+
https://<jamf-host>/api/<resource-path>?page=0&page-size=50&sort=fieldName:asc&filter=<rsql-expression>
12+
```
13+
14+
- `page`: zero-based page index.
15+
- `page-size`: number of results per page.
16+
- `sort`: optional; `fieldName:asc` or `fieldName:desc`.
17+
- `filter`: your RSQL query string (URL-encoded).
18+
19+
---
20+
21+
## 🔍 Example: Query Computers by Name
22+
23+
**Goal:** Find all computers whose name contains `test`.
24+
25+
**Endpoint:**
26+
27+
```
28+
GET /api/v1/computers-inventory
29+
```
30+
31+
**RSQL Filter:**
32+
33+
```
34+
general.name==*test*
35+
```
36+
37+
**Full URL (URL-encoded):**
38+
39+
```
40+
https://your-jamf-url.com/api/v1/computers-inventory?filter=general.name%3D%3D%2Atest%2A
41+
```
42+
43+
44+
45+
## 🧑‍💻 Creating an RSQL Query using `url.Values{}` in Go
46+
47+
```go
48+
import (
49+
"net/http"
50+
"net/url"
51+
)
52+
53+
func buildJamfQuery() (*http.Request, error) {
54+
baseURL := "https://your-jamf-url.com/api/v1/computers-inventory"
55+
56+
params := url.Values{}
57+
params.Set("page", "0")
58+
params.Set("page-size", "50")
59+
params.Set("sort", "general.name:asc")
60+
params.Set("filter", `general.name==*test*`)
61+
62+
fullURL := baseURL + "?" + params.Encode()
63+
64+
req, err := http.NewRequest("GET", fullURL, nil)
65+
if err != nil {
66+
return nil, err
67+
}
68+
69+
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
70+
return req, nil
71+
}
72+
```
73+
74+
- `url.Values{}.Encode()` handles correct URL encoding for you.
75+
- The RSQL filter will be encoded automatically (e.g. `==``%3D%3D`, `*``%2A`).
76+
77+
---

examples/bookmarks/GetBookmarks/GetBookmarks.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"log"
7+
"net/url"
78

89
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
910
)
@@ -18,8 +19,10 @@ func main() {
1819
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
1920
}
2021

22+
// For more information on how to add parameters to this request, see docs/url_queries.md
23+
2124
// Call function
22-
bookmarksList, err := client.GetBookmarks("")
25+
bookmarksList, err := client.GetBookmarks(url.Values{})
2326
if err != nil {
2427
log.Fatalf("Error fetching accounts: %v", err)
2528
}

examples/buildings/GetBuildingResourceHistoryByID/GetBuildingResourceHistoryByID.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"log"
6+
"net/url"
67

78
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
89
)
@@ -18,8 +19,9 @@ func main() {
1819
}
1920

2021
// Example: Fetch the resource history of a building by ID
22+
// For more information on how to add parameters to this request, see docs/url_queries.md
2123
buildingID := "" // Replace with a real building ID
22-
history, err := client.GetBuildingResourceHistoryByID(buildingID, "")
24+
history, err := client.GetBuildingResourceHistoryByID(buildingID, url.Values{})
2325
if err != nil {
2426
log.Fatalf("Error fetching building resource history: %v", err)
2527
}

examples/buildings/GetBuildings/GetBuildings.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"log"
7+
"net/url"
78

89
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
910
)
@@ -18,8 +19,10 @@ func main() {
1819
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
1920
}
2021

22+
// For more information on how to add parameters to this request, see docs/url_queries.md
23+
2124
// Call GetBuildings function
22-
accountsList, err := client.GetBuildings("")
25+
accountsList, err := client.GetBuildings(url.Values{})
2326
if err != nil {
2427
log.Fatalf("Error fetching accounts: %v", err)
2528
}

examples/categories/GetCategories/GetCategories.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"log"
6+
"net/url"
67

78
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
89
)
@@ -18,9 +19,10 @@ func main() {
1819
}
1920

2021
// Define the sort and filter query parameters
21-
// none
22+
// For more information on how to add parameters to this request, see docs/url_queries.md
23+
2224
// Call the GetCategories function
23-
categories, err := client.GetCategories("") // Will return all results by default
25+
categories, err := client.GetCategories(url.Values{}) // Will return all results by default
2426
if err != nil {
2527
fmt.Printf("Error fetching categories: %v\n", err)
2628
return

examples/cloud_idp/GetCloudIdentityProviders/GetCloudIdentityProviders.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"log"
7+
"net/url"
78

89
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
910
)
@@ -19,10 +20,11 @@ func main() {
1920
}
2021

2122
// Optional: Define sort filter (e.g., "id:asc" or "displayName:desc")
22-
sortFilter := "id:desc"
23+
// For more information on how to add parameters to this request, see docs/url_queries.md
24+
params := url.Values{}
2325

2426
// Call GetCloudIdentityProviders function
25-
cloudIdps, err := client.GetCloudIdentityProviders(sortFilter)
27+
cloudIdps, err := client.GetCloudIdentityProviders(params)
2628
if err != nil {
2729
log.Fatalf("Error fetching cloud identity providers: %v", err)
2830
}

examples/computer_extension_attributes/GetComputerExtensionAttributes/GetComputerExtensionAttributes.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/xml"
55
"fmt"
66
"log"
7+
"net/url"
78

89
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
910
)
@@ -19,7 +20,8 @@ func main() {
1920
}
2021

2122
// Call GetComputerExtensionAttributes function
22-
attributes, err := client.GetComputerExtensionAttributes("")
23+
// For more information on how to add parameters to this request, see docs/url_queries.md
24+
attributes, err := client.GetComputerExtensionAttributes(url.Values{})
2325
if err != nil {
2426
log.Fatalf("Error fetching Computer Extension Attributes: %v", err)
2527
}

examples/computer_inventory/GetComputersFileVaultInventory/GetComputersFileVaultInventory.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"log"
7+
"net/url"
78

89
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
910
)
@@ -19,10 +20,12 @@ func main() {
1920
}
2021

2122
// Sort filter
22-
sortFilter := "sort=id:desc"
23+
// For more information on how to add parameters to this request, see docs/url_queries.md
24+
params := url.Values{}
25+
params.Add("sort", "id:desc")
2326

2427
// Call the GetComputersFileVaultInventory function
25-
fileVaultInventory, err := client.GetComputersFileVaultInventory(sortFilter)
28+
fileVaultInventory, err := client.GetComputersFileVaultInventory(params)
2629
if err != nil {
2730
log.Fatalf("Error fetching FileVault inventory: %v", err)
2831
}

0 commit comments

Comments
 (0)