-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_plans.go
50 lines (42 loc) · 1.36 KB
/
service_plans.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
package resources
import (
"fmt"
"github.com/cloudfoundry/cli/cf/models"
)
type ServicePlanResource struct {
Resource
Entity ServicePlanEntity
}
type ServicePlanEntity struct {
Name string
Free bool
Public bool
Active bool
Description string `json:"description"`
ServiceOfferingGUID string `json:"service_guid"`
ServiceOffering ServiceOfferingResource `json:"service"`
}
type ServicePlanDescription struct {
ServiceLabel string
ServicePlanName string
ServiceProvider string
}
func (resource ServicePlanResource) ToFields() (fields models.ServicePlanFields) {
fields.GUID = resource.Metadata.GUID
fields.Name = resource.Entity.Name
fields.Free = resource.Entity.Free
fields.Description = resource.Entity.Description
fields.Public = resource.Entity.Public
fields.Active = resource.Entity.Active
fields.ServiceOfferingGUID = resource.Entity.ServiceOfferingGUID
return
}
func (planDesc ServicePlanDescription) String() string {
if planDesc.ServiceProvider == "" {
return fmt.Sprintf("%s %s", planDesc.ServiceLabel, planDesc.ServicePlanName) // v2 plan
}
return fmt.Sprintf("%s %s %s", planDesc.ServiceLabel, planDesc.ServiceProvider, planDesc.ServicePlanName) // v1 plan
}
type ServiceMigrateV1ToV2Response struct {
ChangedCount int `json:"changed_count"`
}