github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccv3/isolation_segment.go (about) 1 package ccv3 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" 5 "code.cloudfoundry.org/cli/resources" 6 ) 7 8 // CreateIsolationSegment will create an Isolation Segment on the Cloud 9 // Controller. Note: This will not validate that the placement tag exists in 10 // the diego cluster. 11 func (client *Client) CreateIsolationSegment(isolationSegment resources.IsolationSegment) (resources.IsolationSegment, Warnings, error) { 12 var responseBody resources.IsolationSegment 13 14 _, warnings, err := client.MakeRequest(RequestParams{ 15 RequestName: internal.PostIsolationSegmentsRequest, 16 RequestBody: isolationSegment, 17 ResponseBody: &responseBody, 18 }) 19 20 return responseBody, warnings, err 21 } 22 23 // DeleteIsolationSegment removes an isolation segment from the cloud 24 // controller. Note: This will only remove it from the cloud controller 25 // database. It will not remove it from diego. 26 func (client *Client) DeleteIsolationSegment(guid string) (Warnings, error) { 27 _, warnings, err := client.MakeRequest(RequestParams{ 28 RequestName: internal.DeleteIsolationSegmentRequest, 29 URIParams: internal.Params{"isolation_segment_guid": guid}, 30 }) 31 32 return warnings, err 33 } 34 35 // GetIsolationSegment returns back the requested isolation segment that 36 // matches the GUID. 37 func (client *Client) GetIsolationSegment(guid string) (resources.IsolationSegment, Warnings, error) { 38 var responseBody resources.IsolationSegment 39 40 _, warnings, err := client.MakeRequest(RequestParams{ 41 RequestName: internal.GetIsolationSegmentRequest, 42 URIParams: internal.Params{"isolation_segment_guid": guid}, 43 ResponseBody: &responseBody, 44 }) 45 46 return responseBody, warnings, err 47 } 48 49 // GetIsolationSegments lists isolation segments with optional filters. 50 func (client *Client) GetIsolationSegments(query ...Query) ([]resources.IsolationSegment, Warnings, error) { 51 var isolationSegments []resources.IsolationSegment 52 53 _, warnings, err := client.MakeListRequest(RequestParams{ 54 RequestName: internal.GetIsolationSegmentsRequest, 55 Query: query, 56 ResponseBody: resources.IsolationSegment{}, 57 AppendToList: func(item interface{}) error { 58 isolationSegments = append(isolationSegments, item.(resources.IsolationSegment)) 59 return nil 60 }, 61 }) 62 63 return isolationSegments, warnings, err 64 }