Skip to content

Commit 68d14ca

Browse files
authored
Merge pull request #46 from deploymenttheory/dev
+ sdk coverage for licensed software
2 parents 8bfeaf3 + 2b1722b commit 68d14ca

File tree

12 files changed

+937
-200
lines changed

12 files changed

+937
-200
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,41 @@ This documentation outlines the API endpoints available for managing LDAP server
825825
- [x] ✅ **DELETE** `/JSSResource/ldapservers/name/{name}`
826826
`DeleteLDAPServerByName` deletes an LDAP server by its name.
827827
828+
### Jamf Pro Classic API - Licensed Software
829+
830+
This documentation outlines the API endpoints available for managing Licensed Software within Jamf Pro using the Classic API, which supports XML data structures.
831+
832+
## Endpoints
833+
834+
- [x] ✅ **GET** `/JSSResource/licensedsoftware`
835+
`GetLicensedSoftware` retrieves a serialized list of all Licensed Software.
836+
837+
- [x] ✅ **GET** `/JSSResource/licensedsoftware/id/{id}`
838+
`GetLicensedSoftwareByID` fetches details of a single Licensed Software item by its ID.
839+
840+
- [x] ✅ **GET** `/JSSResource/licensedsoftware/name/{name}`
841+
`GetLicensedSoftwareByName` retrieves details of a Licensed Software item by its name.
842+
843+
- [x] ✅ **POST** `/JSSResource/licensedsoftware/id/0`
844+
`CreateLicensedSoftware` creates a new Licensed Software item. The ID `0` in the endpoint indicates creation.
845+
846+
- [x] ✅ **PUT** `/JSSResource/licensedsoftware/id/{id}`
847+
`UpdateLicensedSoftwareByID` updates an existing Licensed Software item by its ID.
848+
849+
- [x] ✅ **PUT** `/JSSResource/licensedsoftware/name/{name}`
850+
`UpdateLicensedSoftwareByName` updates an existing Licensed Software item by its name.
851+
852+
- [x] ✅ **DELETE** `/JSSResource/licensedsoftware/id/{id}`
853+
`DeleteLicensedSoftwareByID` deletes a Licensed Software item by its ID.
854+
855+
- [x] ✅ **DELETE** `/JSSResource/licensedsoftware/name/{name}`
856+
`DeleteLicensedSoftwareByName` deletes a Licensed Software item by its name.
857+
828858
829859
## Progress Summary
830860
831-
- Total Endpoints: 276
832-
- Covered: 257
861+
- Total Endpoints: 284
862+
- Covered: 265
833863
- Not Covered: 19
834864
- Partially Covered: 0
835865
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
9+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
10+
)
11+
12+
func main() {
13+
// Define the path to the JSON configuration file
14+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Instantiate the default logger and set the desired log level
23+
logger := http_client.NewDefaultLogger()
24+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
25+
26+
// Configuration for the jamfpro
27+
config := jamfpro.Config{
28+
InstanceName: authConfig.InstanceName,
29+
LogLevel: logLevel,
30+
Logger: logger,
31+
ClientID: authConfig.ClientID,
32+
ClientSecret: authConfig.ClientSecret,
33+
}
34+
35+
// Create a new jamfpro client instance
36+
client, err := jamfpro.NewClient(config)
37+
if err != nil {
38+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
39+
}
40+
41+
// Define the licensed software details
42+
licensedSoftware := &jamfpro.ResponseLicensedSoftware{
43+
General: jamfpro.LicensedSoftwareGeneral{
44+
Name: "Adobe Creative Suite",
45+
Publisher: "Adobe Systems Incorporated",
46+
Platform: "Mac",
47+
SendEmailOnViolation: true,
48+
RemoveTitlesFromInventoryReports: false,
49+
ExcludeTitlesPurchasedFromAppStore: false,
50+
Notes: "string",
51+
Site: jamfpro.LicensedSoftwareSite{
52+
ID: -1,
53+
Name: "None",
54+
},
55+
},
56+
SoftwareDefinitions: []jamfpro.SoftwareDefinition{
57+
{
58+
CompareType: "like",
59+
Name: "string",
60+
Version: 14,
61+
},
62+
},
63+
FontDefinitions: []jamfpro.LicensedSoftwareFontDefinition{
64+
{
65+
CompareType: "like",
66+
Name: "string",
67+
Version: 14,
68+
},
69+
},
70+
PluginDefinitions: []jamfpro.LicensedSoftwarePluginDefinition{
71+
{
72+
CompareType: "like",
73+
Name: "string",
74+
Version: 14,
75+
},
76+
},
77+
Licenses: []jamfpro.LicensedSoftwareLicense{
78+
{
79+
Size: 1,
80+
License: jamfpro.LicenseDetail{
81+
SerialNumber1: "string",
82+
SerialNumber2: "string",
83+
OrganizationName: "string",
84+
RegisteredTo: "string",
85+
LicenseType: "Standard",
86+
LicenseCount: 500,
87+
Notes: "string",
88+
Purchasing: jamfpro.PurchasingDetail{
89+
IsPerpetual: true,
90+
IsAnnual: false,
91+
PONumber: "string",
92+
Vendor: "string",
93+
PurchasePrice: "string",
94+
PurchasingAccount: "string",
95+
PODate: "2017-07-07 18:37:04",
96+
LicenseExpires: "2017-07-07 18:37:04",
97+
LifeExpectancy: 0,
98+
PurchasingContact: "string",
99+
},
100+
Attachments: []jamfpro.LicensedSoftwareAttachment{
101+
{
102+
ID: 1,
103+
Filename: "icon.png",
104+
URI: "https://example.jamfcloud/attachment.html?id=1&o=r",
105+
},
106+
},
107+
},
108+
},
109+
},
110+
}
111+
112+
// Create the licensed software in Jamf Pro
113+
createdSoftware, err := client.CreateLicensedSoftware(licensedSoftware)
114+
if err != nil {
115+
log.Fatalf("Error creating licensed software: %v", err)
116+
}
117+
118+
// Pretty print the created software details
119+
createdSoftwareXML, err := xml.MarshalIndent(createdSoftware, "", " ")
120+
if err != nil {
121+
log.Fatalf("Error marshaling created software data: %v", err)
122+
}
123+
fmt.Println("Created Licensed Software:", string(createdSoftwareXML))
124+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
8+
)
9+
10+
func main() {
11+
// Define the path to the JSON configuration file
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
13+
14+
// Load the client OAuth credentials from the configuration file
15+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
18+
}
19+
20+
// Instantiate the default logger and set the desired log level
21+
logger := http_client.NewDefaultLogger()
22+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
23+
24+
// Configuration for the jamfpro
25+
config := jamfpro.Config{
26+
InstanceName: authConfig.InstanceName,
27+
LogLevel: logLevel,
28+
Logger: logger,
29+
ClientID: authConfig.ClientID,
30+
ClientSecret: authConfig.ClientSecret,
31+
}
32+
33+
// Create a new jamfpro client instance
34+
client, err := jamfpro.NewClient(config)
35+
if err != nil {
36+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
37+
}
38+
39+
licensedSoftwareID := 1 // Set your ID here
40+
41+
// Delete licensed software by ID
42+
err = client.DeleteLicensedSoftwareByID(licensedSoftwareID)
43+
if err != nil {
44+
log.Fatalf("Error deleting licensed software by ID: %v", err)
45+
}
46+
47+
log.Println("Licensed software deleted successfully by ID")
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
8+
)
9+
10+
func main() {
11+
// Define the path to the JSON configuration file
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
13+
14+
// Load the client OAuth credentials from the configuration file
15+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
18+
}
19+
20+
// Instantiate the default logger and set the desired log level
21+
logger := http_client.NewDefaultLogger()
22+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
23+
24+
// Configuration for the jamfpro
25+
config := jamfpro.Config{
26+
InstanceName: authConfig.InstanceName,
27+
LogLevel: logLevel,
28+
Logger: logger,
29+
ClientID: authConfig.ClientID,
30+
ClientSecret: authConfig.ClientSecret,
31+
}
32+
33+
// Create a new jamfpro client instance
34+
client, err := jamfpro.NewClient(config)
35+
if err != nil {
36+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
37+
}
38+
39+
licensedSoftwareName := "Adobe Creative Suite"
40+
41+
// Delete licensed software by name
42+
err = client.DeleteLicensedSoftwareByName(licensedSoftwareName)
43+
if err != nil {
44+
log.Fatalf("Error deleting licensed software by name: %v", err)
45+
}
46+
47+
log.Println("Licensed software deleted successfully by name")
48+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
9+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
10+
)
11+
12+
func main() {
13+
// Define the path to the JSON configuration file
14+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Instantiate the default logger and set the desired log level
23+
logger := http_client.NewDefaultLogger()
24+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
25+
26+
// Configuration for the jamfpro
27+
config := jamfpro.Config{
28+
InstanceName: authConfig.InstanceName,
29+
LogLevel: logLevel,
30+
Logger: logger,
31+
ClientID: authConfig.ClientID,
32+
ClientSecret: authConfig.ClientSecret,
33+
}
34+
35+
// Create a new jamfpro client instance
36+
client, err := jamfpro.NewClient(config)
37+
if err != nil {
38+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
39+
}
40+
41+
// Call the GetLicensedSoftware function
42+
licensedSoftware, err := client.GetLicensedSoftware()
43+
if err != nil {
44+
log.Fatalf("Error retrieving licensed software: %v", err)
45+
}
46+
47+
// Output the result
48+
softwareXML, err := xml.MarshalIndent(licensedSoftware, "", " ")
49+
if err != nil {
50+
log.Fatalf("Error marshaling licensed software data: %v", err)
51+
}
52+
fmt.Println("Licensed Software List:", string(softwareXML))
53+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
9+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
10+
)
11+
12+
func main() {
13+
// Define the path to the JSON configuration file
14+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Instantiate the default logger and set the desired log level
23+
logger := http_client.NewDefaultLogger()
24+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
25+
26+
// Configuration for the jamfpro
27+
config := jamfpro.Config{
28+
InstanceName: authConfig.InstanceName,
29+
LogLevel: logLevel,
30+
Logger: logger,
31+
ClientID: authConfig.ClientID,
32+
ClientSecret: authConfig.ClientSecret,
33+
}
34+
35+
// Create a new jamfpro client instance
36+
client, err := jamfpro.NewClient(config)
37+
if err != nil {
38+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
39+
}
40+
41+
// ID of the licensed software to fetch
42+
softwareID := 1 // Replace with actual ID
43+
44+
licensedSoftware, err := client.GetLicensedSoftwareByID(softwareID)
45+
if err != nil {
46+
log.Fatalf("Failed to get licensed software by ID: %v", err)
47+
}
48+
49+
// Pretty print the created software details
50+
createdSoftwareXML, err := xml.MarshalIndent(licensedSoftware, "", " ")
51+
if err != nil {
52+
log.Fatalf("Error marshaling created software data: %v", err)
53+
}
54+
fmt.Println("Created Licensed Software:", string(createdSoftwareXML))
55+
}

0 commit comments

Comments
 (0)