module AliMNS { export class MNSTopic extends MNS implements IMNSTopic { public constructor ( account , region ? ) { super ( account , region ) ; this . _urlTopic = this . makeTopicURL ( ) ; } public listTopicP ( prefix ? , pageSize ? , pageMarker ? ) { var headers = { } ; if ( prefix ) headers [ "x-mns-prefix" ] = prefix ; if ( pageMarker ) headers [ "x-mns-marker" ] = pageMarker ; if ( pageSize ) headers [ "x-mns-ret-number" ] = pageSize ; var url = this . _urlTopic . slice ( 0 , - 1 ) ; debug ( "GET " + url ) ; return this . _openStack . sendP ( "GET" , url , null , headers ) ; } public createTopicP ( name , options ? ) { var body = { Topic : "" } ; if ( options ) body . Topic = options ; var url = Url . resolve ( this . _urlTopic , name ) ; debug ( "PUT " + url , body ) ; return this . _openStack . sendP ( "PUT" , url , body ) ; } public deleteTopicP ( name ) { var url = Url . resolve ( this . _urlTopic , name ) ; debug ( "DELETE " + url ) ; return this . _openStack . sendP ( "DELETE" , url ) ; } private makeTopicURL ( ) { return Util . format ( this . _patternTopic , this . _account . getHttps ( ) ? "https" : "http" , this . _account . getAccountId ( ) , this . _region . toString ( ) ) ; } private _patternTopic = "%s://%s.mns.%s.aliyuncs.com/topics/" ; private _urlTopic : String ; } }