From 90081d6e8ff90d01a9c1b3d2c849ae7aad25e4e8 Mon Sep 17 00:00:00 2001 From: Adphi Date: Tue, 23 Jul 2019 09:52:34 +0200 Subject: [PATCH] improved comments --- app.go | 2 +- capabilities.go | 2 +- doc.go | 2 +- errors.go | 8 ++++---- gonextcloud.go | 12 ++++++++++++ group.go | 2 +- groupfolders.go | 1 + monitoring.go | 7 +++++++ notification.go | 1 + responses.go | 1 + shares.go | 31 +++++++++++++++++++++++-------- user.go | 5 +++-- 12 files changed, 56 insertions(+), 18 deletions(-) diff --git a/app.go b/app.go index 880d8bd..a18874a 100644 --- a/app.go +++ b/app.go @@ -1,6 +1,6 @@ package gonextcloud -//App +// App is a nextcloud application (plugin) type App struct { ID string `json:"id"` Ocsid string `json:"ocsid"` diff --git a/capabilities.go b/capabilities.go index c416ba4..834cfb7 100644 --- a/capabilities.go +++ b/capabilities.go @@ -1,6 +1,6 @@ package gonextcloud -//Capabilities +// Capabilities is the capabilities provided by the Nextcloud server type Capabilities struct { Core struct { Pollinterval int `json:"pollinterval"` diff --git a/doc.go b/doc.go index 3722379..61ef16d 100644 --- a/doc.go +++ b/doc.go @@ -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: https://docs.nextcloud.com/server/13/admin_manual/configuration_user/user_provisioning_api.html diff --git a/errors.go b/errors.go index c109580..bab43af 100644 --- a/errors.go +++ b/errors.go @@ -5,7 +5,7 @@ import ( "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 { Code int 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 { 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 { Field string 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 { Errors map[string]error } diff --git a/gonextcloud.go b/gonextcloud.go index c572f7f..cac1563 100644 --- a/gonextcloud.go +++ b/gonextcloud.go @@ -13,19 +13,31 @@ func NewClient(hostname string) (Client, error) { // Client is the main client interface type Client interface { + // Nextcloud Apps client Apps() Apps + // Nextcloud App Config client AppsConfig() AppsConfig + // Nextcloud Group Folders client GroupFolders() GroupFolders + // Nextcloud Notifications client Notifications() Notifications + // Nextcloud Shares client Shares() Shares + // Nextcloud Users client Users() Users + // Nextcloud Groups client Groups() Groups + // Nextcloud WebDav (files) client WebDav() WebDav + // Nextcloud Monitoring client Monitoring() (*Monitoring, error) + // Login authorize client Login(username string, password string) error + // Logout clear connetion and session Logout() error } +// Auth is the standard auth methods type Auth interface { Login(username string, password string) error Logout() error diff --git a/group.go b/group.go index 4c5c655..e1d0940 100644 --- a/group.go +++ b/group.go @@ -1,6 +1,6 @@ package gonextcloud -//Group +// Group is a Nextcloud group type Group struct { ID string `json:"id"` Displayname string `json:"displayname"` diff --git a/groupfolders.go b/groupfolders.go index 6c31967..0343340 100644 --- a/groupfolders.go +++ b/groupfolders.go @@ -18,6 +18,7 @@ type groupFolderBadFormatGroups struct { Size int `json:"size"` } +// GroupFolder is group shared folder from groupfolders application type GroupFolder struct { ID int `json:"id"` MountPoint string `json:"mount_point"` diff --git a/monitoring.go b/monitoring.go index 29dccc4..116b335 100644 --- a/monitoring.go +++ b/monitoring.go @@ -1,5 +1,6 @@ package gonextcloud +// System contains the operating system statistics type System struct { Version string `json:"version"` Theme string `json:"theme"` @@ -18,7 +19,9 @@ type System struct { SwapFree int `json:"swap_free"` } +// Monitoring contains the nextcloud monitoring statistics type Monitoring struct { + // Nextcloud Statistics Nextcloud struct { System System `json:"system"` Storage Storage `json:"storage"` @@ -32,6 +35,7 @@ type Monitoring struct { NumFedSharesReceived int `json:"num_fed_shares_received"` } `json:"shares"` } `json:"nextcloud"` + // Server statistics Server struct { Webserver string `json:"webserver"` Php struct { @@ -46,15 +50,18 @@ type Monitoring struct { Size int `json:"size"` } `json:"database"` } `json:"server"` + // Active users statistics ActiveUsers ActiveUsers `json:"activeUsers"` } +// ActiveUsers contains the active users statistics type ActiveUsers struct { Last5Minutes int `json:"last5minutes"` Last1Hour int `json:"last1hour"` Last24Hours int `json:"last24hours"` } +// Storage contains the storage statistics type Storage struct { NumUsers int `json:"num_users"` NumFiles int `json:"num_files"` diff --git a/notification.go b/notification.go index 5690f63..21801fe 100644 --- a/notification.go +++ b/notification.go @@ -2,6 +2,7 @@ package gonextcloud import "time" +// Notification is a nextcloud notification (from notification app) type Notification struct { NotificationID int `json:"notification_id"` App string `json:"app"` diff --git a/responses.go b/responses.go index 05215a3..d436798 100644 --- a/responses.go +++ b/responses.go @@ -119,6 +119,7 @@ type capabilitiesResponse struct { } `json:"ocs"` } +// Version contains the nextcloud version informations type Version struct { Major int `json:"major"` Minor int `json:"minor"` diff --git a/shares.go b/shares.go index bdc149f..a91a2d0 100644 --- a/shares.go +++ b/shares.go @@ -1,22 +1,36 @@ package gonextcloud +// ShareType is the nextcloud shares types enum : type ShareType int + +// SharePermission is the nextcloud share permissions enum type SharePermission int const ( - UserShare ShareType = 0 - GroupShare ShareType = 1 - PublicLinkShare ShareType = 3 + // UserShare is a file or folder shared with other user(s) + UserShare ShareType = 0 + // GroupShare is a file or folder shared with a group + GroupShare ShareType = 1 + // PublicLinkShare is a file or folder shared through public link + PublicLinkShare ShareType = 3 + // FederatedCloudShare is a file or folder shared through federated cloud FederatedCloudShare ShareType = 6 - ReadPermission SharePermission = 1 - UpdatePermission SharePermission = 2 - CreatePermission SharePermission = 4 - DeletePermission SharePermission = 8 + // ReadPermission grant read permission + ReadPermission SharePermission = 1 + // UpdatePermission grant update permission + UpdatePermission SharePermission = 2 + // CreatePermission grant create permission + CreatePermission SharePermission = 4 + // DeletePermission grant delete permission + DeletePermission SharePermission = 8 + // ReSharePermission grant resharing permission ReSharePermission SharePermission = 16 - AllPermissions SharePermission = 31 + // AllPermissions grant all permissions + AllPermissions SharePermission = 31 ) +// ShareUpdate contains the data required in order to update a nextcloud share type ShareUpdate struct { ShareID int Permissions SharePermission @@ -25,6 +39,7 @@ type ShareUpdate struct { ExpireDate string } +// Share is a nextcloud share type Share struct { ID string `json:"id"` ShareType int `json:"share_type"` diff --git a/user.go b/user.go index 954e3df..a0156f0 100644 --- a/user.go +++ b/user.go @@ -2,7 +2,7 @@ package gonextcloud 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 { Username string Email string @@ -12,7 +12,7 @@ type User struct { Groups []string } -//UserDetails is the raw Nextcloud User response +// UserDetails is the raw Nextcloud User response type UserDetails struct { Enabled bool `json:"enabled"` ID string `json:"id"` @@ -33,6 +33,7 @@ type UserDetails struct { Locale string `json:"locale,omitempty"` } +// Quota is a use storage Quota type Quota struct { Free int64 `json:"free"` Used int64 `json:"used"`