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
/
Copy pathlog_drain.go
86 lines (72 loc) · 2.71 KB
/
log_drain.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
// 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"
)
// Log drains provide a way to forward your Heroku logs to an external syslog
// server for long-term archiving. This external service must be configured to
// receive syslog packets from Heroku, whereupon its URL can be added to an app
// using this API. Some addons will add a log drain when they are provisioned to
// an app. These drains can only be removed by removing the add-on.
type LogDrain struct {
// addon that created the drain
Addon *struct {
Id string `json:"id"`
} `json:"addon"`
// when log drain was created
CreatedAt time.Time `json:"created_at"`
// unique identifier of this log drain
Id string `json:"id"`
// token associated with the log drain
Token string `json:"token"`
// when log drain was updated
UpdatedAt time.Time `json:"updated_at"`
// url associated with the log drain
URL string `json:"url"`
}
// Create a new log drain.
//
// appIdentity is the unique identifier of the LogDrain's App. url is the url
// associated with the log drain.
func (c *Client) LogDrainCreate(appIdentity string, url string) (*LogDrain, error) {
params := struct {
URL string `json:"url"`
}{
URL: url,
}
var logDrainRes LogDrain
return &logDrainRes, c.Post(&logDrainRes, "/apps/"+appIdentity+"/log-drains", params)
}
// Delete an existing log drain. Log drains added by add-ons can only be removed
// by removing the add-on.
//
// appIdentity is the unique identifier of the LogDrain's App. logDrainIdentity
// is the unique identifier of the LogDrain.
func (c *Client) LogDrainDelete(appIdentity string, logDrainIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/log-drains/" + logDrainIdentity)
}
// Info for existing log drain.
//
// appIdentity is the unique identifier of the LogDrain's App. logDrainIdentity
// is the unique identifier of the LogDrain.
func (c *Client) LogDrainInfo(appIdentity string, logDrainIdentity string) (*LogDrain, error) {
var logDrain LogDrain
return &logDrain, c.Get(&logDrain, "/apps/"+appIdentity+"/log-drains/"+logDrainIdentity)
}
// List existing log drains.
//
// appIdentity is the unique identifier of the LogDrain's App. lr is an optional
// ListRange that sets the Range options for the paginated list of results.
func (c *Client) LogDrainList(appIdentity string, lr *ListRange) ([]LogDrain, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/log-drains", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var logDrainsRes []LogDrain
return logDrainsRes, c.DoReq(req, &logDrainsRes)
}