forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_plan.go
41 lines (34 loc) · 1.19 KB
/
service_plan.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
package ccv3
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/api/cloudcontroller/jsonry"
)
// ServicePlan represents a Cloud Controller V3 Service Plan.
type ServicePlan struct {
// GUID is a unique service plan identifier.
GUID string
// Name is the name of the service plan.
Name string
// VisibilityType can be "public", "admin", "organization" or "space"
VisibilityType string `json:"visibility_type"`
// ServicePlanGUID is the GUID of the service offering
ServiceOfferingGUID string `jsonry:"relationships.service_offering.data.guid"`
Metadata *Metadata
}
func (sp *ServicePlan) UnmarshalJSON(data []byte) error {
return jsonry.Unmarshal(data, sp)
}
// GetServicePlans lists service plan with optional filters.
func (client *Client) GetServicePlans(query ...Query) ([]ServicePlan, Warnings, error) {
var resources []ServicePlan
_, warnings, err := client.MakeListRequest(RequestParams{
RequestName: internal.GetServicePlansRequest,
Query: query,
ResponseBody: ServicePlan{},
AppendToList: func(item interface{}) error {
resources = append(resources, item.(ServicePlan))
return nil
},
})
return resources, warnings, err
}