github.com/ablease/cli@v6.37.1-0.20180613014814-3adbb7d7fb19+incompatible/api/cloudcontroller/ccv2/organization_quota.go (about) 1 package ccv2 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/internal" 6 ) 7 8 // OrganizationQuota is the definition of a quota for an organization. 9 type OrganizationQuota struct { 10 11 // GUID is the unique OrganizationQuota identifier. 12 GUID string 13 14 // Name is the name of the OrganizationQuota. 15 Name string 16 } 17 18 // UnmarshalJSON helps unmarshal a Cloud Controller organization quota response. 19 func (application *OrganizationQuota) UnmarshalJSON(data []byte) error { 20 var ccOrgQuota struct { 21 Metadata internal.Metadata `json:"metadata"` 22 Entity struct { 23 Name string `json:"name"` 24 } `json:"entity"` 25 } 26 err := cloudcontroller.DecodeJSON(data, &ccOrgQuota) 27 if err != nil { 28 return err 29 } 30 31 application.GUID = ccOrgQuota.Metadata.GUID 32 application.Name = ccOrgQuota.Entity.Name 33 34 return nil 35 } 36 37 // GetOrganizationQuota returns an Organization Quota associated with the 38 // provided GUID. 39 func (client *Client) GetOrganizationQuota(guid string) (OrganizationQuota, Warnings, error) { 40 request, err := client.newHTTPRequest(requestOptions{ 41 RequestName: internal.GetOrganizationQuotaDefinitionRequest, 42 URIParams: Params{"organization_quota_guid": guid}, 43 }) 44 if err != nil { 45 return OrganizationQuota{}, nil, err 46 } 47 48 var orgQuota OrganizationQuota 49 response := cloudcontroller.Response{ 50 Result: &orgQuota, 51 } 52 53 err = client.connection.Make(request, &response) 54 return orgQuota, response.Warnings, err 55 }