forked from cloudfoundry-community/cloudfoundry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organization_summary.go
55 lines (44 loc) · 1.41 KB
/
organization_summary.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package v2action
import "sort"
type OrganizationSummary struct {
Organization
QuotaName string
DomainNames []string
SpaceNames []string
}
func (actor Actor) GetOrganizationSummaryByName(orgName string) (OrganizationSummary, Warnings, error) {
var allWarnings Warnings
org, warnings, err := actor.GetOrganizationByName(orgName)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return OrganizationSummary{}, allWarnings, err
}
orgSummary := OrganizationSummary{
Organization: org,
}
domains, warnings, err := actor.GetOrganizationDomains(org.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return OrganizationSummary{}, allWarnings, err
}
for _, domain := range domains {
orgSummary.DomainNames = append(orgSummary.DomainNames, domain.Name)
}
sort.Strings(orgSummary.DomainNames)
quota, warnings, err := actor.GetOrganizationQuota(org.QuotaDefinitionGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return OrganizationSummary{}, allWarnings, err
}
orgSummary.QuotaName = quota.Name
spaces, warnings, err := actor.GetOrganizationSpaces(org.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return OrganizationSummary{}, allWarnings, err
}
for _, space := range spaces {
orgSummary.SpaceNames = append(orgSummary.SpaceNames, space.Name)
}
sort.Strings(orgSummary.SpaceNames)
return orgSummary, allWarnings, nil
}