Newer
Older
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
package api
import (
"context"
"time"
subpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/subscriptionmanagement"
nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/client"
)
// ResetAllSubscriptions stops all running subscriptions and restarts them the same way they ran before.
func ResetAllSubscriptions(ctx context.Context, addr string) (*subpb.ResetAllSubscriptionsResponse, error) {
subClient, err := nbi.SubManagementClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &subpb.ResetAllSubscriptionsRequest{
Timestamp: time.Now().UnixNano(),
}
return subClient.ResetAllSubscriptions(ctx, req)
}
// GetAll returns information about all running subscriptions.
func GetAll(ctx context.Context, addr string) (*subpb.GetAllResponse, error) {
subClient, err := nbi.SubManagementClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &subpb.GetAllRequest{
Timestamp: time.Now().UnixNano(),
}
return subClient.GetAll(ctx, req)
}
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
// Get fetches detailed info for one specific available subscription.
func Get(ctx context.Context, addr string, subID string) (*subpb.GetResponse, error) {
subClient, err := nbi.SubManagementClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &subpb.GetRequest{
Timestamp: time.Now().UnixNano(),
Subid: subID,
}
return subClient.Get(ctx, req)
}
// Delete stops and removes one specific running subscription is a no-op if object connected to ID does not exist.
func Delete(ctx context.Context, addr string, subID string) (*subpb.DeleteResponse, error) {
subClient, err := nbi.SubManagementClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &subpb.DeleteRequest{
Timestamp: time.Now().UnixNano(),
Subid: subID,
}
return subClient.Delete(ctx, req)
}
// Add creates a new subscription for the network element matching the provided ID using the provided subscribe options.
func Add(ctx context.Context, addr string, mneID string, subscribeOptions *subpb.Subscription) (*subpb.AddResponse, error) {
subClient, err := nbi.SubManagementClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &subpb.AddRequest{
Timestamp: time.Now().UnixNano(),
Mneid: mneID,
Subscription: subscribeOptions,
}
return subClient.Add(ctx, req)
}