Skip to content

Commit aa4b801

Browse files
committed
chore: Update go-api-http-client dependency to v0.2.12
1 parent 6fe3541 commit aa4b801

File tree

5 files changed

+108
-10
lines changed

5 files changed

+108
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
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/localtesting/jamfpro/clientconfig.json"
13+
14+
// Initialize the Jamf Pro client with the HTTP client configuration
15+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
18+
}
19+
20+
// Accept the terms and conditions
21+
err = client.AcceptJamfAppCatalogAppInstallerTermsAndConditions()
22+
if err != nil {
23+
log.Fatalf("Error: %v", err)
24+
}
25+
26+
fmt.Println("Successfully accepted Jamf App Catalog App Installer terms and conditions.")
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file
13+
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
14+
15+
// Initialize the Jamf Pro client with the HTTP client configuration
16+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
19+
}
20+
21+
// Fetch t&c status
22+
status, err := client.GetJamfAppCatalogAppInstallerTermsAndConditionsStatus()
23+
if err != nil {
24+
log.Fatalf("Error fetching Terms And Conditions Status: %v", err)
25+
}
26+
27+
// Pretty print the fetched Terms And Conditions Status using JSON marshaling
28+
statusJSON, err := json.MarshalIndent(status, "", " ") // Indent with 4 spaces
29+
if err != nil {
30+
log.Fatalf("Error marshaling Terms And Conditions Status data: %v", err)
31+
}
32+
fmt.Println("Fetched Terms And Conditions Status:", string(statusJSON))
33+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.4
44

55
// Deploymenttheory
66
require (
7-
github.com/deploymenttheory/go-api-http-client v0.2.11
7+
github.com/deploymenttheory/go-api-http-client v0.2.12
88
github.com/deploymenttheory/go-api-http-client-integrations v0.0.11
99
)
1010

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4=
4242
github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
4343
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4444
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
45-
github.com/deploymenttheory/go-api-http-client v0.2.11 h1:hEVxXX60cUxRqKkJBHADC/S91+iCPYdBIwkT6stexTY=
46-
github.com/deploymenttheory/go-api-http-client v0.2.11/go.mod h1:LKDnBcieS6CyikZjTKPpziVdxnTwzBHE6Hx1cuWRcuU=
45+
github.com/deploymenttheory/go-api-http-client v0.2.12 h1:ZPnxbF9/S3EBTx8aFzRcofyChT/+AXmRm4xnyoCNK+0=
46+
github.com/deploymenttheory/go-api-http-client v0.2.12/go.mod h1:LKDnBcieS6CyikZjTKPpziVdxnTwzBHE6Hx1cuWRcuU=
4747
github.com/deploymenttheory/go-api-http-client-integrations v0.0.11 h1:1jRrAeD6iGXw7DDccoYTre0XS9bVbCAk3lmFCO43Z28=
4848
github.com/deploymenttheory/go-api-http-client-integrations v0.0.11/go.mod h1:FQPNu+QaAyq9XWSjItJo82ABvkiGwdOlt73Qm6vp3MU=
4949
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=

sdk/jamfpro/jamfproapi_app_installers.go

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ type ResponseJamfAppCatalogDeploymentCreateAndUpdate struct {
2828
Href string `json:"href"`
2929
}
3030

31+
type ResponseJamfAppCatalogDeploymentTermsAndConditionsStatus struct {
32+
Accepted bool `json:"accepted"`
33+
AcceptanceTime string `json:"acceptanceTime"`
34+
}
35+
3136
// Resource
3237

3338
type ResourceJamfAppCatalogAppInstaller struct {
@@ -61,13 +66,12 @@ type JamfAppCatalogAppInstallerSubsetMediaSource struct {
6166

6267
// Struct which represents AppInstallers object JSON from Pro API
6368
type ResourceJamfAppCatalogDeployment struct {
64-
ID string `json:"id"`
65-
Name string `json:"name,omitempty"`
66-
Enabled *bool `json:"enabled"`
67-
AppTitleId string `json:"appTitleId,omitempty"`
68-
DeploymentType string `json:"deploymentType,omitempty"`
69-
UpdateBehavior string `json:"updateBehavior,omitempty"`
70-
// TODO why is this not the object?
69+
ID string `json:"id"`
70+
Name string `json:"name,omitempty"`
71+
Enabled *bool `json:"enabled"`
72+
AppTitleId string `json:"appTitleId,omitempty"`
73+
DeploymentType string `json:"deploymentType,omitempty"`
74+
UpdateBehavior string `json:"updateBehavior,omitempty"`
7175
CategoryId string `json:"categoryId,omitempty"`
7276
SiteId string `json:"siteId,omitempty"`
7377
SmartGroupId string `json:"smartGroupId,omitempty"`
@@ -110,6 +114,40 @@ type JamfAppCatalogDeploymentSubsetCategory struct {
110114

111115
// CRUD
112116

117+
// GetJamfAppCatalogAppInstallerTermsAndConditionsStatus returns the terms and conditions status for the Jamf App Catalog
118+
func (c *Client) GetJamfAppCatalogAppInstallerTermsAndConditionsStatus() (*ResponseJamfAppCatalogDeploymentTermsAndConditionsStatus, error) {
119+
endpoint := fmt.Sprintf("%s/terms-and-conditions", uriJamfAppCatalogAppInstaller)
120+
121+
var globalSettings ResponseJamfAppCatalogDeploymentTermsAndConditionsStatus
122+
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &globalSettings)
123+
if err != nil {
124+
return nil, fmt.Errorf(errMsgFailedGet, "printers", err)
125+
}
126+
127+
if resp != nil && resp.Body != nil {
128+
defer resp.Body.Close()
129+
}
130+
131+
return &globalSettings, nil
132+
}
133+
134+
// AcceptJamfAppCatalogAppInstallerTermsAndConditions accepts the terms and conditions for the Jamf App Catalog
135+
// This is required on an account by account basis.
136+
func (c *Client) AcceptJamfAppCatalogAppInstallerTermsAndConditions() error {
137+
endpoint := fmt.Sprintf("%s/terms-and-conditions", uriJamfAppCatalogAppInstaller)
138+
139+
resp, err := c.HTTP.DoRequest("POST", endpoint, nil, nil)
140+
if err != nil {
141+
return fmt.Errorf("failed to accept terms and conditions: %v", err)
142+
}
143+
144+
if resp != nil && resp.Body != nil {
145+
defer resp.Body.Close()
146+
}
147+
148+
return nil
149+
}
150+
113151
// Gets full list of Get Jamf App Catalog App Installer Titles & handles pagination
114152
func (c *Client) GetJamfAppCatalogAppInstallerTitles(sort_filter string) (*ResponseJamfAppCatalogTitleList, error) {
115153
resp, err := c.DoPaginatedGet(

0 commit comments

Comments
 (0)