github.com/LukasHeimann/cloudfoundrycli@v7.1.0+incompatible/api/cloudcontroller/ccv3/isolation_segment.go (about)

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