-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_instances.go
36 lines (29 loc) · 1.06 KB
/
service_instances.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
package resources
import "github.com/cloudfoundry/cli/cf/models"
type PaginatedServiceInstanceResources struct {
TotalResults int `json:"total_results"`
Resources []ServiceInstanceResource
}
type ServiceInstanceResource struct {
Resource
Entity ServiceInstanceEntity
}
type ServiceInstanceEntity struct {
Name string
ServiceBindings []ServiceBindingResource `json:"service_bindings"`
ServicePlan ServicePlanResource `json:"service_plan"`
}
func (resource ServiceInstanceResource) ToFields() (fields models.ServiceInstanceFields) {
fields.Guid = resource.Metadata.Guid
fields.Name = resource.Entity.Name
return
}
func (resource ServiceInstanceResource) ToModel() (instance models.ServiceInstance) {
instance.ServiceInstanceFields = resource.ToFields()
instance.ServicePlan = resource.Entity.ServicePlan.ToFields()
instance.ServiceBindings = []models.ServiceBindingFields{}
for _, bindingResource := range resource.Entity.ServiceBindings {
instance.ServiceBindings = append(instance.ServiceBindings, bindingResource.ToFields())
}
return
}