Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ go.work

# macOS File System
.DS_Store

clientconfig.json
49 changes: 31 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ For those who prefer using configuration files for setting up the client, the SD
"log_export_path": "/your/log/path/", // optional, ensure permissions to file path
"export_logs": true, // or false
"hide_sensitive_data": false, // redact sensitive data from logs
"instance_domain": "https://lbgsandbox.jamfcloud.com",
"instance_domain": "https://yourinstance.jamfcloud.com",
"auth_method": "oauth2", // or "basic"
"client_id": "your_client_id", // Required if using oauth2
"client_secret": "your_client_secret", // Required if using oauth2
Expand Down Expand Up @@ -1129,44 +1129,57 @@ This documentation provides details on the API endpoints available for managing

- Total Operations Covered: 8

### Jamf Pro Classic API - Distribution Points
### Jamf Pro API - Distribution Points

This documentation outlines the operations available for managing Distribution Points within Jamf Pro using the Classic API, which supports XML data structures.

<!-- TODO: Add by name functionality -->

## Operations

- [x] ✅ **GET** `/JSSResource/distributionpoints`
- [x] ✅ **GET** `/v1/distribution-points`
- `GetDistributionPoints` operation retrieves a serialized list of all distribution points.

- [x] ✅ **GET** `/JSSResource/distributionpoints/id/{id}`
- [x] ✅ **GET** `/v1/distribution-points/{id}`
- `GetDistributionPointByID` operation fetches a single distribution point by its ID.

- [x] ✅ **GET** `/JSSResource/distributionpoints/name/{name}`
- `GetDistributionPointByName` operation retrieves a distribution point by its name.
<!-- - [x] ✅ **GET** `/JSSResource/distributionpoints/name/{name}`
- `GetDistributionPointByName` operation retrieves a distribution point by its name. -->

- [x] ✅ **POST** `/JSSResource/distributionpoints/id/0`
- `CreateDistributionPoint` operation creates a new distribution point with the provided details. The ID `0` in the endpoint indicates creation.
- [x] ✅ **POST** `/v1/distribution-points`
- `CreateDistributionPoint` operation creates a new distribution point with the provided details.

- [x] ✅ **PUT** `/JSSResource/distributionpoints/id/{id}`
- [x] ✅ **PUT** `/v1/distribution-points/{id}`
- `UpdateDistributionPointByID` operation updates an existing distribution point by its ID.

- [x] ✅ **PUT** `/JSSResource/distributionpoints/name/{name}`
- `UpdateDistributionPointByName` operation updates an existing distribution point by its name.
<!-- - [x] ✅ **PUT** `/JSSResource/distributionpoints/name/{name}`
- `UpdateDistributionPointByName` operation updates an existing distribution point by its name. -->

- [x] ✅ **DELETE** `/JSSResource/distributionpoints/id/{id}`
- [x] ✅ **DELETE** `/v1/distribution-points/{id}`
- `DeleteDistributionPointByID` operation deletes a distribution point by its ID.

- [x] ✅ **DELETE** `/JSSResource/distributionpoints/name/{name}`
- `DeleteDistributionPointByName` operation deletes a distribution point by its name.
<!-- - [x] ✅ **DELETE** `/JSSResource/distributionpoints/name/{name}`
- `DeleteDistributionPointByName` operation deletes a distribution point by its name. -->

- [] ❌ **POST** `/v1/distribution-points/delete-multiple`
- Currently not implemented

- [] ❌ **PATCH** `/v1/distribution-points/{id}`
- Currently not implemented

- [] ❌ **GET** `/v1/distribution-points/{id}/history`
- Currently not implemented

- [] ❌ **POST** `/v1/distribution-points/{id}/history`
- Currently not implemented

## Summary

- Total Endpoints Covered: 3
- `/JSSResource/distributionpoints`
- `/JSSResource/distributionpoints/id/{id}`
- `/JSSResource/distributionpoints/name/{name}`
- `/v1/distribution-points`
- `/v1/distribution-points/{id}`

- Total Operations Covered: 8
- Total Operations Covered: 5


### Jamf Pro Classic API - Directory Bindings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"encoding/xml"
"encoding/json"
"fmt"
"log"

