mirror of
https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
synced 2024-11-22 00:06:25 +00:00
Added Group Search, Improved documentation
This commit is contained in:
parent
b1fadec550
commit
8230c87476
245
README.md
245
README.md
@ -23,18 +23,22 @@ A simple Client for Nextcloud's API in Go.
|
||||
- ~~demote subadmin~~
|
||||
- ~~send welcome mail~~
|
||||
- [Groups](#groups)
|
||||
- create
|
||||
- delete
|
||||
- get members
|
||||
- get subadmins
|
||||
- ~~create~~
|
||||
- ~~delete~~
|
||||
- ~~get members~~
|
||||
- ~~get subadmins~~
|
||||
- [Apps](#apps)
|
||||
- list
|
||||
- get infos
|
||||
- enable
|
||||
- disable
|
||||
|
||||
# Getting started
|
||||
## Authentication
|
||||
# client
|
||||
--
|
||||
import "github.com/partitio/gonextcloud/client"
|
||||
|
||||
|
||||
## Usage
|
||||
```go
|
||||
package main
|
||||
|
||||
@ -56,86 +60,191 @@ func main() {
|
||||
}
|
||||
defer c.Logout()
|
||||
}
|
||||
````
|
||||
```
|
||||
|
||||
#### func NewClient
|
||||
|
||||
```go
|
||||
func NewClient(hostname string) (*Client, error)
|
||||
```
|
||||
|
||||
## Authentication
|
||||
#### func (*Client) Login
|
||||
|
||||
```go
|
||||
func (c *Client) Login(username string, password string) error
|
||||
```
|
||||
|
||||
#### func (*Client) Logout
|
||||
```go
|
||||
func (c *Client) Logout() error
|
||||
```
|
||||
## Users
|
||||
List :
|
||||
```go
|
||||
func (c *Client) UserList() ([]string, error)
|
||||
```
|
||||
Search
|
||||
```go
|
||||
func (c *Client) UserSearch(search string) ([]string, error)
|
||||
```
|
||||
Get
|
||||
#### func (*Client) User
|
||||
|
||||
```go
|
||||
func (c *Client) User(name string) (*types.User, error)
|
||||
```
|
||||
Create
|
||||
|
||||
#### func (*Client) UserCreate
|
||||
|
||||
```go
|
||||
func (c *Client) UserCreate(username string, password string) error
|
||||
```
|
||||
Delete
|
||||
|
||||
#### func (*Client) UserDelete
|
||||
|
||||
```go
|
||||
func (c *Client) UserDelete(name string) error
|
||||
func (c *Client) UserDelete(name string) error
|
||||
```
|
||||
Enable
|
||||
|
||||
#### func (*Client) UserDisable
|
||||
|
||||
```go
|
||||
func (c *Client) UserEnable(name string) error
|
||||
func (c *Client) UserDisable(name string) error
|
||||
```
|
||||
Disable
|
||||
|
||||
#### func (*Client) UserEnable
|
||||
|
||||
```go
|
||||
func (c *Client) UserDisable(name string) error
|
||||
func (c *Client) UserEnable(name string) error
|
||||
```
|
||||
Update
|
||||
|
||||
#### func (*Client) UserGroupAdd
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateEmail(name string, email string) error
|
||||
func (c *Client) UserGroupAdd(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupDemote
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateDisplayName(name string, displayName string) error
|
||||
func (c *Client) UserGroupDemote(name string, group string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserUpdatePhone(name string, phone string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserUpdateAddress(name string, address string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserUpdateWebSite(name string, website string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserUpdateTwitter(name string, twitter string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserUpdatePassword(name string, password string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserUpdateQuota(name string, quota string) error
|
||||
```
|
||||
Groups
|
||||
|
||||
#### func (*Client) UserGroupList
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupList(name string) ([]string, error)
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserGroupAdd(name string, group string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserGroupRemove(name string, group string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserGroupPromote(name string, group string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserGroupDemote(name string, group string) error
|
||||
```
|
||||
```go
|
||||
func (c *Client) UserGroupSubAdminList(name string) ([]string, error)
|
||||
```
|
||||
Welcome Mail
|
||||
```go
|
||||
func (c *Client) UserSendWelcomeEmail(name string) error
|
||||
```
|
||||
## Groups
|
||||
TODO
|
||||
|
||||
## Apps
|
||||
TODO
|
||||
#### func (*Client) UserGroupPromote
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupPromote(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupRemove
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupRemove(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupSubAdminList
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupSubAdminList(name string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserList
|
||||
|
||||
```go
|
||||
func (c *Client) UserList() ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserSearch
|
||||
|
||||
```go
|
||||
func (c *Client) UserSearch(search string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserSendWelcomeEmail
|
||||
|
||||
```go
|
||||
func (c *Client) UserSendWelcomeEmail(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateAddress
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateAddress(name string, address string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateDisplayName
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateDisplayName(name string, displayName string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateEmail
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateEmail(name string, email string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdatePassword
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdatePassword(name string, password string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdatePhone
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdatePhone(name string, phone string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateQuota
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateQuota(name string, quota string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateTwitter
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateTwitter(name string, twitter string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateWebSite
|
||||
|
||||
## Groups
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateWebSite(name string, website string) error
|
||||
```
|
||||
#### func (*Client) GroupCreate
|
||||
|
||||
```go
|
||||
func (c *Client) GroupCreate(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) GroupDelete
|
||||
|
||||
```go
|
||||
func (c *Client) GroupDelete(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) GroupList
|
||||
|
||||
```go
|
||||
func (c *Client) GroupList() ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupSearch
|
||||
|
||||
```go
|
||||
func (c *Client) GroupSearch(search string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupSubAdminList
|
||||
|
||||
```go
|
||||
func (c *Client) GroupSubAdminList(name string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupUsers
|
||||
|
||||
```go
|
||||
func (c *Client) GroupUsers(name string) ([]string, error)
|
||||
```
|
||||
|
@ -16,6 +16,7 @@ func (c *Client) Login(username string, password string) error {
|
||||
Auth: []string{c.username, c.password},
|
||||
}
|
||||
c.session = req.NewSession(&options)
|
||||
// TODO What to do with capabilities ? (other thant connection validation)
|
||||
u := c.baseURL.ResolveReference(routes.capabilities)
|
||||
r, err := c.session.Get(u.String(), nil)
|
||||
if err != nil {
|
||||
|
@ -1,3 +1,43 @@
|
||||
/*
|
||||
Package client is a Go client for the Nextcloud Provisioning 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
|
||||
|
||||
Usage
|
||||
|
||||
You use the library by creating a client object and calling methods on it.
|
||||
|
||||
For example, to list all the Nextcloud's instance users:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/partitio/gonextcloud/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
url := "https://www.mynextcloud.com"
|
||||
username := "admin"
|
||||
password := "password"
|
||||
c, err := client.NewClient(url)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := c.Login(username, password); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer c.Logout()
|
||||
|
||||
users, err := c.UserList()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Users :", users)
|
||||
}
|
||||
*/
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
|
@ -20,7 +20,7 @@ func (c *Client) GroupList() ([]string, error) {
|
||||
return gr.Ocs.Data.Groups, nil
|
||||
}
|
||||
|
||||
func (c *Client) Group(name string) ([]string, error) {
|
||||
func (c *Client) GroupUsers(name string) ([]string, error) {
|
||||
res, err := c.baseRequest(routes.groups, name, "", nil, http.MethodGet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -33,6 +33,22 @@ func (c *Client) Group(name string) ([]string, error) {
|
||||
return r.Ocs.Data.Users, nil
|
||||
}
|
||||
|
||||
func (c *Client) GroupSearch(search string) ([]string, error) {
|
||||
ro := &req.RequestOptions{
|
||||
Params: map[string]string{"search": search},
|
||||
}
|
||||
res, err := c.baseRequest(routes.groups, "", "", ro, http.MethodGet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r types.GroupListResponse
|
||||
res.JSON(&r)
|
||||
if r.Ocs.Meta.Statuscode != 100 {
|
||||
return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message)
|
||||
}
|
||||
return r.Ocs.Data.Groups, nil
|
||||
}
|
||||
|
||||
func (c *Client) GroupCreate(name string) error {
|
||||
ro := &req.RequestOptions{
|
||||
Data: map[string]string{
|
||||
|
230
docs/README.md
Normal file
230
docs/README.md
Normal file
@ -0,0 +1,230 @@
|
||||
# client
|
||||
--
|
||||
import "github.com/partitio/gonextcloud/client"
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/partitio/gonextcloud/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
url := "https://www.mynextcloud.com"
|
||||
username := "admin"
|
||||
password := "password"
|
||||
c, err := client.NewClient(url)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := c.Login(username, password); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer c.Logout()
|
||||
}
|
||||
```
|
||||
|
||||
#### type Client
|
||||
|
||||
```go
|
||||
type Client struct {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### func NewClient
|
||||
|
||||
```go
|
||||
func NewClient(hostname string) (*Client, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupCreate
|
||||
|
||||
```go
|
||||
func (c *Client) GroupCreate(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) GroupDelete
|
||||
|
||||
```go
|
||||
func (c *Client) GroupDelete(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) GroupList
|
||||
|
||||
```go
|
||||
func (c *Client) GroupList() ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupSearch
|
||||
|
||||
```go
|
||||
func (c *Client) GroupSearch(search string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupSubAdminList
|
||||
|
||||
```go
|
||||
func (c *Client) GroupSubAdminList(name string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) GroupUsers
|
||||
|
||||
```go
|
||||
func (c *Client) GroupUsers(name string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) Login
|
||||
|
||||
```go
|
||||
func (c *Client) Login(username string, password string) error
|
||||
```
|
||||
|
||||
#### func (*Client) Logout
|
||||
|
||||
```go
|
||||
func (c *Client) Logout() error
|
||||
```
|
||||
|
||||
#### func (*Client) User
|
||||
|
||||
```go
|
||||
func (c *Client) User(name string) (*types.User, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserCreate
|
||||
|
||||
```go
|
||||
func (c *Client) UserCreate(username string, password string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserDelete
|
||||
|
||||
```go
|
||||
func (c *Client) UserDelete(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserDisable
|
||||
|
||||
```go
|
||||
func (c *Client) UserDisable(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserEnable
|
||||
|
||||
```go
|
||||
func (c *Client) UserEnable(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupAdd
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupAdd(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupDemote
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupDemote(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupList
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupList(name string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupPromote
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupPromote(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupRemove
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupRemove(name string, group string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserGroupSubAdminList
|
||||
|
||||
```go
|
||||
func (c *Client) UserGroupSubAdminList(name string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserList
|
||||
|
||||
```go
|
||||
func (c *Client) UserList() ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserSearch
|
||||
|
||||
```go
|
||||
func (c *Client) UserSearch(search string) ([]string, error)
|
||||
```
|
||||
|
||||
#### func (*Client) UserSendWelcomeEmail
|
||||
|
||||
```go
|
||||
func (c *Client) UserSendWelcomeEmail(name string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateAddress
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateAddress(name string, address string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateDisplayName
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateDisplayName(name string, displayName string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateEmail
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateEmail(name string, email string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdatePassword
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdatePassword(name string, password string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdatePhone
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdatePhone(name string, phone string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateQuota
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateQuota(name string, quota string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateTwitter
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateTwitter(name string, twitter string) error
|
||||
```
|
||||
|
||||
#### func (*Client) UserUpdateWebSite
|
||||
|
||||
```go
|
||||
func (c *Client) UserUpdateWebSite(name string, website string) error
|
||||
```
|
||||
|
||||
#### type Routes
|
||||
|
||||
```go
|
||||
type Routes struct {
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user