forked from goamz/goamz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
topic.go
104 lines (88 loc) · 2.3 KB
/
topic.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package sns
import (
"errors"
)
type Topic struct {
SNS *SNS
TopicArn string
}
type ListTopicsResp struct {
Topics []Topic `xml:"ListTopicsResult>Topics>member"`
NextToken string
ResponseMetadata
}
type CreateTopicResp struct {
Topic Topic `xml:"CreateTopicResult"`
ResponseMetadata
}
type DeleteTopicResp struct {
ResponseMetadata
}
type GetTopicAttributesResp struct {
Attributes []AttributeEntry `xml:"GetTopicAttributesResult>Attributes>entry"`
ResponseMetadata
}
type SetTopicAttributesResponse struct {
ResponseMetadata
}
// ListTopics
//
// See http://goo.gl/lfrMK for more details.
func (sns *SNS) ListTopics(NextToken *string) (resp *ListTopicsResp, err error) {
resp = &ListTopicsResp{}
params := makeParams("ListTopics")
if NextToken != nil {
params["NextToken"] = *NextToken
}
err = sns.query(params, resp)
for i, _ := range resp.Topics {
resp.Topics[i].SNS = sns
}
return
}
// CreateTopic
//
// See http://goo.gl/m9aAt for more details.
func (sns *SNS) CreateTopic(Name string) (resp *CreateTopicResp, err error) {
resp = &CreateTopicResp{}
params := makeParams("CreateTopic")
params["Name"] = Name
err = sns.query(params, resp)
resp.Topic.SNS = sns
return
}
// Delete
//
// Helper function for deleting a topic
func (topic *Topic) Delete() (resp *DeleteTopicResp, err error) {
resp = &DeleteTopicResp{}
params := makeParams("DeleteTopic")
params["TopicArn"] = topic.TopicArn
err = topic.SNS.query(params, resp)
return
}
// GetTopicAttributes
//
// See http://goo.gl/WXRoX for more details.
func (sns *SNS) GetTopicAttributes(TopicArn string) (resp *GetTopicAttributesResp, err error) {
resp = &GetTopicAttributesResp{}
params := makeParams("GetTopicAttributes")
params["TopicArn"] = TopicArn
err = sns.query(params, resp)
return
}
// SetTopicAttributes
//
// See http://goo.gl/oVYW7 for more details.
func (sns *SNS) SetTopicAttributes(AttributeName, AttributeValue, TopicArn string) (resp *SetTopicAttributesResponse, err error) {
resp = &SetTopicAttributesResponse{}
params := makeParams("SetTopicAttributes")
if AttributeName == "" || TopicArn == "" {
return nil, errors.New("Invalid Attribute Name or TopicArn")
}
params["AttributeName"] = AttributeName
params["AttributeValue"] = AttributeValue
params["TopicArn"] = TopicArn
err = sns.query(params, resp)
return
}