Add GetGlobalAttachmentSettings (#414)
Add GetGlobalAttachmentSettings Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/414 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
5b418aa8c6
commit
87f7b1866d
2 changed files with 26 additions and 0 deletions
|
@ -23,6 +23,14 @@ type GlobalAPISettings struct {
|
||||||
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
|
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GlobalAttachmentSettings contains global Attachment settings exposed by API
|
||||||
|
type GlobalAttachmentSettings struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
AllowedTypes string `json:"allowed_types"`
|
||||||
|
MaxSize int64 `json:"max_size"`
|
||||||
|
MaxFiles int `json:"max_files"`
|
||||||
|
}
|
||||||
|
|
||||||
// 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 {
|
||||||
|
@ -49,3 +57,12 @@ func (c *Client) GetGlobalAPISettings() (settings *GlobalAPISettings, err error)
|
||||||
conf := new(GlobalAPISettings)
|
conf := new(GlobalAPISettings)
|
||||||
return conf, c.getParsedResponse("GET", "/settings/api", jsonHeader, nil, &conf)
|
return conf, c.getParsedResponse("GET", "/settings/api", jsonHeader, nil, &conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGlobalAttachmentSettings get global repository settings witch are exposed by API
|
||||||
|
func (c *Client) GetGlobalAttachmentSettings() (settings *GlobalAttachmentSettings, err error) {
|
||||||
|
if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
conf := new(GlobalAttachmentSettings)
|
||||||
|
return conf, c.getParsedResponse("GET", "/settings/attachment", jsonHeader, nil, &conf)
|
||||||
|
}
|
||||||
|
|
|
@ -35,4 +35,13 @@ func TestGetGlobalSettings(t *testing.T) {
|
||||||
DefaultGitTreesPerPage: 1000,
|
DefaultGitTreesPerPage: 1000,
|
||||||
DefaultMaxBlobSize: 10485760,
|
DefaultMaxBlobSize: 10485760,
|
||||||
}, apiSettings)
|
}, apiSettings)
|
||||||
|
|
||||||
|
attachSettings, err := c.GetGlobalAttachmentSettings()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, &GlobalAttachmentSettings{
|
||||||
|
Enabled: true,
|
||||||
|
AllowedTypes: "image/jpeg,image/png,application/zip,application/gzip",
|
||||||
|
MaxSize: 4,
|
||||||
|
MaxFiles: 5,
|
||||||
|
}, attachSettings)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue