-
Notifications
You must be signed in to change notification settings - Fork 1
/
status.go
95 lines (80 loc) · 2.56 KB
/
status.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
package riotapi
import (
"encoding/json"
"fmt"
"net/http"
)
// Shard a League of Leguends shard data
type Shard struct {
Hostname string `json:"hostname"`
Locales []string `json:"locales"`
Name string `json:"name"`
RegionTag string `json:"region_tag"`
Slug string `json:"slug"`
}
// Shards get a listing for all of the LoL shards
func (c *APIClient) Shards() (shards []*Shard, err error) {
req, err := http.NewRequest("GET", "http://status.leagueoflegends.com/shards", nil)
var data []byte
data, err = c.do(req, false)
if err != nil {
return shards, err
}
err = json.Unmarshal(data, &shards)
if err != nil {
return shards, err
}
return shards, nil
}
// ShardStatus a report of the current status of a shard
type ShardStatus struct {
Hostname string `json:"hostname"`
Locales []string `json:"locales"`
Name string `json:"region_tag"`
Services []*Service `json:"services"`
Slug string `json:"slug,omitempty"`
}
// Service a shard service
type Service struct {
Incidents []*Incident `json:"incidents"`
Name string `json:"name"`
Slug string `json:"slug,omitempty"`
Status string `json:"status"`
}
// Incident an incident report
type Incident struct {
Active bool `json:"active"`
CreatedAt string `json:"created_at"`
ID int `json:"id"`
Updates []*IncidentMessage `json:"updates"`
}
// IncidentMessage a message about an incident
type IncidentMessage struct {
Author string `json:"author"`
Content string `json:"content"`
CreatedAt string `json:"created_at"`
ID string `json:"id"`
Severity string `json:"severity"`
Translations []*MessageTranslation `json:"translations"`
UpdatedAt string `json:"update_at"`
}
// MessageTranslation a translation of a message into another locale
type MessageTranslation struct {
Content string `json:"content"`
Locale string `json:"locale"`
UpdatedAt string `json:"updated_at"`
}
// ShardStatus get the status of a specified shard
func (c *APIClient) ShardStatus(name string) (ss *ShardStatus, err error) {
req, err := http.NewRequest("GET", fmt.Sprintf("http://status.leagueoflegends.com/shards/%s", name), nil)
var data []byte
data, err = c.do(req, false)
if err != nil {
return ss, err
}
err = json.Unmarshal(data, &ss)
if err != nil {
return ss, err
}
return ss, err
}