Expand All @@ -10,51 +10,70 @@ import (

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"

configFilePath := "/Users/work/Documents/clientconfig.json"
// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}

// New distribution point to create
newDistributionPoint := jamfpro.ResourceFileShareDistributionPoint{
Name: "New York Share",
IPAddress: "ny.company.com",
IsMaster: true,
EnableLoadBalancing: false,
SSHUsername: "casperadmin",
Password: "password",
ConnectionType: "SMB",
ShareName: "Caspershare",
WorkgroupOrDomain: "COMPANY",
SharePort: 139,
ReadOnlyUsername: "casperinstall",
ReadOnlyPassword: "password",
ReadWriteUsername: "casperwrite",
ReadWritePassword: "password",
HTTPDownloadsEnabled: true,
HTTPURL: "http://ny.company.com/CasperShare",
Context: "CasperShare",
Protocol: "http",
Port: 80,
NoAuthenticationRequired: false,
UsernamePasswordRequired: true,
HTTPUsername: "casperinstall",
HTTPPassword: "password",
// Define variables for pointer fields

// List of distribution points to create
distributionPoints := []jamfpro.ResourceFileShareDistributionPoint{
{
Name: "example-distribution-point-min",
ServerName: "servername",
FileSharingConnectionType: "NONE",
HTTPSEnabled: true,
HTTPSPort: 443,
HTTPSSecurityType: "NONE",
},
{
Name: "example-distribution-point-max-smb",
ServerName: "servername",
Principal: false,
// If EnableLoadBalancing is true, BackupDistributionPointID needs to have the
// valid ID if another distribution point
EnableLoadBalancing: true,
BackupDistributionPointID: "108",
FileSharingConnectionType: "SMB",
HTTPSEnabled: true,
HTTPSPort: 443,
HTTPSSecurityType: "USERNAME_PASSWORD",
HTTPSContext: "context",
HTTPSUsername: "username",
HTTPSPassword: "password",
ShareName: "sharename",
Workgroup: "workgroup",
Port: 443,
ReadWriteUsername: "username",
ReadWritePassword: "password",
ReadOnlyUsername: "username",
ReadOnlyPassword: "password",
SSHUsername: "username",
SSHPassword: "password",
LocalPathToShare: "parf",
},
}

// Loop through the list and create each distribution point
for _, distributionPoint := range distributionPoints {
createDistributionPointandLog(client, distributionPoint)
}

}

func createDistributionPointandLog(client *jamfpro.Client, newDistributionPoint jamfpro.ResourceFileShareDistributionPoint) {
// Call CreateDistributionPoint function
createdDistributionPoint, err := client.CreateDistributionPoint(&newDistributionPoint)
if err != nil {
log.Fatalf("Error creating distribution point: %v", err)
log.Fatalf("Error creating distribution point: %v, %v", err, newDistributionPoint)
}

// Pretty print the newly created distribution point in XML
createdDistributionPointXML, err := xml.MarshalIndent(createdDistributionPoint, "", " ")
createdDistributionPointJSON, err := json.MarshalIndent(createdDistributionPoint, "", " ")
if err != nil {
log.Fatalf("Error marshaling created distribution point data: %v", err)
}
fmt.Println("Created Distribution Point:\n", string(createdDistributionPointXML))
fmt.Println("Created Distribution Point:\n", string(createdDistributionPointJSON))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
configFilePath := "/Users/work/Documents/clientconfig.json"

// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
Expand All @@ -18,7 +18,7 @@ func main() {
}

// ID of the distribution point to delete
distributionPointID := "1" // Replace with the actual ID
distributionPointID := "136" // Replace with the actual ID

// Call DeleteDistributionPointByID function
err = client.DeleteDistributionPointByID(distributionPointID)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"encoding/xml"
"encoding/json"
"fmt"
"log"

Expand All @@ -10,27 +10,29 @@ import (

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
configFilePath := "/Users/work/Documents/clientconfig.json"

// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}

// ID of the distribution point to fetch
distributionPointID := "1" // Replace with actual ID
// ID of the distribution point to delete
distributionPointID := "135" // Replace with the actual ID

// Call GetDistributionPointByID function
distributionPoint, err := client.GetDistributionPointByID(distributionPointID)
if err != nil {
log.Fatalf("Error fetching distribution point: %v", err)
}

// Pretty print the distribution point in XML
distributionPointXML, err := xml.MarshalIndent(distributionPoint, "", " ")
// Pretty print the newly created distribution point in XML
distributionPointJSON, err := json.MarshalIndent(distributionPoint, "", " ")
if err != nil {
log.Fatalf("Error marshaling distribution point data: %v", err)
log.Fatalf("Error marshaling created distribution point data: %v", err)
}
fmt.Println("Fetched Distribution Point:\n", string(distributionPointXML))
fmt.Println("Retrieved Distribution Point:\n", string(distributionPointJSON))

fmt.Println("Distribution Point retrieved successfully")
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"encoding/xml"
"encoding/json"
"fmt"
"log"

Expand All @@ -10,24 +10,26 @@ import (

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
configFilePath := "/Users/work/Documents/clientconfig.json"

// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}

// Call GetDistributionPoints function
distributionPoints, err := client.GetDistributionPoints()
// Call GetDistributionPointByID function
distributionPoint, err := client.GetDistributionPoints()
if err != nil {
log.Fatalf("Error fetching distribution points: %v", err)
log.Fatalf("Error fetching distribution point: %v", err)
}

// Pretty print the distribution points in XML
distributionPointsXML, err := xml.MarshalIndent(distributionPoints, "", " ") // Indent with 4 spaces
// Pretty print the newly created distribution point in XML
distributionPointJSON, err := json.MarshalIndent(distributionPoint, "", " ")
if err != nil {
log.Fatalf("Error marshaling distribution points data: %v", err)
log.Fatalf("Error marshaling created distribution point data: %v", err)
}
fmt.Println("Fetched Distribution Points:\n", string(distributionPointsXML))
fmt.Println("Retrieved Distribution Point:\n", string(distributionPointJSON))

fmt.Println("Distribution Point retrieved successfully")
}
Loading
Loading