github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/api/cloudcontroller/ccv3/organization_quota.go (about) 1 package ccv3 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" 6 "code.cloudfoundry.org/cli/types" 7 ) 8 9 // OrgQuota represents a Cloud Controller organization quota. 10 type OrgQuota struct { 11 // GUID is the unique ID of the organization quota. 12 GUID string `json:"guid,omitempty"` 13 // Name is the name of the organization quota 14 Name string `json:"name"` 15 // Apps contain the various limits that are associated with applications 16 Apps AppLimit `json:"apps"` 17 // Services contain the various limits that are associated with services 18 Services ServiceLimit `json:"services"` 19 // Routes contain the various limits that are associated with routes 20 Routes RouteLimit `json:"routes"` 21 } 22 23 type AppLimit struct { 24 TotalMemory types.NullInt `json:"total_memory_in_mb"` 25 InstanceMemory types.NullInt `json:"per_process_memory_in_mb"` 26 TotalAppInstances types.NullInt `json:"total_instances"` 27 } 28 29 type ServiceLimit struct { 30 TotalServiceInstances types.NullInt `json:"total_service_instances"` 31 PaidServicePlans bool `json:"paid_services_allowed"` 32 } 33 34 type RouteLimit struct { 35 TotalRoutes types.NullInt `json:"total_routes"` 36 TotalRoutePorts types.NullInt `json:"total_reserved_ports"` 37 } 38 39 func (client *Client) GetOrganizationQuotas(query ...Query) ([]OrgQuota, Warnings, error) { 40 request, err := client.newHTTPRequest(requestOptions{ 41 RequestName: internal.GetOrganizationQuotasRequest, 42 Query: query, 43 }) 44 if err != nil { 45 return []OrgQuota{}, nil, err 46 } 47 48 var orgQuotasList []OrgQuota 49 warnings, err := client.paginate(request, OrgQuota{}, func(item interface{}) error { 50 if orgQuota, ok := item.(OrgQuota); ok { 51 orgQuotasList = append(orgQuotasList, orgQuota) 52 } else { 53 return ccerror.UnknownObjectInListError{ 54 Expected: OrgQuota{}, 55 Unexpected: item, 56 } 57 } 58 return nil 59 }) 60 61 return orgQuotasList, warnings, err 62 }