Added missing comments

This commit is contained in:
Philippe-Adrien Nousse 2018-07-30 10:18:54 +02:00
parent 17ca4cbf14
commit 62ed77f142
6 changed files with 20 additions and 8 deletions

View File

@ -49,18 +49,12 @@ func (c *Client) GroupCreate(name string) error {
"groupid": name, "groupid": name,
}, },
} }
if err := c.groupBaseRequest("", "", ro, http.MethodPost); err != nil { return c.groupBaseRequest("", "", ro, http.MethodPost)
return err
}
return nil
} }
//GroupDelete deletes the group //GroupDelete deletes the group
func (c *Client) GroupDelete(name string) error { func (c *Client) GroupDelete(name string) error {
if err := c.groupBaseRequest(name, "", nil, http.MethodDelete); err != nil { return c.groupBaseRequest(name, "", nil, http.MethodDelete)
return err
}
return nil
} }
//GroupSubAdminList lists the group's subadmins //GroupSubAdminList lists the group's subadmins

View File

@ -1,5 +1,6 @@
package types package types
//App
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,5 +1,6 @@
package types package types
//Capabilities
type Capabilities struct { type Capabilities struct {
Core struct { Core struct {
Pollinterval int `json:"pollinterval"` Pollinterval int `json:"pollinterval"`

View File

@ -5,11 +5,13 @@ import (
"strings" "strings"
) )
//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
} }
//ErrorFromMeta return a types.APIError from the Response's types.Meta
func ErrorFromMeta(meta Meta) *APIError { func ErrorFromMeta(meta Meta) *APIError {
return &APIError{ return &APIError{
meta.Statuscode, meta.Statuscode,
@ -17,15 +19,18 @@ func ErrorFromMeta(meta Meta) *APIError {
} }
} }
//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
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
type UserUpdateError struct { type UserUpdateError struct {
Errors map[string]error Errors map[string]error
} }
@ -38,6 +43,7 @@ func (e *UserUpdateError) Error() string {
return strings.Join(errors, ",") return strings.Join(errors, ",")
} }
//NewUpdateError returns an UpdateError based on an UpdateError channel
func NewUpdateError(errors chan UpdateError) *UserUpdateError { func NewUpdateError(errors chan UpdateError) *UserUpdateError {
empty := true empty := true
var ue UserUpdateError var ue UserUpdateError

View File

@ -1,5 +1,6 @@
package types package types
//Meta
type Meta struct { type Meta struct {
Status string `json:"status"` Status string `json:"status"`
Statuscode int `json:"statuscode"` Statuscode int `json:"statuscode"`
@ -8,6 +9,7 @@ type Meta struct {
Itemsperpage string `json:"itemsperpage"` Itemsperpage string `json:"itemsperpage"`
} }
//ErrorResponse
type ErrorResponse struct { type ErrorResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -15,6 +17,7 @@ type ErrorResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//UserListResponse
type UserListResponse struct { type UserListResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -24,6 +27,7 @@ type UserListResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//UserResponse
type UserResponse struct { type UserResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -31,6 +35,7 @@ type UserResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//BaseResponse
type BaseResponse struct { type BaseResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -38,6 +43,7 @@ type BaseResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//GroupListResponse
type GroupListResponse struct { type GroupListResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -47,6 +53,7 @@ type GroupListResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//AppListResponse
type AppListResponse struct { type AppListResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -56,6 +63,7 @@ type AppListResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//AppResponse
type AppResponse struct { type AppResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
@ -63,6 +71,7 @@ type AppResponse struct {
} `json:"ocs"` } `json:"ocs"`
} }
//CapabilitiesResponse
type CapabilitiesResponse struct { type CapabilitiesResponse struct {
Ocs struct { Ocs struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`

View File

@ -1,5 +1,6 @@
package types package types
//User
type User struct { type User struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`
ID string `json:"id"` ID string `json:"id"`