- Checks
- Tags
- Outages
- Integrations
go get -u github.com/uptime-com/rest-api-clients/golang/uptime
go test -v ./uptime
To view godocs locally, run godoc
. Open http://localhost:6060 in a web browser and navigate to the go-uptime package under Third party.
The Uptime.com API Docs may also be a useful reference.
import (
"context"
uptime "github.com/uptime-com/rest-api-clients/golang/uptime"
)
clientConfig := &uptime.Config {
Token: "my-api-token",
RateMilliseconds: 2000,
}
client, err := uptime.NewClient(clientConfig)
c := &uptime.Check {
CheckType: "HTTP",
Address: "https://uptime.com",
Interval: 1,
Threshold: 15,
Locations: []string{"US East", "GBR", "AUT"},
ContactGroups: []string{"Default"},
Tags: []string{"testing"},
}
ctx := context.Background()
newCheck, response, err := client.Checks.Create(ctx, c)
pk := 478926
opt := &uptime.CheckStatsOptions{
StartDate: "2020-01-01T00:00:00Z",
EndDate: "2020-01-02T00:00:00Z",
Location: "US East",
LocationsResponseTimes: true,
IncludeAlerts: true,
Download: false,
PDF: false,
}
stats, response, err := client.Checks.Stats(context.Background(), pk, opt)
fmt.Printf("Check %d statistics: %d outage(s), %ds total downtime\n", pk, stats.Totals.Outages, stats.Totals.DowntimeSecs)
options := &uptime.OutageListOptions {
Ordering: "-created_at",
}
ctx := context.Background()
outages, resp, err := client.Outages.List(ctx, options)
tagId = 12345
ctx := context.Background()
resp, err := client.Tags.Delete(ctx, tagId)
Contributions are welcome! Please feel free to fork and submit a pull request with any improvements.
go-uptime was originally created by Kyle Gentle, with support from Elias Laham and the Dev Team at Uptime.com.