github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccv3/space_quota.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  func (client Client) ApplySpaceQuota(quotaGUID string, spaceGUID string) (resources.RelationshipList, Warnings, error) {
     9  	var responseBody resources.RelationshipList
    10  
    11  	_, warnings, err := client.MakeRequest(RequestParams{
    12  		RequestName:  internal.PostSpaceQuotaRelationshipsRequest,
    13  		URIParams:    internal.Params{"quota_guid": quotaGUID},
    14  		RequestBody:  resources.RelationshipList{GUIDs: []string{spaceGUID}},
    15  		ResponseBody: &responseBody,
    16  	})
    17  
    18  	return responseBody, warnings, err
    19  }
    20  
    21  func (client Client) CreateSpaceQuota(spaceQuota resources.SpaceQuota) (resources.SpaceQuota, Warnings, error) {
    22  	var responseBody resources.SpaceQuota
    23  
    24  	_, warnings, err := client.MakeRequest(RequestParams{
    25  		RequestName:  internal.PostSpaceQuotaRequest,
    26  		RequestBody:  spaceQuota,
    27  		ResponseBody: &responseBody,
    28  	})
    29  
    30  	return responseBody, warnings, err
    31  }
    32  
    33  func (client Client) DeleteSpaceQuota(spaceQuotaGUID string) (JobURL, Warnings, error) {
    34  	jobURL, warnings, err := client.MakeRequest(RequestParams{
    35  		RequestName: internal.DeleteSpaceQuotaRequest,
    36  		URIParams:   internal.Params{"quota_guid": spaceQuotaGUID},
    37  	})
    38  
    39  	return jobURL, warnings, err
    40  }
    41  
    42  func (client Client) GetSpaceQuota(spaceQuotaGUID string) (resources.SpaceQuota, Warnings, error) {
    43  	var responseBody resources.SpaceQuota
    44  
    45  	_, warnings, err := client.MakeRequest(RequestParams{
    46  		RequestName:  internal.GetSpaceQuotaRequest,
    47  		URIParams:    internal.Params{"quota_guid": spaceQuotaGUID},
    48  		ResponseBody: &responseBody,
    49  	})
    50  
    51  	return responseBody, warnings, err
    52  }
    53  
    54  func (client *Client) GetSpaceQuotas(query ...Query) ([]resources.SpaceQuota, Warnings, error) {
    55  	var spaceQuotas []resources.SpaceQuota
    56  
    57  	_, warnings, err := client.MakeListRequest(RequestParams{
    58  		RequestName:  internal.GetSpaceQuotasRequest,
    59  		Query:        query,
    60  		ResponseBody: resources.SpaceQuota{},
    61  		AppendToList: func(item interface{}) error {
    62  			spaceQuotas = append(spaceQuotas, item.(resources.SpaceQuota))
    63  			return nil
    64  		},
    65  	})
    66  
    67  	return spaceQuotas, warnings, err
    68  }
    69  
    70  func (client *Client) UnsetSpaceQuota(spaceQuotaGUID, spaceGUID string) (Warnings, error) {
    71  	_, warnings, err := client.MakeRequest(RequestParams{
    72  		RequestName: internal.DeleteSpaceQuotaFromSpaceRequest,
    73  		URIParams:   internal.Params{"quota_guid": spaceQuotaGUID, "space_guid": spaceGUID},
    74  	})
    75  
    76  	return warnings, err
    77  }
    78  
    79  func (client *Client) UpdateSpaceQuota(spaceQuota resources.SpaceQuota) (resources.SpaceQuota, Warnings, error) {
    80  	spaceQuotaGUID := spaceQuota.GUID
    81  	spaceQuota.GUID = ""
    82  
    83  	var responseBody resources.SpaceQuota
    84  
    85  	_, warnings, err := client.MakeRequest(RequestParams{
    86  		RequestName:  internal.PatchSpaceQuotaRequest,
    87  		URIParams:    internal.Params{"quota_guid": spaceQuotaGUID},
    88  		RequestBody:  spaceQuota,
    89  		ResponseBody: &responseBody,
    90  	})
    91  
    92  	return responseBody, warnings, err
    93  }