github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccv3/relationship.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  // DeleteIsolationSegmentOrganization will delete the relationship between
     9  // the isolation segment and the organization provided.
    10  func (client *Client) DeleteIsolationSegmentOrganization(isolationSegmentGUID string, orgGUID string) (Warnings, error) {
    11  	_, warnings, err := client.MakeRequest(RequestParams{
    12  		RequestName: internal.DeleteIsolationSegmentRelationshipOrganizationRequest,
    13  		URIParams:   internal.Params{"isolation_segment_guid": isolationSegmentGUID, "organization_guid": orgGUID},
    14  	})
    15  
    16  	return warnings, err
    17  }
    18  
    19  // GetOrganizationDefaultIsolationSegment returns the relationship between an
    20  // organization and it's default isolation segment.
    21  func (client *Client) GetOrganizationDefaultIsolationSegment(orgGUID string) (resources.Relationship, Warnings, error) {
    22  	var responseBody resources.Relationship
    23  
    24  	_, warnings, err := client.MakeRequest(RequestParams{
    25  		RequestName:  internal.GetOrganizationRelationshipDefaultIsolationSegmentRequest,
    26  		URIParams:    internal.Params{"organization_guid": orgGUID},
    27  		ResponseBody: &responseBody,
    28  	})
    29  
    30  	return responseBody, warnings, err
    31  }
    32  
    33  // GetSpaceIsolationSegment returns the relationship between a space and it's
    34  // isolation segment.
    35  func (client *Client) GetSpaceIsolationSegment(spaceGUID string) (resources.Relationship, Warnings, error) {
    36  	var responseBody resources.Relationship
    37  
    38  	_, warnings, err := client.MakeRequest(RequestParams{
    39  		RequestName:  internal.GetSpaceRelationshipIsolationSegmentRequest,
    40  		URIParams:    internal.Params{"space_guid": spaceGUID},
    41  		ResponseBody: &responseBody,
    42  	})
    43  
    44  	return responseBody, warnings, err
    45  }
    46  
    47  // SetApplicationDroplet sets the specified droplet on the given application.
    48  func (client *Client) SetApplicationDroplet(appGUID string, dropletGUID string) (resources.Relationship, Warnings, error) {
    49  	var responseBody resources.Relationship
    50  
    51  	_, warnings, err := client.MakeRequest(RequestParams{
    52  		RequestName:  internal.PatchApplicationCurrentDropletRequest,
    53  		URIParams:    internal.Params{"app_guid": appGUID},
    54  		RequestBody:  resources.Relationship{GUID: dropletGUID},
    55  		ResponseBody: &responseBody,
    56  	})
    57  
    58  	return responseBody, warnings, err
    59  }
    60  
    61  // UpdateOrganizationDefaultIsolationSegmentRelationship sets the default isolation segment
    62  // for an organization on the controller.
    63  // If isoSegGuid is empty it will reset the default isolation segment.
    64  func (client *Client) UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID string, isoSegGUID string) (resources.Relationship, Warnings, error) {
    65  	var responseBody resources.Relationship
    66  
    67  	_, warnings, err := client.MakeRequest(RequestParams{
    68  		RequestName:  internal.PatchOrganizationRelationshipDefaultIsolationSegmentRequest,
    69  		URIParams:    internal.Params{"organization_guid": orgGUID},
    70  		RequestBody:  resources.Relationship{GUID: isoSegGUID},
    71  		ResponseBody: &responseBody,
    72  	})
    73  
    74  	return responseBody, warnings, err
    75  }
    76  
    77  // UpdateSpaceIsolationSegmentRelationship assigns an isolation segment to a space and
    78  // returns the relationship.
    79  func (client *Client) UpdateSpaceIsolationSegmentRelationship(spaceGUID string, isolationSegmentGUID string) (resources.Relationship, Warnings, error) {
    80  	var responseBody resources.Relationship
    81  
    82  	_, warnings, err := client.MakeRequest(RequestParams{
    83  		RequestName:  internal.PatchSpaceRelationshipIsolationSegmentRequest,
    84  		URIParams:    internal.Params{"space_guid": spaceGUID},
    85  		RequestBody:  resources.Relationship{GUID: isolationSegmentGUID},
    86  		ResponseBody: &responseBody,
    87  	})
    88  
    89  	return responseBody, warnings, err
    90  }