forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains.go
89 lines (71 loc) · 2.63 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package strategy
type DomainsEndpointStrategy interface {
OrgDomainURL(orgGuid, name string) string
DomainURL(name string) string
OrgDomainsURL(orgGuid string) string
PrivateDomainsURL() string
SharedDomainsURL() string
DeleteDomainURL(guid string) string
DeleteSharedDomainURL(guid string) string
PrivateDomainsByOrgURL(guid string) string
}
type domainsEndpointStrategy struct{}
func (s domainsEndpointStrategy) DomainURL(name string) string {
return buildURL(v2("domains"), params{
inlineRelationsDepth: 1,
q: map[string]string{"name": name},
})
}
func (s domainsEndpointStrategy) OrgDomainsURL(orgGuid string) string {
return v2("organizations", orgGuid, "domains")
}
func (s domainsEndpointStrategy) OrgDomainURL(orgGuid, name string) string {
return buildURL(s.OrgDomainsURL(orgGuid), params{
inlineRelationsDepth: 1,
q: map[string]string{"name": name},
})
}
func (s domainsEndpointStrategy) PrivateDomainsURL() string {
return v2("domains")
}
func (s domainsEndpointStrategy) SharedDomainsURL() string {
return v2("domains")
}
func (s domainsEndpointStrategy) PrivateDomainsByOrgURL(orgGuid string) string {
return v2("domains")
}
func (s domainsEndpointStrategy) DeleteDomainURL(guid string) string {
return buildURL(v2("domains", guid), params{recursive: true})
}
func (s domainsEndpointStrategy) DeleteSharedDomainURL(guid string) string {
return buildURL(v2("domains", guid), params{recursive: true})
}
type separatedDomainsEndpointStrategy struct{}
func (s separatedDomainsEndpointStrategy) DomainURL(name string) string {
return buildURL(v2("shared_domains"), params{
q: map[string]string{"name": name},
})
}
func (s separatedDomainsEndpointStrategy) OrgDomainsURL(orgGuid string) string {
return v2("organizations", orgGuid, "private_domains")
}
func (s separatedDomainsEndpointStrategy) OrgDomainURL(orgGuid, name string) string {
return buildURL(s.OrgDomainsURL(orgGuid), params{
q: map[string]string{"name": name},
})
}
func (s separatedDomainsEndpointStrategy) PrivateDomainsURL() string {
return v2("private_domains")
}
func (s separatedDomainsEndpointStrategy) SharedDomainsURL() string {
return v2("shared_domains")
}
func (s separatedDomainsEndpointStrategy) PrivateDomainsByOrgURL(orgGuid string) string {
return v2("organizations", orgGuid, "private_domains")
}
func (s separatedDomainsEndpointStrategy) DeleteDomainURL(guid string) string {
return buildURL(v2("private_domains", guid), params{recursive: true})
}
func (s separatedDomainsEndpointStrategy) DeleteSharedDomainURL(guid string) string {
return buildURL(v2("shared_domains", guid), params{recursive: true})
}