improved comments

This commit is contained in:
Adphi 2019-07-23 09:52:34 +02:00
parent 5d284c1ad8
commit 90081d6e8f
12 changed files with 56 additions and 18 deletions

2
app.go
View File

@ -1,6 +1,6 @@
package gonextcloud package gonextcloud
//App // App is a nextcloud application (plugin)
type App struct { type App struct {
ID string `json:"id"` ID string `json:"id"`
Ocsid string `json:"ocsid"` Ocsid string `json:"ocsid"`

View File

@ -1,6 +1,6 @@
package gonextcloud package gonextcloud
//Capabilities // Capabilities is the capabilities provided by the Nextcloud server
type Capabilities struct { type Capabilities struct {
Core struct { Core struct {
Pollinterval int `json:"pollinterval"` Pollinterval int `json:"pollinterval"`

2
doc.go
View File

@ -1,5 +1,5 @@
/* /*
A simple Go Client for Nextcloud's API. Package gonextcloud is a simple Go Client for Nextcloud's API.
For more information about the Provisioning API, see the documentation: For more information about the Provisioning API, see the documentation:
https://docs.nextcloud.com/server/13/admin_manual/configuration_user/user_provisioning_api.html https://docs.nextcloud.com/server/13/admin_manual/configuration_user/user_provisioning_api.html

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
) )
//APIError contains the returned error code and message from the Nextcloud's API // APIError contains the returned error code and message from the Nextcloud's API
type APIError struct { type APIError struct {
Code int Code int
Message string Message string
@ -19,18 +19,18 @@ func errorFromMeta(meta meta) *APIError {
} }
} }
//Error return the types.APIError string // Error return the types.APIError string
func (e *APIError) Error() string { func (e *APIError) Error() string {
return fmt.Sprintf("%d : %s", e.Code, e.Message) return fmt.Sprintf("%d : %s", e.Code, e.Message)
} }
//UpdateError contains the user's field and corresponding error // UpdateError contains the user's field and corresponding error
type UpdateError struct { type UpdateError struct {
Field string Field string
Error error Error error
} }
//UpdateError contains the errors resulting from a UserUpdate or a UserCreateFull call // UserUpdateError contains the errors resulting from a UserUpdate or a UserCreateFull call
type UserUpdateError struct { type UserUpdateError struct {
Errors map[string]error Errors map[string]error
} }

View File

@ -13,19 +13,31 @@ func NewClient(hostname string) (Client, error) {
// Client is the main client interface // Client is the main client interface
type Client interface { type Client interface {
// Nextcloud Apps client
Apps() Apps Apps() Apps
// Nextcloud App Config client
AppsConfig() AppsConfig AppsConfig() AppsConfig
// Nextcloud Group Folders client
GroupFolders() GroupFolders GroupFolders() GroupFolders
// Nextcloud Notifications client
Notifications() Notifications Notifications() Notifications
// Nextcloud Shares client
Shares() Shares Shares() Shares
// Nextcloud Users client
Users() Users Users() Users
// Nextcloud Groups client
Groups() Groups Groups() Groups
// Nextcloud WebDav (files) client
WebDav() WebDav WebDav() WebDav
// Nextcloud Monitoring client
Monitoring() (*Monitoring, error) Monitoring() (*Monitoring, error)
// Login authorize client
Login(username string, password string) error Login(username string, password string) error
// Logout clear connetion and session
Logout() error Logout() error
} }
// Auth is the standard auth methods
type Auth interface { type Auth interface {
Login(username string, password string) error Login(username string, password string) error
Logout() error Logout() error

View File

@ -1,6 +1,6 @@
package gonextcloud package gonextcloud
//Group // Group is a Nextcloud group
type Group struct { type Group struct {
ID string `json:"id"` ID string `json:"id"`
Displayname string `json:"displayname"` Displayname string `json:"displayname"`

View File

@ -18,6 +18,7 @@ type groupFolderBadFormatGroups struct {
Size int `json:"size"` Size int `json:"size"`
} }
// GroupFolder is group shared folder from groupfolders application
type GroupFolder struct { type GroupFolder struct {
ID int `json:"id"` ID int `json:"id"`
MountPoint string `json:"mount_point"` MountPoint string `json:"mount_point"`

View File

@ -1,5 +1,6 @@
package gonextcloud package gonextcloud
// System contains the operating system statistics
type System struct { type System struct {
Version string `json:"version"` Version string `json:"version"`
Theme string `json:"theme"` Theme string `json:"theme"`
@ -18,7 +19,9 @@ type System struct {
SwapFree int `json:"swap_free"` SwapFree int `json:"swap_free"`
} }
// Monitoring contains the nextcloud monitoring statistics
type Monitoring struct { type Monitoring struct {
// Nextcloud Statistics
Nextcloud struct { Nextcloud struct {
System System `json:"system"` System System `json:"system"`
Storage Storage `json:"storage"` Storage Storage `json:"storage"`
@ -32,6 +35,7 @@ type Monitoring struct {
NumFedSharesReceived int `json:"num_fed_shares_received"` NumFedSharesReceived int `json:"num_fed_shares_received"`
} `json:"shares"` } `json:"shares"`
} `json:"nextcloud"` } `json:"nextcloud"`
// Server statistics
Server struct { Server struct {
Webserver string `json:"webserver"` Webserver string `json:"webserver"`
Php struct { Php struct {
@ -46,15 +50,18 @@ type Monitoring struct {
Size int `json:"size"` Size int `json:"size"`
} `json:"database"` } `json:"database"`
} `json:"server"` } `json:"server"`
// Active users statistics
ActiveUsers ActiveUsers `json:"activeUsers"` ActiveUsers ActiveUsers `json:"activeUsers"`
} }
// ActiveUsers contains the active users statistics
type ActiveUsers struct { type ActiveUsers struct {
Last5Minutes int `json:"last5minutes"` Last5Minutes int `json:"last5minutes"`
Last1Hour int `json:"last1hour"` Last1Hour int `json:"last1hour"`
Last24Hours int `json:"last24hours"` Last24Hours int `json:"last24hours"`
} }
// Storage contains the storage statistics
type Storage struct { type Storage struct {
NumUsers int `json:"num_users"` NumUsers int `json:"num_users"`
NumFiles int `json:"num_files"` NumFiles int `json:"num_files"`

View File

@ -2,6 +2,7 @@ package gonextcloud
import "time" import "time"
// Notification is a nextcloud notification (from notification app)
type Notification struct { type Notification struct {
NotificationID int `json:"notification_id"` NotificationID int `json:"notification_id"`
App string `json:"app"` App string `json:"app"`

View File

@ -119,6 +119,7 @@ type capabilitiesResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
// Version contains the nextcloud version informations
type Version struct { type Version struct {
Major int `json:"major"` Major int `json:"major"`
Minor int `json:"minor"` Minor int `json:"minor"`

View File

@ -1,22 +1,36 @@
package gonextcloud package gonextcloud
// ShareType is the nextcloud shares types enum :
type ShareType int type ShareType int
// SharePermission is the nextcloud share permissions enum
type SharePermission int type SharePermission int
const ( const (
// UserShare is a file or folder shared with other user(s)
UserShare ShareType = 0 UserShare ShareType = 0
// GroupShare is a file or folder shared with a group
GroupShare ShareType = 1 GroupShare ShareType = 1
// PublicLinkShare is a file or folder shared through public link
PublicLinkShare ShareType = 3 PublicLinkShare ShareType = 3
// FederatedCloudShare is a file or folder shared through federated cloud
FederatedCloudShare ShareType = 6 FederatedCloudShare ShareType = 6
// ReadPermission grant read permission
ReadPermission SharePermission = 1 ReadPermission SharePermission = 1
// UpdatePermission grant update permission
UpdatePermission SharePermission = 2 UpdatePermission SharePermission = 2
// CreatePermission grant create permission
CreatePermission SharePermission = 4 CreatePermission SharePermission = 4
// DeletePermission grant delete permission
DeletePermission SharePermission = 8 DeletePermission SharePermission = 8
// ReSharePermission grant resharing permission
ReSharePermission SharePermission = 16 ReSharePermission SharePermission = 16
// AllPermissions grant all permissions
AllPermissions SharePermission = 31 AllPermissions SharePermission = 31
) )
// ShareUpdate contains the data required in order to update a nextcloud share
type ShareUpdate struct { type ShareUpdate struct {
ShareID int ShareID int
Permissions SharePermission Permissions SharePermission
@ -25,6 +39,7 @@ type ShareUpdate struct {
ExpireDate string ExpireDate string
} }
// Share is a nextcloud share
type Share struct { type Share struct {
ID string `json:"id"` ID string `json:"id"`
ShareType int `json:"share_type"` ShareType int `json:"share_type"`

View File

@ -2,7 +2,7 @@ package gonextcloud
import "strconv" import "strconv"
//User encapsulate the data needed to create a new Nextcloud's User // User encapsulate the data needed to create a new Nextcloud's User
type User struct { type User struct {
Username string Username string
Email string Email string
@ -12,7 +12,7 @@ type User struct {
Groups []string Groups []string
} }
//UserDetails is the raw Nextcloud User response // UserDetails is the raw Nextcloud User response
type UserDetails struct { type UserDetails struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`
ID string `json:"id"` ID string `json:"id"`
@ -33,6 +33,7 @@ type UserDetails struct {
Locale string `json:"locale,omitempty"` Locale string `json:"locale,omitempty"`
} }
// Quota is a use storage Quota
type Quota struct { type Quota struct {
Free int64 `json:"free"` Free int64 `json:"free"`
Used int64 `json:"used"` Used int64 `json:"used"`