Skip to content

Commit df722c6

Browse files
authored
Merge pull request #4 from aliyun/revert_add_api
Add some deleted interface
2 parents 2de69a2 + b7a2cb6 commit df722c6

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed

message.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ type Queues struct {
242242
NextMarker string `xml:"NextMarker" json:"next_marker"`
243243
}
244244

245+
type QueueDetails struct {
246+
XMLName xml.Name `xml:"Queues" json:"-"`
247+
Attrs []QueueAttribute `xml:"Queue" json:"queues"`
248+
NextMarker string `xml:"NextMarker" json:"next_marker"`
249+
}
250+
245251
type Topic struct {
246252
TopicURL string `xml:"TopicURL" json:"url"`
247253
}
@@ -252,6 +258,12 @@ type Topics struct {
252258
NextMarker string `xml:"NextMarker" json:"next_marker"`
253259
}
254260

261+
type TopicDetails struct {
262+
XMLName xml.Name `xml:"Topics" json:"-"`
263+
Attrs []TopicAttribute `xml:"Topic" json:"topics"`
264+
NextMarker string `xml:"NextMarker" json:"next_marker"`
265+
}
266+
255267
type Subscription struct {
256268
SubscriptionURL string `xml:"SubscriptionURL" json:"url"`
257269
}
@@ -261,3 +273,9 @@ type Subscriptions struct {
261273
Subscriptions []Subscription `xml:"Subscription" json:"subscriptions"`
262274
NextMarker string `xml:"NextMarker" json:"next_marker"`
263275
}
276+
277+
type SubscriptionDetails struct {
278+
XMLName xml.Name `xml:"Subscriptions" json:"-"`
279+
Attrs []SubscriptionAttribute `xml:"Subscription" json:"subscriptions"`
280+
NextMarker string `xml:"NextMarker" json:"next_marker"`
281+
}

queue_manager.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type AliQueueManager interface {
1616
GetQueueAttributes(queueName string) (attr QueueAttribute, err error)
1717
DeleteQueue(queueName string) (err error)
1818
ListQueue(nextMarker string, retNumber int32, prefix string) (queues Queues, err error)
19+
ListQueueDetail(nextMarker string, retNumber int32, prefix string) (queueDetails QueueDetails, err error)
1920
}
2021

2122
type MNSQueueManager struct {
@@ -215,3 +216,35 @@ func (p *MNSQueueManager) ListQueue(nextMarker string, retNumber int32, prefix s
215216

216217
return
217218
}
219+
220+
func (p *MNSQueueManager) ListQueueDetail(nextMarker string, retNumber int32, prefix string) (queueDetails QueueDetails, err error) {
221+
222+
header := map[string]string{}
223+
224+
marker := strings.TrimSpace(nextMarker)
225+
if len(marker) > 0 {
226+
if marker != "" {
227+
header["x-mns-marker"] = marker
228+
}
229+
}
230+
231+
if retNumber > 0 {
232+
if retNumber >= 1 && retNumber <= 1000 {
233+
header["x-mns-ret-number"] = strconv.Itoa(int(retNumber))
234+
} else {
235+
err = ERR_MNS_RET_NUMBER_RANGE_ERROR.New()
236+
return
237+
}
238+
}
239+
240+
prefix = strings.TrimSpace(prefix)
241+
if prefix != "" {
242+
header["x-mns-prefix"] = prefix
243+
}
244+
245+
header["x-mns-with-meta"] = "true"
246+
247+
_, err = send(p.cli, p.decoder, GET, header, nil, "queues", &queueDetails)
248+
249+
return
250+
}

topic.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type AliMNSTopic interface {
2121
GetSubscriptionAttributes(subscriptionName string) (attr SubscriptionAttribute, err error)
2222
Unsubscribe(subscriptionName string) (err error)
2323
ListSubscriptionByTopic(nextMarker string, retNumber int32, prefix string) (subscriptions Subscriptions, err error)
24+
ListSubscriptionDetailByTopic(nextMarker string, retNumber int32, prefix string) (subscriptionDetails SubscriptionDetails, err error)
2425
}
2526

2627
type MNSTopic struct {
@@ -154,3 +155,34 @@ func (p *MNSTopic) ListSubscriptionByTopic(nextMarker string, retNumber int32, p
154155

155156
return
156157
}
158+
159+
func (p *MNSTopic) ListSubscriptionDetailByTopic(nextMarker string, retNumber int32, prefix string) (subscriptionDetails SubscriptionDetails, err error) {
160+
header := map[string]string{}
161+
162+
marker := strings.TrimSpace(nextMarker)
163+
if len(marker) > 0 {
164+
if marker != "" {
165+
header["x-mns-marker"] = marker
166+
}
167+
}
168+
169+
if retNumber > 0 {
170+
if retNumber >= 1 && retNumber <= 1000 {
171+
header["x-mns-ret-number"] = strconv.Itoa(int(retNumber))
172+
} else {
173+
err = ERR_MNS_RET_NUMBER_RANGE_ERROR.New()
174+
return
175+
}
176+
}
177+
178+
prefix = strings.TrimSpace(prefix)
179+
if prefix != "" {
180+
header["x-mns-prefix"] = prefix
181+
}
182+
183+
header["x-mns-with-meta"] = "true"
184+
185+
_, err = send(p.client, p.decoder, GET, header, nil, fmt.Sprintf("topics/%s/subscriptions", p.name), &subscriptionDetails)
186+
187+
return
188+
}

topic_manager.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type AliTopicManager interface {
1616
GetTopicAttributes(topicName string) (attr TopicAttribute, err error)
1717
DeleteTopic(topicName string) (err error)
1818
ListTopic(nextMarker string, retNumber int32, prefix string) (topics Topics, err error)
19+
ListTopicDetail(nextMarker string, retNumber int32, prefix string) (topicDetails TopicDetails, err error)
1920
}
2021

2122
type MNSTopicManager struct {
@@ -142,3 +143,35 @@ func (p *MNSTopicManager) ListTopic(nextMarker string, retNumber int32, prefix s
142143

143144
return
144145
}
146+
147+
func (p *MNSTopicManager) ListTopicDetail(nextMarker string, retNumber int32, prefix string) (topicDetails TopicDetails, err error) {
148+
149+
header := map[string]string{}
150+
151+
marker := strings.TrimSpace(nextMarker)
152+
if len(marker) > 0 {
153+
if marker != "" {
154+
header["x-mns-marker"] = marker
155+
}
156+
}
157+
158+
if retNumber > 0 {
159+
if retNumber >= 1 && retNumber <= 1000 {
160+
header["x-mns-ret-number"] = strconv.Itoa(int(retNumber))
161+
} else {
162+
err = ERR_MNS_RET_NUMBER_RANGE_ERROR.New()
163+
return
164+
}
165+
}
166+
167+
prefix = strings.TrimSpace(prefix)
168+
if prefix != "" {
169+
header["x-mns-prefix"] = prefix
170+
}
171+
172+
header["x-mns-with-meta"] = "true"
173+
174+
_, err = send(p.cli, p.decoder, GET, header, nil, "topics", &topicDetails)
175+
176+
return
177+
}

0 commit comments

Comments
 (0)