// Copyright 2014 The Gogs Authors. All rights reserved.
+// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
var (
_ Payloader = &CreatePayload{}
_ Payloader = &PushPayload{}
+ _ Payloader = &IssuePayload{}
_ Payloader = &PullRequestPayload{}
)
HookIssueLabelCleared HookIssueAction = "label_cleared"
// HookIssueSynchronized synchronized
HookIssueSynchronized HookIssueAction = "synchronized"
+ // HookIssueMilestoned is an issue action for when a milestone is set on an issue.
+ HookIssueMilestoned HookIssueAction = "milestoned"
+ // HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue.
+ HookIssueDemilestoned HookIssueAction = "demilestoned"
)
+// IssuePayload represents the payload information that is sent along with an issue event.
+type IssuePayload struct {
+ Secret string `json:"secret"`
+ Action HookIssueAction `json:"action"`
+ Index int64 `json:"number"`
+ Changes *ChangesPayload `json:"changes,omitempty"`
+ Issue *Issue `json:"issue"`
+ Repository *Repository `json:"repository"`
+ Sender *User `json:"sender"`
+}
+
+// SetSecret modifies the secret of the IssuePayload.
+func (p *IssuePayload) SetSecret(secret string) {
+ p.Secret = secret
+}
+
+// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
+func (p *IssuePayload) JSONPayload() ([]byte, error) {
+ return json.MarshalIndent(p, "", " ")
+}
+
// ChangesFromPayload FIXME
type ChangesFromPayload struct {
From string `json:"from"`
Sender *User `json:"sender"`
}
-// SetSecret FIXME
+// SetSecret modifies the secret of the PullRequestPayload.
func (p *PullRequestPayload) SetSecret(secret string) {
p.Secret = secret
}
// Issue an issue to a repository
type Issue struct {
ID int64 `json:"id"`
+ URL string `json:"url"`
Index int64 `json:"number"`
Poster *User `json:"user"`
Title string `json:"title"`
// PullRequest represents a pull request API object.
type PullRequest struct {
ID int64 `json:"id"`
+ URL string `json:"url"`
Index int64 `json:"number"`
Poster *User `json:"user"`
Title string `json:"title"`
--- /dev/null
+// Copyright 2016 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package gitea
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "time"
+)
+
+// Release represents a repository release
+type Release struct {
+ ID int64 `json:"id"`
+ TagName string `json:"name"`
+ Target string `json:"target_commitish"`
+ Title string `json:"name"`
+ Note string `json:"body"`
+ URL string `json:"url"`
+ TarURL string `json:"tarball_url"`
+ ZipURL string `json:"zipball_url"`
+ IsDraft bool `json:"draft"`
+ IsPrerelease bool `json:"prerelease"`
+ CreatedAt time.Time `json:"created_at"`
+ PublishedAt time.Time `json:"published_at"`
+ Publisher *User `json:"author"`
+}
+
+// ListReleases list releases of a repository
+func (c *Client) ListReleases(user, repo string) ([]*Release, error) {
+ releases := make([]*Release, 0, 10)
+ err := c.getParsedResponse("GET",
+ fmt.Sprintf("/repos/%s/%s/releases", user, repo),
+ nil, nil, &releases)
+ return releases, err
+}
+
+// GetRelease get a release of a repository
+func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) {
+ r := new(Release)
+ err := c.getParsedResponse("GET",
+ fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id),
+ nil, nil, &r)
+ return r, err
+}
+
+// CreateReleaseOption options when creating a release
+type CreateReleaseOption struct {
+ TagName string `json:"tag_name" binding:"Required"`
+ Target string `json:"target_commitish"`
+ Title string `json:"name"`
+ Note string `json:"body"`
+ IsDraft bool `json:"draft"`
+ IsPrerelease bool `json:"prerelease"`
+}
+
+// CreateRelease create a release
+func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Release, error) {
+ body, err := json.Marshal(form)
+ if err != nil {
+ return nil, err
+ }
+ r := new(Release)
+ err = c.getParsedResponse("POST",
+ fmt.Sprintf("/repos/%s/%s/releases", user, repo),
+ jsonHeader, bytes.NewReader(body), r)
+ return r, err
+}
+
+// EditReleaseOption options when editing a release
+type EditReleaseOption struct {
+ TagName string `json:"tag_name"`
+ Target string `json:"target_commitish"`
+ Title string `json:"name"`
+ Note string `json:"body"`
+ IsDraft *bool `json:"draft"`
+ IsPrerelease *bool `json:"prerelease"`
+}
+
+// EditRelease edit a release
+func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, error) {
+ body, err := json.Marshal(form)
+ if err != nil {
+ return nil, err
+ }
+ r := new(Release)
+ err = c.getParsedResponse("PATCH",
+ fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id),
+ jsonHeader, bytes.NewReader(body), r)
+ return r, err
+}
+
+// DeleteRelease delete a release from a repository
+func (c *Client) DeleteRelease(user, repo string, id int64) error {
+ _, err := c.getResponse("DELETE",
+ fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id),
+ nil, nil)
+ return err
+}
+++ /dev/null
-// Copyright 2016 The Gitea Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package gitea
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "time"
-)
-
-// Release represents a repository release
-type Release struct {
- ID int64 `json:"id"`
- TagName string `json:"name"`
- Target string `json:"target_commitish"`
- Title string `json:"name"`
- Note string `json:"body"`
- URL string `json:"url"`
- TarURL string `json:"tarball_url"`
- ZipURL string `json:"zipball_url"`
- IsDraft bool `json:"draft"`
- IsPrerelease bool `json:"prerelease"`
- CreatedAt time.Time `json:"created_at"`
- PublishedAt time.Time `json:"published_at"`
- Publisher *User `json:"author"`
-}
-
-// ListReleases list releases of a repository
-func (c *Client) ListReleases(user, repo string) ([]*Release, error) {
- releases := make([]*Release, 0, 10)
- err := c.getParsedResponse("GET",
- fmt.Sprintf("/repos/%s/%s/releases", user, repo),
- nil, nil, &releases)
- return releases, err
-}
-
-// GetRelease get a release of a repository
-func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) {
- r := new(Release)
- err := c.getParsedResponse("GET",
- fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id),
- nil, nil, &r)
- return r, err
-}
-
-// CreateReleaseOption options when creating a release
-type CreateReleaseOption struct {
- TagName string `json:"tag_name" binding:"Required"`
- Target string `json:"target_commitish"`
- Title string `json:"name"`
- Note string `json:"body"`
- IsDraft bool `json:"draft"`
- IsPrerelease bool `json:"prerelease"`
-}
-
-// CreateRelease create a release
-func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Release, error) {
- body, err := json.Marshal(form)
- if err != nil {
- return nil, err
- }
- r := new(Release)
- err = c.getParsedResponse("POST",
- fmt.Sprintf("/repos/%s/%s/releases", user, repo),
- jsonHeader, bytes.NewReader(body), r)
- return r, err
-}
-
-// EditReleaseOption options when editing a release
-type EditReleaseOption struct {
- TagName string `json:"tag_name"`
- Target string `json:"target_commitish"`
- Title string `json:"name"`
- Note string `json:"body"`
- IsDraft *bool `json:"draft"`
- IsPrerelease *bool `json:"prerelease"`
-}
-
-// EditRelease edit a release
-func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, error) {
- body, err := json.Marshal(form)
- if err != nil {
- return nil, err
- }
- r := new(Release)
- err = c.getParsedResponse("PATCH",
- fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id),
- jsonHeader, bytes.NewReader(body), r)
- return r, err
-}
-
-// DeleteRelease delete a release from a repository
-func (c *Client) DeleteRelease(user, repo string, id int64) error {
- _, err := c.getResponse("DELETE",
- fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id),
- nil, nil)
- return err
-}
Description string `json:"description"`
Private bool `json:"private"`
Fork bool `json:"fork"`
+ Mirror bool `json:"mirror"`
HTMLURL string `json:"html_url"`
SSHURL string `json:"ssh_url"`
CloneURL string `json:"clone_url"`
--- /dev/null
+// Copyright 2017 Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package gitea
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "time"
+)
+
+// GPGKey a user GPG key to sign commit and tag in repository
+type GPGKey struct {
+ ID int64 `json:"id"`
+ PrimaryKeyID string `json:"primary_key_id"`
+ KeyID string `json:"key_id"`
+ PublicKey string `json:"public_key"`
+ Emails []*GPGKeyEmail `json:"emails"`
+ SubsKey []*GPGKey `json:"subkeys"`
+ CanSign bool `json:"can_sign"`
+ CanEncryptComms bool `json:"can_encrypt_comms"`
+ CanEncryptStorage bool `json:"can_encrypt_storage"`
+ CanCertify bool `json:"can_certify"`
+ Created time.Time `json:"created_at,omitempty"`
+ Expires time.Time `json:"expires_at,omitempty"`
+}
+
+// GPGKeyEmail a email attache to a GPGKey
+type GPGKeyEmail struct {
+ Email string `json:"email"`
+ Verified bool `json:"verified"`
+}
+
+// CreateGPGKeyOption options create user GPG key
+type CreateGPGKeyOption struct {
+ ArmoredKey string `json:"armored_public_key" binding:"Required"`
+}
+
+// ListMyGPGKeys list all the GPG keys of current user
+func (c *Client) ListMyGPGKeys() ([]*GPGKey, error) {
+ keys := make([]*GPGKey, 0, 10)
+ return keys, c.getParsedResponse("GET", "/user/gpg_keys", nil, nil, &keys)
+}
+
+// GetGPGKey get current user's GPG key by key id
+func (c *Client) GetGPGKey(keyID int64) (*GPGKey, error) {
+ key := new(GPGKey)
+ return key, c.getParsedResponse("GET", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil, &key)
+}
+
+// CreateGPGKey create GPG key with options
+func (c *Client) CreateGPGKey(opt CreateGPGKeyOption) (*GPGKey, error) {
+ body, err := json.Marshal(&opt)
+ if err != nil {
+ return nil, err
+ }
+ key := new(GPGKey)
+ return key, c.getParsedResponse("POST", "/user/gpg_keys", jsonHeader, bytes.NewReader(body), key)
+}
+
+// DeleteGPGKey delete GPG key with key id
+func (c *Client) DeleteGPGKey(keyID int64) error {
+ _, err := c.getResponse("DELETE", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil)
+ return err
+}
"revisionTime": "2017-02-22T02:52:05Z"
},
{
- "checksumSHA1": "BKj0haFTDebzdC2nACpoGzp3s8A=",
+ "checksumSHA1": "K0VWBaa3ZUE598zVFGavdLB7vW4=",
"path": "code.gitea.io/sdk/gitea",
- "revision": "2064cc397bc48b0a46f8324a97421a824b11882e",
- "revisionTime": "2016-12-31T14:43:27Z"
+ "revision": "06902fe19508c7ede2be38b71287c665efa1f10d",
+ "revisionTime": "2017-02-19T11:17:32Z"
},
{
"checksumSHA1": "IyfS7Rbl6OgR83QR7TOfKdDCq+M=",