github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/resources/spaces.go (about) 1 package resources 2 3 import "code.cloudfoundry.org/cli/cf/models" 4 5 type SpaceResource struct { 6 Resource 7 Entity SpaceEntity 8 } 9 10 type SpaceEntity struct { 11 Name string 12 Organization OrganizationResource 13 Applications []ApplicationResource `json:"apps"` 14 Domains []DomainResource 15 ServiceInstances []ServiceInstanceResource `json:"service_instances"` 16 SecurityGroups []SecurityGroupResource `json:"security_groups"` 17 SpaceQuotaGUID string `json:"space_quota_definition_guid"` 18 AllowSSH bool `json:"allow_ssh"` 19 } 20 21 func (resource SpaceResource) ToFields() (fields models.SpaceFields) { 22 fields.GUID = resource.Metadata.GUID 23 fields.Name = resource.Entity.Name 24 fields.AllowSSH = resource.Entity.AllowSSH 25 return 26 } 27 28 func (resource SpaceResource) ToModel() (space models.Space) { 29 space.SpaceFields = resource.ToFields() 30 for _, app := range resource.Entity.Applications { 31 space.Applications = append(space.Applications, app.ToFields()) 32 } 33 34 for _, domainResource := range resource.Entity.Domains { 35 space.Domains = append(space.Domains, domainResource.ToFields()) 36 } 37 38 for _, serviceResource := range resource.Entity.ServiceInstances { 39 space.ServiceInstances = append(space.ServiceInstances, serviceResource.ToFields()) 40 } 41 42 for _, securityGroupResource := range resource.Entity.SecurityGroups { 43 space.SecurityGroups = append(space.SecurityGroups, securityGroupResource.ToFields()) 44 } 45 46 space.Organization = resource.Entity.Organization.ToFields() 47 space.SpaceQuotaGUID = resource.Entity.SpaceQuotaGUID 48 return 49 }