github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/resources/organization_resource.go (about) 1 package resources 2 3 import ( 4 "encoding/json" 5 ) 6 7 // Organization represents a Cloud Controller V3 Organization. 8 type Organization struct { 9 // GUID is the unique organization identifier. 10 GUID string `json:"guid,omitempty"` 11 // Name is the name of the organization. 12 Name string `json:"name"` 13 // QuotaGUID is the GUID of the organization Quota applied to this Organization 14 QuotaGUID string `json:"-"` 15 // Suspended is the status of the organization applied to this Organization 16 Suspended bool `json:"suspended"` 17 // Metadata is used for custom tagging of API resources 18 Metadata *Metadata `json:"metadata,omitempty"` 19 } 20 21 func (org *Organization) UnmarshalJSON(data []byte) error { 22 type alias Organization 23 var aliasOrg alias 24 err := json.Unmarshal(data, &aliasOrg) 25 if err != nil { 26 return err 27 } 28 29 *org = Organization(aliasOrg) 30 31 remainingFields := new(struct { 32 Relationships struct { 33 Quota struct { 34 Data struct { 35 GUID string 36 } 37 } 38 } 39 }) 40 41 err = json.Unmarshal(data, &remainingFields) 42 if err != nil { 43 return err 44 } 45 46 org.QuotaGUID = remainingFields.Relationships.Quota.Data.GUID 47 48 return nil 49 }