-
Notifications
You must be signed in to change notification settings - Fork 15
/
api.go
75 lines (65 loc) · 2.81 KB
/
api.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
package main
import (
"github.com/18F/aws-broker/config"
"github.com/18F/aws-broker/taskqueue"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/martini-contrib/render"
"net/http"
"github.com/18F/aws-broker/catalog"
)
/*
type Operation struct {
State string
Description string
AsyncPollIntervalSeconds int `json:"async_poll_interval_seconds, omitempty"`
}
type CreateResponse struct {
DashboardUrl string
LastOperation Operation
}
*/
// CreateInstance processes all requests for creating a new service instance.
// URL: /v2/service_instances/:id
// Request:
// {
// "service_id": "service-guid-here",
// "plan_id": "plan-guid-here",
// "organization_guid": "org-guid-here",
// "space_guid": "space-guid-here"
// }
func CreateInstance(p martini.Params, req *http.Request, r render.Render, brokerDb *gorm.DB, s *config.Settings, c *catalog.Catalog, q *taskqueue.QueueManager) {
resp := createInstance(req, c, brokerDb, p["id"], s, q)
r.JSON(resp.GetStatusCode(), resp)
}
// ModifyInstance processes all requests for modifying an existing service instance.
// URL: /v2/service_instances/:id
// Request:
// {
// "service_id": "service-guid-here",
// "plan_id": "plan-guid-here",
// "organization_guid": "org-guid-here",
// "space_guid": "space-guid-here"
// }
func ModifyInstance(p martini.Params, req *http.Request, r render.Render, brokerDb *gorm.DB, s *config.Settings, c *catalog.Catalog, q *taskqueue.QueueManager) {
resp := modifyInstance(req, c, brokerDb, p["id"], s, q)
r.JSON(resp.GetStatusCode(), resp)
}
// LastOperation processes all requests for binding a service instance to an application.
// URL: /v2/service_instances/:instance_id/last_operation
func LastOperation(p martini.Params, req *http.Request, r render.Render, brokerDb *gorm.DB, s *config.Settings, c *catalog.Catalog, q *taskqueue.QueueManager) {
resp := lastOperation(req, c, brokerDb, p["instance_id"], s, q)
r.JSON(resp.GetStatusCode(), resp)
}
// BindInstance processes all requests for binding a service instance to an application.
// URL: /v2/service_instances/:instance_id/service_bindings/:binding_id
func BindInstance(p martini.Params, req *http.Request, r render.Render, brokerDb *gorm.DB, s *config.Settings, c *catalog.Catalog, q *taskqueue.QueueManager) {
resp := bindInstance(req, c, brokerDb, p["instance_id"], s, q)
r.JSON(resp.GetStatusCode(), resp)
}
// DeleteInstance processes all requests for deleting an existing service instance.
// URL: /v2/service_instances/:instance_id
func DeleteInstance(p martini.Params, req *http.Request, r render.Render, brokerDb *gorm.DB, s *config.Settings, c *catalog.Catalog, q *taskqueue.QueueManager) {
resp := deleteInstance(req, c, brokerDb, p["instance_id"], s, q)
r.JSON(resp.GetStatusCode(), resp)
}