mirror of
https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
synced 2024-12-22 04:40:44 +00:00
updated README.md, unexported responses types
This commit is contained in:
parent
85ab4b93f0
commit
5a9b0d715c
@ -17,7 +17,7 @@ func (a *apps) List() ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r AppListResponse
|
||||
var r appListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Apps, nil
|
||||
}
|
||||
@ -31,7 +31,7 @@ func (a *apps) ListEnabled() ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r AppListResponse
|
||||
var r appListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Apps, nil
|
||||
}
|
||||
@ -45,7 +45,7 @@ func (a *apps) ListDisabled() ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r AppListResponse
|
||||
var r appListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Apps, nil
|
||||
}
|
||||
@ -56,7 +56,7 @@ func (a *apps) Infos(name string) (App, error) {
|
||||
if err != nil {
|
||||
return App{}, err
|
||||
}
|
||||
var r AppResponse
|
||||
var r appResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func (a *appsConfig) List() (apps []string, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r AppConfigResponse
|
||||
var r appConfigResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Data, nil
|
||||
}
|
||||
@ -29,7 +29,7 @@ func (a *appsConfig) Keys(id string) (keys []string, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r AppConfigResponse
|
||||
var r appConfigResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Data, nil
|
||||
}
|
||||
@ -40,7 +40,7 @@ func (a *appsConfig) Value(id, key string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var r AppcConfigValueResponse
|
||||
var r appcConfigValueResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Data, nil
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ func (c *client) Login(username string, password string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var r CapabilitiesResponse
|
||||
var r capabilitiesResponse
|
||||
res.JSON(&r)
|
||||
// No need to check for Ocs.Meta.StatusCode as capabilities are always returned
|
||||
// No need to check for Ocs.meta.StatusCode as capabilities are always returned
|
||||
c.capabilities = &r.Ocs.Data.Capabilities
|
||||
c.version = &r.Ocs.Data.Version
|
||||
// Check if authentication failed
|
||||
|
2
doc.go
2
doc.go
@ -21,7 +21,7 @@ For example, to list all the Nextcloud's instance users:
|
||||
url := "https://www.mynextcloud.com"
|
||||
username := "admin"
|
||||
password := "password"
|
||||
c, err := gonextcloud.newClient(url)
|
||||
c, err := gonextcloud.NewClient(url)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
1566
docs/README.md
1566
docs/README.md
File diff suppressed because it is too large
Load Diff
@ -11,8 +11,8 @@ type APIError struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
//ErrorFromMeta return a types.APIError from the Response's types.Meta
|
||||
func ErrorFromMeta(meta Meta) *APIError {
|
||||
//errorFromMeta return a types.APIError from the Response's types.meta
|
||||
func errorFromMeta(meta meta) *APIError {
|
||||
return &APIError{
|
||||
meta.Statuscode,
|
||||
meta.Message,
|
||||
@ -43,8 +43,8 @@ func (e *UserUpdateError) Error() string {
|
||||
return strings.Join(errors, ", ")
|
||||
}
|
||||
|
||||
//NewUpdateError returns an UpdateError based on an UpdateError channel
|
||||
func NewUpdateError(errors chan *UpdateError) *UserUpdateError {
|
||||
//newUpdateError returns an UpdateError based on an UpdateError channel
|
||||
func newUpdateError(errors chan *UpdateError) *UserUpdateError {
|
||||
ue := UserUpdateError{map[string]error{}}
|
||||
for e := range errors {
|
||||
if e != nil {
|
||||
|
@ -25,7 +25,7 @@ func TestUserUpdateErrors(t *testing.T) {
|
||||
}
|
||||
close(errs)
|
||||
}()
|
||||
uerrs := NewUpdateError(errs)
|
||||
uerrs := newUpdateError(errs)
|
||||
assert.Equal(t, exp, uerrs.Errors)
|
||||
assert.NotEmpty(t, uerrs.Error())
|
||||
}
|
||||
@ -42,6 +42,6 @@ func TestUserUpdateErrorsNil(t *testing.T) {
|
||||
wg.Wait()
|
||||
close(errs)
|
||||
}()
|
||||
uerrs := NewUpdateError(errs)
|
||||
uerrs := newUpdateError(errs)
|
||||
assert.Nil(t, uerrs)
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
package gonextcloud
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// NewClient create a new client
|
||||
func NewClient(hostname string) (Client, error) {
|
||||
return newClient(hostname)
|
||||
@ -130,3 +136,35 @@ type Users interface {
|
||||
GroupDemote(name string, group string) error
|
||||
GroupSubAdminList(name string) ([]string, error)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package gonextcloud
|
||||
|
||||
import "strconv"
|
||||
|
||||
type GroupFolderBadFormatIDAndGroups struct {
|
||||
type groupFolderBadFormatIDAndGroups struct {
|
||||
ID string `json:"id"`
|
||||
MountPoint string `json:"mount_point"`
|
||||
Groups map[string]string `json:"groups"`
|
||||
@ -10,7 +10,7 @@ type GroupFolderBadFormatIDAndGroups struct {
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
type GroupFolderBadFormatGroups struct {
|
||||
type groupFolderBadFormatGroups struct {
|
||||
ID int `json:"id"`
|
||||
MountPoint string `json:"mount_point"`
|
||||
Groups map[string]string `json:"groups"`
|
||||
@ -26,7 +26,7 @@ type GroupFolder struct {
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
func (gf *GroupFolderBadFormatGroups) FormatGroupFolder() GroupFolder {
|
||||
func (gf *groupFolderBadFormatGroups) FormatGroupFolder() GroupFolder {
|
||||
g := GroupFolder{}
|
||||
g.ID = gf.ID
|
||||
g.MountPoint = gf.MountPoint
|
||||
@ -41,7 +41,7 @@ func (gf *GroupFolderBadFormatGroups) FormatGroupFolder() GroupFolder {
|
||||
return g
|
||||
}
|
||||
|
||||
func (gf *GroupFolderBadFormatIDAndGroups) FormatGroupFolder() GroupFolder {
|
||||
func (gf *groupFolderBadFormatIDAndGroups) FormatGroupFolder() GroupFolder {
|
||||
g := GroupFolder{}
|
||||
g.ID, _ = strconv.Atoi(gf.ID)
|
||||
g.MountPoint = gf.MountPoint
|
||||
|
@ -19,7 +19,7 @@ func (g *groupFolders) List() (map[int]GroupFolder, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r GroupFoldersListResponse
|
||||
var r groupFoldersListResponse
|
||||
res.JSON(&r)
|
||||
gfs := formatBadIDAndGroups(r.Ocs.Data)
|
||||
return gfs, nil
|
||||
@ -31,7 +31,7 @@ func (g *groupFolders) Get(id int) (GroupFolder, error) {
|
||||
if err != nil {
|
||||
return GroupFolder{}, err
|
||||
}
|
||||
var r GroupFoldersResponse
|
||||
var r groupFoldersResponse
|
||||
res.JSON(&r)
|
||||
if r.Ocs.Data.ID == 0 {
|
||||
return GroupFolder{}, fmt.Errorf("%d is not a valid groupfolder's id", id)
|
||||
@ -51,7 +51,7 @@ func (g *groupFolders) Create(name string) (id int, err error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var r GroupFoldersCreateResponse
|
||||
var r groupFoldersCreateResponse
|
||||
res.JSON(&r)
|
||||
id, _ = strconv.Atoi(r.Ocs.Data.ID)
|
||||
return id, nil
|
||||
@ -129,7 +129,7 @@ func (g *groupFolders) SetQuota(folderID int, quota int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func formatBadIDAndGroups(g map[string]GroupFolderBadFormatIDAndGroups) map[int]GroupFolder {
|
||||
func formatBadIDAndGroups(g map[string]groupFolderBadFormatIDAndGroups) map[int]GroupFolder {
|
||||
var gfs = map[int]GroupFolder{}
|
||||
for k := range g {
|
||||
i, _ := strconv.Atoi(k)
|
||||
|
@ -17,7 +17,7 @@ func (g *groups) List() ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r GroupListResponse
|
||||
var r groupListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Groups, nil
|
||||
}
|
||||
@ -33,7 +33,7 @@ func (g *groups) ListDetails(search string) ([]Group, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r GroupListDetailsResponse
|
||||
var r groupListDetailsResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Groups, nil
|
||||
}
|
||||
@ -44,7 +44,7 @@ func (g *groups) Users(name string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r UserListResponse
|
||||
var r userListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Users, nil
|
||||
}
|
||||
@ -58,7 +58,7 @@ func (g *groups) Search(search string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r GroupListResponse
|
||||
var r groupListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Groups, nil
|
||||
}
|
||||
@ -84,7 +84,7 @@ func (g *groups) SubAdminList(name string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r UserListResponse
|
||||
var r userListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Users, nil
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ func (c *client) Monitoring() (*Monitoring, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var m MonitoringResponse
|
||||
var m monitoringResponse
|
||||
res.JSON(&m)
|
||||
return &m.Ocs.Data, nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func (n *notifications) List() ([]Notification, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r NotificationsListResponse
|
||||
var r notificationsListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
@ -36,7 +36,7 @@ func (n *notifications) Get(id int) (Notification, error) {
|
||||
if err != nil {
|
||||
return Notification{}, err
|
||||
}
|
||||
var r NotificationResponse
|
||||
var r notificationResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
|
108
responses.go
108
responses.go
@ -1,7 +1,7 @@
|
||||
package gonextcloud
|
||||
|
||||
//Meta
|
||||
type Meta struct {
|
||||
//meta
|
||||
type meta struct {
|
||||
Status string `json:"status"`
|
||||
Statuscode int `json:"statuscode"`
|
||||
Message string `json:"message"`
|
||||
@ -9,109 +9,109 @@ type Meta struct {
|
||||
Itemsperpage string `json:"itemsperpage"`
|
||||
}
|
||||
|
||||
//ErrorResponse
|
||||
type ErrorResponse struct {
|
||||
//errorResponse
|
||||
type errorResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data []interface{} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//UserListResponse
|
||||
type UserListResponse struct {
|
||||
//userListResponse
|
||||
type userListResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Users []string `json:"users"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type UserListDetailsResponse struct {
|
||||
type userListDetailsResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Users map[string]UserDetails `json:"users"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//UserResponse
|
||||
type UserResponse struct {
|
||||
//userResponse
|
||||
type userResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data UserDetails `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//BaseResponse
|
||||
type BaseResponse struct {
|
||||
//baseResponse
|
||||
type baseResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data []string `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//GroupListResponse
|
||||
type GroupListResponse struct {
|
||||
//groupListResponse
|
||||
type groupListResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Groups []string `json:"groups"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//GroupListDetailsResponse
|
||||
type GroupListDetailsResponse struct {
|
||||
//groupListDetailsResponse
|
||||
type groupListDetailsResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Groups []Group `json:"groups"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//AppListResponse
|
||||
type AppListResponse struct {
|
||||
//appListResponse
|
||||
type appListResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Apps []string `json:"apps"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//AppResponse
|
||||
type AppResponse struct {
|
||||
//appResponse
|
||||
type appResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data App `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type AppConfigResponse struct {
|
||||
type appConfigResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Data []string `json:"data"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type AppcConfigValueResponse struct {
|
||||
type appcConfigValueResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Data string `json:"data"`
|
||||
} `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
//CapabilitiesResponse
|
||||
type CapabilitiesResponse struct {
|
||||
//capabilitiesResponse
|
||||
type capabilitiesResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data struct {
|
||||
Version Version `json:"version"`
|
||||
Capabilities Capabilities `json:"capabilities"`
|
||||
@ -127,58 +127,58 @@ type Version struct {
|
||||
Edition string `json:"edition"`
|
||||
}
|
||||
|
||||
type MonitoringResponse struct {
|
||||
type monitoringResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data Monitoring `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type SharesListResponse struct {
|
||||
type sharesListResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data []Share `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type SharesResponse struct {
|
||||
type sharesResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data Share `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type GroupFoldersListResponse struct {
|
||||
type groupFoldersListResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Data map[string]GroupFolderBadFormatIDAndGroups `json:"data"`
|
||||
Meta meta `json:"meta"`
|
||||
Data map[string]groupFolderBadFormatIDAndGroups `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type GroupFoldersCreateResponse struct {
|
||||
type groupFoldersCreateResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Data GroupFolderBadFormatIDAndGroups `json:"data"`
|
||||
Meta meta `json:"meta"`
|
||||
Data groupFolderBadFormatIDAndGroups `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type GroupFoldersResponse struct {
|
||||
type groupFoldersResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Data GroupFolderBadFormatGroups `json:"data"`
|
||||
Meta meta `json:"meta"`
|
||||
Data groupFolderBadFormatGroups `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type NotificationsListResponse struct {
|
||||
type notificationsListResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data []Notification `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
||||
type NotificationResponse struct {
|
||||
type notificationResponse struct {
|
||||
Ocs struct {
|
||||
Meta Meta `json:"meta"`
|
||||
Meta meta `json:"meta"`
|
||||
Data Notification `json:"data"`
|
||||
} `json:"ocs"`
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package gonextcloud
|
||||
|
||||
import "net/url"
|
||||
|
||||
// Routes references the available routes
|
||||
type Routes struct {
|
||||
// apiRoutes references the available routes
|
||||
type apiRoutes struct {
|
||||
capabilities *url.URL
|
||||
users *url.URL
|
||||
groups *url.URL
|
||||
@ -20,7 +20,7 @@ const badRequest = 998
|
||||
|
||||
var (
|
||||
apiPath = &url.URL{Path: "/ocs/v2.php"}
|
||||
routes = Routes{
|
||||
routes = apiRoutes{
|
||||
capabilities: &url.URL{Path: apiPath.Path + "/cloud/capabilities"},
|
||||
users: &url.URL{Path: apiPath.Path + "/cloud/users"},
|
||||
groups: &url.URL{Path: apiPath.Path + "/cloud/groups"},
|
||||
|
@ -20,7 +20,7 @@ func (s *shares) List() ([]Share, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r SharesListResponse
|
||||
var r sharesListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
@ -38,7 +38,7 @@ func (s *shares) GetFromPath(path string, reshares bool, subfiles bool) ([]Share
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r SharesListResponse
|
||||
var r sharesListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
@ -49,7 +49,7 @@ func (s *shares) Get(shareID string) (Share, error) {
|
||||
if err != nil {
|
||||
return Share{}, err
|
||||
}
|
||||
var r SharesListResponse
|
||||
var r sharesListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data[0], nil
|
||||
}
|
||||
@ -81,7 +81,7 @@ func (s *shares) Create(
|
||||
if err != nil {
|
||||
return Share{}, err
|
||||
}
|
||||
var r SharesResponse
|
||||
var r sharesResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
@ -138,7 +138,7 @@ func (s *shares) Update(shareUpdate ShareUpdate) error {
|
||||
wg.Wait()
|
||||
close(errs)
|
||||
}()
|
||||
if err := NewUpdateError(errs); err != nil {
|
||||
if err := newUpdateError(errs); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -25,7 +25,7 @@ func (u *users) List() ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r UserListResponse
|
||||
var r userListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Users, nil
|
||||
}
|
||||
@ -37,7 +37,7 @@ func (u *users) ListDetails() (map[string]UserDetails, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r UserListDetailsResponse
|
||||
var r userListDetailsResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Users, nil
|
||||
}
|
||||
@ -51,7 +51,7 @@ func (u *users) Get(name string) (*UserDetails, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r UserResponse
|
||||
var r userResponse
|
||||
js := res.String()
|
||||
// Nextcloud does not encode JSON properly
|
||||
js = reformatJSON(js)
|
||||
@ -70,7 +70,7 @@ func (u *users) Search(search string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r UserListResponse
|
||||
var r userListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Users, nil
|
||||
}
|
||||
@ -290,7 +290,7 @@ func (u *users) Update(user *UserDetails) error {
|
||||
close(errs)
|
||||
}()
|
||||
// Warning : we actually need to check the *err
|
||||
if err := NewUpdateError(errs); err != nil {
|
||||
if err := newUpdateError(errs); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -343,7 +343,7 @@ func (u *users) GroupList(name string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r GroupListResponse
|
||||
var r groupListResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data.Groups, nil
|
||||
}
|
||||
@ -399,7 +399,7 @@ func (u *users) GroupSubAdminList(name string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r BaseResponse
|
||||
var r baseResponse
|
||||
res.JSON(&r)
|
||||
return r.Ocs.Data, nil
|
||||
}
|
||||
|
4
utils.go
4
utils.go
@ -40,12 +40,12 @@ func (c *client) baseRequest(method string, route *url.URL, ro *req.RequestOptio
|
||||
}
|
||||
// As we cannot read the ReaderCloser twice, we use the string content
|
||||
js := res.String()
|
||||
var r BaseResponse
|
||||
var r baseResponse
|
||||
json.Unmarshal([]byte(js), &r)
|
||||
if r.Ocs.Meta.Statuscode == 200 || r.Ocs.Meta.Statuscode == 100 {
|
||||
return res, nil
|
||||
}
|
||||
err = ErrorFromMeta(r.Ocs.Meta)
|
||||
err = errorFromMeta(r.Ocs.Meta)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
39
webdav.go
39
webdav.go
@ -1,39 +0,0 @@
|
||||
package gonextcloud
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user