-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain.go
47 lines (37 loc) · 1.23 KB
/
domain.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
package lade
import "fmt"
var _ DomainService = new(DomainClient)
type DomainClient struct {
client *Client
}
type DomainCreateOpts struct {
Hostname string `json:"hostname"`
}
type DomainService interface {
Create(appID string, opts *DomainCreateOpts) (*Domain, error)
Delete(domain *Domain) error
Get(appID, domainID string) (*Domain, error)
Head(appID, domainID string) error
List(appID string) ([]*Domain, error)
}
func (d *DomainClient) Create(appID string, opts *DomainCreateOpts) (domain *Domain, err error) {
domain = new(Domain)
err = d.client.doCreate("apps/"+appID+"/domains", opts, domain)
return
}
func (d *DomainClient) Delete(domain *Domain) error {
path := fmt.Sprintf("apps/%d/domains/%d", domain.AppID, domain.ID)
return d.client.doDelete(path, nil)
}
func (d *DomainClient) Get(appID, domainID string) (domain *Domain, err error) {
domain = new(Domain)
err = d.client.doByID("apps/"+appID+"/domains", domainID, nil, domain)
return
}
func (d *DomainClient) Head(appID, domainID string) error {
return d.client.doByID("apps/"+appID+"/domains", domainID, nil, nil)
}
func (d *DomainClient) List(appID string) (domains []*Domain, err error) {
err = d.client.doList("apps/"+appID+"/domains", nil, &domains)
return
}