-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmd_notification.go
50 lines (39 loc) · 1.24 KB
/
cmd_notification.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 main
import (
"log"
"strings"
service "github.com/apiheat/go-edgegrid/v6/service/netlistv2"
"github.com/urfave/cli/v2"
)
// cmdNotificationManagement is used by cli to execute notification management
//
// cmd_search
func cmdNotificationManagement(c *cli.Context) error {
return notificationManagement(c)
}
// notificationManagement execute client API call to notification subscription modification
//
// cmd_search
func notificationManagement(c *cli.Context) error {
if len(c.StringSlice("notificationRecipients")) < 1 {
log.Fatal("Please provide notificationRecipients!")
}
notificationRecipients := strings.Split(c.StringSlice("notificationRecipients")[0], ",")
if len(c.StringSlice("networkListsIDs")) < 1 {
log.Fatal("Please provide networkListsIDs!")
}
networkListsIDs := strings.Split(c.StringSlice("networkListsIDs")[0], ",")
networkListSubscription := service.NetworkListSubscription{
Recipients: notificationRecipients,
UniqueIds: networkListsIDs,
}
notificationAction := service.Subscribe
if c.Bool("unsubscribe") {
notificationAction = service.Unsubscribe
}
netlistErr := apiClient.NetworkListNotification(notificationAction, networkListSubscription)
if netlistErr != nil {
return netlistErr
}
return nil
}