This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
domain.go
73 lines (61 loc) · 2.08 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
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
// WARNING: This code is auto-generated from the Heroku Platform API JSON Schema
// by a Ruby script (gen/gen.rb). Changes should be made to the generation
// script rather than the generated files.
package heroku
import (
"time"
)
// Domains define what web routes should be routed to an app on Heroku.
type Domain struct {
// when domain was created
CreatedAt time.Time `json:"created_at"`
// full hostname
Hostname string `json:"hostname"`
// unique identifier of this domain
Id string `json:"id"`
// when domain was updated
UpdatedAt time.Time `json:"updated_at"`
}
// Create a new domain.
//
// appIdentity is the unique identifier of the Domain's App. hostname is the
// full hostname.
func (c *Client) DomainCreate(appIdentity string, hostname string) (*Domain, error) {
params := struct {
Hostname string `json:"hostname"`
}{
Hostname: hostname,
}
var domainRes Domain
return &domainRes, c.Post(&domainRes, "/apps/"+appIdentity+"/domains", params)
}
// Delete an existing domain
//
// appIdentity is the unique identifier of the Domain's App. domainIdentity is
// the unique identifier of the Domain.
func (c *Client) DomainDelete(appIdentity string, domainIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/domains/" + domainIdentity)
}
// Info for existing domain.
//
// appIdentity is the unique identifier of the Domain's App. domainIdentity is
// the unique identifier of the Domain.
func (c *Client) DomainInfo(appIdentity string, domainIdentity string) (*Domain, error) {
var domain Domain
return &domain, c.Get(&domain, "/apps/"+appIdentity+"/domains/"+domainIdentity)
}
// List existing domains.
//
// appIdentity is the unique identifier of the Domain's App. lr is an optional
// ListRange that sets the Range options for the paginated list of results.
func (c *Client) DomainList(appIdentity string, lr *ListRange) ([]Domain, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/domains", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var domainsRes []Domain
return domainsRes, c.DoReq(req, &domainsRes)
}