forked from Marquis42/ari-proxy
/
endpoint.go
50 lines (44 loc) · 1.04 KB
/
endpoint.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
package client
import (
"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/proxy"
)
type endpoint struct {
c *Client
}
func (e *endpoint) Data(key *ari.Key) (*ari.EndpointData, error) {
data, err := e.c.dataRequest(&proxy.Request{
Kind: "EndpointData",
Key: key,
})
if err != nil {
return nil, err
}
return data.Endpoint, nil
}
func (e *endpoint) Get(key *ari.Key) *ari.EndpointHandle {
k, err := e.c.getRequest(&proxy.Request{
Kind: "EndpointGet",
Key: key,
})
if err != nil {
e.c.log.Warn("failed to get endpoint for handle", "error", err)
return ari.NewEndpointHandle(key, e)
}
return ari.NewEndpointHandle(k, e)
}
func (e *endpoint) List(filter *ari.Key) ([]*ari.Key, error) {
return e.c.listRequest(&proxy.Request{
Kind: "EndpointList",
Key: filter,
})
}
func (e *endpoint) ListByTech(tech string, filter *ari.Key) ([]*ari.Key, error) {
return e.c.listRequest(&proxy.Request{
Kind: "EndpointListByTech",
Key: filter,
EndpointListByTech: &proxy.EndpointListByTech{
Tech: tech,
},
})
}