forked from cloud-gov/aws-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
52 lines (45 loc) · 1.72 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
package main
import (
"github.com/18F/aws-broker/config"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/martini-contrib/render"
"github.com/18F/aws-broker/catalog"
"net/http"
)
/*
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) {
resp := createInstance(req, c, brokerDb, p["id"], s)
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) {
resp := bindInstance(req, c, brokerDb, p["instance_id"], s)
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) {
resp := deleteInstance(req, c, brokerDb, p["instance_id"], s)
r.JSON(resp.GetStatusCode(), resp)
}