forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isolation_segment.go
71 lines (58 loc) · 2.33 KB
/
isolation_segment.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package ccv3
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
)
// IsolationSegment represents a Cloud Controller Isolation Segment.
type IsolationSegment struct {
//GUID is the unique ID of the isolation segment.
GUID string `json:"guid,omitempty"`
//Name is the name of the isolation segment.
Name string `json:"name"`
}
// CreateIsolationSegment will create an Isolation Segment on the Cloud
// Controller. Note: This will not validate that the placement tag exists in
// the diego cluster.
func (client *Client) CreateIsolationSegment(isolationSegment IsolationSegment) (IsolationSegment, Warnings, error) {
var responseBody IsolationSegment
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostIsolationSegmentsRequest,
RequestBody: isolationSegment,
ResponseBody: &responseBody,
})
return responseBody, warnings, err
}
// DeleteIsolationSegment removes an isolation segment from the cloud
// controller. Note: This will only remove it from the cloud controller
// database. It will not remove it from diego.
func (client *Client) DeleteIsolationSegment(guid string) (Warnings, error) {
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.DeleteIsolationSegmentRequest,
URIParams: internal.Params{"isolation_segment_guid": guid},
})
return warnings, err
}
// GetIsolationSegment returns back the requested isolation segment that
// matches the GUID.
func (client *Client) GetIsolationSegment(guid string) (IsolationSegment, Warnings, error) {
var responseBody IsolationSegment
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.GetIsolationSegmentRequest,
URIParams: internal.Params{"isolation_segment_guid": guid},
ResponseBody: &responseBody,
})
return responseBody, warnings, err
}
// GetIsolationSegments lists isolation segments with optional filters.
func (client *Client) GetIsolationSegments(query ...Query) ([]IsolationSegment, Warnings, error) {
var resources []IsolationSegment
_, warnings, err := client.MakeListRequest(RequestParams{
RequestName: internal.GetIsolationSegmentsRequest,
Query: query,
ResponseBody: IsolationSegment{},
AppendToList: func(item interface{}) error {
resources = append(resources, item.(IsolationSegment))
return nil
},
})
return resources, warnings, err
}