-
Notifications
You must be signed in to change notification settings - Fork 2
/
cf-types.go
283 lines (237 loc) · 7.86 KB
/
cf-types.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/**
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package types
// cfAppsResponse describes the Cloud Controller API result for a list of apps
type CfAppsResponse struct {
Count int `json:"total_results"`
Pages int `json:"total_pages"`
Resources []CfAppResource `json:"resources"`
}
type CfAppResource struct {
Meta CfMeta `json:"metadata"`
Entity CfApp `json:"entity"`
}
type CfAppSummary struct {
CfApp
GUID string `json:"guid"`
Routes []CfAppSummaryRoute `json:"routes"`
Services []CfAppSummaryService `json:"services"`
}
type CfAppSummaryService struct {
GUID string `json:"guid"`
Name string `json:"name"`
Plan CfAppSummaryServicePlan `json:"service_plan"`
}
type CfAppSummaryServicePlan struct {
GUID string `json:"guid"`
Name string `json:"name"`
Service CfAppSummaryServicePlanService
}
type CfAppSummaryServicePlanService struct {
GUID string `json:"guid"`
Label string `json:"label"`
}
type CfRoutesResponse struct {
Count int `json:"total_results"`
Pages int `json:"total_pages"`
Resources []CfRouteResource `json:"resources"`
}
type CfRouteResource struct {
Meta CfMeta `json:"metadata"`
Entity CfRoute `json:"entity"`
}
type CfAppSummaryRoute struct {
GUID string `json:"guid"`
Host string `json:"host"`
Domain CfDomain `json:"domain"`
}
type CfDomainResponse struct {
Meta CfMeta `json:"metadata"`
Entity CfDomain `json:"entity"`
}
type CfSpaceResource struct {
Meta CfMeta `json:"metadata"`
Entity CfSpace `json:"entity"`
}
type CfBindingResource struct {
Meta CfMeta `json:"metadata"`
Entity CfBinding `json:"entity"`
}
type CfServicesResources struct {
TotalResults int `json:"total_results"`
Resources []CfServiceResource `json:"resources"`
}
type CfServiceResource struct {
Meta CfMeta `json:"metadata"`
Entity CfService `json:"entity"`
}
type CfServicePlansResources struct {
TotalResults int `json:"total_results"`
Resources []CfServicePlanResource `json:"resources"`
}
type CfServicePlanResource struct {
Meta CfMeta `json:"metadata"`
Entity CfAppSummaryServicePlan `json:"entity"`
}
type CfMeta struct {
GUID string `json:"guid"`
URL string `json:"url"`
}
type CfJob struct {
GUID string `json:"guid"`
Status string `json:"status"`
Error string `json:"error"`
}
type CfJobResponse struct {
Meta CfMeta `json:"metadata"`
Entity CfJob `json:"entity"`
}
type CfService struct {
Name string `json:"label"`
Provider string `json:"provider"`
PlansURL string `json:"service_plans_url"`
BrokerGUID string `json:"service_broker_guid"`
}
type CfUserProvidedService struct {
Name string `json:"name"`
SpaceGUID string `json:"space_guid"`
SyslogDrainURL string `json:"syslog_drain_url,omitempty"`
Credentials map[string]interface{} `json:"credentials,omitempty"`
RouteServiceURL string `json:"route_service_url,omitempty"`
}
type CfUserProvidedServiceResource struct {
Meta CfMeta `json:"metadata"`
Entity CfUserProvidedService `json:"entity"`
}
type CfApp struct {
Name string `json:"name"`
SpaceGUID string `json:"space_guid"`
RoutesURL string `json:"routes_url"`
State string `json:"state"`
BuildpackUrl string `json:"buildpack"`
Command string `json:"command"`
DiskQuota int64 `json:"disk_quota"`
InstanceCount int `json:"instances"`
Memory int64 `json:"memory"`
Path string `json:"path"`
Envs map[string]interface{} `json:"environment_json"`
}
type ServiceBindingResponse struct {
Credentials map[string]string `json:"credentials"`
}
type CfAppInstance struct {
State string `json:"state"`
Since float64 `json:"since"`
}
type CfCopyBitsRequest struct {
SrcAppGUID string `json:"source_app_guid"`
}
type CfRoute struct {
Host string `json:"host"`
DomainURL string `json:"domain_url"`
DomainGUID string `json:"domain_guid"`
}
type CfCreateRouteRequest struct {
Host string `json:"host"`
DomainGUID string `json:"domain_guid"`
SpaceGUID string `json:"space_guid"`
}
type CfDomain struct {
GUID string `json:"guid"`
Name string `json:"name"`
}
type CfSpace struct {
GUID string `json:"guid"`
Name string `json:"name"`
OrgGUID string `json:"organization_guid"`
}
// CfServiceContext describes a CF Service Instance within the Cloud Controller
type CfServiceContext struct {
InstanceID string
OrgName string
SpaceName string
SpaceGUID string
InstanceName string
AppName string
}
// CFBindingResponse describes a CF Service Binding within the Cloud Controller
type CfBinding struct {
GUID string `json:"guid"`
AppGUID string `json:"app_guid"`
ServiceInstanceGUID string `json:"service_instance_guid"`
}
type CfServiceInstanceCreateRequest struct {
Name string `json:"name"`
SpaceGUID string `json:"space_guid"`
PlanGUID string `json:"service_plan_guid,omitempty"`
Params map[string]interface{} `json:"parameters,omitempty"`
Tags []string `json:"tags,omitempty"`
}
type CfServiceInstanceCreateResponse struct {
Meta CfMeta `json:"metadata"`
}
type CfServiceBindingCreateRequest struct {
ServiceInstanceGUID string `json:"service_instance_guid"`
AppGUID string `json:"app_guid"`
Params map[string]interface{} `json:"parameters,omitempty"`
}
type CfServiceBindingCreateResponse struct {
Meta CfMeta `json:"metadata"`
}
type CfBindingsResources struct {
TotalResults int `json:"total_results"`
Resources []CfBindingResource `json:"resources"`
}
type CfVcapApplication struct {
Name string `json:"name"`
Uris []string `json:"uris"`
}
type CfServiceBrokerResources struct {
TotalResults int `json:"total_results"`
Resources []CfServiceBrokerResource `json:"resources"`
}
type CfServiceBrokerResource struct {
Meta CfMeta `json:"metadata"`
Entity CfServiceBroker `json:"entity"`
}
type CfServiceBroker struct {
Name string `json:"name,omitempty"`
URL string `json:"broker_url"`
Username string `json:"auth_username"`
Password string `json:"auth_password"`
}
const (
AppStarted = "STARTED"
AppStopped = "STOPPED"
)
func NewCfAppResource(summary CfAppSummary, newName string, spaceGUID string) *CfAppResource {
summary.CfApp.Name = newName
summary.CfApp.State = AppStopped
summary.CfApp.SpaceGUID = spaceGUID
return &CfAppResource{Meta: CfMeta{GUID: summary.GUID}, Entity: summary.CfApp}
}
func NewCfServiceInstanceRequest(name string, spaceGUID string, plan CfAppSummaryServicePlan) *CfServiceInstanceCreateRequest {
return &CfServiceInstanceCreateRequest{
Name: name,
PlanGUID: plan.GUID,
SpaceGUID: spaceGUID,
Tags: []string{plan.Service.Label}}
}
func NewCfServiceBindingRequest(appGUID string, svcInstanceGUID string) *CfServiceBindingCreateRequest {
return &CfServiceBindingCreateRequest{
AppGUID: appGUID,
ServiceInstanceGUID: svcInstanceGUID}
}