/
sqs_queues.go
84 lines (75 loc) · 1.66 KB
/
sqs_queues.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
79
80
81
82
83
84
package main
import (
"github.com/bporter816/aws-tui/model"
"github.com/bporter816/aws-tui/repo"
"github.com/bporter816/aws-tui/ui"
"github.com/bporter816/aws-tui/utils"
"github.com/bporter816/aws-tui/view"
"github.com/gdamore/tcell/v2"
)
type SQSQueues struct {
*ui.Table
view.SQS
repo *repo.SQS
app *Application
model []model.SQSQueue
}
func NewSQSQueues(repo *repo.SQS, app *Application) *SQSQueues {
s := &SQSQueues{
Table: ui.NewTable([]string{
"NAME",
"TYPE",
}, 1, 0),
repo: repo,
app: app,
}
return s
}
func (s SQSQueues) GetLabels() []string {
return []string{"Queues"}
}
func (s SQSQueues) accessPolicyHandler() {
row, err := s.GetRowSelection()
if err != nil {
return
}
accessPolicyView := NewSQSAccessPolicy(s.repo, s.model[row-1].QueueUrl, s.app)
s.app.AddAndSwitch(accessPolicyView)
}
func (s SQSQueues) tagsHandler() {
row, err := s.GetRowSelection()
if err != nil {
return
}
tagsView := NewTags(s.repo, s.GetService(), s.model[row-1].QueueUrl, s.app)
s.app.AddAndSwitch(tagsView)
}
func (s SQSQueues) GetKeyActions() []KeyAction {
return []KeyAction{
{
Key: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
Description: "Access Policy",
Action: s.accessPolicyHandler,
},
{
Key: tcell.NewEventKey(tcell.KeyRune, 't', tcell.ModNone),
Description: "Tags",
Action: s.tagsHandler,
},
}
}
func (s *SQSQueues) Render() {
model, err := s.repo.ListQueues()
if err != nil {
panic(err)
}
s.model = model
var data [][]string
for _, v := range model {
data = append(data, []string{
v.Name,
utils.BoolToString(v.IsFifo, "FIFO", "Standard"),
})
}
s.SetData(data)
}