Skip to content

Commit f5290e3

Browse files
authored
Merge pull request #448 from deploymenttheory/dev-jl-testing
Icons test implementation, classicapi_policies.go amended for bugfixes in provider
2 parents d0685d1 + 7522194 commit f5290e3

File tree

6 files changed

+74
-160
lines changed

6 files changed

+74
-160
lines changed

examples/icon/UploadIcon/UploadIcon.go

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,53 @@ package main
33
import (
44
"fmt"
55
"log"
6+
"net/http"
7+
"os"
8+
"time"
69

10+
"github.com/deploymenttheory/go-api-http-client-integrations/jamf/jamfprointegration"
11+
"github.com/deploymenttheory/go-api-http-client/httpclient"
712
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
13+
"go.uber.org/zap"
814
)
915

1016
func main() {
11-
// Define the path to the JSON configuration file
12-
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
17+
logger, _ := zap.NewDevelopment()
18+
clientIntegration, _ := jamfprointegration.BuildWithOAuth(
19+
"https://lbgsandbox.jamfcloud.com",
20+
logger.Sugar(),
21+
5*time.Second,
22+
os.Getenv("CLIENT_ID"),
23+
os.Getenv("CLIENT_SECRET"),
24+
false,
25+
&httpclient.ProdExecutor{Client: &http.Client{}},
26+
)
27+
clientConfig := httpclient.ClientConfig{
28+
Integration: clientIntegration,
29+
Sugar: logger.Sugar(),
30+
PopulateDefaultValues: true,
31+
HideSensitiveData: false,
32+
MaxRetryAttempts: 5,
33+
HTTPExecutor: &httpclient.ProdExecutor{Client: &http.Client{}},
34+
}
35+
36+
libClient, err := clientConfig.Build()
1337

14-
// Initialize the Jamf Pro client with the HTTP client configuration
15-
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
1638
if err != nil {
17-
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
39+
fmt.Printf("error: %v", err)
1840
}
1941

20-
// Path to the icon file you want to upload
21-
filePath := []string{
22-
"/Users/dafyddwatkins/localtesting/terraform/support_files/icons/Icon_macOS.svg.png",
23-
}
42+
client := jamfpro.Client{HTTP: libClient}
43+
44+
// Client done
45+
46+
filePath := "/Users/joseph/github/go-api-sdk-jamfpro/examples/icon/UploadIcon/cat.png"
2447

25-
// Call the UploadIcon function
2648
uploadResponse, err := client.UploadIcon(filePath)
2749
if err != nil {
2850
fmt.Printf("Error uploading icon: %s\n", err)
2951
return
3052
}
3153

32-
// Print out the response from the server
33-
fmt.Printf("Icon uploaded successfully!\nURL: %s\nID: %d\n", uploadResponse.URL, uploadResponse.ID)
54+
log.Println(uploadResponse)
3455
}

examples/icon/UploadIcon/cat.png

12.1 KB
Loading

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.22.4
44

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

