forked from cloudfoundry-community/cloudfoundry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_offerings.go
42 lines (36 loc) · 1.19 KB
/
service_offerings.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
package resources
import "cf/models"
type PaginatedServiceOfferingResources struct {
Resources []ServiceOfferingResource
}
type ServiceOfferingResource struct {
Resource
Entity ServiceOfferingEntity
}
type ServiceOfferingEntity struct {
Label string
Version string
Description string
DocumentationUrl string `json:"documentation_url"`
Provider string
ServicePlans []ServicePlanResource `json:"service_plans"`
}
func (resource ServiceOfferingResource) ToFields() (fields models.ServiceOfferingFields) {
fields.Label = resource.Entity.Label
fields.Version = resource.Entity.Version
fields.Provider = resource.Entity.Provider
fields.Description = resource.Entity.Description
fields.Guid = resource.Metadata.Guid
fields.DocumentationUrl = resource.Entity.DocumentationUrl
return
}
func (resource ServiceOfferingResource) ToModel() (offering models.ServiceOffering) {
offering.ServiceOfferingFields = resource.ToFields()
for _, p := range resource.Entity.ServicePlans {
servicePlan := models.ServicePlanFields{}
servicePlan.Name = p.Entity.Name
servicePlan.Guid = p.Metadata.Guid
offering.Plans = append(offering.Plans, servicePlan)
}
return offering
}