/
client.go
65 lines (50 loc) · 1.38 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Referred https://github.com/google/go-github
// BSD-3-Clause https://github.com/google/go-github/blob/master/LICENSE
package jamfproapi
import (
"fmt"
"net/url"
"path"
"github.com/kenchan0130/go-jamf-pro/jamf"
)
type service struct {
client *Client
}
type services struct {
APIAuthentication *APIAuthenticationService
Categories *CategoriesService
Icon *IconService
Scripts *ScriptsService
SSOFailover *SSOFailoverService
}
type Client struct {
*jamf.BaseClient
common service
services
}
type ListOptions struct {
Page *int `url:"page,omitempty"`
PageSize *int `url:"page-size,omitempty"`
Sort *[]string `url:"sort,omitempty" del:","`
Filter *string `url:"filter,omitempty"`
}
const apiEndpointPath = "/api"
func NewClient(serverURL string) (*Client, error) {
u, err := url.Parse(serverURL)
if err != nil {
return nil, fmt.Errorf("url.Parse(): %v", err)
}
u.Path = path.Join(u.Path, apiEndpointPath)
client := jamf.NewBaseClient(u)
client.DefaultContentType = "application/json; charset=utf-8"
c := &Client{
BaseClient: client,
}
c.common.client = c
c.APIAuthentication = (*APIAuthenticationService)(&c.common)
c.Categories = (*CategoriesService)(&c.common)
c.Icon = (*IconService)(&c.common)
c.Scripts = (*ScriptsService)(&c.common)
c.SSOFailover = (*SSOFailoverService)(&c.common)
return c, nil
}