This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
release.go
105 lines (89 loc) · 3.01 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// WARNING: This code is auto-generated from the Heroku Platform API JSON Schema
// by a Ruby script (gen/gen.rb). Changes should be made to the generation
// script rather than the generated files.
package heroku
import (
"time"
)
// A release represents a combination of code, config vars and add-ons for an
// app on Heroku.
type Release struct {
// when release was created
CreatedAt time.Time `json:"created_at"`
// description of changes in this release
Description string `json:"description"`
// unique identifier of release
Id string `json:"id"`
// when release was updated
UpdatedAt time.Time `json:"updated_at"`
// slug running in this release
Slug *struct {
Id string `json:"id"`
} `json:"slug"`
// user that created the release
User struct {
Id string `json:"id"`
Email string `json:"email"`
} `json:"user"`
// unique version assigned to the release
Version int `json:"version"`
}
// Info for existing release.
//
// appIdentity is the unique identifier of the Release's App. releaseIdentity is
// the unique identifier of the Release.
func (c *Client) ReleaseInfo(appIdentity string, releaseIdentity string) (*Release, error) {
var release Release
return &release, c.Get(&release, "/apps/"+appIdentity+"/releases/"+releaseIdentity)
}
// List existing releases.
//
// appIdentity is the unique identifier of the Release's App. lr is an optional
// ListRange that sets the Range options for the paginated list of results.
func (c *Client) ReleaseList(appIdentity string, lr *ListRange) ([]Release, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/releases", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var releasesRes []Release
return releasesRes, c.DoReq(req, &releasesRes)
}
// Create new release. The API cannot be used to create releases on Bamboo apps.
//
// appIdentity is the unique identifier of the Release's App. slug is the unique
// identifier of slug. options is the struct of optional parameters for this
// action.
func (c *Client) ReleaseCreate(appIdentity string, slug string, options *ReleaseCreateOpts) (*Release, error) {
params := struct {
Slug string `json:"slug"`
Description *string `json:"description,omitempty"`
}{
Slug: slug,
}
if options != nil {
params.Description = options.Description
}
var releaseRes Release
return &releaseRes, c.Post(&releaseRes, "/apps/"+appIdentity+"/releases", params)
}
// ReleaseCreateOpts holds the optional parameters for ReleaseCreate
type ReleaseCreateOpts struct {
// description of changes in this release
Description *string `json:"description,omitempty"`
}
// Rollback to an existing release.
//
// appIdentity is the unique identifier of the Release's App. release is the
// unique identifier of release.
func (c *Client) ReleaseRollback(appIdentity string, release string) (*Release, error) {
params := struct {
Release string `json:"release"`
}{
Release: release,
}
var releaseRes Release
return &releaseRes, c.Post(&releaseRes, "/apps/"+appIdentity+"/releases", params)
}