-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains.go
54 lines (43 loc) · 1.15 KB
/
domains.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
package gsuitemdm
//
// GSuiteMDM domain-specific funcs
//
import (
"errors"
"fmt"
)
// Build a list of all configured domains
func (mdms *GSuiteMDMService) BuildFullDomainList() []string {
var domains []string
// Range through the slice of configured domains
for _, d := range mdms.C.Domains {
domains = append(domains, d.DomainName)
}
return domains
}
// Get a CustomerID for a given domain
func (mdms *GSuiteMDMService) GetDomainCustomerID(domain string) (string, error) {
// Range through the slice of configured domains and look for the specified domain
for _, d := range mdms.C.Domains {
switch d.DomainName {
case domain:
// Domain found, return the domain's CustomerID
return d.CustomerID, nil
}
}
return "", errors.New(fmt.Sprintf("Could not find CustomerID for domain %s", domain))
}
// Check to see if a domain is configured
func (mdms *GSuiteMDMService) IsDomainConfigured(domain string) bool {
var ok = false
// Iterate through the slice of configured domains and look for the specified domain
for _, d := range mdms.C.Domains {
if domain == d.DomainName {
// Domain found!
ok = true
break
}
}
return ok
}
// EOF