Add GetGlobalAPISettings Function (#404)
Get Global Limitation Settings Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/404 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
88552ee13a
commit
6594bf0b20
2 changed files with 30 additions and 2 deletions
|
@ -15,6 +15,14 @@ type GlobalRepoSettings struct {
|
||||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GlobalAPISettings contains global api settings exposed by it
|
||||||
|
type GlobalAPISettings struct {
|
||||||
|
MaxResponseItems int `json:"max_response_items"`
|
||||||
|
DefaultPagingNum int `json:"default_paging_num"`
|
||||||
|
DefaultGitTreesPerPage int `json:"default_git_trees_per_page"`
|
||||||
|
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetGlobalUISettings get global ui settings witch are exposed by API
|
// GetGlobalUISettings get global ui settings witch are exposed by API
|
||||||
func (c *Client) GetGlobalUISettings() (settings *GlobalUISettings, err error) {
|
func (c *Client) GetGlobalUISettings() (settings *GlobalUISettings, err error) {
|
||||||
if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil {
|
if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil {
|
||||||
|
@ -32,3 +40,12 @@ func (c *Client) GetGlobalRepoSettings() (settings *GlobalRepoSettings, err erro
|
||||||
conf := new(GlobalRepoSettings)
|
conf := new(GlobalRepoSettings)
|
||||||
return conf, c.getParsedResponse("GET", "/settings/repository", jsonHeader, nil, &conf)
|
return conf, c.getParsedResponse("GET", "/settings/repository", jsonHeader, nil, &conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGlobalAPISettings get global api settings witch are exposed by it
|
||||||
|
func (c *Client) GetGlobalAPISettings() (settings *GlobalAPISettings, err error) {
|
||||||
|
if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
conf := new(GlobalAPISettings)
|
||||||
|
return conf, c.getParsedResponse("GET", "/settings/api", jsonHeader, nil, &conf)
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,17 @@ func TestGetGlobalSettings(t *testing.T) {
|
||||||
|
|
||||||
repoSettings, err := c.GetGlobalRepoSettings()
|
repoSettings, err := c.GetGlobalRepoSettings()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.False(t, repoSettings.HTTPGitDisabled)
|
assert.EqualValues(t, &GlobalRepoSettings{
|
||||||
assert.False(t, repoSettings.MirrorsDisabled)
|
HTTPGitDisabled: false,
|
||||||
|
MirrorsDisabled: false,
|
||||||
|
}, repoSettings)
|
||||||
|
|
||||||
|
apiSettings, err := c.GetGlobalAPISettings()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, &GlobalAPISettings{
|
||||||
|
MaxResponseItems: 50,
|
||||||
|
DefaultPagingNum: 30,
|
||||||
|
DefaultGitTreesPerPage: 1000,
|
||||||
|
DefaultMaxBlobSize: 10485760,
|
||||||
|
}, apiSettings)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue