forked from pivotal-cf/brokerapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_broker.go
101 lines (81 loc) · 3.13 KB
/
service_broker.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
package brokerapi
import (
"encoding/json"
"errors"
)
type ServiceBroker interface {
Services() []Service
Provision(instanceID string, details ProvisionDetails, asyncAllowed bool) (ProvisionedServiceSpec, error)
Deprovision(instanceID string, details DeprovisionDetails, asyncAllowed bool) (IsAsync, error)
Bind(instanceID, bindingID string, details BindDetails) (Binding, error)
Unbind(instanceID, bindingID string, details UnbindDetails) error
Update(instanceID string, details UpdateDetails, asyncAllowed bool) (IsAsync, error)
LastOperation(instanceID string) (LastOperation, error)
}
type IsAsync bool
type ProvisionDetails struct {
ServiceID string `json:"service_id"`
PlanID string `json:"plan_id"`
OrganizationGUID string `json:"organization_guid"`
SpaceGUID string `json:"space_guid"`
RawParameters json.RawMessage `json:"parameters,omitempty"`
}
type ProvisionedServiceSpec struct {
IsAsync bool
DashboardURL string
}
type BindDetails struct {
AppGUID string `json:"app_guid"`
PlanID string `json:"plan_id"`
ServiceID string `json:"service_id"`
BindResource *BindResource `json:"bind_resource,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
type BindResource struct {
AppGuid string `json:"app_guid,omitempty"`
Route string `json:"route,omitempty"`
}
type UnbindDetails struct {
PlanID string `json:"plan_id"`
ServiceID string `json:"service_id"`
}
type DeprovisionDetails struct {
PlanID string `json:"plan_id"`
ServiceID string `json:"service_id"`
}
type UpdateDetails struct {
ServiceID string `json:"service_id"`
PlanID string `json:"plan_id"`
Parameters map[string]interface{} `json:"parameters"`
PreviousValues PreviousValues `json:"previous_values"`
}
type PreviousValues struct {
PlanID string `json:"plan_id"`
ServiceID string `json:"service_id"`
OrgID string `json:"organization_id"`
SpaceID string `json:"space_id"`
}
type LastOperation struct {
State LastOperationState
Description string
}
type LastOperationState string
const (
InProgress LastOperationState = "in progress"
Succeeded LastOperationState = "succeeded"
Failed LastOperationState = "failed"
)
type Binding struct {
Credentials interface{} `json:"credentials"`
SyslogDrainURL string `json:"syslog_drain_url,omitempty"`
}
var (
ErrInstanceAlreadyExists = errors.New("instance already exists")
ErrInstanceDoesNotExist = errors.New("instance does not exist")
ErrInstanceLimitMet = errors.New("instance limit for this service has been reached")
ErrBindingAlreadyExists = errors.New("binding already exists")
ErrBindingDoesNotExist = errors.New("binding does not exist")
ErrAsyncRequired = errors.New("This service plan requires client support for asynchronous service operations.")
ErrPlanChangeNotSupported = errors.New("The requested plan migration cannot be performed")
ErrRawParamsInvalid = errors.New("The format of the parameters is not valid JSON")
)