forked from cloudfoundry/brokerapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_broker.go
126 lines (103 loc) · 4 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
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) (DeprovisionServiceSpec, error)
Bind(instanceID, bindingID string, details BindDetails) (Binding, error)
Unbind(instanceID, bindingID string, details UnbindDetails) error
Update(instanceID string, details UpdateDetails, asyncAllowed bool) (UpdateServiceSpec, error)
LastOperation(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 {
ContainerPath string `json:"container_path"`
Mode string `json:"mode"`
Private VolumeMountPrivate `json:"private"`
}
type VolumeMountPrivate 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")
)