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
/
organization_app.go
191 lines (159 loc) · 5.85 KB
/
organization_app.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// 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"
)
// An organization app encapsulates the organization specific functionality of
// Heroku apps.
type OrganizationApp struct {
// when app was archived
ArchivedAt *time.Time `json:"archived_at"`
// description from buildpack of app
BuildpackProvidedDescription *string `json:"buildpack_provided_description"`
// when app was created
CreatedAt time.Time `json:"created_at"`
// git repo URL of app
GitURL string `json:"git_url"`
// unique identifier of app
Id string `json:"id"`
// is the current member a collaborator on this app.
Joined bool `json:"joined"`
// are other organization members forbidden from joining this app.
Locked bool `json:"locked"`
// maintenance status of app
Maintenance bool `json:"maintenance"`
// unique name of app
Name string `json:"name"`
// organization that owns this app
Organization *struct {
Name string `json:"name"`
} `json:"organization"`
// identity of app owner
Owner *struct {
Email string `json:"email"`
Id string `json:"id"`
} `json:"owner"`
// identity of app region
Region struct {
Id string `json:"id"`
Name string `json:"name"`
} `json:"region"`
// when app was released
ReleasedAt *time.Time `json:"released_at"`
// git repo size in bytes of app
RepoSize *int `json:"repo_size"`
// slug size in bytes of app
SlugSize *int `json:"slug_size"`
// identity of app stack
Stack struct {
Id string `json:"id"`
Name string `json:"name"`
} `json:"stack"`
// when app was updated
UpdatedAt time.Time `json:"updated_at"`
// web URL of app
WebURL string `json:"web_url"`
}
// Create a new app in the specified organization, in the default organization
// if unspecified, or in personal account, if default organization is not set.
//
// options is the struct of optional parameters for this action.
func (c *Client) OrganizationAppCreate(options *OrganizationAppCreateOpts) (*OrganizationApp, error) {
var organizationAppRes OrganizationApp
return &organizationAppRes, c.Post(&organizationAppRes, "/organizations/apps", options)
}
// OrganizationAppCreateOpts holds the optional parameters for OrganizationAppCreate
type OrganizationAppCreateOpts struct {
// are other organization members forbidden from joining this app.
Locked *bool `json:"locked,omitempty"`
// unique name of app
Name *string `json:"name,omitempty"`
// organization that owns this app
Organization *string `json:"organization,omitempty"`
// force creation of the app in the user account even if a default org is set.
Personal *bool `json:"personal,omitempty"`
// identity of app region
Region *string `json:"region,omitempty"`
// identity of app stack
Stack *string `json:"stack,omitempty"`
}
// List apps in the default organization, or in personal account, if default
// organization is not set.
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results.
func (c *Client) OrganizationAppList(lr *ListRange) ([]OrganizationApp, error) {
req, err := c.NewRequest("GET", "/organizations/apps", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationAppsRes []OrganizationApp
return organizationAppsRes, c.DoReq(req, &organizationAppsRes)
}
// List organization apps.
//
// organizationIdentity is the unique identifier of the OrganizationApp's
// Organization. lr is an optional ListRange that sets the Range options for the
// paginated list of results.
func (c *Client) OrganizationAppListForOrganization(organizationIdentity string, lr *ListRange) ([]OrganizationApp, error) {
req, err := c.NewRequest("GET", "/organizations/"+organizationIdentity+"/apps", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationAppsRes []OrganizationApp
return organizationAppsRes, c.DoReq(req, &organizationAppsRes)
}
// Info for an organization app.
//
// appIdentity is the unique identifier of the OrganizationApp's App.
func (c *Client) OrganizationAppInfo(appIdentity string) (*OrganizationApp, error) {
var organizationApp OrganizationApp
return &organizationApp, c.Get(&organizationApp, "/organizations/apps/"+appIdentity)
}
// Lock or unlock an organization app.
//
// appIdentity is the unique identifier of the OrganizationApp's App. locked is
// the are other organization members forbidden from joining this app.
func (c *Client) OrganizationAppUpdateLocked(appIdentity string, locked bool) (*OrganizationApp, error) {
params := struct {
Locked bool `json:"locked"`
}{
Locked: locked,
}
var organizationAppRes OrganizationApp
return &organizationAppRes, c.Patch(&organizationAppRes, "/organizations/apps/"+appIdentity, params)
}
// Transfer an existing organization app to another Heroku account.
//
// appIdentity is the unique identifier of the OrganizationApp's App. owner is
// the unique email address of account or unique identifier of an account.
func (c *Client) OrganizationAppTransferToAccount(appIdentity string, owner string) (*OrganizationApp, error) {
params := struct {
Owner string `json:"owner"`
}{
Owner: owner,
}
var organizationAppRes OrganizationApp
return &organizationAppRes, c.Patch(&organizationAppRes, "/organizations/apps/"+appIdentity, params)
}
// Transfer an existing organization app to another organization.
//
// appIdentity is the unique identifier of the OrganizationApp's App. owner is
// the unique name of organization.
func (c *Client) OrganizationAppTransferToOrganization(appIdentity string, owner string) (*OrganizationApp, error) {
params := struct {
Owner string `json:"owner"`
}{
Owner: owner,
}
var organizationAppRes OrganizationApp
return &organizationAppRes, c.Patch(&organizationAppRes, "/organizations/apps/"+appIdentity, params)
}