/
sns_delivery_policy.go
47 lines (41 loc) · 986 Bytes
/
sns_delivery_policy.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
package main
import (
"github.com/aws/aws-sdk-go-v2/aws/arn"
"github.com/bporter816/aws-tui/repo"
"github.com/bporter816/aws-tui/ui"
"github.com/bporter816/aws-tui/utils"
"github.com/bporter816/aws-tui/view"
)
type SNSDeliveryPolicy struct {
*ui.Text
view.SNS
repo *repo.SNS
topicArn string
app *Application
}
func NewSNSDeliveryPolicy(repo *repo.SNS, topicArn string, app *Application) *SNSDeliveryPolicy {
s := &SNSDeliveryPolicy{
Text: ui.NewText(true, "json"),
repo: repo,
topicArn: topicArn,
app: app,
}
return s
}
func (s SNSDeliveryPolicy) GetLabels() []string {
arn, err := arn.Parse(s.topicArn)
if err != nil {
panic(err)
}
return []string{utils.GetResourceNameFromArn(arn), "Delivery Policy"}
}
func (s SNSDeliveryPolicy) GetKeyActions() []KeyAction {
return []KeyAction{}
}
func (s SNSDeliveryPolicy) Render() {
policy, err := s.repo.GetDeliveryPolicy(s.topicArn)
if err != nil {
panic(err)
}
s.SetText(policy)
}