forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains.go
103 lines (83 loc) · 3.05 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package strategy
type DomainsEndpointStrategy interface {
OrgDomainURL(orgGUID, name string) string
SharedDomainURL(name string) string
PrivateDomainURL(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) SharedDomainURL(name string) string {
return buildURL(v2("domains"), params{
inlineRelationsDepth: 1,
q: map[string]string{"name": name},
})
}
func (s domainsEndpointStrategy) PrivateDomainURL(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) SharedDomainURL(name string) string {
return buildURL(v2("shared_domains"), params{
q: map[string]string{"name": name},
})
}
func (s separatedDomainsEndpointStrategy) PrivateDomainURL(name string) string {
return buildURL(v2("private_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})
}