-
Notifications
You must be signed in to change notification settings - Fork 2
/
disk.go
49 lines (40 loc) · 1.01 KB
/
disk.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
package radarr
import (
"encoding/json"
"fmt"
)
// Diskspace disk space Radarr response
type Diskspace struct {
Path string `json:"path"`
Label string `json:"label"`
FreeSpace int64 `json:"freeSpace"`
TotalSpace int64 `json:"totalSpace"`
}
// Diskspaces describe disk space info on your Radarr instance
type Diskspaces []Diskspace
// DiskspaceService contains Radarr diskspace operations
type DiskspaceService struct {
s *Service
}
func newDiskspaceService(s *Service) *DiskspaceService {
return &DiskspaceService{s}
}
// Get return Radarr disk space info
func (s *DiskspaceService) Get() (*Diskspaces, error) {
diskspaceURL := fmt.Sprintf("%s/api%s", s.s.url, diskspaceURI)
resp, err := s.s.client.Get(diskspaceURL)
if err != nil {
return nil, err
}
defer resp.Body.Close()
err = parseRadarrResponse(resp)
if err != nil {
return nil, err
}
var diskspaces Diskspaces
err = json.NewDecoder(resp.Body).Decode(&diskspaces)
if err != nil {
return nil, err
}
return &diskspaces, nil
}