forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organizations.go
41 lines (32 loc) · 991 Bytes
/
organizations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package resources
import "github.com/cloudfoundry/cli/cf/models"
type OrganizationResource struct {
Resource
Entity OrganizationEntity
}
type OrganizationEntity struct {
Name string
QuotaDefinition QuotaResource `json:"quota_definition"`
Spaces []SpaceResource
Domains []DomainResource
}
func (resource OrganizationResource) ToFields() (fields models.OrganizationFields) {
fields.Name = resource.Entity.Name
fields.Guid = resource.Metadata.Guid
fields.QuotaDefinition = resource.Entity.QuotaDefinition.ToFields()
return
}
func (resource OrganizationResource) ToModel() (org models.Organization) {
org.OrganizationFields = resource.ToFields()
spaces := []models.SpaceFields{}
for _, s := range resource.Entity.Spaces {
spaces = append(spaces, s.ToFields())
}
org.Spaces = spaces
domains := []models.DomainFields{}
for _, d := range resource.Entity.Domains {
domains = append(domains, d.ToFields())
}
org.Domains = domains
return
}