module AliMNS { export class Subscription implements ISubscription { constructor ( name , topic ) { this . _name = name ; this . _topic = topic ; this . _urlAttr = this . makeAttrURL ( ) ; this . _openStack = new OpenStack ( topic . getAccount ( ) ) ; } public getName ( ) { return this . _name ; } public getTopic ( ) { return this . _topic ; } public getAttrsP ( ) { debug ( "GET " + this . _urlAttr ) ; return this . _openStack . sendP ( "GET" , this . _urlAttr ) ; } public setAttrsP ( options ) { var body = { Subscription : options } ; debug ( "PUT " + this . _urlAttr , body ) ; return this . _openStack . sendP ( "PUT" , this . _urlAttr + "?metaoverride=true" , body ) ; } public static NotifyStrategy = { BACKOFF_RETRY : "BACKOFF_RETRY" , EXPONENTIAL_DECAY_RETRY : "EXPONENTIAL_DECAY_RETRY" } ; public static NotifyContentFormat = { XML : "XML" , SIMPLIFIED : "SIMPLIFIED" } ; private makeAttrURL ( ) { return Util . format ( this . _pattern , this . _topic . getAccount ( ) . getHttps ( ) ? "https" : "http" , this . _topic . getAccount ( ) . getAccountId ( ) , this . _topic . getRegion ( ) . toString ( ) , this . _topic . getName ( ) , this . _name ) ; } protected _openStack : OpenStack ; private _name : string ; private _topic : Topic ; private _urlAttr : string ; private _pattern = "%s://%s.mns.%s.aliyuncs.com/topics/%s/subscriptions/%s" ; } }