-
Notifications
You must be signed in to change notification settings - Fork 39
/
release.go
71 lines (59 loc) · 2.56 KB
/
release.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package sentry
import (
"fmt"
"time"
)
// Release is your release for a orgs teams project
type Release struct {
DateCreated *time.Time `json:"dateCreated,omitempty"`
DateReleased *time.Time `json:"dateReleased,omitempty"`
DateStarted *time.Time `json:"dateStarted,omitempty"`
FirstEvent *time.Time `json:"firstEvent,omitempty"`
LastEvent *time.Time `json:"lastEvent,omitempty"`
NewGroups *int `json:"newGroups,omitempty"`
Owner *string `json:"owner,omitempty"`
Ref *string `json:"ref,omitempty"`
ShortVersion string `json:"shortVersion"`
URL *string `json:"url,omitempty"`
Version string `json:"version"`
}
// NewRelease is used to create a new release
type NewRelease struct {
// Optional commit ref.
Ref *string `json:"ref,omitempty"`
// Optional URL to point to the online source code
URL *string `json:"url,omitempty"`
// Required for creating the release
Version string `json:"version"`
// Optional to set when it started
DateStarted *time.Time `json:"dateStarted,omitempty"`
// Optional to set when it was released to the public
DateReleased *time.Time `json:"dateReleased,omitempty"`
}
// GetRelease will fetch a release from your org and project this does need a version string
func (c *Client) GetRelease(o Organization, p Project, version string) (Release, error) {
var rel Release
err := c.do("GET", fmt.Sprintf("projects/%s/%s/releases/%s", *o.Slug, *p.Slug, version), &rel, nil)
return rel, err
}
// GetReleases will fetch all releases from your org and project
func (c *Client) GetReleases(o Organization, p Project) ([]Release, *Link, error) {
var rel []Release
link, err := c.doWithPagination("GET", fmt.Sprintf("projects/%s/%s/releases", *o.Slug, *p.Slug), &rel, nil)
return rel, link, err
}
// CreateRelease will create a new release for a project in a org
func (c *Client) CreateRelease(o Organization, p Project, r NewRelease) (Release, error) {
var rel Release
err := c.do("POST", fmt.Sprintf("projects/%s/%s/releases", *o.Slug, *p.Slug), &rel, &r)
return rel, err
}
// UpdateRelease will update ref, url, started, released for a release.
// Version should not change.
func (c *Client) UpdateRelease(o Organization, p Project, r Release) error {
return c.do("PUT", fmt.Sprintf("projects/%s/%s/releases/%s", *o.Slug, *p.Slug, r.Version), &r, &r)
}
// DeleteRelease will delete the release from your project
func (c *Client) DeleteRelease(o Organization, p Project, r Release) error {
return c.do("DELETE", fmt.Sprintf("projects/%s/%s/releases/%s", *o.Slug, *p.Slug, r.Version), nil, nil)
}