summaryrefslogtreecommitdiffstats
path: root/vendor/code.gitea.io/sdk/gitea/issue_milestone.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/code.gitea.io/sdk/gitea/issue_milestone.go')
-rw-r--r--vendor/code.gitea.io/sdk/gitea/issue_milestone.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go
new file mode 100644
index 0000000000..58f17893a7
--- /dev/null
+++ b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go
@@ -0,0 +1,69 @@
+// Copyright 2016 The Gogs 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"
+)
+
+type Milestone struct {
+ ID int64 `json:"id"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ State StateType `json:"state"`
+ OpenIssues int `json:"open_issues"`
+ ClosedIssues int `json:"closed_issues"`
+ Closed *time.Time `json:"closed_at"`
+ Deadline *time.Time `json:"due_on"`
+}
+
+func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) {
+ milestones := make([]*Milestone, 0, 10)
+ return milestones, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), nil, nil, &milestones)
+}
+
+func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) {
+ milestone := new(Milestone)
+ return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
+}
+
+type CreateMilestoneOption struct {
+ Title string `json:"title"`
+ Description string `json:"description"`
+ Deadline *time.Time `json:"due_on"`
+}
+
+func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) {
+ body, err := json.Marshal(&opt)
+ if err != nil {
+ return nil, err
+ }
+ milestone := new(Milestone)
+ return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
+}
+
+type EditMilestoneOption struct {
+ Title string `json:"title"`
+ Description *string `json:"description"`
+ State *string `json:"state"`
+ Deadline *time.Time `json:"due_on"`
+}
+
+func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) {
+ body, err := json.Marshal(&opt)
+ if err != nil {
+ return nil, err
+ }
+ milestone := new(Milestone)
+ return milestone, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), milestone)
+}
+
+func (c *Client) DeleteMilestone(owner, repo string, id int64) error {
+ _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil)
+ return err
+}