github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/api/resources/service_plans.go (about) 1 package resources 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/cf/models" 7 ) 8 9 type ServicePlanResource struct { 10 Resource 11 Entity ServicePlanEntity 12 } 13 14 type ServicePlanEntity struct { 15 Name string 16 Free bool 17 Public bool 18 Active bool 19 Description string `json:"description"` 20 ServiceOfferingGUID string `json:"service_guid"` 21 ServiceOffering ServiceOfferingResource `json:"service"` 22 } 23 24 type ServicePlanDescription struct { 25 ServiceLabel string 26 ServicePlanName string 27 ServiceProvider string 28 } 29 30 func (resource ServicePlanResource) ToFields() (fields models.ServicePlanFields) { 31 fields.GUID = resource.Metadata.GUID 32 fields.Name = resource.Entity.Name 33 fields.Free = resource.Entity.Free 34 fields.Description = resource.Entity.Description 35 fields.Public = resource.Entity.Public 36 fields.Active = resource.Entity.Active 37 fields.ServiceOfferingGUID = resource.Entity.ServiceOfferingGUID 38 return 39 } 40 41 func (planDesc ServicePlanDescription) String() string { 42 if planDesc.ServiceProvider == "" { 43 return fmt.Sprintf("%s %s", planDesc.ServiceLabel, planDesc.ServicePlanName) // v2 plan 44 } 45 return fmt.Sprintf("%s %s %s", planDesc.ServiceLabel, planDesc.ServiceProvider, planDesc.ServicePlanName) // v1 plan 46 } 47 48 type ServiceMigrateV1ToV2Response struct { 49 ChangedCount int `json:"changed_count"` 50 }