forked from pivotal-cf/brokerapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_broker.go
147 lines (121 loc) · 4.85 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
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
package brokerapi
import (
"encoding/json"
"errors"
"context"
)
type ServiceBroker interface {
Services(context context.Context) []Service
Provision(context context.Context, instanceID string, details ProvisionDetails, asyncAllowed bool) (ProvisionedServiceSpec, error)
Deprovision(context context.Context, instanceID string, details DeprovisionDetails, asyncAllowed bool) (DeprovisionServiceSpec, error)
Bind(context context.Context, instanceID, bindingID string, details BindDetails) (Binding, error)
Unbind(context context.Context, instanceID, bindingID string, details UnbindDetails) error
Update(context context.Context, instanceID string, details UpdateDetails, asyncAllowed bool) (UpdateServiceSpec, error)
LastOperation(context context.Context, instanceID, operationData string) (LastOperation, error)
}
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
OperationData 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 UpdateServiceSpec struct {
IsAsync bool
OperationData string
}
type DeprovisionServiceSpec struct {
IsAsync bool
OperationData string
}
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"`
RouteServiceURL string `json:"route_service_url,omitempty"`
VolumeMounts []VolumeMount `json:"volume_mounts,omitempty"`
}
type VolumeMount struct {
Driver string `json:"driver"`
ContainerDir string `json:"container_dir"`
Mode string `json:"mode"`
DeviceType string `json:"device_type"`
Device SharedDevice `json:"device"`
}
type SharedDevice struct {
VolumeId string `json:"volume_id"`
MountConfig map[string]interface{} `json:"mount_config"`
}
type V2_9Binding struct {
Credentials interface{} `json:"credentials"`
SyslogDrainURL string `json:"syslog_drain_url,omitempty"`
RouteServiceURL string `json:"route_service_url,omitempty"`
VolumeMounts []V2_9VolumeMount `json:"volume_mounts,omitempty"`
}
type V2_9VolumeMount struct {
ContainerPath string `json:"container_path"`
Mode string `json:"mode"`
Private V2_9VolumeMountPrivate `json:"private"`
}
type V2_9VolumeMountPrivate struct {
Driver string `json:"driver"`
GroupId string `json:"group_id"`
Config string `json:"config"`
}
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")
ErrPlanQuotaExceeded = errors.New("The quota for this service plan has been exceeded. Please contact your Operator for help.")
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")
ErrAppGuidNotProvided = errors.New("app_guid is a required field but was not provided")
)