2019-07-22 14:17:11 +00:00
|
|
|
package gonextcloud
|
2018-12-11 09:27:11 +00:00
|
|
|
|
2019-07-22 14:40:42 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// NewClient create a new client
|
|
|
|
func NewClient(hostname string) (Client, error) {
|
|
|
|
return newClient(hostname)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client is the main client interface
|
2018-12-11 09:27:11 +00:00
|
|
|
type Client interface {
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Apps client
|
2018-12-11 09:27:11 +00:00
|
|
|
Apps() Apps
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud App Config client
|
2018-12-11 09:27:11 +00:00
|
|
|
AppsConfig() AppsConfig
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Group Folders client
|
2018-12-11 09:27:11 +00:00
|
|
|
GroupFolders() GroupFolders
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Notifications client
|
2018-12-11 09:27:11 +00:00
|
|
|
Notifications() Notifications
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Shares client
|
2018-12-11 09:27:11 +00:00
|
|
|
Shares() Shares
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Users client
|
2018-12-11 09:27:11 +00:00
|
|
|
Users() Users
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Groups client
|
2018-12-11 09:27:11 +00:00
|
|
|
Groups() Groups
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud WebDav (files) client
|
2019-07-13 23:49:50 +00:00
|
|
|
WebDav() WebDav
|
2019-07-23 07:52:34 +00:00
|
|
|
// Nextcloud Monitoring client
|
2019-07-22 14:17:11 +00:00
|
|
|
Monitoring() (*Monitoring, error)
|
2019-07-23 07:52:34 +00:00
|
|
|
// Login authorize client
|
2019-01-16 15:25:20 +00:00
|
|
|
Login(username string, password string) error
|
2019-07-23 07:52:34 +00:00
|
|
|
// Logout clear connetion and session
|
2019-01-16 15:25:20 +00:00
|
|
|
Logout() error
|
2018-12-11 09:27:11 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 07:52:34 +00:00
|
|
|
// Auth is the standard auth methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type Auth interface {
|
|
|
|
Login(username string, password string) error
|
|
|
|
Logout() error
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// Apps available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// AppsConfig available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type AppsConfig interface {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// Groups available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type Groups interface {
|
|
|
|
List() ([]string, error)
|
2019-01-31 12:23:06 +00:00
|
|
|
ListDetails(search string) ([]Group, error)
|
2018-12-11 09:27:11 +00:00
|
|
|
Users(name string) ([]string, error)
|
|
|
|
Search(search string) ([]string, error)
|
|
|
|
Create(name string) error
|
|
|
|
Delete(name string) error
|
|
|
|
SubAdminList(name string) ([]string, error)
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// GroupFolders available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type GroupFolders interface {
|
|
|
|
List() (map[int]GroupFolder, error)
|
|
|
|
Get(id int) (GroupFolder, error)
|
|
|
|
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
|
|
|
|
SetGroupPermissions(folderID int, groupName string, permission SharePermission) error
|
|
|
|
SetQuota(folderID int, quota int) error
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// Notifications available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type Notifications interface {
|
|
|
|
List() ([]Notification, error)
|
|
|
|
Get(id int) (Notification, error)
|
|
|
|
Delete(id int) error
|
|
|
|
DeleteAll() error
|
|
|
|
Create(userID, title, message string) error
|
|
|
|
AdminAvailable() error
|
|
|
|
Available() error
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// Shares available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type Shares interface {
|
|
|
|
List() ([]Share, error)
|
|
|
|
GetFromPath(path string, reshares bool, subfiles bool) ([]Share, error)
|
|
|
|
Get(shareID string) (Share, error)
|
|
|
|
Create(
|
|
|
|
path string,
|
|
|
|
shareType ShareType,
|
|
|
|
permission SharePermission,
|
|
|
|
shareWith string,
|
|
|
|
publicUpload bool,
|
|
|
|
password string,
|
|
|
|
) (Share, error)
|
|
|
|
Delete(shareID int) error
|
|
|
|
Update(shareUpdate ShareUpdate) error
|
|
|
|
UpdateExpireDate(shareID int, expireDate string) error
|
|
|
|
UpdatePublicUpload(shareID int, public bool) error
|
|
|
|
UpdatePassword(shareID int, password string) error
|
|
|
|
UpdatePermissions(shareID int, permissions SharePermission) error
|
|
|
|
}
|
|
|
|
|
2019-07-22 14:17:11 +00:00
|
|
|
// Users available methods
|
2018-12-11 09:27:11 +00:00
|
|
|
type Users interface {
|
|
|
|
List() ([]string, error)
|
2019-01-03 13:09:23 +00:00
|
|
|
ListDetails() (map[string]UserDetails, error)
|
|
|
|
Get(name string) (*UserDetails, error)
|
2018-12-11 09:27:11 +00:00
|
|
|
Search(search string) ([]string, error)
|
2019-01-03 13:09:23 +00:00
|
|
|
Create(username string, password string, user *UserDetails) error
|
2018-12-11 09:27:11 +00:00
|
|
|
CreateWithoutPassword(username, email, displayName, quota, language string, groups ...string) error
|
2019-01-03 13:09:23 +00:00
|
|
|
CreateBatchWithoutPassword(users []User) error
|
2018-12-11 09:27:11 +00:00
|
|
|
Delete(name string) error
|
|
|
|
Enable(name string) error
|
|
|
|
Disable(name string) error
|
|
|
|
SendWelcomeEmail(name string) error
|
2019-01-03 13:09:23 +00:00
|
|
|
Update(user *UserDetails) error
|
2018-12-11 09:27:11 +00:00
|
|
|
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
|
2019-01-16 14:31:22 +00:00
|
|
|
UpdateQuota(name string, quota int64) error
|
2018-12-11 09:27:11 +00:00
|
|
|
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)
|
|
|
|
}
|
2019-07-22 14:40:42 +00:00
|
|
|
|
|
|
|
// WebDav available methods
|
|
|
|
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
|
|
|
|
}
|