module AliMNS { export class MNS implements IMNS { constructor ( account , region ? ) { this . _account = account ; if ( region ) { if ( typeof region === "string" ) this . _region = new Region ( region , NetworkType . Public , Zone . China ) ; else this . _region = region ; } this . _url = this . makeURL ( ) ; this . _openStack = new OpenStack ( account ) ; } public listP ( 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 . _url . slice ( 0 , - 1 ) ; debug ( "GET " + url ) ; return this . _openStack . sendP ( "GET" , url , null , headers ) ; } public createP ( name , options ? ) { var body = { Queue : "" } ; if ( options ) body . Queue = options ; var url = Url . resolve ( this . _url , name ) ; debug ( "PUT " + url , body ) ; return this . _openStack . sendP ( "PUT" , url , body ) ; } public deleteP ( name ) { var url = Url . resolve ( this . _url , name ) ; debug ( "DELETE " + url ) ; return this . _openStack . sendP ( "DELETE" , url ) ; } private makeURL ( ) { return Util . format ( this . _pattern , this . _account . getHttps ( ) ? "https" : "http" , this . _account . getAccountId ( ) , this . _region . toString ( ) ) ; } protected _account : Account ; protected _region = new Region ( City . Hangzhou ) ; private _pattern = "%s://%s.mns.%s.aliyuncs.com/queues/" ; private _url : string ; protected _openStack : OpenStack ; } export var MQS = MNS ; }