-
Notifications
You must be signed in to change notification settings - Fork 0
/
alert-note.go
52 lines (40 loc) · 925 Bytes
/
alert-note.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
package alert
import (
"context"
"fmt"
"time"
"github.com/AlecAivazis/survey/v2"
"mmesh.dev/m-api-go/grpc/resources/events"
"mmesh.dev/m-cli/pkg/grpc"
"mmesh.dev/m-cli/pkg/input"
"mmesh.dev/m-cli/pkg/output"
"mmesh.dev/m-cli/pkg/status"
)
func (api *API) NewNote(a *events.Alert) {
if a == nil {
a = getAlert()
}
nxc, grpcConn := grpc.GetMonitoringAPIClient()
defer grpcConn.Close()
acr := &events.AlertNewCommentRequest{
AccountID: a.AccountID,
AlertID: a.AlertID,
Comment: &events.AlertComment{
Timestamp: time.Now().UnixMilli(),
// UserID: userID,
// UserEmail: userEmail,
Text: input.GetMultiline("Note:", "", "", survey.Required),
},
}
s := output.Spinner()
_, err := nxc.NewAlertComment(context.TODO(), acr)
if err != nil {
s.Stop()
status.Error(err, "Unable to add alert note")
}
s.Stop()
fmt.Printf(`
Your input has been sent!
Thanks for using mmesh!
`)
}