-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathclient_impl.go
99 lines (84 loc) · 2.17 KB
/
client_impl.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package gonextcloud
import (
"net/url"
req "github.com/levigross/grequests"
"gitlab.bertha.cloud/adphi/gowebdav"
)
// client is the API client that performs all operations against a Nextcloud server.
type client struct {
baseURL *url.URL
username string
password string
session *req.Session
headers map[string]string
capabilities *Capabilities
version *Version
apps *apps
appsConfig *appsConfig
groupFolders *groupFolders
notifications *notifications
shares *shares
users *users
groups *groups
webdav *webDav
}
// newClient create a new client from the Nextcloud Instance URL
func newClient(hostname string) (*client, error) {
baseURL, err := url.ParseRequestURI(hostname)
if err != nil {
baseURL, err = url.ParseRequestURI("https://" + hostname)
if err != nil {
return nil, err
}
}
c := &client{
baseURL: baseURL,
headers: map[string]string{
"OCS-APIREQUEST": "true",
"Accept": "application/json",
},
}
c.apps = &apps{c}
c.appsConfig = &appsConfig{c}
c.groupFolders = &groupFolders{c}
c.notifications = ¬ifications{c}
c.shares = &shares{c}
c.users = &users{c}
c.groups = &groups{c}
// Create empty webdav client
// It will be replaced after login
c.webdav = &webDav{Client: &gowebdav.Client{}}
return c, nil
}
// apps return the apps client Interface
func (c *client) Apps() Apps {
return c.apps
}
// appsConfig return the appsConfig client Interface
func (c *client) AppsConfig() AppsConfig {
return c.appsConfig
}
// groupFolders return the groupFolders client Interface
func (c *client) GroupFolders() GroupFolders {
return c.groupFolders
}
// notifications return the notifications client Interface
func (c *client) Notifications() Notifications {
return c.notifications
}
// shares return the shares client Interface
func (c *client) Shares() Shares {
return c.shares
}
// users return the users client Interface
func (c *client) Users() Users {
return c.users
}
// groups return the groups client Interface
func (c *client) Groups() Groups {
return c.groups
}
// WebDav return the WebDav client Interface
func (c *client) WebDav() WebDav {
return c.webdav
}