1111
require (
@@ -33,7 +33,8 @@ require (
3333
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect
3434
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect
3535
github.com/aws/smithy-go v1.20.3 // indirect
36-
golang.org/x/text v0.16.0 // indirect
36+
github.com/jmespath/go-jmespath v0.4.0 // indirect
37+
golang.org/x/text v0.17.0 // indirect
3738
)
3839

3940
require (
@@ -43,6 +44,6 @@ require (
4344
github.com/google/uuid v1.6.0 // indirect
4445
go.uber.org/multierr v1.11.0 // indirect
4546
go.uber.org/zap v1.27.0
46-
golang.org/x/net v0.26.0 // indirect
47+
golang.org/x/net v0.28.0 // indirect
4748

4849
)

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=
4242
github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
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.10 h1:rV9IEqt3R6LDm+OVNoMLeuouuw615licr3ULaHEFa2s=
46-
github.com/deploymenttheory/go-api-http-client v0.2.10/go.mod h1:LKDnBcieS6CyikZjTKPpziVdxnTwzBHE6Hx1cuWRcuU=
47-
github.com/deploymenttheory/go-api-http-client-integrations v0.0.10 h1:mqwtrYme4xqvDsP57rSaK56te6MHQ/nYsljdfm2WbX4=
48-
github.com/deploymenttheory/go-api-http-client-integrations v0.0.10/go.mod h1:oZAXBOpuXwdZodSWZzT4XhXXvwW6I2LylhSF46Ruk20=
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=
47+
github.com/deploymenttheory/go-api-http-client-integrations v0.0.11 h1:1jRrAeD6iGXw7DDccoYTre0XS9bVbCAk3lmFCO43Z28=
48+
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=
5050
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
5151
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -71,8 +71,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
7171
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
7272
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
7373
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
74-
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
75-
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
74+
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
75+
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
7676
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7777
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7878
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -88,8 +88,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8888
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
8989
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
9090
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
91-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
92-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
91+
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
92+
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
9393
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9494
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
9595
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

sdk/jamfpro/classicapi_policies.go

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ type ResponsePolicyCreateAndUpdate struct {
3737

3838
// ResourcePolicy represents the response structure for a single policy
3939
type ResourcePolicy struct {
40-
General PolicySubsetGeneral `xml:"general"`
41-
Scope *PolicySubsetScope `xml:"scope,omitempty"`
42-
SelfService *PolicySubsetSelfService `xml:"self_service,omitempty"`
43-
PackageConfiguration *PolicySubsetPackageConfiguration `xml:"package_configuration,omitempty"`
44-
Scripts *[]PolicySubsetScript `xml:"scripts>script,omitempty"`
45-
Printers *PolicySubsetPrinters `xml:"printers,omitempty"`
46-
DockItems *PolicySubsetDockItems `xml:"dock_items,omitempty"`
47-
AccountMaintenance *PolicySubsetAccountMaintenance `xml:"account_maintenance,omitempty"`
48-
Maintenance *PolicySubsetMaintenance `xml:"maintenance,omitempty"`
49-
FilesProcesses *PolicySubsetFilesProcesses `xml:"files_processes,omitempty"`
50-
UserInteraction *PolicySubsetUserInteraction `xml:"user_interaction,omitempty"`
51-
DiskEncryption *PolicySubsetDiskEncryption `xml:"disk_encryption,omitempty"`
52-
Reboot *PolicySubsetReboot `xml:"reboot,omitempty"`
40+
General PolicySubsetGeneral `xml:"general"` // Required
41+
Scope PolicySubsetScope `xml:"scope,omitempty"` // Required? Come back to later
42+
SelfService PolicySubsetSelfService `xml:"self_service,omitempty"` // Not required but also not listable
43+
PackageConfiguration PolicySubsetPackageConfiguration `xml:"package_configuration"` // List inside
44+
Scripts []PolicySubsetScript `xml:"scripts>script"` // Done
45+
Printers PolicySubsetPrinters `xml:"printers"` // List Inside
46+
DockItems []PolicySubsetDockItem `xml:"dock_items>dock_item"` // Done
47+
AccountMaintenance PolicySubsetAccountMaintenance `xml:"account_maintenance,omitempty"` // Come back to
48+
Maintenance PolicySubsetMaintenance `xml:"maintenance"` // Only one
49+
FilesProcesses PolicySubsetFilesProcesses `xml:"files_processes,omitempty"` // Only one
50+
UserInteraction PolicySubsetUserInteraction `xml:"user_interaction,omitempty"` // Only one
51+
DiskEncryption PolicySubsetDiskEncryption `xml:"disk_encryption,omitempty"` // Only one
52+
Reboot PolicySubsetReboot `xml:"reboot,omitempty"` // Only One
5353
}
5454

5555
// Subsets & Containers
@@ -154,19 +154,19 @@ type PolicySubsetScopeExclusions struct {
154154

155155
// PolicySubsetSelfService represents the self service settings of a policy
156156
type PolicySubsetSelfService struct {
157-
UseForSelfService bool `xml:"use_for_self_service"`
158-
SelfServiceDisplayName string `xml:"self_service_display_name"`
159-
InstallButtonText string `xml:"install_button_text"`
160-
ReinstallButtonText string `xml:"re_install_button_text"`
161-
SelfServiceDescription string `xml:"self_service_description"`
162-
ForceUsersToViewDescription bool `xml:"force_users_to_view_description"`
163-
SelfServiceIcon *SharedResourceSelfServiceIcon `xml:"self_service_icon"`
164-
FeatureOnMainPage bool `xml:"feature_on_main_page"`
165-
SelfServiceCategories *[]PolicySubsetSelfServiceCategory `xml:"self_service_categories>category"`
166-
Notification bool `xml:"notification"`
167-
NotificationType string `xml:"notification_type"`
168-
NotificationSubject string `xml:"notification_subject"`
169-
NotificationMessage string `xml:"notification_message"`
157+
UseForSelfService bool `xml:"use_for_self_service"`
158+
SelfServiceDisplayName string `xml:"self_service_display_name"`
159+
InstallButtonText string `xml:"install_button_text"`
160+
ReinstallButtonText string `xml:"re_install_button_text"`
161+
SelfServiceDescription string `xml:"self_service_description"`
162+
ForceUsersToViewDescription bool `xml:"force_users_to_view_description"`
163+
SelfServiceIcon *SharedResourceSelfServiceIcon `xml:"self_service_icon"`
164+
FeatureOnMainPage bool `xml:"feature_on_main_page"`
165+
SelfServiceCategories []PolicySubsetSelfServiceCategory `xml:"self_service_categories>category"`
166+
Notification bool `xml:"notification"`
167+
NotificationType string `xml:"notification_type"`
168+
NotificationSubject string `xml:"notification_subject"`
169+
NotificationMessage string `xml:"notification_message"`
170170
}
171171

172172
// Package Configuration
@@ -206,9 +206,8 @@ type PolicySubsetScript struct {
206206

207207
// PolicySubsetPrinters represents the printers settings of a policy
208208
type PolicySubsetPrinters struct {
209-
// Size int `xml:"size"`
210-
LeaveExistingDefault bool `xml:"leave_existing_default"`
211-
Printer *[]PolicySubsetPrinter `xml:"printer"`
209+
LeaveExistingDefault bool `xml:"leave_existing_default"`
210+
Printer []PolicySubsetPrinter `xml:"printer"`
212211
}
213212

214213
type PolicySubsetPrinter struct {
@@ -220,12 +219,6 @@ type PolicySubsetPrinter struct {
220219

221220
// Dock Items
222221

223-
// PolicySubsetDockItems represents the dock items settings of a policy
224-
type PolicySubsetDockItems struct {
225-
// Size int `xml:"size"`
226-
DockItem *[]PolicySubsetDockItem `xml:"dock_item"`
227-
}
228-
229222
type PolicySubsetDockItem struct {
230223
ID int `xml:"id"`
231224
Name string `xml:"name"`

sdk/jamfpro/jamfproapi_icon.go

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)