README.md 21.4 KB
Newer Older
Adphi's avatar
Adphi committed
1
![Nextcloud](https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Nextcloud_Logo.svg/640px-Nextcloud_Logo.svg.png)
Philippe-Adrien Nousse's avatar
Philippe-Adrien Nousse committed
2

Adphi's avatar
Adphi committed
3
4
[![pipeline status](https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud/badges/master/pipeline.svg)](https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud/commits/master)
[![coverage report](https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud/badges/master/coverage.svg)](https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud/commits/master)
Adphi's avatar
Adphi committed
5
6
[![Go Report Card](https://goreportcard.com/badge/gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud)](https://goreportcard.com/report/gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud)
[![GoDoc](https://godoc.org/gitlab.com/gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud?status.svg)](https://godoc.org/gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud)
Philippe-Adrien Nousse's avatar
Philippe-Adrien Nousse committed
7
8
9
# GoNextcloud

A simple Client for Nextcloud's Provisioning API in Go.
10

Adphi's avatar
Adphi committed
11
12
13
14
For more information about the Provisioning API, see the documentation:
https://docs.nextcloud.com/server/13/admin_manual/configuration_user/user_provisioning_api.html

## Usage
15

Philippe-Adrien Nousse's avatar
Philippe-Adrien Nousse committed
16
```go
Adphi's avatar
Adphi committed
17
import "gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud"
Philippe-Adrien Nousse's avatar
Philippe-Adrien Nousse committed
18
```
19

Adphi's avatar
Adphi committed
20
You use the library by creating a client object and calling methods on it.
21

Adphi's avatar
Adphi committed
22
For example, to list all the Nextcloud's instance users:
23
```go
Adphi's avatar
Adphi committed
24
25
26
27
package main

import (
    "fmt"
Adphi's avatar
Adphi committed
28
    "gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud"
Adphi's avatar
Adphi committed
29
30
31
32
33
34
)

func main() {
    url := "https://www.mynextcloud.com"
    username := "admin"
    password := "password"
Adphi's avatar
Adphi committed
35
    c, err := gonextcloud.NewClient(url)
Adphi's avatar
Adphi committed
36
37
    if err != nil {
        panic(err)
Adphi's avatar
Adphi committed
38
    }
Adphi's avatar
Adphi committed
39
40
41
42
43
    if err := c.Login(username, password); err != nil {
        panic(err)
    }
    defer c.Logout()

Adphi's avatar
Adphi committed
44
    users, err := c.Users().List()
Adphi's avatar
Adphi committed
45
46
47
48
49
    if err != nil {
        panic(err)
    }
    fmt.Println("Users :", users)
}
50
```
Adphi's avatar
Adphi committed
51

52
53
54
55
56
57
58
## Run tests
Configure the tests for your instance by editing [example.config.yml](example.config.yml) and renaming it config.yml

then run the tests :
```bash
$ go test -v .
```
Adphi's avatar
Adphi committed
59
60
61
62
63
64

## Docs

#### type Client

```go
65
66
67
68
69
70
71
72
73
74
75
76
type Client interface {
	Apps() Apps
	AppsConfig() AppsConfig
	GroupFolders() GroupFolders
	Notifications() Notifications
	Shares() Shares
	Users() Users
	Groups() Groups
	WebDav() WebDav
	Monitoring() (*Monitoring, error)
	Login(username string, password string) error
	Logout() error
Adphi's avatar
Adphi committed
77
78
79
}
```

80
Client is the main client interface
Adphi's avatar
Adphi committed
81
82
83
84

#### func  NewClient

```go
85
func NewClient(hostname string) (Client, error)
Adphi's avatar
Adphi committed
86
```
87
NewClient create a new client
Adphi's avatar
Adphi committed
88

89
#### ShareType and SharePermission
Adphi's avatar
Adphi committed
90
91

```go
92
93
94
95
96
const (
	UserShare           ShareType = 0
	GroupShare          ShareType = 1
	PublicLinkShare     ShareType = 3
	FederatedCloudShare ShareType = 6
Adphi's avatar
Adphi committed
97

98
99
100
101
102
103
104
	ReadPermission    SharePermission = 1
	UpdatePermission  SharePermission = 2
	CreatePermission  SharePermission = 4
	DeletePermission  SharePermission = 8
	ReSharePermission SharePermission = 16
	AllPermissions    SharePermission = 31
)
Adphi's avatar
Adphi committed
105
106
```

107
#### type APIError
Adphi's avatar
Adphi committed
108
109

```go
110
111
112
type APIError struct {
	Code    int
	Message string
Adphi's avatar
Adphi committed
113
114
115
}
```

116
APIError contains the returned error code and message from the Nextcloud's API
Adphi's avatar
Adphi committed
117

118
#### func (*APIError) Error
Adphi's avatar
Adphi committed
119
120

```go
121
func (e *APIError) Error() string
Adphi's avatar
Adphi committed
122
```
123
Error return the types.APIError string
Adphi's avatar
Adphi committed
124

125
#### type ActiveUsers
Adphi's avatar
Adphi committed
126
127

```go
128
129
130
131
type ActiveUsers struct {
	Last5Minutes int `json:"last5minutes"`
	Last1Hour    int `json:"last1hour"`
	Last24Hours  int `json:"last24hours"`
Adphi's avatar
Adphi committed
132
133
134
135
}
```


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#### type App

```go
type App struct {
	ID            string   `json:"id"`
	Ocsid         string   `json:"ocsid"`
	Name          string   `json:"name"`
	Summary       string   `json:"summary"`
	Description   string   `json:"description"`
	Licence       string   `json:"licence"`
	Author        string   `json:"author"`
	Version       string   `json:"version"`
	Namespace     string   `json:"namespace"`
	Types         []string `json:"types"`
	Documentation struct {
		Admin     string `json:"admin"`
		Developer string `json:"developer"`
		User      string `json:"user"`
	} `json:"documentation"`
	Category   []string `json:"category"`
	Website    string   `json:"website"`
	Bugs       string   `json:"bugs"`
	Repository struct {
		Attributes struct {
			Type string `json:"type"`
		} `json:"@attributes"`
		Value string `json:"@value"`
	} `json:"repository"`
	Screenshot   []interface{} `json:"screenshot"`
	Dependencies struct {
		Owncloud struct {
			Attributes struct {
				MinVersion string `json:"min-version"`
				MaxVersion string `json:"max-version"`
			} `json:"@attributes"`
		} `json:"owncloud"`
		Nextcloud struct {
			Attributes struct {
				MinVersion string `json:"min-version"`
				MaxVersion string `json:"max-version"`
			} `json:"@attributes"`
		} `json:"nextcloud"`
	} `json:"dependencies"`
	Settings struct {
		Admin           []string      `json:"admin"`
		AdminSection    []string      `json:"admin-section"`
		Personal        []interface{} `json:"personal"`
		PersonalSection []interface{} `json:"personal-section"`
	} `json:"settings"`
	Info        []interface{} `json:"info"`
	Remote      []interface{} `json:"remote"`
	Public      []interface{} `json:"public"`
	RepairSteps struct {
		Install       []interface{} `json:"install"`
		PreMigration  []interface{} `json:"pre-migration"`
		PostMigration []interface{} `json:"post-migration"`
		LiveMigration []interface{} `json:"live-migration"`
		Uninstall     []interface{} `json:"uninstall"`
	} `json:"repair-steps"`
	BackgroundJobs     []interface{} `json:"background-jobs"`
	TwoFactorProviders []interface{} `json:"two-factor-providers"`
	Commands           []interface{} `json:"commands"`
	Activity           struct {
		Filters   []interface{} `json:"filters"`
		Settings  []interface{} `json:"settings"`
		Providers []interface{} `json:"providers"`
	} `json:"activity"`
}
Adphi's avatar
Adphi committed
204
205
```

206
App
Adphi's avatar
Adphi committed
207

208
#### type Apps
Adphi's avatar
Adphi committed
209
210

```go
211
212
213
214
215
216
217
218
type Apps interface {
	List() ([]string, error)
	ListEnabled() ([]string, error)
	ListDisabled() ([]string, error)
	Infos(name string) (App, error)
	Enable(name string) error
	Disable(name string) error
}
Adphi's avatar
Adphi committed
219
220
```

221
Apps available methods
Adphi's avatar
Adphi committed
222

223
#### type AppsConfig
Adphi's avatar
Adphi committed
224
225

```go
226
type AppsConfig interface {
Adphi's avatar
Adphi committed
227
228
229
230
231
232
233
234
235
236
	List() (apps []string, err error)
	Keys(id string) (keys []string, err error)
	Value(id, key string) (string, error)
	SetValue(id, key, value string) error
	DeleteValue(id, key, value string) error
	Get() (map[string]map[string]string, error)
	Details(appID string) (map[string]string, error)
}
```

237
AppsConfig available methods
Adphi's avatar
Adphi committed
238

239
#### type Auth
Adphi's avatar
Adphi committed
240
241

```go
242
243
244
type Auth interface {
	Login(username string, password string) error
	Logout() error
Adphi's avatar
Adphi committed
245
246
247
248
}
```


249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#### type Capabilities

```go
type Capabilities struct {
	Core struct {
		Pollinterval int    `json:"pollinterval"`
		WebdavRoot   string `json:"webdav-root"`
	} `json:"core"`
	Bruteforce struct {
		Delay int `json:"delay"`
	} `json:"bruteforce"`
	Activity struct {
		Apiv2 []string `json:"apiv2"`
	} `json:"activity"`
	Ocm struct {
		Enabled    bool   `json:"enabled"`
		APIVersion string `json:"apiVersion"`
		EndPoint   string `json:"endPoint"`
		ShareTypes []struct {
			Name      string `json:"name"`
			Protocols struct {
				Webdav string `json:"webdav"`
			} `json:"protocols"`
		} `json:"shareTypes"`
	} `json:"ocm"`
	Dav struct {
		Chunking string `json:"chunking"`
	} `json:"dav"`
	FilesSharing struct {
		APIEnabled bool `json:"api_enabled"`
		Public     struct {
			Enabled  bool `json:"enabled"`
			Password struct {
				Enforced bool `json:"enforced"`
			} `json:"password"`
			ExpireDate struct {
				Enabled bool `json:"enabled"`
			} `json:"expire_date"`
			SendMail        bool `json:"send_mail"`
			Upload          bool `json:"upload"`
			UploadFilesDrop bool `json:"upload_files_drop"`
		} `json:"public"`
		Resharing bool `json:"resharing"`
		User      struct {
			SendMail   bool `json:"send_mail"`
			ExpireDate struct {
				Enabled bool `json:"enabled"`
			} `json:"expire_date"`
		} `json:"user"`
		GroupSharing bool `json:"group_sharing"`
		Group        struct {
			Enabled    bool `json:"enabled"`
			ExpireDate struct {
				Enabled bool `json:"enabled"`
			} `json:"expire_date"`
		} `json:"group"`
		DefaultPermissions int `json:"default_permissions"`
		Federation         struct {
			Outgoing   bool `json:"outgoing"`
			Incoming   bool `json:"incoming"`
			ExpireDate struct {
				Enabled bool `json:"enabled"`
			} `json:"expire_date"`
		} `json:"federation"`
		Sharebymail struct {
			Enabled         bool `json:"enabled"`
			UploadFilesDrop struct {
				Enabled bool `json:"enabled"`
			} `json:"upload_files_drop"`
			Password struct {
				Enabled bool `json:"enabled"`
			} `json:"password"`
			ExpireDate struct {
				Enabled bool `json:"enabled"`
			} `json:"expire_date"`
		} `json:"sharebymail"`
	} `json:"files_sharing"`
	Notifications struct {
		OcsEndpoints       []string `json:"ocs-endpoints"`
		Push               []string `json:"push"`
		AdminNotifications []string `json:"admin-notifications"`
	} `json:"notifications"`
	PasswordPolicy struct {
		MinLength                int  `json:"minLength"`
		EnforceNonCommonPassword bool `json:"enforceNonCommonPassword"`
		EnforceNumericCharacters bool `json:"enforceNumericCharacters"`
		EnforceSpecialCharacters bool `json:"enforceSpecialCharacters"`
		EnforceUpperLowerCase    bool `json:"enforceUpperLowerCase"`
	} `json:"password_policy"`
	Theming struct {
		Name              string `json:"name"`
		URL               string `json:"url"`
		Slogan            string `json:"slogan"`
		Color             string `json:"color"`
		ColorText         string `json:"color-text"`
		ColorElement      string `json:"color-element"`
		Logo              string `json:"logo"`
		Background        string `json:"background"`
		BackgroundPlain   bool   `json:"background-plain"`
		BackgroundDefault bool   `json:"background-default"`
	} `json:"theming"`
	Files struct {
		Bigfilechunking  bool     `json:"bigfilechunking"`
		BlacklistedFiles []string `json:"blacklisted_files"`
		Undelete         bool     `json:"undelete"`
		Versioning       bool     `json:"versioning"`
	} `json:"files"`
	Registration struct {
		Enabled  bool   `json:"enabled"`
		APIRoot  string `json:"apiRoot"`
		APILevel string `json:"apiLevel"`
	} `json:"registration"`
Adphi's avatar
Adphi committed
361
362
363
}
```

364
Capabilities
Adphi's avatar
Adphi committed
365
366
367



368
#### type Group
Adphi's avatar
Adphi committed
369
370

```go
371
372
373
374
375
376
377
378
type Group struct {
	ID          string `json:"id"`
	Displayname string `json:"displayname"`
	UserCount   int    `json:"usercount"`
	Disabled    int    `json:"disabled"`
	CanAdd      bool   `json:"canAdd"`
	CanRemove   bool   `json:"canRemove"`
}
Adphi's avatar
Adphi committed
379
380
```

381
Group
Adphi's avatar
Adphi committed
382

383
#### type GroupFolder
Adphi's avatar
Adphi committed
384
385

```go
386
387
388
389
390
391
392
type GroupFolder struct {
	ID         int                        `json:"id"`
	MountPoint string                     `json:"mount_point"`
	Groups     map[string]SharePermission `json:"groups"`
	Quota      int                        `json:"quota"`
	Size       int                        `json:"size"`
}
Adphi's avatar
Adphi committed
393
394
395
```


396
#### type GroupFolders
Adphi's avatar
Adphi committed
397
398

```go
399
400
401
type GroupFolders interface {
	List() (map[int]GroupFolder, error)
	Get(id int) (GroupFolder, error)
Adphi's avatar
Adphi committed
402
403
404
405
	Create(name string) (id int, err error)
	Rename(groupID int, name string) error
	AddGroup(folderID int, groupName string) error
	RemoveGroup(folderID int, groupName string) error
406
	SetGroupPermissions(folderID int, groupName string, permission SharePermission) error
Adphi's avatar
Adphi committed
407
408
409
410
	SetQuota(folderID int, quota int) error
}
```

411
GroupFolders available methods
Adphi's avatar
Adphi committed
412
413
414
415

#### type Groups

```go
416
type Groups interface {
Adphi's avatar
Adphi committed
417
	List() ([]string, error)
418
	ListDetails(search string) ([]Group, error)
Adphi's avatar
Adphi committed
419
420
421
422
423
424
425
426
	Users(name string) ([]string, error)
	Search(search string) ([]string, error)
	Create(name string) error
	Delete(name string) error
	SubAdminList(name string) ([]string, error)
}
```

427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
Groups available methods

#### type Monitoring

```go
type Monitoring struct {
	Nextcloud struct {
		System  System  `json:"system"`
		Storage Storage `json:"storage"`
		Shares  struct {
			NumShares               int `json:"num_shares"`
			NumSharesUser           int `json:"num_shares_user"`
			NumSharesGroups         int `json:"num_shares_groups"`
			NumSharesLink           int `json:"num_shares_link"`
			NumSharesLinkNoPassword int `json:"num_shares_link_no_password"`
			NumFedSharesSent        int `json:"num_fed_shares_sent"`
			NumFedSharesReceived    int `json:"num_fed_shares_received"`
		} `json:"shares"`
	} `json:"nextcloud"`
	Server struct {
		Webserver string `json:"webserver"`
		Php       struct {
			Version           string `json:"version"`
			MemoryLimit       int    `json:"memory_limit"`
			MaxExecutionTime  int    `json:"max_execution_time"`
			UploadMaxFilesize int    `json:"upload_max_filesize"`
		} `json:"php"`
		Database struct {
			Type    string `json:"type"`
			Version string `json:"version"`
			Size    int    `json:"size"`
		} `json:"database"`
	} `json:"server"`
	ActiveUsers ActiveUsers `json:"activeUsers"`
Adphi's avatar
Adphi committed
461
462
463
464
}
```


465
#### type Notification
Adphi's avatar
Adphi committed
466
467

```go
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
type Notification struct {
	NotificationID        int           `json:"notification_id"`
	App                   string        `json:"app"`
	User                  string        `json:"user"`
	Datetime              time.Time     `json:"datetime"`
	ObjectType            string        `json:"object_type"`
	ObjectID              string        `json:"object_id"`
	Subject               string        `json:"subject"`
	Message               string        `json:"message"`
	Link                  string        `json:"link"`
	SubjectRich           string        `json:"subjectRich"`
	SubjectRichParameters []interface{} `json:"subjectRichParameters"`
	MessageRich           string        `json:"messageRich"`
	MessageRichParameters []interface{} `json:"messageRichParameters"`
	Icon                  string        `json:"icon"`
	Actions               []interface{} `json:"actions"`
}
Adphi's avatar
Adphi committed
485
486
487
```


488
#### type Notifications
Adphi's avatar
Adphi committed
489
490

```go
491
492
493
type Notifications interface {
	List() ([]Notification, error)
	Get(id int) (Notification, error)
Adphi's avatar
Adphi committed
494
495
496
497
498
499
500
501
	Delete(id int) error
	DeleteAll() error
	Create(userID, title, message string) error
	AdminAvailable() error
	Available() error
}
```

502
Notifications available methods
Adphi's avatar
Adphi committed
503

504
#### type Quota
Adphi's avatar
Adphi committed
505
506

```go
507
508
509
510
511
512
type Quota struct {
	Free     int64   `json:"free"`
	Used     int64   `json:"used"`
	Total    int64   `json:"total"`
	Relative float64 `json:"relative"`
	Quota    int64   `json:"quota"`
Adphi's avatar
Adphi committed
513
514
515
516
}
```


517
#### func (*Quota) String
Adphi's avatar
Adphi committed
518
519

```go
520
func (q *Quota) String() string
Adphi's avatar
Adphi committed
521
522
```

523
#### type Share
Adphi's avatar
Adphi committed
524
525

```go
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
type Share struct {
	ID                   string      `json:"id"`
	ShareType            int         `json:"share_type"`
	UIDOwner             string      `json:"uid_owner"`
	DisplaynameOwner     string      `json:"displayname_owner"`
	Permissions          int         `json:"permissions"`
	Stime                int         `json:"stime"`
	Parent               interface{} `json:"parent"`
	Expiration           string      `json:"expiration"`
	Token                string      `json:"token"`
	UIDFileOwner         string      `json:"uid_file_owner"`
	DisplaynameFileOwner string      `json:"displayname_file_owner"`
	Path                 string      `json:"path"`
	ItemType             string      `json:"item_type"`
	Mimetype             string      `json:"mimetype"`
	StorageID            string      `json:"storage_id"`
	Storage              int         `json:"storage"`
	ItemSource           int         `json:"item_source"`
	FileSource           int         `json:"file_source"`
	FileParent           int         `json:"file_parent"`
	FileTarget           string      `json:"file_target"`
	ShareWith            string      `json:"share_with"`
	ShareWithDisplayname string      `json:"share_with_displayname"`
	MailSend             int         `json:"mail_send"`
	Tags                 []string    `json:"tags"`
}
Adphi's avatar
Adphi committed
552
553
554
```


555
#### type SharePermission
Adphi's avatar
Adphi committed
556
557

```go
558
type SharePermission int
Adphi's avatar
Adphi committed
559
560
561
```


562
#### type ShareType
Adphi's avatar
Adphi committed
563
564

```go
565
type ShareType int
Adphi's avatar
Adphi committed
566
567
568
```


569
#### type ShareUpdate
Adphi's avatar
Adphi committed
570
571

```go
572
573
574
575
576
577
578
type ShareUpdate struct {
	ShareID      int
	Permissions  SharePermission
	Password     string
	PublicUpload bool
	ExpireDate   string
}
Adphi's avatar
Adphi committed
579
580
581
```


582
#### type Shares
Adphi's avatar
Adphi committed
583
584

```go
585
586
587
588
type Shares interface {
	List() ([]Share, error)
	GetFromPath(path string, reshares bool, subfiles bool) ([]Share, error)
	Get(shareID string) (Share, error)
Adphi's avatar
Adphi committed
589
590
	Create(
		path string,
591
592
		shareType ShareType,
		permission SharePermission,
Adphi's avatar
Adphi committed
593
594
595
		shareWith string,
		publicUpload bool,
		password string,
596
	) (Share, error)
Adphi's avatar
Adphi committed
597
	Delete(shareID int) error
598
	Update(shareUpdate ShareUpdate) error
Adphi's avatar
Adphi committed
599
600
601
	UpdateExpireDate(shareID int, expireDate string) error
	UpdatePublicUpload(shareID int, public bool) error
	UpdatePassword(shareID int, password string) error
602
	UpdatePermissions(shareID int, permissions SharePermission) error
Adphi's avatar
Adphi committed
603
604
605
}
```

606
```
Adphi's avatar
Adphi committed
607
608
609
610

#### type Users

```go
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
type Users interface {
	List() ([]string, error)
	ListDetails() (map[string]UserDetails, error)
	Get(name string) (*UserDetails, error)
	Search(search string) ([]string, error)
	Create(username string, password string, user *UserDetails) error
	CreateWithoutPassword(username, email, displayName, quota, language string, groups ...string) error
	CreateBatchWithoutPassword(users []User) error
	Delete(name string) error
	Enable(name string) error
	Disable(name string) error
	SendWelcomeEmail(name string) error
	Update(user *UserDetails) error
	UpdateEmail(name string, email string) error
	UpdateDisplayName(name string, displayName string) error
	UpdatePhone(name string, phone string) error
	UpdateAddress(name string, address string) error
	UpdateWebSite(name string, website string) error
	UpdateTwitter(name string, twitter string) error
	UpdatePassword(name string, password string) error
	UpdateQuota(name string, quota int64) error
	GroupList(name string) ([]string, error)
	GroupAdd(name string, group string) error
	GroupRemove(name string, group string) error
	GroupPromote(name string, group string) error
	GroupDemote(name string, group string) error
	GroupSubAdminList(name string) ([]string, error)
Adphi's avatar
Adphi committed
638
639
640
}
```

641
Users available methods
Adphi's avatar
Adphi committed
642

643
#### type Version
Adphi's avatar
Adphi committed
644
645

```go
646
647
648
649
650
651
652
type Version struct {
	Major   int    `json:"major"`
	Minor   int    `json:"minor"`
	Micro   int    `json:"micro"`
	String  string `json:"string"`
	Edition string `json:"edition"`
}
Adphi's avatar
Adphi committed
653
654
655
```


656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
#### type WebDav

```go
type WebDav interface {
	// ReadDir reads the contents of a remote directory
	ReadDir(path string) ([]os.FileInfo, error)
	// Stat returns the file stats for a specified path
	Stat(path string) (os.FileInfo, error)
	// Remove removes a remote file
	Remove(path string) error
	// RemoveAll removes remote files
	RemoveAll(path string) error
	// Mkdir makes a directory
	Mkdir(path string, _ os.FileMode) error
	// MkdirAll like mkdir -p, but for webdav
	MkdirAll(path string, _ os.FileMode) error
	// Rename moves a file from A to B
	Rename(oldpath, newpath string, overwrite bool) error
	// Copy copies a file from A to B
	Copy(oldpath, newpath string, overwrite bool) error
	// Read reads the contents of a remote file
	Read(path string) ([]byte, error)
	// ReadStream reads the stream for a given path
	ReadStream(path string) (io.ReadCloser, error)
	// Write writes data to a given path
	Write(path string, data []byte, _ os.FileMode) error
	// WriteStream writes a stream
	WriteStream(path string, stream io.Reader, _ os.FileMode) error

	// Walk walks the file tree rooted at root, calling walkFn for each file or
	// directory in the tree, including root.
	Walk(path string, walkFunc filepath.WalkFunc) error
}
Adphi's avatar
Adphi committed
689
690
```

691
WebDav available methods
Adphi's avatar
Adphi committed
692
693


694
#### type Storage
Adphi's avatar
Adphi committed
695
696

```go
697
698
699
700
701
702
703
704
type Storage struct {
	NumUsers         int `json:"num_users"`
	NumFiles         int `json:"num_files"`
	NumStorages      int `json:"num_storages"`
	NumStoragesLocal int `json:"num_storages_local"`
	NumStoragesHome  int `json:"num_storages_home"`
	NumStoragesOther int `json:"num_storages_other"`
}
Adphi's avatar
Adphi committed
705
706
707
```


708
#### type System
Adphi's avatar
Adphi committed
709
710

```go
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
type System struct {
	Version             string    `json:"version"`
	Theme               string    `json:"theme"`
	EnableAvatars       string    `json:"enable_avatars"`
	EnablePreviews      string    `json:"enable_previews"`
	MemcacheLocal       string    `json:"memcache.local"`
	MemcacheDistributed string    `json:"memcache.distributed"`
	FilelockingEnabled  string    `json:"filelocking.enabled"`
	MemcacheLocking     string    `json:"memcache.locking"`
	Debug               string    `json:"debug"`
	Freespace           int64     `json:"freespace"`
	Cpuload             []float32 `json:"cpuload"`
	MemTotal            int       `json:"mem_total"`
	MemFree             int       `json:"mem_free"`
	SwapTotal           int       `json:"swap_total"`
	SwapFree            int       `json:"swap_free"`
}
Adphi's avatar
Adphi committed
728
729
730
```


731
#### type UpdateError
Adphi's avatar
Adphi committed
732
733

```go
734
735
736
737
type UpdateError struct {
	Field string
	Error error
}
Adphi's avatar
Adphi committed
738
739
```

740
UpdateError contains the user's field and corresponding error
Adphi's avatar
Adphi committed
741

742
#### type User
Adphi's avatar
Adphi committed
743
744

```go
745
746
747
748
749
750
751
752
type User struct {
	Username    string
	Email       string
	DisplayName string
	Quota       string
	Language    string
	Groups      []string
}
Adphi's avatar
Adphi committed
753
754
```

755
User encapsulate the data needed to create a new Nextcloud's User
Adphi's avatar
Adphi committed
756

757
#### type UserDetails
Adphi's avatar
Adphi committed
758
759

```go
760
761
762
763
764
765
766
767
768
769
770
771
type UserDetails struct {
	Enabled     bool     `json:"enabled"`
	ID          string   `json:"id"`
	Quota       Quota    `json:"quota"`
	Email       string   `json:"email"`
	Displayname string   `json:"displayname"`
	Phone       string   `json:"phone"`
	Address     string   `json:"address"`
	Website     string   `json:"website"`
	Twitter     string   `json:"twitter"`
	Groups      []string `json:"groups"`
	Language    string   `json:"language,omitempty"`
Adphi's avatar
Adphi committed
772

773
774
775
776
777
778
	StorageLocation string        `json:"storageLocation,omitempty"`
	LastLogin       int64         `json:"lastLogin,omitempty"`
	Backend         string        `json:"backend,omitempty"`
	Subadmin        []interface{} `json:"subadmin,omitempty"`
	Locale          string        `json:"locale,omitempty"`
}
Adphi's avatar
Adphi committed
779
780
```

781
UserDetails is the raw Nextcloud User response
Adphi's avatar
Adphi committed
782

783
#### type UserUpdateError
Adphi's avatar
Adphi committed
784
785

```go
786
787
788
type UserUpdateError struct {
	Errors map[string]error
}
Adphi's avatar
Adphi committed
789
790
```

791
792
UpdateError contains the errors resulting from a UserUpdate or a UserCreateFull
call
Adphi's avatar
Adphi committed
793

794
#### func (*UserUpdateError) Error
Adphi's avatar
Adphi committed
795
796

```go
797
func (e *UserUpdateError) Error() string