mirror of
https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
synced 2024-11-24 21:26:25 +00:00
Fix coverage in Makefile
This commit is contained in:
parent
77765f51b8
commit
4a1bec45bf
3
Makefile
3
Makefile
@ -21,7 +21,8 @@ msan: dep ## Run memory sanitizer
|
|||||||
|
|
||||||
coverage: ## Generate global code coverage report
|
coverage: ## Generate global code coverage report
|
||||||
@mkdir -p cover
|
@mkdir -p cover
|
||||||
go tool cover -html=cover/gonextcloud.cov -o coverage.html
|
@touch cover/${PROJECT_NAME}cov
|
||||||
|
go tool cover -html=cover/${PROJECT_NAME}cov -o coverage.html
|
||||||
|
|
||||||
dep: ## Get the dependencies
|
dep: ## Get the dependencies
|
||||||
@mkdir -p vendor
|
@mkdir -p vendor
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
mode: count
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:15.47,18.16 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:21.2,23.30 3 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:18.16,20.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:26.57,27.16 1 13
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:30.2,31.16 2 12
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:34.2,38.55 4 11
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:41.2,41.25 1 11
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:27.16,29.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:31.16,33.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:38.55,40.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:44.62,49.16 3 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:52.2,54.30 3 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:49.16,51.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:57.87,64.71 2 4
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:67.2,67.17 1 3
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:70.2,70.27 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:64.71,66.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:67.17,69.3 1 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:73.48,75.2 1 3
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:77.48,82.2 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:84.49,89.2 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:91.58,93.2 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:95.53,99.19 4 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:113.2,113.12 1 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:117.2,117.35 1 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:99.19,100.50 1 22
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:100.50,102.38 2 12
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:102.38,104.87 2 12
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:104.87,109.6 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:113.12,116.3 2 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:120.67,122.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:124.79,126.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:128.67,130.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:132.71,134.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:136.71,138.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:140.71,142.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:144.73,146.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:148.64,150.2 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:152.63,154.16 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:157.2,159.31 3 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:154.16,156.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:162.64,169.2 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:171.67,178.2 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:180.68,187.2 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:189.67,196.2 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:198.71,199.19 1 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:202.2,205.16 4 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:208.2,210.24 3 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:199.19,201.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:205.16,207.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:213.83,221.2 2 20
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:223.106,226.2 2 32
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:228.40,230.25 2 44
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:235.2,235.14 1 24
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:230.25,231.15 1 180
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go:231.15,233.4 1 20
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:13.138,14.19 1 52
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:17.2,18.16 2 51
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:21.2,21.20 1 51
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:24.2,28.30 2 51
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:37.2,37.16 1 51
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:41.2,44.34 4 50
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:48.2,48.17 1 48
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:14.19,16.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:18.16,20.3 1 42
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:21.20,23.3 1 7
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:28.30,30.3 1 17
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:30.8,30.38 1 34
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:30.38,32.3 1 7
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:32.8,32.37 1 27
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:32.37,34.3 1 22
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:34.8,34.40 1 5
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:34.40,36.3 1 5
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:37.16,39.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:44.34,47.3 2 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go:51.39,58.2 4 11
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:9.46,11.16 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:14.2,16.29 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:11.16,13.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:19.53,24.16 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:27.2,29.29 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:24.16,26.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:32.54,37.16 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:40.2,42.29 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:37.16,39.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:45.59,47.16 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:50.2,52.24 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:47.16,49.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:55.47,57.16 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:60.2,62.12 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:57.16,59.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:65.48,67.16 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:70.2,72.12 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:67.16,69.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go:75.106,78.2 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:11.64,22.16 7 3
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:25.2,30.19 4 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:34.2,34.12 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:22.16,24.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:30.19,33.3 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:37.33,43.2 4 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:45.34,47.27 1 57
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:50.2,50.45 1 56
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go:47.27,49.3 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client.go:58.50,60.16 2 3
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client.go:67.2,74.16 2 3
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client.go:60.16,62.17 2 2
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client.go:62.17,64.4 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:9.48,11.16 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:14.2,16.31 3 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:11.16,13.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:19.60,21.16 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:24.2,26.30 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:21.16,23.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:29.63,34.16 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:37.2,39.31 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:34.16,36.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:42.49,48.72 2 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:51.2,51.12 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:48.72,50.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:54.49,55.77 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:58.2,58.12 1 1
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:55.77,57.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:61.67,63.16 2 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:66.2,68.30 3 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:63.16,65.3 1 0
|
|
||||||
gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go:71.107,74.2 2 2
|
|
0
cover/gonextcloudcov
Normal file
0
cover/gonextcloudcov
Normal file
596
coverage.html
596
coverage.html
@ -54,18 +54,6 @@
|
|||||||
<div id="nav">
|
<div id="nav">
|
||||||
<select id="files">
|
<select id="files">
|
||||||
|
|
||||||
<option value="file0">gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/apps.go (0.0%)</option>
|
|
||||||
|
|
||||||
<option value="file1">gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/auth.go (100.0%)</option>
|
|
||||||
|
|
||||||
<option value="file2">gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client.go (85.7%)</option>
|
|
||||||
|
|
||||||
<option value="file3">gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/groups.go (35.3%)</option>
|
|
||||||
|
|
||||||
<option value="file4">gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/users.go (89.0%)</option>
|
|
||||||
|
|
||||||
<option value="file5">gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/utils.go (100.0%)</option>
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="legend">
|
<div id="legend">
|
||||||
@ -87,590 +75,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
<pre class="file" id="file0" style="display: none">package gonextcloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
req "github.com/levigross/grequests"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Client) AppList() ([]string, error) <span class="cov0" title="0">{
|
|
||||||
res, err := c.baseRequest(routes.apps, "", "", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.AppListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Apps, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) AppListEnabled() ([]string, error) <span class="cov0" title="0">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Params: map[string]string{"filter": "enabled"},
|
|
||||||
}
|
|
||||||
res, err := c.baseRequest(routes.apps, "", "", ro, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.AppListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Apps, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) AppListDisabled() ([]string, error) <span class="cov0" title="0">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Params: map[string]string{"filter": "disabled"},
|
|
||||||
}
|
|
||||||
res, err := c.baseRequest(routes.apps, "", "", ro, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.AppListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Apps, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) AppInfos(name string) (types.App, error) <span class="cov0" title="0">{
|
|
||||||
res, err := c.baseRequest(routes.apps, name, "", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return types.App{}, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.AppResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) AppEnable(name string) error <span class="cov0" title="0">{
|
|
||||||
res, err := c.baseRequest(routes.apps, name, "", nil, http.MethodPut)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.BaseResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) AppDisable(name string) error <span class="cov0" title="0">{
|
|
||||||
res, err := c.baseRequest(routes.apps, name, "", nil, http.MethodDelete)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.BaseResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) appsBaseRequest(name string, route string, ro *req.RequestOptions, method string) error <span class="cov0" title="0">{
|
|
||||||
_, err := c.baseRequest(routes.apps, name, route, ro, method)
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<pre class="file" id="file1" style="display: none">package gonextcloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
req "github.com/levigross/grequests"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
var unauthorized = fmt.Errorf("login first")
|
|
||||||
|
|
||||||
func (c *Client) Login(username string, password string) error <span class="cov3" title="3">{
|
|
||||||
c.username = username
|
|
||||||
c.password = password
|
|
||||||
options := req.RequestOptions{
|
|
||||||
Headers: c.headers,
|
|
||||||
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)
|
|
||||||
res, err := c.session.Get(u.String(), nil)
|
|
||||||
if err != nil </span><span class="cov1" title="1">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
<span class="cov2" title="2">var r types.CapabilitiesResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
// No need to check for Ocs.Meta.StatusCode as capabilities are always returned
|
|
||||||
c.capabilities = &r.Ocs.Data.Capabilities
|
|
||||||
// Check if authentication failed
|
|
||||||
if !c.loggedIn() </span><span class="cov1" title="1">{
|
|
||||||
e := types.APIError{Message: "authentication failed"}
|
|
||||||
return &e
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">return nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) Logout() error <span class="cov1" title="1">{
|
|
||||||
c.session.CloseIdleConnections()
|
|
||||||
c.session.HTTPClient.Jar = nil
|
|
||||||
// Clear capabilities as it is used to check for valid authentication
|
|
||||||
c.capabilities = nil
|
|
||||||
return nil
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) loggedIn() bool <span class="cov10" title="57">{
|
|
||||||
// When authentication failed, capabilities doesn't contains core information
|
|
||||||
if c.capabilities == nil </span><span class="cov1" title="1">{
|
|
||||||
return false
|
|
||||||
}</span>
|
|
||||||
<span class="cov9" title="56">return c.capabilities.Core.WebdavRoot != ""</span>
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<pre class="file" id="file2" style="display: none">/*
|
|
||||||
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"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-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 gonextcloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
req "github.com/levigross/grequests"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
||||||
"net/url"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
baseURL *url.URL
|
|
||||||
username string
|
|
||||||
password string
|
|
||||||
session *req.Session
|
|
||||||
headers map[string]string
|
|
||||||
capabilities *types.Capabilities
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient(hostname string) (*Client, error) <span class="cov10" title="3">{
|
|
||||||
baseURL, err := url.ParseRequestURI(hostname)
|
|
||||||
if err != nil </span><span class="cov6" title="2">{
|
|
||||||
baseURL, err = url.ParseRequestURI("https://" + hostname)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
<span class="cov10" title="3">c := Client{
|
|
||||||
baseURL: baseURL,
|
|
||||||
headers: map[string]string{
|
|
||||||
"OCS-APIREQUEST": "true",
|
|
||||||
"Accept": "application/json",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return &c, nil</span>
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<pre class="file" id="file3" style="display: none">package gonextcloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
req "github.com/levigross/grequests"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Client) GroupList() ([]string, error) <span class="cov1" title="1">{
|
|
||||||
res, err := c.baseRequest(routes.groups, "", "", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">var r types.GroupListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Groups, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GroupUsers(name string) ([]string, error) <span class="cov0" title="0">{
|
|
||||||
res, err := c.baseRequest(routes.groups, name, "", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.UserListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Users, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GroupSearch(search string) ([]string, error) <span class="cov0" title="0">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Params: map[string]string{"search": search},
|
|
||||||
}
|
|
||||||
res, err := c.baseRequest(routes.groups, "", "", ro, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.GroupListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Groups, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GroupCreate(name string) error <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"groupid": name,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if err := c.groupBaseRequest("", "", ro, http.MethodPost); err != nil </span><span class="cov0" title="0">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">return nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GroupDelete(name string) error <span class="cov1" title="1">{
|
|
||||||
if err := c.groupBaseRequest(name, "", nil, http.MethodDelete); err != nil </span><span class="cov0" title="0">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">return nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GroupSubAdminList(name string) ([]string, error) <span class="cov0" title="0">{
|
|
||||||
res, err := c.baseRequest(routes.groups, name, "subadmins", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov0" title="0">var r types.UserListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Users, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) groupBaseRequest(name string, route string, ro *req.RequestOptions, method string) error <span class="cov10" title="2">{
|
|
||||||
_, err := c.baseRequest(routes.groups, name, route, ro, method)
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<pre class="file" id="file4" style="display: none">package gonextcloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"github.com/fatih/structs"
|
|
||||||
req "github.com/levigross/grequests"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
||||||
"net/http"
|
|
||||||
"path"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Client) UserList() ([]string, error) <span class="cov1" title="1">{
|
|
||||||
res, err := c.baseRequest(routes.users, "", "", nil, http.MethodGet)
|
|
||||||
//res, err := c.session.Get(u.String(), nil)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">var r types.UserListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Users, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) User(name string) (*types.User, error) <span class="cov5" title="13">{
|
|
||||||
if name == "" </span><span class="cov1" title="1">{
|
|
||||||
return nil, &types.APIError{Message: "name cannot be empty"}
|
|
||||||
}</span>
|
|
||||||
<span class="cov5" title="12">res, err := c.baseRequest(routes.users, name, "", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov1" title="1">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov5" title="11">var r types.UserResponse
|
|
||||||
js := res.String()
|
|
||||||
// Nextcloud does not encode JSON properly
|
|
||||||
js = reformatJSON(js)
|
|
||||||
if err := json.Unmarshal([]byte(js), &r); err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov5" title="11">return &r.Ocs.Data, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UserSearch(search string) ([]string, error) <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Params: map[string]string{"search": search},
|
|
||||||
}
|
|
||||||
res, err := c.baseRequest(routes.users, "", "", ro, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">var r types.UserListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Users, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UserCreate(username string, password string, user *types.User) error <span class="cov3" title="4">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"userid": username,
|
|
||||||
"password": password,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if err := c.userBaseRequest("", "", ro, http.MethodPost); err != nil </span><span class="cov1" title="1">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
<span class="cov2" title="3">if user == nil </span><span class="cov2" title="2">{
|
|
||||||
return nil
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">return c.UserUpdate(user)</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UserDelete(name string) error <span class="cov2" title="3">{
|
|
||||||
return c.userBaseRequest(name, "", nil, http.MethodDelete)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserEnable(name string) error <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "enable", ro, http.MethodPut)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserDisable(name string) error <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "disable", ro, http.MethodPut)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserSendWelcomeEmail(name string) error <span class="cov0" title="0">{
|
|
||||||
return c.userBaseRequest(name, "welcome", nil, http.MethodPost)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdate(user *types.User) error <span class="cov2" title="2">{
|
|
||||||
m := structs.Map(user)
|
|
||||||
errs := make(chan types.UpdateError)
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
for k := range m </span><span class="cov6" title="22">{
|
|
||||||
if !ignoredUserField(k) && m[k].(string) != "" </span><span class="cov5" title="12">{
|
|
||||||
wg.Add(1)
|
|
||||||
go func(key string, value string) </span><span class="cov5" title="12">{
|
|
||||||
defer wg.Done()
|
|
||||||
if err := c.userUpdateAttribute(user.ID, strings.ToLower(key), value); err != nil </span><span class="cov0" title="0">{
|
|
||||||
errs <- types.UpdateError{
|
|
||||||
Field: key,
|
|
||||||
Error: err,
|
|
||||||
}
|
|
||||||
}</span>
|
|
||||||
}(k, m[k].(string))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<span class="cov2" title="2">go func() </span><span class="cov2" title="2">{
|
|
||||||
wg.Wait()
|
|
||||||
close(errs)
|
|
||||||
}</span>()
|
|
||||||
<span class="cov2" title="2">return types.NewUpdateError(errs)</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UserUpdateEmail(name string, email string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "email", email)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdateDisplayName(name string, displayName string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "displayname", displayName)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdatePhone(name string, phone string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "phone", phone)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdateAddress(name string, address string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "address", address)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdateWebSite(name string, website string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "website", website)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdateTwitter(name string, twitter string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "twitter", twitter)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdatePassword(name string, password string) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "password", password)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserUpdateQuota(name string, quota int) error <span class="cov1" title="1">{
|
|
||||||
return c.userUpdateAttribute(name, "quota", strconv.Itoa(quota))
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserGroupList(name string) ([]string, error) <span class="cov1" title="1">{
|
|
||||||
res, err := c.baseRequest(routes.users, name, "groups", nil, http.MethodGet)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov1" title="1">var r types.GroupListResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data.Groups, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UserGroupAdd(name string, group string) error <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"groupid": group,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "groups", ro, http.MethodPost)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserGroupRemove(name string, group string) error <span class="cov0" title="0">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"groupid": group,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "groups", ro, http.MethodDelete)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserGroupPromote(name string, group string) error <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"groupid": group,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "subadmins", ro, http.MethodPost)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserGroupDemote(name string, group string) error <span class="cov1" title="1">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"groupid": group,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "subadmins", ro, http.MethodDelete)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) UserGroupSubAdminList(name string) ([]string, error) <span class="cov2" title="2">{
|
|
||||||
if !c.loggedIn() </span><span class="cov0" title="0">{
|
|
||||||
return nil, unauthorized
|
|
||||||
}</span>
|
|
||||||
<span class="cov2" title="2">u := c.baseURL.ResolveReference(routes.users)
|
|
||||||
u.Path = path.Join(u.Path, name, "subadmins")
|
|
||||||
res, err := c.session.Get(u.String(), nil)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov2" title="2">var r types.BaseResponse
|
|
||||||
res.JSON(&r)
|
|
||||||
return r.Ocs.Data, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) userUpdateAttribute(name string, key string, value string) error <span class="cov6" title="20">{
|
|
||||||
ro := &req.RequestOptions{
|
|
||||||
Data: map[string]string{
|
|
||||||
"key": key,
|
|
||||||
"value": value,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return c.userBaseRequest(name, "", ro, http.MethodPut)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func (c *Client) userBaseRequest(name string, route string, ro *req.RequestOptions, method string) error <span class="cov7" title="32">{
|
|
||||||
_, err := c.baseRequest(routes.users, name, route, ro, method)
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
func ignoredUserField(key string) bool <span class="cov7" title="44">{
|
|
||||||
keys := []string{"ID", "Quota", "Enabled", "Groups", "Language"}
|
|
||||||
for _, k := range keys </span><span class="cov10" title="180">{
|
|
||||||
if key == k </span><span class="cov6" title="20">{
|
|
||||||
return true
|
|
||||||
}</span>
|
|
||||||
}
|
|
||||||
<span class="cov6" title="24">return false</span>
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<pre class="file" id="file5" style="display: none">package gonextcloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
req "github.com/levigross/grequests"
|
|
||||||
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"path"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Client) baseRequest(route *url.URL, name string, subroute string, ro *req.RequestOptions, method string) (*req.Response, error) <span class="cov10" title="52">{
|
|
||||||
if !c.loggedIn() </span><span class="cov1" title="1">{
|
|
||||||
return nil, unauthorized
|
|
||||||
}</span>
|
|
||||||
<span class="cov9" title="51">u := c.baseURL.ResolveReference(route)
|
|
||||||
if name != "" </span><span class="cov9" title="42">{
|
|
||||||
u.Path = path.Join(u.Path, name)
|
|
||||||
}</span>
|
|
||||||
<span class="cov9" title="51">if subroute != "" </span><span class="cov5" title="7">{
|
|
||||||
u.Path = path.Join(u.Path, subroute)
|
|
||||||
}</span>
|
|
||||||
<span class="cov9" title="51">var (
|
|
||||||
res *req.Response
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if method == http.MethodGet </span><span class="cov7" title="17">{
|
|
||||||
res, err = c.session.Get(u.String(), ro)
|
|
||||||
}</span> else<span class="cov9" title="34"> if method == http.MethodPost </span><span class="cov5" title="7">{
|
|
||||||
res, err = c.session.Post(u.String(), ro)
|
|
||||||
}</span> else<span class="cov8" title="27"> if method == http.MethodPut </span><span class="cov8" title="22">{
|
|
||||||
res, err = c.session.Put(u.String(), ro)
|
|
||||||
}</span> else<span class="cov4" title="5"> if method == http.MethodDelete </span><span class="cov4" title="5">{
|
|
||||||
res, err = c.session.Delete(u.String(), ro)
|
|
||||||
}</span>
|
|
||||||
<span class="cov9" title="51">if err != nil </span><span class="cov1" title="1">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
// As we cannot read the ReaderCloser twice, we use the string content
|
|
||||||
<span class="cov9" title="50">js := res.String()
|
|
||||||
var r types.BaseResponse
|
|
||||||
json.Unmarshal([]byte(js), &r)
|
|
||||||
if r.Ocs.Meta.Statuscode != 100 </span><span class="cov2" title="2">{
|
|
||||||
err := types.ErrorFromMeta(r.Ocs.Meta)
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov9" title="48">return res, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
func reformatJSON(json string) string <span class="cov6" title="11">{
|
|
||||||
// Nextcloud encode boolean as string
|
|
||||||
json = strings.Replace(json, "\"true\"", "true", -1)
|
|
||||||
json = strings.Replace(json, "\"false\"", "false", -1)
|
|
||||||
// Nextcloud encode quota as an empty array for never connected users
|
|
||||||
json = strings.Replace(json, "\"quota\":[],", "", -1)
|
|
||||||
return json
|
|
||||||
}</span>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
Reference in New Issue
Block a user