-
Notifications
You must be signed in to change notification settings - Fork 24
/
caches.go
78 lines (69 loc) · 2.35 KB
/
caches.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
package apigee
import (
"path"
)
const cachesPath = "caches"
// CachesService is an interface for interfacing with the Apigee Edge Admin API
// dealing with caches.
type CachesService interface {
List(string) ([]string, *Response, error)
Get(string, string) (*Cache, *Response, error)
}
type CachesServiceOp struct {
client *ApigeeClient
}
var _ CachesService = &CachesServiceOp{}
// Cache contains information about a cache within an Edge organization.
type Cache struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
OverflowToDisk bool `json:"overflowToDisk,omitempty"`
Persistent bool `json:"persistent,omitempty"`
Distributed bool `json:"distributed,omitempty"`
DiskSizeInMB int `json:"diskSizeInMB,omitempty"`
InMemorySizeInKB int `json:"inMemorySizeInKB,omitempty"`
MaxElementsInMemory int `json:"maxElementsInMemory,omitempty"`
MaxElementsOnDisk int `json:"maxElementsOnDisk,omitempty"`
Expiry CacheExpiry `json:"expirySettings,omitempty"`
}
// List retrieves the list of cache names for the organization referred by the ApigeeClient,
// or a set of cache names for a specific environment within an organization.
func (s *CachesServiceOp) List(env string) ([]string, *Response, error) {
var p1 string
if env == "" {
p1 = cachesPath
} else {
p1 = path.Join("e", env, cachesPath)
}
req, e := s.client.NewRequest("GET", p1, nil)
if e != nil {
return nil, nil, e
}
namelist := make([]string,0)
resp, e := s.client.Do(req, &namelist)
if e != nil {
return nil, resp, e
}
return namelist, resp, e
}
// Get retrieves the information about a Cache in an organization, or about a
// cache in an environment within an organization. This information includes the
// properties, and the created and last modified details.
func (s *CachesServiceOp) Get(name, env string) (*Cache, *Response, error) {
var p1 string
if env == "" {
p1 = path.Join(cachesPath, env)
} else {
p1 = path.Join("e", env, cachesPath)
}
req, e := s.client.NewRequest("GET", p1, nil)
if e != nil {
return nil, nil, e
}
returnedCache := Cache{}
resp, e := s.client.Do(req, &returnedCache)
if e != nil {
return nil, resp, e
}
return &returnedCache, resp, e
}