Jamf API Client SDK in Go
Install
If you don't have a project yet and you're just trying to experiment with the package, you can create a new directory, initialize a new Go module there, and then try to fetch the dependency:
mkdir myproject
cd myproject
go mod init myproject
go get github.com/deploymenttheory/go-jamfpro-api@latest
to add module requirements and sums:
go mod tidy
package main
import (
"fmt"
"log"
jamf "github.com/deploymenttheory/go-jamfpro-api"
)
func main() {
// Credentials and URL for Jamf API
username := "your-jamf-api-account"
password := "your-jamf-api-account-password"
url := "your-jamf-instance" // e.g., "yourcompany.jamfcloud.com"
// Set up the configuration for the Jamf Pro API client
cfg := jamf.Config{
AuthMethod: jamf.BasicAuthConfig{
Username: username,
Password: password,
},
URL: url,
HTTPClient: &http.Client{},
HttpRetryTimeout: 30 * time.Second, // Optional, defaults to 10 seconds if not defined
}
}
Usage
sample code: examples
Get auth token in curl
$ curl -u username:password -X POST "https://xxxxx.jamfcloud.com/api/auth/tokens"
$ token=xxxxx
$ curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" "https://xxxxx.jamfcloud.com/api/v1/departments"
Go SDK for Jamf Pro API Progress Tracker
API Coverage Progress
Date: YYYY-MM-DD
Maintainer: [Your Name]
Overview
This document tracks the progress of API endpoint coverage tests. As endpoints are tested, they will be marked as covered.
Coverage Legend
- ✅ - Covered
- ❌ - Not Covered
- ⚠️ - Partially Covered
Endpoints
Accounts - /JSSResource/accounts
- ✅ GET
/userid/{id} - GetAccountByID retrieves the Account by its ID
- ✅ GET
/username/{username} - GetAccountByName retrieves the Account by its name
- ✅ GET
/ - GetAccounts retrieves all user accounts
- ✅ GET
/groupid/{id} - GetAccountGroupByID retrieves the Account Group by its ID
- ✅ GET
/groupname/{id} - GetAccountGroupByName retrieves the Account Group by its name
- ✅ POST
/ - CreateAccount creates a new Jamf Pro Account.
- ✅ POST
/groupid/0 - CreateAccountGroup creates a new Jamf Pro Account Group.
- ✅ PUT
/userid/{id} - UpdateAccountByID updates an existing Jamf Pro Account by ID
- ✅ PUT
/username/{id} - UpdateAccountByName updates an existing Jamf Pro Account by Name
- ✅ PUT
/groupid/{id} - UpdateAccountGroupByID updates an existing Jamf Pro Account Group by ID
- ✅ PUT
/groupname/{id} - UpdateAccountGroupByName updates an existing Jamf Pro Account Group by Name
- ✅ DELETE
/userid/{id} - DeleteAccountByID deletes an existing Jamf Pro Account by ID
- ✅ DELETE
/username/{username} - DeleteAccountByName deletes an existing Jamf Pro Account by Name
- ✅ DELETE
/groupid/{id} - DeleteAccountGroupByID deletes an existing Jamf Pro Account Group by ID
- ✅ DELETE
/groupname/{username} - DeleteAccountGroupByName deletes an existing Jamf Pro Account Group by Name
Activation Code - /JSSResource/activationcode
- ✅ GET
/JSSResource/activationcode - GetActivationCode retrieves the current activation code.
- ✅ PUT
/JSSResource/activationcode - UpdateActivationCode updates the activation code.
Product API
- ❌ GET
/products - Retrieve list of products
- ❌ POST
/products - Add a new product
- ❌ PUT
/products/{id} - Update product details
- ❌ DELETE
/products/{id} - Remove a product
Order API
- ❌ GET
/orders - Retrieve list of orders
- ❌ POST
/orders - Create a new order
- ❌ PUT
/orders/{id} - Update order details
- ❌ DELETE
/orders/{id} - Cancel an order
Progress Summary
- Total Endpoints: XX
- Covered: XX
- Not Covered: XX
- Partially Covered: XX
Notes
- Add any relevant notes or comments about the coverage progress here.