mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-19 10:12:54 +02:00
Migrate gitea-sdk to v0.12.0 (#133)
Migrate Update code.gitea.io/sdk/gitea to v0.12.0. Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/133 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
29
vendor/code.gitea.io/sdk/gitea/repo_key.go
generated
vendored
29
vendor/code.gitea.io/sdk/gitea/repo_key.go
generated
vendored
@ -8,6 +8,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -24,10 +25,32 @@ type DeployKey struct {
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeployKeysOptions options for listing a repository's deploy keys
|
||||
type ListDeployKeysOptions struct {
|
||||
ListOptions
|
||||
KeyID int64
|
||||
Fingerprint string
|
||||
}
|
||||
|
||||
// QueryEncode turns options into querystring argument
|
||||
func (opt *ListDeployKeysOptions) QueryEncode() string {
|
||||
query := opt.getURLQuery()
|
||||
if opt.KeyID > 0 {
|
||||
query.Add("key_id", fmt.Sprintf("%d", opt.KeyID))
|
||||
}
|
||||
if len(opt.Fingerprint) > 0 {
|
||||
query.Add("fingerprint", opt.Fingerprint)
|
||||
}
|
||||
return query.Encode()
|
||||
}
|
||||
|
||||
// ListDeployKeys list all the deploy keys of one repository
|
||||
func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error) {
|
||||
keys := make([]*DeployKey, 0, 10)
|
||||
return keys, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys", user, repo), nil, nil, &keys)
|
||||
func (c *Client) ListDeployKeys(user, repo string, opt ListDeployKeysOptions) ([]*DeployKey, error) {
|
||||
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/keys", user, repo))
|
||||
opt.setDefaults()
|
||||
link.RawQuery = opt.QueryEncode()
|
||||
keys := make([]*DeployKey, 0, opt.PageSize)
|
||||
return keys, c.getParsedResponse("GET", link.String(), nil, nil, &keys)
|
||||
}
|
||||
|
||||
// GetDeployKey get one deploy key with key id
|
||||
|
Reference in New Issue
Block a user