github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccv3/organization_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) ApplyOrganizationQuota(quotaGuid, orgGuid string) (resources.RelationshipList, Warnings, error) { 9 var responseBody resources.RelationshipList 10 11 _, warnings, err := client.MakeRequest(RequestParams{ 12 RequestName: internal.PostOrganizationQuotaApplyRequest, 13 URIParams: internal.Params{"quota_guid": quotaGuid}, 14 RequestBody: resources.RelationshipList{GUIDs: []string{orgGuid}}, 15 ResponseBody: &responseBody, 16 }) 17 18 return responseBody, warnings, err 19 } 20 21 func (client *Client) CreateOrganizationQuota(orgQuota resources.OrganizationQuota) (resources.OrganizationQuota, Warnings, error) { 22 var responseOrgQuota resources.OrganizationQuota 23 24 _, warnings, err := client.MakeRequest(RequestParams{ 25 RequestName: internal.PostOrganizationQuotaRequest, 26 RequestBody: orgQuota, 27 ResponseBody: &responseOrgQuota, 28 }) 29 30 return responseOrgQuota, warnings, err 31 } 32 33 func (client *Client) DeleteOrganizationQuota(quotaGUID string) (JobURL, Warnings, error) { 34 jobURL, warnings, err := client.MakeRequest(RequestParams{ 35 RequestName: internal.DeleteOrganizationQuotaRequest, 36 URIParams: internal.Params{"quota_guid": quotaGUID}, 37 }) 38 39 return jobURL, warnings, err 40 } 41 42 func (client *Client) GetOrganizationQuota(quotaGUID string) (resources.OrganizationQuota, Warnings, error) { 43 var responseBody resources.OrganizationQuota 44 45 _, warnings, err := client.MakeRequest(RequestParams{ 46 RequestName: internal.GetOrganizationQuotaRequest, 47 URIParams: internal.Params{"quota_guid": quotaGUID}, 48 ResponseBody: &responseBody, 49 }) 50 51 return responseBody, warnings, err 52 } 53 54 func (client *Client) GetOrganizationQuotas(query ...Query) ([]resources.OrganizationQuota, Warnings, error) { 55 var organizationQuotas []resources.OrganizationQuota 56 57 _, warnings, err := client.MakeListRequest(RequestParams{ 58 RequestName: internal.GetOrganizationQuotasRequest, 59 Query: query, 60 ResponseBody: resources.OrganizationQuota{}, 61 AppendToList: func(item interface{}) error { 62 organizationQuotas = append(organizationQuotas, item.(resources.OrganizationQuota)) 63 return nil 64 }, 65 }) 66 67 return organizationQuotas, warnings, err 68 } 69 70 func (client *Client) UpdateOrganizationQuota(orgQuota resources.OrganizationQuota) (resources.OrganizationQuota, Warnings, error) { 71 orgQuotaGUID := orgQuota.GUID 72 orgQuota.GUID = "" 73 74 var responseBody resources.OrganizationQuota 75 76 _, warnings, err := client.MakeRequest(RequestParams{ 77 RequestName: internal.PatchOrganizationQuotaRequest, 78 URIParams: internal.Params{"quota_guid": orgQuotaGUID}, 79 RequestBody: orgQuota, 80 ResponseBody: &responseBody, 81 }) 82 83 return responseBody, warnings, err 84 }