github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/api/resources/organizations.go (about) 1 package resources 2 3 import "code.cloudfoundry.org/cli/cf/models" 4 5 type OrganizationResource struct { 6 Resource 7 Entity OrganizationEntity 8 } 9 10 type OrganizationEntity struct { 11 Name string `json:"name"` 12 QuotaDefinition QuotaResource `json:"quota_definition"` 13 Spaces []SpaceResource 14 Domains []DomainResource 15 SpaceQuotas []SpaceQuotaResource `json:"space_quota_definitions"` 16 } 17 18 func (resource OrganizationResource) ToFields() (fields models.OrganizationFields) { 19 fields.Name = resource.Entity.Name 20 fields.GUID = resource.Metadata.GUID 21 22 fields.QuotaDefinition = resource.Entity.QuotaDefinition.ToFields() 23 return 24 } 25 26 func (resource OrganizationResource) ToModel() (org models.Organization) { 27 org.OrganizationFields = resource.ToFields() 28 29 spaces := []models.SpaceFields{} 30 for _, s := range resource.Entity.Spaces { 31 spaces = append(spaces, s.ToFields()) 32 } 33 org.Spaces = spaces 34 35 domains := []models.DomainFields{} 36 for _, d := range resource.Entity.Domains { 37 domains = append(domains, d.ToFields()) 38 } 39 org.Domains = domains 40 41 spaceQuotas := []models.SpaceQuota{} 42 for _, sq := range resource.Entity.SpaceQuotas { 43 spaceQuotas = append(spaceQuotas, sq.ToModel()) 44 } 45 org.SpaceQuotas = spaceQuotas 46 return 47 }