spec.py 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319
  1. """
  2. AMQP Specification
  3. ==================
  4. This module implements the constants and classes that comprise AMQP protocol
  5. level constructs. It should rarely be directly referenced outside of Pika's
  6. own internal use.
  7. .. note:: Auto-generated code by codegen.py, do not edit directly. Pull
  8. requests to this file without accompanying ``utils/codegen.py`` changes will be
  9. rejected.
  10. """
  11. import struct
  12. from pika import amqp_object
  13. from pika import data
  14. from pika.compat import str_or_bytes, unicode_type
  15. # Python 3 support for str object
  16. str = bytes
  17. PROTOCOL_VERSION = (0, 9, 1)
  18. PORT = 5672
  19. ACCESS_REFUSED = 403
  20. CHANNEL_ERROR = 504
  21. COMMAND_INVALID = 503
  22. CONNECTION_FORCED = 320
  23. CONTENT_TOO_LARGE = 311
  24. FRAME_BODY = 3
  25. FRAME_END = 206
  26. FRAME_END_SIZE = 1
  27. FRAME_ERROR = 501
  28. FRAME_HEADER = 2
  29. FRAME_HEADER_SIZE = 7
  30. FRAME_HEARTBEAT = 8
  31. FRAME_MAX_SIZE = 131072
  32. FRAME_METHOD = 1
  33. FRAME_MIN_SIZE = 4096
  34. INTERNAL_ERROR = 541
  35. INVALID_PATH = 402
  36. NOT_ALLOWED = 530
  37. NOT_FOUND = 404
  38. NOT_IMPLEMENTED = 540
  39. NO_CONSUMERS = 313
  40. NO_ROUTE = 312
  41. PERSISTENT_DELIVERY_MODE = 2
  42. PRECONDITION_FAILED = 406
  43. REPLY_SUCCESS = 200
  44. RESOURCE_ERROR = 506
  45. RESOURCE_LOCKED = 405
  46. SYNTAX_ERROR = 502
  47. TRANSIENT_DELIVERY_MODE = 1
  48. UNEXPECTED_FRAME = 505
  49. class Connection(amqp_object.Class):
  50. INDEX = 0x000A # 10
  51. NAME = 'Connection'
  52. class Start(amqp_object.Method):
  53. INDEX = 0x000A000A # 10, 10; 655370
  54. NAME = 'Connection.Start'
  55. def __init__(self, version_major=0, version_minor=9, server_properties=None, mechanisms='PLAIN', locales='en_US'):
  56. self.version_major = version_major
  57. self.version_minor = version_minor
  58. self.server_properties = server_properties
  59. self.mechanisms = mechanisms
  60. self.locales = locales
  61. @property
  62. def synchronous(self):
  63. return True
  64. def decode(self, encoded, offset=0):
  65. self.version_major = struct.unpack_from('B', encoded, offset)[0]
  66. offset += 1
  67. self.version_minor = struct.unpack_from('B', encoded, offset)[0]
  68. offset += 1
  69. (self.server_properties, offset) = data.decode_table(encoded, offset)
  70. length = struct.unpack_from('>I', encoded, offset)[0]
  71. offset += 4
  72. self.mechanisms = encoded[offset:offset + length]
  73. try:
  74. self.mechanisms = str(self.mechanisms)
  75. except UnicodeEncodeError:
  76. pass
  77. offset += length
  78. length = struct.unpack_from('>I', encoded, offset)[0]
  79. offset += 4
  80. self.locales = encoded[offset:offset + length]
  81. try:
  82. self.locales = str(self.locales)
  83. except UnicodeEncodeError:
  84. pass
  85. offset += length
  86. return self
  87. def encode(self):
  88. pieces = list()
  89. pieces.append(struct.pack('B', self.version_major))
  90. pieces.append(struct.pack('B', self.version_minor))
  91. data.encode_table(pieces, self.server_properties)
  92. assert isinstance(self.mechanisms, str_or_bytes),\
  93. 'A non-string value was supplied for self.mechanisms'
  94. value = self.mechanisms.encode('utf-8') if isinstance(self.mechanisms, unicode_type) else self.mechanisms
  95. pieces.append(struct.pack('>I', len(value)))
  96. pieces.append(value)
  97. assert isinstance(self.locales, str_or_bytes),\
  98. 'A non-string value was supplied for self.locales'
  99. value = self.locales.encode('utf-8') if isinstance(self.locales, unicode_type) else self.locales
  100. pieces.append(struct.pack('>I', len(value)))
  101. pieces.append(value)
  102. return pieces
  103. class StartOk(amqp_object.Method):
  104. INDEX = 0x000A000B # 10, 11; 655371
  105. NAME = 'Connection.StartOk'
  106. def __init__(self, client_properties=None, mechanism='PLAIN', response=None, locale='en_US'):
  107. self.client_properties = client_properties
  108. self.mechanism = mechanism
  109. self.response = response
  110. self.locale = locale
  111. @property
  112. def synchronous(self):
  113. return False
  114. def decode(self, encoded, offset=0):
  115. (self.client_properties, offset) = data.decode_table(encoded, offset)
  116. self.mechanism, offset = data.decode_short_string(encoded, offset)
  117. length = struct.unpack_from('>I', encoded, offset)[0]
  118. offset += 4
  119. self.response = encoded[offset:offset + length]
  120. try:
  121. self.response = str(self.response)
  122. except UnicodeEncodeError:
  123. pass
  124. offset += length
  125. self.locale, offset = data.decode_short_string(encoded, offset)
  126. return self
  127. def encode(self):
  128. pieces = list()
  129. data.encode_table(pieces, self.client_properties)
  130. assert isinstance(self.mechanism, str_or_bytes),\
  131. 'A non-string value was supplied for self.mechanism'
  132. data.encode_short_string(pieces, self.mechanism)
  133. assert isinstance(self.response, str_or_bytes),\
  134. 'A non-string value was supplied for self.response'
  135. value = self.response.encode('utf-8') if isinstance(self.response, unicode_type) else self.response
  136. pieces.append(struct.pack('>I', len(value)))
  137. pieces.append(value)
  138. assert isinstance(self.locale, str_or_bytes),\
  139. 'A non-string value was supplied for self.locale'
  140. data.encode_short_string(pieces, self.locale)
  141. return pieces
  142. class Secure(amqp_object.Method):
  143. INDEX = 0x000A0014 # 10, 20; 655380
  144. NAME = 'Connection.Secure'
  145. def __init__(self, challenge=None):
  146. self.challenge = challenge
  147. @property
  148. def synchronous(self):
  149. return True
  150. def decode(self, encoded, offset=0):
  151. length = struct.unpack_from('>I', encoded, offset)[0]
  152. offset += 4
  153. self.challenge = encoded[offset:offset + length]
  154. try:
  155. self.challenge = str(self.challenge)
  156. except UnicodeEncodeError:
  157. pass
  158. offset += length
  159. return self
  160. def encode(self):
  161. pieces = list()
  162. assert isinstance(self.challenge, str_or_bytes),\
  163. 'A non-string value was supplied for self.challenge'
  164. value = self.challenge.encode('utf-8') if isinstance(self.challenge, unicode_type) else self.challenge
  165. pieces.append(struct.pack('>I', len(value)))
  166. pieces.append(value)
  167. return pieces
  168. class SecureOk(amqp_object.Method):
  169. INDEX = 0x000A0015 # 10, 21; 655381
  170. NAME = 'Connection.SecureOk'
  171. def __init__(self, response=None):
  172. self.response = response
  173. @property
  174. def synchronous(self):
  175. return False
  176. def decode(self, encoded, offset=0):
  177. length = struct.unpack_from('>I', encoded, offset)[0]
  178. offset += 4
  179. self.response = encoded[offset:offset + length]
  180. try:
  181. self.response = str(self.response)
  182. except UnicodeEncodeError:
  183. pass
  184. offset += length
  185. return self
  186. def encode(self):
  187. pieces = list()
  188. assert isinstance(self.response, str_or_bytes),\
  189. 'A non-string value was supplied for self.response'
  190. value = self.response.encode('utf-8') if isinstance(self.response, unicode_type) else self.response
  191. pieces.append(struct.pack('>I', len(value)))
  192. pieces.append(value)
  193. return pieces
  194. class Tune(amqp_object.Method):
  195. INDEX = 0x000A001E # 10, 30; 655390
  196. NAME = 'Connection.Tune'
  197. def __init__(self, channel_max=0, frame_max=0, heartbeat=0):
  198. self.channel_max = channel_max
  199. self.frame_max = frame_max
  200. self.heartbeat = heartbeat
  201. @property
  202. def synchronous(self):
  203. return True
  204. def decode(self, encoded, offset=0):
  205. self.channel_max = struct.unpack_from('>H', encoded, offset)[0]
  206. offset += 2
  207. self.frame_max = struct.unpack_from('>I', encoded, offset)[0]
  208. offset += 4
  209. self.heartbeat = struct.unpack_from('>H', encoded, offset)[0]
  210. offset += 2
  211. return self
  212. def encode(self):
  213. pieces = list()
  214. pieces.append(struct.pack('>H', self.channel_max))
  215. pieces.append(struct.pack('>I', self.frame_max))
  216. pieces.append(struct.pack('>H', self.heartbeat))
  217. return pieces
  218. class TuneOk(amqp_object.Method):
  219. INDEX = 0x000A001F # 10, 31; 655391
  220. NAME = 'Connection.TuneOk'
  221. def __init__(self, channel_max=0, frame_max=0, heartbeat=0):
  222. self.channel_max = channel_max
  223. self.frame_max = frame_max
  224. self.heartbeat = heartbeat
  225. @property
  226. def synchronous(self):
  227. return False
  228. def decode(self, encoded, offset=0):
  229. self.channel_max = struct.unpack_from('>H', encoded, offset)[0]
  230. offset += 2
  231. self.frame_max = struct.unpack_from('>I', encoded, offset)[0]
  232. offset += 4
  233. self.heartbeat = struct.unpack_from('>H', encoded, offset)[0]
  234. offset += 2
  235. return self
  236. def encode(self):
  237. pieces = list()
  238. pieces.append(struct.pack('>H', self.channel_max))
  239. pieces.append(struct.pack('>I', self.frame_max))
  240. pieces.append(struct.pack('>H', self.heartbeat))
  241. return pieces
  242. class Open(amqp_object.Method):
  243. INDEX = 0x000A0028 # 10, 40; 655400
  244. NAME = 'Connection.Open'
  245. def __init__(self, virtual_host='/', capabilities='', insist=False):
  246. self.virtual_host = virtual_host
  247. self.capabilities = capabilities
  248. self.insist = insist
  249. @property
  250. def synchronous(self):
  251. return True
  252. def decode(self, encoded, offset=0):
  253. self.virtual_host, offset = data.decode_short_string(encoded, offset)
  254. self.capabilities, offset = data.decode_short_string(encoded, offset)
  255. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  256. offset += 1
  257. self.insist = (bit_buffer & (1 << 0)) != 0
  258. return self
  259. def encode(self):
  260. pieces = list()
  261. assert isinstance(self.virtual_host, str_or_bytes),\
  262. 'A non-string value was supplied for self.virtual_host'
  263. data.encode_short_string(pieces, self.virtual_host)
  264. assert isinstance(self.capabilities, str_or_bytes),\
  265. 'A non-string value was supplied for self.capabilities'
  266. data.encode_short_string(pieces, self.capabilities)
  267. bit_buffer = 0
  268. if self.insist:
  269. bit_buffer |= 1 << 0
  270. pieces.append(struct.pack('B', bit_buffer))
  271. return pieces
  272. class OpenOk(amqp_object.Method):
  273. INDEX = 0x000A0029 # 10, 41; 655401
  274. NAME = 'Connection.OpenOk'
  275. def __init__(self, known_hosts=''):
  276. self.known_hosts = known_hosts
  277. @property
  278. def synchronous(self):
  279. return False
  280. def decode(self, encoded, offset=0):
  281. self.known_hosts, offset = data.decode_short_string(encoded, offset)
  282. return self
  283. def encode(self):
  284. pieces = list()
  285. assert isinstance(self.known_hosts, str_or_bytes),\
  286. 'A non-string value was supplied for self.known_hosts'
  287. data.encode_short_string(pieces, self.known_hosts)
  288. return pieces
  289. class Close(amqp_object.Method):
  290. INDEX = 0x000A0032 # 10, 50; 655410
  291. NAME = 'Connection.Close'
  292. def __init__(self, reply_code=None, reply_text='', class_id=None, method_id=None):
  293. self.reply_code = reply_code
  294. self.reply_text = reply_text
  295. self.class_id = class_id
  296. self.method_id = method_id
  297. @property
  298. def synchronous(self):
  299. return True
  300. def decode(self, encoded, offset=0):
  301. self.reply_code = struct.unpack_from('>H', encoded, offset)[0]
  302. offset += 2
  303. self.reply_text, offset = data.decode_short_string(encoded, offset)
  304. self.class_id = struct.unpack_from('>H', encoded, offset)[0]
  305. offset += 2
  306. self.method_id = struct.unpack_from('>H', encoded, offset)[0]
  307. offset += 2
  308. return self
  309. def encode(self):
  310. pieces = list()
  311. pieces.append(struct.pack('>H', self.reply_code))
  312. assert isinstance(self.reply_text, str_or_bytes),\
  313. 'A non-string value was supplied for self.reply_text'
  314. data.encode_short_string(pieces, self.reply_text)
  315. pieces.append(struct.pack('>H', self.class_id))
  316. pieces.append(struct.pack('>H', self.method_id))
  317. return pieces
  318. class CloseOk(amqp_object.Method):
  319. INDEX = 0x000A0033 # 10, 51; 655411
  320. NAME = 'Connection.CloseOk'
  321. def __init__(self):
  322. pass
  323. @property
  324. def synchronous(self):
  325. return False
  326. def decode(self, encoded, offset=0):
  327. return self
  328. def encode(self):
  329. pieces = list()
  330. return pieces
  331. class Blocked(amqp_object.Method):
  332. INDEX = 0x000A003C # 10, 60; 655420
  333. NAME = 'Connection.Blocked'
  334. def __init__(self, reason=''):
  335. self.reason = reason
  336. @property
  337. def synchronous(self):
  338. return False
  339. def decode(self, encoded, offset=0):
  340. self.reason, offset = data.decode_short_string(encoded, offset)
  341. return self
  342. def encode(self):
  343. pieces = list()
  344. assert isinstance(self.reason, str_or_bytes),\
  345. 'A non-string value was supplied for self.reason'
  346. data.encode_short_string(pieces, self.reason)
  347. return pieces
  348. class Unblocked(amqp_object.Method):
  349. INDEX = 0x000A003D # 10, 61; 655421
  350. NAME = 'Connection.Unblocked'
  351. def __init__(self):
  352. pass
  353. @property
  354. def synchronous(self):
  355. return False
  356. def decode(self, encoded, offset=0):
  357. return self
  358. def encode(self):
  359. pieces = list()
  360. return pieces
  361. class Channel(amqp_object.Class):
  362. INDEX = 0x0014 # 20
  363. NAME = 'Channel'
  364. class Open(amqp_object.Method):
  365. INDEX = 0x0014000A # 20, 10; 1310730
  366. NAME = 'Channel.Open'
  367. def __init__(self, out_of_band=''):
  368. self.out_of_band = out_of_band
  369. @property
  370. def synchronous(self):
  371. return True
  372. def decode(self, encoded, offset=0):
  373. self.out_of_band, offset = data.decode_short_string(encoded, offset)
  374. return self
  375. def encode(self):
  376. pieces = list()
  377. assert isinstance(self.out_of_band, str_or_bytes),\
  378. 'A non-string value was supplied for self.out_of_band'
  379. data.encode_short_string(pieces, self.out_of_band)
  380. return pieces
  381. class OpenOk(amqp_object.Method):
  382. INDEX = 0x0014000B # 20, 11; 1310731
  383. NAME = 'Channel.OpenOk'
  384. def __init__(self, channel_id=''):
  385. self.channel_id = channel_id
  386. @property
  387. def synchronous(self):
  388. return False
  389. def decode(self, encoded, offset=0):
  390. length = struct.unpack_from('>I', encoded, offset)[0]
  391. offset += 4
  392. self.channel_id = encoded[offset:offset + length]
  393. try:
  394. self.channel_id = str(self.channel_id)
  395. except UnicodeEncodeError:
  396. pass
  397. offset += length
  398. return self
  399. def encode(self):
  400. pieces = list()
  401. assert isinstance(self.channel_id, str_or_bytes),\
  402. 'A non-string value was supplied for self.channel_id'
  403. value = self.channel_id.encode('utf-8') if isinstance(self.channel_id, unicode_type) else self.channel_id
  404. pieces.append(struct.pack('>I', len(value)))
  405. pieces.append(value)
  406. return pieces
  407. class Flow(amqp_object.Method):
  408. INDEX = 0x00140014 # 20, 20; 1310740
  409. NAME = 'Channel.Flow'
  410. def __init__(self, active=None):
  411. self.active = active
  412. @property
  413. def synchronous(self):
  414. return True
  415. def decode(self, encoded, offset=0):
  416. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  417. offset += 1
  418. self.active = (bit_buffer & (1 << 0)) != 0
  419. return self
  420. def encode(self):
  421. pieces = list()
  422. bit_buffer = 0
  423. if self.active:
  424. bit_buffer |= 1 << 0
  425. pieces.append(struct.pack('B', bit_buffer))
  426. return pieces
  427. class FlowOk(amqp_object.Method):
  428. INDEX = 0x00140015 # 20, 21; 1310741
  429. NAME = 'Channel.FlowOk'
  430. def __init__(self, active=None):
  431. self.active = active
  432. @property
  433. def synchronous(self):
  434. return False
  435. def decode(self, encoded, offset=0):
  436. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  437. offset += 1
  438. self.active = (bit_buffer & (1 << 0)) != 0
  439. return self
  440. def encode(self):
  441. pieces = list()
  442. bit_buffer = 0
  443. if self.active:
  444. bit_buffer |= 1 << 0
  445. pieces.append(struct.pack('B', bit_buffer))
  446. return pieces
  447. class Close(amqp_object.Method):
  448. INDEX = 0x00140028 # 20, 40; 1310760
  449. NAME = 'Channel.Close'
  450. def __init__(self, reply_code=None, reply_text='', class_id=None, method_id=None):
  451. self.reply_code = reply_code
  452. self.reply_text = reply_text
  453. self.class_id = class_id
  454. self.method_id = method_id
  455. @property
  456. def synchronous(self):
  457. return True
  458. def decode(self, encoded, offset=0):
  459. self.reply_code = struct.unpack_from('>H', encoded, offset)[0]
  460. offset += 2
  461. self.reply_text, offset = data.decode_short_string(encoded, offset)
  462. self.class_id = struct.unpack_from('>H', encoded, offset)[0]
  463. offset += 2
  464. self.method_id = struct.unpack_from('>H', encoded, offset)[0]
  465. offset += 2
  466. return self
  467. def encode(self):
  468. pieces = list()
  469. pieces.append(struct.pack('>H', self.reply_code))
  470. assert isinstance(self.reply_text, str_or_bytes),\
  471. 'A non-string value was supplied for self.reply_text'
  472. data.encode_short_string(pieces, self.reply_text)
  473. pieces.append(struct.pack('>H', self.class_id))
  474. pieces.append(struct.pack('>H', self.method_id))
  475. return pieces
  476. class CloseOk(amqp_object.Method):
  477. INDEX = 0x00140029 # 20, 41; 1310761
  478. NAME = 'Channel.CloseOk'
  479. def __init__(self):
  480. pass
  481. @property
  482. def synchronous(self):
  483. return False
  484. def decode(self, encoded, offset=0):
  485. return self
  486. def encode(self):
  487. pieces = list()
  488. return pieces
  489. class Access(amqp_object.Class):
  490. INDEX = 0x001E # 30
  491. NAME = 'Access'
  492. class Request(amqp_object.Method):
  493. INDEX = 0x001E000A # 30, 10; 1966090
  494. NAME = 'Access.Request'
  495. def __init__(self, realm='/data', exclusive=False, passive=True, active=True, write=True, read=True):
  496. self.realm = realm
  497. self.exclusive = exclusive
  498. self.passive = passive
  499. self.active = active
  500. self.write = write
  501. self.read = read
  502. @property
  503. def synchronous(self):
  504. return True
  505. def decode(self, encoded, offset=0):
  506. self.realm, offset = data.decode_short_string(encoded, offset)
  507. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  508. offset += 1
  509. self.exclusive = (bit_buffer & (1 << 0)) != 0
  510. self.passive = (bit_buffer & (1 << 1)) != 0
  511. self.active = (bit_buffer & (1 << 2)) != 0
  512. self.write = (bit_buffer & (1 << 3)) != 0
  513. self.read = (bit_buffer & (1 << 4)) != 0
  514. return self
  515. def encode(self):
  516. pieces = list()
  517. assert isinstance(self.realm, str_or_bytes),\
  518. 'A non-string value was supplied for self.realm'
  519. data.encode_short_string(pieces, self.realm)
  520. bit_buffer = 0
  521. if self.exclusive:
  522. bit_buffer |= 1 << 0
  523. if self.passive:
  524. bit_buffer |= 1 << 1
  525. if self.active:
  526. bit_buffer |= 1 << 2
  527. if self.write:
  528. bit_buffer |= 1 << 3
  529. if self.read:
  530. bit_buffer |= 1 << 4
  531. pieces.append(struct.pack('B', bit_buffer))
  532. return pieces
  533. class RequestOk(amqp_object.Method):
  534. INDEX = 0x001E000B # 30, 11; 1966091
  535. NAME = 'Access.RequestOk'
  536. def __init__(self, ticket=1):
  537. self.ticket = ticket
  538. @property
  539. def synchronous(self):
  540. return False
  541. def decode(self, encoded, offset=0):
  542. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  543. offset += 2
  544. return self
  545. def encode(self):
  546. pieces = list()
  547. pieces.append(struct.pack('>H', self.ticket))
  548. return pieces
  549. class Exchange(amqp_object.Class):
  550. INDEX = 0x0028 # 40
  551. NAME = 'Exchange'
  552. class Declare(amqp_object.Method):
  553. INDEX = 0x0028000A # 40, 10; 2621450
  554. NAME = 'Exchange.Declare'
  555. def __init__(self, ticket=0, exchange=None, type='direct', passive=False, durable=False, auto_delete=False, internal=False, nowait=False, arguments=None):
  556. self.ticket = ticket
  557. self.exchange = exchange
  558. self.type = type
  559. self.passive = passive
  560. self.durable = durable
  561. self.auto_delete = auto_delete
  562. self.internal = internal
  563. self.nowait = nowait
  564. self.arguments = arguments
  565. @property
  566. def synchronous(self):
  567. return True
  568. def decode(self, encoded, offset=0):
  569. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  570. offset += 2
  571. self.exchange, offset = data.decode_short_string(encoded, offset)
  572. self.type, offset = data.decode_short_string(encoded, offset)
  573. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  574. offset += 1
  575. self.passive = (bit_buffer & (1 << 0)) != 0
  576. self.durable = (bit_buffer & (1 << 1)) != 0
  577. self.auto_delete = (bit_buffer & (1 << 2)) != 0
  578. self.internal = (bit_buffer & (1 << 3)) != 0
  579. self.nowait = (bit_buffer & (1 << 4)) != 0
  580. (self.arguments, offset) = data.decode_table(encoded, offset)
  581. return self
  582. def encode(self):
  583. pieces = list()
  584. pieces.append(struct.pack('>H', self.ticket))
  585. assert isinstance(self.exchange, str_or_bytes),\
  586. 'A non-string value was supplied for self.exchange'
  587. data.encode_short_string(pieces, self.exchange)
  588. assert isinstance(self.type, str_or_bytes),\
  589. 'A non-string value was supplied for self.type'
  590. data.encode_short_string(pieces, self.type)
  591. bit_buffer = 0
  592. if self.passive:
  593. bit_buffer |= 1 << 0
  594. if self.durable:
  595. bit_buffer |= 1 << 1
  596. if self.auto_delete:
  597. bit_buffer |= 1 << 2
  598. if self.internal:
  599. bit_buffer |= 1 << 3
  600. if self.nowait:
  601. bit_buffer |= 1 << 4
  602. pieces.append(struct.pack('B', bit_buffer))
  603. data.encode_table(pieces, self.arguments)
  604. return pieces
  605. class DeclareOk(amqp_object.Method):
  606. INDEX = 0x0028000B # 40, 11; 2621451
  607. NAME = 'Exchange.DeclareOk'
  608. def __init__(self):
  609. pass
  610. @property
  611. def synchronous(self):
  612. return False
  613. def decode(self, encoded, offset=0):
  614. return self
  615. def encode(self):
  616. pieces = list()
  617. return pieces
  618. class Delete(amqp_object.Method):
  619. INDEX = 0x00280014 # 40, 20; 2621460
  620. NAME = 'Exchange.Delete'
  621. def __init__(self, ticket=0, exchange=None, if_unused=False, nowait=False):
  622. self.ticket = ticket
  623. self.exchange = exchange
  624. self.if_unused = if_unused
  625. self.nowait = nowait
  626. @property
  627. def synchronous(self):
  628. return True
  629. def decode(self, encoded, offset=0):
  630. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  631. offset += 2
  632. self.exchange, offset = data.decode_short_string(encoded, offset)
  633. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  634. offset += 1
  635. self.if_unused = (bit_buffer & (1 << 0)) != 0
  636. self.nowait = (bit_buffer & (1 << 1)) != 0
  637. return self
  638. def encode(self):
  639. pieces = list()
  640. pieces.append(struct.pack('>H', self.ticket))
  641. assert isinstance(self.exchange, str_or_bytes),\
  642. 'A non-string value was supplied for self.exchange'
  643. data.encode_short_string(pieces, self.exchange)
  644. bit_buffer = 0
  645. if self.if_unused:
  646. bit_buffer |= 1 << 0
  647. if self.nowait:
  648. bit_buffer |= 1 << 1
  649. pieces.append(struct.pack('B', bit_buffer))
  650. return pieces
  651. class DeleteOk(amqp_object.Method):
  652. INDEX = 0x00280015 # 40, 21; 2621461
  653. NAME = 'Exchange.DeleteOk'
  654. def __init__(self):
  655. pass
  656. @property
  657. def synchronous(self):
  658. return False
  659. def decode(self, encoded, offset=0):
  660. return self
  661. def encode(self):
  662. pieces = list()
  663. return pieces
  664. class Bind(amqp_object.Method):
  665. INDEX = 0x0028001E # 40, 30; 2621470
  666. NAME = 'Exchange.Bind'
  667. def __init__(self, ticket=0, destination=None, source=None, routing_key='', nowait=False, arguments=None):
  668. self.ticket = ticket
  669. self.destination = destination
  670. self.source = source
  671. self.routing_key = routing_key
  672. self.nowait = nowait
  673. self.arguments = arguments
  674. @property
  675. def synchronous(self):
  676. return True
  677. def decode(self, encoded, offset=0):
  678. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  679. offset += 2
  680. self.destination, offset = data.decode_short_string(encoded, offset)
  681. self.source, offset = data.decode_short_string(encoded, offset)
  682. self.routing_key, offset = data.decode_short_string(encoded, offset)
  683. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  684. offset += 1
  685. self.nowait = (bit_buffer & (1 << 0)) != 0
  686. (self.arguments, offset) = data.decode_table(encoded, offset)
  687. return self
  688. def encode(self):
  689. pieces = list()
  690. pieces.append(struct.pack('>H', self.ticket))
  691. assert isinstance(self.destination, str_or_bytes),\
  692. 'A non-string value was supplied for self.destination'
  693. data.encode_short_string(pieces, self.destination)
  694. assert isinstance(self.source, str_or_bytes),\
  695. 'A non-string value was supplied for self.source'
  696. data.encode_short_string(pieces, self.source)
  697. assert isinstance(self.routing_key, str_or_bytes),\
  698. 'A non-string value was supplied for self.routing_key'
  699. data.encode_short_string(pieces, self.routing_key)
  700. bit_buffer = 0
  701. if self.nowait:
  702. bit_buffer |= 1 << 0
  703. pieces.append(struct.pack('B', bit_buffer))
  704. data.encode_table(pieces, self.arguments)
  705. return pieces
  706. class BindOk(amqp_object.Method):
  707. INDEX = 0x0028001F # 40, 31; 2621471
  708. NAME = 'Exchange.BindOk'
  709. def __init__(self):
  710. pass
  711. @property
  712. def synchronous(self):
  713. return False
  714. def decode(self, encoded, offset=0):
  715. return self
  716. def encode(self):
  717. pieces = list()
  718. return pieces
  719. class Unbind(amqp_object.Method):
  720. INDEX = 0x00280028 # 40, 40; 2621480
  721. NAME = 'Exchange.Unbind'
  722. def __init__(self, ticket=0, destination=None, source=None, routing_key='', nowait=False, arguments=None):
  723. self.ticket = ticket
  724. self.destination = destination
  725. self.source = source
  726. self.routing_key = routing_key
  727. self.nowait = nowait
  728. self.arguments = arguments
  729. @property
  730. def synchronous(self):
  731. return True
  732. def decode(self, encoded, offset=0):
  733. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  734. offset += 2
  735. self.destination, offset = data.decode_short_string(encoded, offset)
  736. self.source, offset = data.decode_short_string(encoded, offset)
  737. self.routing_key, offset = data.decode_short_string(encoded, offset)
  738. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  739. offset += 1
  740. self.nowait = (bit_buffer & (1 << 0)) != 0
  741. (self.arguments, offset) = data.decode_table(encoded, offset)
  742. return self
  743. def encode(self):
  744. pieces = list()
  745. pieces.append(struct.pack('>H', self.ticket))
  746. assert isinstance(self.destination, str_or_bytes),\
  747. 'A non-string value was supplied for self.destination'
  748. data.encode_short_string(pieces, self.destination)
  749. assert isinstance(self.source, str_or_bytes),\
  750. 'A non-string value was supplied for self.source'
  751. data.encode_short_string(pieces, self.source)
  752. assert isinstance(self.routing_key, str_or_bytes),\
  753. 'A non-string value was supplied for self.routing_key'
  754. data.encode_short_string(pieces, self.routing_key)
  755. bit_buffer = 0
  756. if self.nowait:
  757. bit_buffer |= 1 << 0
  758. pieces.append(struct.pack('B', bit_buffer))
  759. data.encode_table(pieces, self.arguments)
  760. return pieces
  761. class UnbindOk(amqp_object.Method):
  762. INDEX = 0x00280033 # 40, 51; 2621491
  763. NAME = 'Exchange.UnbindOk'
  764. def __init__(self):
  765. pass
  766. @property
  767. def synchronous(self):
  768. return False
  769. def decode(self, encoded, offset=0):
  770. return self
  771. def encode(self):
  772. pieces = list()
  773. return pieces
  774. class Queue(amqp_object.Class):
  775. INDEX = 0x0032 # 50
  776. NAME = 'Queue'
  777. class Declare(amqp_object.Method):
  778. INDEX = 0x0032000A # 50, 10; 3276810
  779. NAME = 'Queue.Declare'
  780. def __init__(self, ticket=0, queue='', passive=False, durable=False, exclusive=False, auto_delete=False, nowait=False, arguments=None):
  781. self.ticket = ticket
  782. self.queue = queue
  783. self.passive = passive
  784. self.durable = durable
  785. self.exclusive = exclusive
  786. self.auto_delete = auto_delete
  787. self.nowait = nowait
  788. self.arguments = arguments
  789. @property
  790. def synchronous(self):
  791. return True
  792. def decode(self, encoded, offset=0):
  793. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  794. offset += 2
  795. self.queue, offset = data.decode_short_string(encoded, offset)
  796. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  797. offset += 1
  798. self.passive = (bit_buffer & (1 << 0)) != 0
  799. self.durable = (bit_buffer & (1 << 1)) != 0
  800. self.exclusive = (bit_buffer & (1 << 2)) != 0
  801. self.auto_delete = (bit_buffer & (1 << 3)) != 0
  802. self.nowait = (bit_buffer & (1 << 4)) != 0
  803. (self.arguments, offset) = data.decode_table(encoded, offset)
  804. return self
  805. def encode(self):
  806. pieces = list()
  807. pieces.append(struct.pack('>H', self.ticket))
  808. assert isinstance(self.queue, str_or_bytes),\
  809. 'A non-string value was supplied for self.queue'
  810. data.encode_short_string(pieces, self.queue)
  811. bit_buffer = 0
  812. if self.passive:
  813. bit_buffer |= 1 << 0
  814. if self.durable:
  815. bit_buffer |= 1 << 1
  816. if self.exclusive:
  817. bit_buffer |= 1 << 2
  818. if self.auto_delete:
  819. bit_buffer |= 1 << 3
  820. if self.nowait:
  821. bit_buffer |= 1 << 4
  822. pieces.append(struct.pack('B', bit_buffer))
  823. data.encode_table(pieces, self.arguments)
  824. return pieces
  825. class DeclareOk(amqp_object.Method):
  826. INDEX = 0x0032000B # 50, 11; 3276811
  827. NAME = 'Queue.DeclareOk'
  828. def __init__(self, queue=None, message_count=None, consumer_count=None):
  829. self.queue = queue
  830. self.message_count = message_count
  831. self.consumer_count = consumer_count
  832. @property
  833. def synchronous(self):
  834. return False
  835. def decode(self, encoded, offset=0):
  836. self.queue, offset = data.decode_short_string(encoded, offset)
  837. self.message_count = struct.unpack_from('>I', encoded, offset)[0]
  838. offset += 4
  839. self.consumer_count = struct.unpack_from('>I', encoded, offset)[0]
  840. offset += 4
  841. return self
  842. def encode(self):
  843. pieces = list()
  844. assert isinstance(self.queue, str_or_bytes),\
  845. 'A non-string value was supplied for self.queue'
  846. data.encode_short_string(pieces, self.queue)
  847. pieces.append(struct.pack('>I', self.message_count))
  848. pieces.append(struct.pack('>I', self.consumer_count))
  849. return pieces
  850. class Bind(amqp_object.Method):
  851. INDEX = 0x00320014 # 50, 20; 3276820
  852. NAME = 'Queue.Bind'
  853. def __init__(self, ticket=0, queue='', exchange=None, routing_key='', nowait=False, arguments=None):
  854. self.ticket = ticket
  855. self.queue = queue
  856. self.exchange = exchange
  857. self.routing_key = routing_key
  858. self.nowait = nowait
  859. self.arguments = arguments
  860. @property
  861. def synchronous(self):
  862. return True
  863. def decode(self, encoded, offset=0):
  864. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  865. offset += 2
  866. self.queue, offset = data.decode_short_string(encoded, offset)
  867. self.exchange, offset = data.decode_short_string(encoded, offset)
  868. self.routing_key, offset = data.decode_short_string(encoded, offset)
  869. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  870. offset += 1
  871. self.nowait = (bit_buffer & (1 << 0)) != 0
  872. (self.arguments, offset) = data.decode_table(encoded, offset)
  873. return self
  874. def encode(self):
  875. pieces = list()
  876. pieces.append(struct.pack('>H', self.ticket))
  877. assert isinstance(self.queue, str_or_bytes),\
  878. 'A non-string value was supplied for self.queue'
  879. data.encode_short_string(pieces, self.queue)
  880. assert isinstance(self.exchange, str_or_bytes),\
  881. 'A non-string value was supplied for self.exchange'
  882. data.encode_short_string(pieces, self.exchange)
  883. assert isinstance(self.routing_key, str_or_bytes),\
  884. 'A non-string value was supplied for self.routing_key'
  885. data.encode_short_string(pieces, self.routing_key)
  886. bit_buffer = 0
  887. if self.nowait:
  888. bit_buffer |= 1 << 0
  889. pieces.append(struct.pack('B', bit_buffer))
  890. data.encode_table(pieces, self.arguments)
  891. return pieces
  892. class BindOk(amqp_object.Method):
  893. INDEX = 0x00320015 # 50, 21; 3276821
  894. NAME = 'Queue.BindOk'
  895. def __init__(self):
  896. pass
  897. @property
  898. def synchronous(self):
  899. return False
  900. def decode(self, encoded, offset=0):
  901. return self
  902. def encode(self):
  903. pieces = list()
  904. return pieces
  905. class Purge(amqp_object.Method):
  906. INDEX = 0x0032001E # 50, 30; 3276830
  907. NAME = 'Queue.Purge'
  908. def __init__(self, ticket=0, queue='', nowait=False):
  909. self.ticket = ticket
  910. self.queue = queue
  911. self.nowait = nowait
  912. @property
  913. def synchronous(self):
  914. return True
  915. def decode(self, encoded, offset=0):
  916. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  917. offset += 2
  918. self.queue, offset = data.decode_short_string(encoded, offset)
  919. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  920. offset += 1
  921. self.nowait = (bit_buffer & (1 << 0)) != 0
  922. return self
  923. def encode(self):
  924. pieces = list()
  925. pieces.append(struct.pack('>H', self.ticket))
  926. assert isinstance(self.queue, str_or_bytes),\
  927. 'A non-string value was supplied for self.queue'
  928. data.encode_short_string(pieces, self.queue)
  929. bit_buffer = 0
  930. if self.nowait:
  931. bit_buffer |= 1 << 0
  932. pieces.append(struct.pack('B', bit_buffer))
  933. return pieces
  934. class PurgeOk(amqp_object.Method):
  935. INDEX = 0x0032001F # 50, 31; 3276831
  936. NAME = 'Queue.PurgeOk'
  937. def __init__(self, message_count=None):
  938. self.message_count = message_count
  939. @property
  940. def synchronous(self):
  941. return False
  942. def decode(self, encoded, offset=0):
  943. self.message_count = struct.unpack_from('>I', encoded, offset)[0]
  944. offset += 4
  945. return self
  946. def encode(self):
  947. pieces = list()
  948. pieces.append(struct.pack('>I', self.message_count))
  949. return pieces
  950. class Delete(amqp_object.Method):
  951. INDEX = 0x00320028 # 50, 40; 3276840
  952. NAME = 'Queue.Delete'
  953. def __init__(self, ticket=0, queue='', if_unused=False, if_empty=False, nowait=False):
  954. self.ticket = ticket
  955. self.queue = queue
  956. self.if_unused = if_unused
  957. self.if_empty = if_empty
  958. self.nowait = nowait
  959. @property
  960. def synchronous(self):
  961. return True
  962. def decode(self, encoded, offset=0):
  963. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  964. offset += 2
  965. self.queue, offset = data.decode_short_string(encoded, offset)
  966. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  967. offset += 1
  968. self.if_unused = (bit_buffer & (1 << 0)) != 0
  969. self.if_empty = (bit_buffer & (1 << 1)) != 0
  970. self.nowait = (bit_buffer & (1 << 2)) != 0
  971. return self
  972. def encode(self):
  973. pieces = list()
  974. pieces.append(struct.pack('>H', self.ticket))
  975. assert isinstance(self.queue, str_or_bytes),\
  976. 'A non-string value was supplied for self.queue'
  977. data.encode_short_string(pieces, self.queue)
  978. bit_buffer = 0
  979. if self.if_unused:
  980. bit_buffer |= 1 << 0
  981. if self.if_empty:
  982. bit_buffer |= 1 << 1
  983. if self.nowait:
  984. bit_buffer |= 1 << 2
  985. pieces.append(struct.pack('B', bit_buffer))
  986. return pieces
  987. class DeleteOk(amqp_object.Method):
  988. INDEX = 0x00320029 # 50, 41; 3276841
  989. NAME = 'Queue.DeleteOk'
  990. def __init__(self, message_count=None):
  991. self.message_count = message_count
  992. @property
  993. def synchronous(self):
  994. return False
  995. def decode(self, encoded, offset=0):
  996. self.message_count = struct.unpack_from('>I', encoded, offset)[0]
  997. offset += 4
  998. return self
  999. def encode(self):
  1000. pieces = list()
  1001. pieces.append(struct.pack('>I', self.message_count))
  1002. return pieces
  1003. class Unbind(amqp_object.Method):
  1004. INDEX = 0x00320032 # 50, 50; 3276850
  1005. NAME = 'Queue.Unbind'
  1006. def __init__(self, ticket=0, queue='', exchange=None, routing_key='', arguments=None):
  1007. self.ticket = ticket
  1008. self.queue = queue
  1009. self.exchange = exchange
  1010. self.routing_key = routing_key
  1011. self.arguments = arguments
  1012. @property
  1013. def synchronous(self):
  1014. return True
  1015. def decode(self, encoded, offset=0):
  1016. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  1017. offset += 2
  1018. self.queue, offset = data.decode_short_string(encoded, offset)
  1019. self.exchange, offset = data.decode_short_string(encoded, offset)
  1020. self.routing_key, offset = data.decode_short_string(encoded, offset)
  1021. (self.arguments, offset) = data.decode_table(encoded, offset)
  1022. return self
  1023. def encode(self):
  1024. pieces = list()
  1025. pieces.append(struct.pack('>H', self.ticket))
  1026. assert isinstance(self.queue, str_or_bytes),\
  1027. 'A non-string value was supplied for self.queue'
  1028. data.encode_short_string(pieces, self.queue)
  1029. assert isinstance(self.exchange, str_or_bytes),\
  1030. 'A non-string value was supplied for self.exchange'
  1031. data.encode_short_string(pieces, self.exchange)
  1032. assert isinstance(self.routing_key, str_or_bytes),\
  1033. 'A non-string value was supplied for self.routing_key'
  1034. data.encode_short_string(pieces, self.routing_key)
  1035. data.encode_table(pieces, self.arguments)
  1036. return pieces
  1037. class UnbindOk(amqp_object.Method):
  1038. INDEX = 0x00320033 # 50, 51; 3276851
  1039. NAME = 'Queue.UnbindOk'
  1040. def __init__(self):
  1041. pass
  1042. @property
  1043. def synchronous(self):
  1044. return False
  1045. def decode(self, encoded, offset=0):
  1046. return self
  1047. def encode(self):
  1048. pieces = list()
  1049. return pieces
  1050. class Basic(amqp_object.Class):
  1051. INDEX = 0x003C # 60
  1052. NAME = 'Basic'
  1053. class Qos(amqp_object.Method):
  1054. INDEX = 0x003C000A # 60, 10; 3932170
  1055. NAME = 'Basic.Qos'
  1056. def __init__(self, prefetch_size=0, prefetch_count=0, global_qos=False):
  1057. self.prefetch_size = prefetch_size
  1058. self.prefetch_count = prefetch_count
  1059. self.global_qos = global_qos
  1060. @property
  1061. def synchronous(self):
  1062. return True
  1063. def decode(self, encoded, offset=0):
  1064. self.prefetch_size = struct.unpack_from('>I', encoded, offset)[0]
  1065. offset += 4
  1066. self.prefetch_count = struct.unpack_from('>H', encoded, offset)[0]
  1067. offset += 2
  1068. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1069. offset += 1
  1070. self.global_qos = (bit_buffer & (1 << 0)) != 0
  1071. return self
  1072. def encode(self):
  1073. pieces = list()
  1074. pieces.append(struct.pack('>I', self.prefetch_size))
  1075. pieces.append(struct.pack('>H', self.prefetch_count))
  1076. bit_buffer = 0
  1077. if self.global_qos:
  1078. bit_buffer |= 1 << 0
  1079. pieces.append(struct.pack('B', bit_buffer))
  1080. return pieces
  1081. class QosOk(amqp_object.Method):
  1082. INDEX = 0x003C000B # 60, 11; 3932171
  1083. NAME = 'Basic.QosOk'
  1084. def __init__(self):
  1085. pass
  1086. @property
  1087. def synchronous(self):
  1088. return False
  1089. def decode(self, encoded, offset=0):
  1090. return self
  1091. def encode(self):
  1092. pieces = list()
  1093. return pieces
  1094. class Consume(amqp_object.Method):
  1095. INDEX = 0x003C0014 # 60, 20; 3932180
  1096. NAME = 'Basic.Consume'
  1097. def __init__(self, ticket=0, queue='', consumer_tag='', no_local=False, no_ack=False, exclusive=False, nowait=False, arguments=None):
  1098. self.ticket = ticket
  1099. self.queue = queue
  1100. self.consumer_tag = consumer_tag
  1101. self.no_local = no_local
  1102. self.no_ack = no_ack
  1103. self.exclusive = exclusive
  1104. self.nowait = nowait
  1105. self.arguments = arguments
  1106. @property
  1107. def synchronous(self):
  1108. return True
  1109. def decode(self, encoded, offset=0):
  1110. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  1111. offset += 2
  1112. self.queue, offset = data.decode_short_string(encoded, offset)
  1113. self.consumer_tag, offset = data.decode_short_string(encoded, offset)
  1114. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1115. offset += 1
  1116. self.no_local = (bit_buffer & (1 << 0)) != 0
  1117. self.no_ack = (bit_buffer & (1 << 1)) != 0
  1118. self.exclusive = (bit_buffer & (1 << 2)) != 0
  1119. self.nowait = (bit_buffer & (1 << 3)) != 0
  1120. (self.arguments, offset) = data.decode_table(encoded, offset)
  1121. return self
  1122. def encode(self):
  1123. pieces = list()
  1124. pieces.append(struct.pack('>H', self.ticket))
  1125. assert isinstance(self.queue, str_or_bytes),\
  1126. 'A non-string value was supplied for self.queue'
  1127. data.encode_short_string(pieces, self.queue)
  1128. assert isinstance(self.consumer_tag, str_or_bytes),\
  1129. 'A non-string value was supplied for self.consumer_tag'
  1130. data.encode_short_string(pieces, self.consumer_tag)
  1131. bit_buffer = 0
  1132. if self.no_local:
  1133. bit_buffer |= 1 << 0
  1134. if self.no_ack:
  1135. bit_buffer |= 1 << 1
  1136. if self.exclusive:
  1137. bit_buffer |= 1 << 2
  1138. if self.nowait:
  1139. bit_buffer |= 1 << 3
  1140. pieces.append(struct.pack('B', bit_buffer))
  1141. data.encode_table(pieces, self.arguments)
  1142. return pieces
  1143. class ConsumeOk(amqp_object.Method):
  1144. INDEX = 0x003C0015 # 60, 21; 3932181
  1145. NAME = 'Basic.ConsumeOk'
  1146. def __init__(self, consumer_tag=None):
  1147. self.consumer_tag = consumer_tag
  1148. @property
  1149. def synchronous(self):
  1150. return False
  1151. def decode(self, encoded, offset=0):
  1152. self.consumer_tag, offset = data.decode_short_string(encoded, offset)
  1153. return self
  1154. def encode(self):
  1155. pieces = list()
  1156. assert isinstance(self.consumer_tag, str_or_bytes),\
  1157. 'A non-string value was supplied for self.consumer_tag'
  1158. data.encode_short_string(pieces, self.consumer_tag)
  1159. return pieces
  1160. class Cancel(amqp_object.Method):
  1161. INDEX = 0x003C001E # 60, 30; 3932190
  1162. NAME = 'Basic.Cancel'
  1163. def __init__(self, consumer_tag=None, nowait=False):
  1164. self.consumer_tag = consumer_tag
  1165. self.nowait = nowait
  1166. @property
  1167. def synchronous(self):
  1168. return True
  1169. def decode(self, encoded, offset=0):
  1170. self.consumer_tag, offset = data.decode_short_string(encoded, offset)
  1171. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1172. offset += 1
  1173. self.nowait = (bit_buffer & (1 << 0)) != 0
  1174. return self
  1175. def encode(self):
  1176. pieces = list()
  1177. assert isinstance(self.consumer_tag, str_or_bytes),\
  1178. 'A non-string value was supplied for self.consumer_tag'
  1179. data.encode_short_string(pieces, self.consumer_tag)
  1180. bit_buffer = 0
  1181. if self.nowait:
  1182. bit_buffer |= 1 << 0
  1183. pieces.append(struct.pack('B', bit_buffer))
  1184. return pieces
  1185. class CancelOk(amqp_object.Method):
  1186. INDEX = 0x003C001F # 60, 31; 3932191
  1187. NAME = 'Basic.CancelOk'
  1188. def __init__(self, consumer_tag=None):
  1189. self.consumer_tag = consumer_tag
  1190. @property
  1191. def synchronous(self):
  1192. return False
  1193. def decode(self, encoded, offset=0):
  1194. self.consumer_tag, offset = data.decode_short_string(encoded, offset)
  1195. return self
  1196. def encode(self):
  1197. pieces = list()
  1198. assert isinstance(self.consumer_tag, str_or_bytes),\
  1199. 'A non-string value was supplied for self.consumer_tag'
  1200. data.encode_short_string(pieces, self.consumer_tag)
  1201. return pieces
  1202. class Publish(amqp_object.Method):
  1203. INDEX = 0x003C0028 # 60, 40; 3932200
  1204. NAME = 'Basic.Publish'
  1205. def __init__(self, ticket=0, exchange='', routing_key='', mandatory=False, immediate=False):
  1206. self.ticket = ticket
  1207. self.exchange = exchange
  1208. self.routing_key = routing_key
  1209. self.mandatory = mandatory
  1210. self.immediate = immediate
  1211. @property
  1212. def synchronous(self):
  1213. return False
  1214. def decode(self, encoded, offset=0):
  1215. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  1216. offset += 2
  1217. self.exchange, offset = data.decode_short_string(encoded, offset)
  1218. self.routing_key, offset = data.decode_short_string(encoded, offset)
  1219. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1220. offset += 1
  1221. self.mandatory = (bit_buffer & (1 << 0)) != 0
  1222. self.immediate = (bit_buffer & (1 << 1)) != 0
  1223. return self
  1224. def encode(self):
  1225. pieces = list()
  1226. pieces.append(struct.pack('>H', self.ticket))
  1227. assert isinstance(self.exchange, str_or_bytes),\
  1228. 'A non-string value was supplied for self.exchange'
  1229. data.encode_short_string(pieces, self.exchange)
  1230. assert isinstance(self.routing_key, str_or_bytes),\
  1231. 'A non-string value was supplied for self.routing_key'
  1232. data.encode_short_string(pieces, self.routing_key)
  1233. bit_buffer = 0
  1234. if self.mandatory:
  1235. bit_buffer |= 1 << 0
  1236. if self.immediate:
  1237. bit_buffer |= 1 << 1
  1238. pieces.append(struct.pack('B', bit_buffer))
  1239. return pieces
  1240. class Return(amqp_object.Method):
  1241. INDEX = 0x003C0032 # 60, 50; 3932210
  1242. NAME = 'Basic.Return'
  1243. def __init__(self, reply_code=None, reply_text='', exchange=None, routing_key=None):
  1244. self.reply_code = reply_code
  1245. self.reply_text = reply_text
  1246. self.exchange = exchange
  1247. self.routing_key = routing_key
  1248. @property
  1249. def synchronous(self):
  1250. return False
  1251. def decode(self, encoded, offset=0):
  1252. self.reply_code = struct.unpack_from('>H', encoded, offset)[0]
  1253. offset += 2
  1254. self.reply_text, offset = data.decode_short_string(encoded, offset)
  1255. self.exchange, offset = data.decode_short_string(encoded, offset)
  1256. self.routing_key, offset = data.decode_short_string(encoded, offset)
  1257. return self
  1258. def encode(self):
  1259. pieces = list()
  1260. pieces.append(struct.pack('>H', self.reply_code))
  1261. assert isinstance(self.reply_text, str_or_bytes),\
  1262. 'A non-string value was supplied for self.reply_text'
  1263. data.encode_short_string(pieces, self.reply_text)
  1264. assert isinstance(self.exchange, str_or_bytes),\
  1265. 'A non-string value was supplied for self.exchange'
  1266. data.encode_short_string(pieces, self.exchange)
  1267. assert isinstance(self.routing_key, str_or_bytes),\
  1268. 'A non-string value was supplied for self.routing_key'
  1269. data.encode_short_string(pieces, self.routing_key)
  1270. return pieces
  1271. class Deliver(amqp_object.Method):
  1272. INDEX = 0x003C003C # 60, 60; 3932220
  1273. NAME = 'Basic.Deliver'
  1274. def __init__(self, consumer_tag=None, delivery_tag=None, redelivered=False, exchange=None, routing_key=None):
  1275. self.consumer_tag = consumer_tag
  1276. self.delivery_tag = delivery_tag
  1277. self.redelivered = redelivered
  1278. self.exchange = exchange
  1279. self.routing_key = routing_key
  1280. @property
  1281. def synchronous(self):
  1282. return False
  1283. def decode(self, encoded, offset=0):
  1284. self.consumer_tag, offset = data.decode_short_string(encoded, offset)
  1285. self.delivery_tag = struct.unpack_from('>Q', encoded, offset)[0]
  1286. offset += 8
  1287. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1288. offset += 1
  1289. self.redelivered = (bit_buffer & (1 << 0)) != 0
  1290. self.exchange, offset = data.decode_short_string(encoded, offset)
  1291. self.routing_key, offset = data.decode_short_string(encoded, offset)
  1292. return self
  1293. def encode(self):
  1294. pieces = list()
  1295. assert isinstance(self.consumer_tag, str_or_bytes),\
  1296. 'A non-string value was supplied for self.consumer_tag'
  1297. data.encode_short_string(pieces, self.consumer_tag)
  1298. pieces.append(struct.pack('>Q', self.delivery_tag))
  1299. bit_buffer = 0
  1300. if self.redelivered:
  1301. bit_buffer |= 1 << 0
  1302. pieces.append(struct.pack('B', bit_buffer))
  1303. assert isinstance(self.exchange, str_or_bytes),\
  1304. 'A non-string value was supplied for self.exchange'
  1305. data.encode_short_string(pieces, self.exchange)
  1306. assert isinstance(self.routing_key, str_or_bytes),\
  1307. 'A non-string value was supplied for self.routing_key'
  1308. data.encode_short_string(pieces, self.routing_key)
  1309. return pieces
  1310. class Get(amqp_object.Method):
  1311. INDEX = 0x003C0046 # 60, 70; 3932230
  1312. NAME = 'Basic.Get'
  1313. def __init__(self, ticket=0, queue='', no_ack=False):
  1314. self.ticket = ticket
  1315. self.queue = queue
  1316. self.no_ack = no_ack
  1317. @property
  1318. def synchronous(self):
  1319. return True
  1320. def decode(self, encoded, offset=0):
  1321. self.ticket = struct.unpack_from('>H', encoded, offset)[0]
  1322. offset += 2
  1323. self.queue, offset = data.decode_short_string(encoded, offset)
  1324. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1325. offset += 1
  1326. self.no_ack = (bit_buffer & (1 << 0)) != 0
  1327. return self
  1328. def encode(self):
  1329. pieces = list()
  1330. pieces.append(struct.pack('>H', self.ticket))
  1331. assert isinstance(self.queue, str_or_bytes),\
  1332. 'A non-string value was supplied for self.queue'
  1333. data.encode_short_string(pieces, self.queue)
  1334. bit_buffer = 0
  1335. if self.no_ack:
  1336. bit_buffer |= 1 << 0
  1337. pieces.append(struct.pack('B', bit_buffer))
  1338. return pieces
  1339. class GetOk(amqp_object.Method):
  1340. INDEX = 0x003C0047 # 60, 71; 3932231
  1341. NAME = 'Basic.GetOk'
  1342. def __init__(self, delivery_tag=None, redelivered=False, exchange=None, routing_key=None, message_count=None):
  1343. self.delivery_tag = delivery_tag
  1344. self.redelivered = redelivered
  1345. self.exchange = exchange
  1346. self.routing_key = routing_key
  1347. self.message_count = message_count
  1348. @property
  1349. def synchronous(self):
  1350. return False
  1351. def decode(self, encoded, offset=0):
  1352. self.delivery_tag = struct.unpack_from('>Q', encoded, offset)[0]
  1353. offset += 8
  1354. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1355. offset += 1
  1356. self.redelivered = (bit_buffer & (1 << 0)) != 0
  1357. self.exchange, offset = data.decode_short_string(encoded, offset)
  1358. self.routing_key, offset = data.decode_short_string(encoded, offset)
  1359. self.message_count = struct.unpack_from('>I', encoded, offset)[0]
  1360. offset += 4
  1361. return self
  1362. def encode(self):
  1363. pieces = list()
  1364. pieces.append(struct.pack('>Q', self.delivery_tag))
  1365. bit_buffer = 0
  1366. if self.redelivered:
  1367. bit_buffer |= 1 << 0
  1368. pieces.append(struct.pack('B', bit_buffer))
  1369. assert isinstance(self.exchange, str_or_bytes),\
  1370. 'A non-string value was supplied for self.exchange'
  1371. data.encode_short_string(pieces, self.exchange)
  1372. assert isinstance(self.routing_key, str_or_bytes),\
  1373. 'A non-string value was supplied for self.routing_key'
  1374. data.encode_short_string(pieces, self.routing_key)
  1375. pieces.append(struct.pack('>I', self.message_count))
  1376. return pieces
  1377. class GetEmpty(amqp_object.Method):
  1378. INDEX = 0x003C0048 # 60, 72; 3932232
  1379. NAME = 'Basic.GetEmpty'
  1380. def __init__(self, cluster_id=''):
  1381. self.cluster_id = cluster_id
  1382. @property
  1383. def synchronous(self):
  1384. return False
  1385. def decode(self, encoded, offset=0):
  1386. self.cluster_id, offset = data.decode_short_string(encoded, offset)
  1387. return self
  1388. def encode(self):
  1389. pieces = list()
  1390. assert isinstance(self.cluster_id, str_or_bytes),\
  1391. 'A non-string value was supplied for self.cluster_id'
  1392. data.encode_short_string(pieces, self.cluster_id)
  1393. return pieces
  1394. class Ack(amqp_object.Method):
  1395. INDEX = 0x003C0050 # 60, 80; 3932240
  1396. NAME = 'Basic.Ack'
  1397. def __init__(self, delivery_tag=0, multiple=False):
  1398. self.delivery_tag = delivery_tag
  1399. self.multiple = multiple
  1400. @property
  1401. def synchronous(self):
  1402. return False
  1403. def decode(self, encoded, offset=0):
  1404. self.delivery_tag = struct.unpack_from('>Q', encoded, offset)[0]
  1405. offset += 8
  1406. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1407. offset += 1
  1408. self.multiple = (bit_buffer & (1 << 0)) != 0
  1409. return self
  1410. def encode(self):
  1411. pieces = list()
  1412. pieces.append(struct.pack('>Q', self.delivery_tag))
  1413. bit_buffer = 0
  1414. if self.multiple:
  1415. bit_buffer |= 1 << 0
  1416. pieces.append(struct.pack('B', bit_buffer))
  1417. return pieces
  1418. class Reject(amqp_object.Method):
  1419. INDEX = 0x003C005A # 60, 90; 3932250
  1420. NAME = 'Basic.Reject'
  1421. def __init__(self, delivery_tag=None, requeue=True):
  1422. self.delivery_tag = delivery_tag
  1423. self.requeue = requeue
  1424. @property
  1425. def synchronous(self):
  1426. return False
  1427. def decode(self, encoded, offset=0):
  1428. self.delivery_tag = struct.unpack_from('>Q', encoded, offset)[0]
  1429. offset += 8
  1430. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1431. offset += 1
  1432. self.requeue = (bit_buffer & (1 << 0)) != 0
  1433. return self
  1434. def encode(self):
  1435. pieces = list()
  1436. pieces.append(struct.pack('>Q', self.delivery_tag))
  1437. bit_buffer = 0
  1438. if self.requeue:
  1439. bit_buffer |= 1 << 0
  1440. pieces.append(struct.pack('B', bit_buffer))
  1441. return pieces
  1442. class RecoverAsync(amqp_object.Method):
  1443. INDEX = 0x003C0064 # 60, 100; 3932260
  1444. NAME = 'Basic.RecoverAsync'
  1445. def __init__(self, requeue=False):
  1446. self.requeue = requeue
  1447. @property
  1448. def synchronous(self):
  1449. return False
  1450. def decode(self, encoded, offset=0):
  1451. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1452. offset += 1
  1453. self.requeue = (bit_buffer & (1 << 0)) != 0
  1454. return self
  1455. def encode(self):
  1456. pieces = list()
  1457. bit_buffer = 0
  1458. if self.requeue:
  1459. bit_buffer |= 1 << 0
  1460. pieces.append(struct.pack('B', bit_buffer))
  1461. return pieces
  1462. class Recover(amqp_object.Method):
  1463. INDEX = 0x003C006E # 60, 110; 3932270
  1464. NAME = 'Basic.Recover'
  1465. def __init__(self, requeue=False):
  1466. self.requeue = requeue
  1467. @property
  1468. def synchronous(self):
  1469. return True
  1470. def decode(self, encoded, offset=0):
  1471. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1472. offset += 1
  1473. self.requeue = (bit_buffer & (1 << 0)) != 0
  1474. return self
  1475. def encode(self):
  1476. pieces = list()
  1477. bit_buffer = 0
  1478. if self.requeue:
  1479. bit_buffer |= 1 << 0
  1480. pieces.append(struct.pack('B', bit_buffer))
  1481. return pieces
  1482. class RecoverOk(amqp_object.Method):
  1483. INDEX = 0x003C006F # 60, 111; 3932271
  1484. NAME = 'Basic.RecoverOk'
  1485. def __init__(self):
  1486. pass
  1487. @property
  1488. def synchronous(self):
  1489. return False
  1490. def decode(self, encoded, offset=0):
  1491. return self
  1492. def encode(self):
  1493. pieces = list()
  1494. return pieces
  1495. class Nack(amqp_object.Method):
  1496. INDEX = 0x003C0078 # 60, 120; 3932280
  1497. NAME = 'Basic.Nack'
  1498. def __init__(self, delivery_tag=0, multiple=False, requeue=True):
  1499. self.delivery_tag = delivery_tag
  1500. self.multiple = multiple
  1501. self.requeue = requeue
  1502. @property
  1503. def synchronous(self):
  1504. return False
  1505. def decode(self, encoded, offset=0):
  1506. self.delivery_tag = struct.unpack_from('>Q', encoded, offset)[0]
  1507. offset += 8
  1508. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1509. offset += 1
  1510. self.multiple = (bit_buffer & (1 << 0)) != 0
  1511. self.requeue = (bit_buffer & (1 << 1)) != 0
  1512. return self
  1513. def encode(self):
  1514. pieces = list()
  1515. pieces.append(struct.pack('>Q', self.delivery_tag))
  1516. bit_buffer = 0
  1517. if self.multiple:
  1518. bit_buffer |= 1 << 0
  1519. if self.requeue:
  1520. bit_buffer |= 1 << 1
  1521. pieces.append(struct.pack('B', bit_buffer))
  1522. return pieces
  1523. class Tx(amqp_object.Class):
  1524. INDEX = 0x005A # 90
  1525. NAME = 'Tx'
  1526. class Select(amqp_object.Method):
  1527. INDEX = 0x005A000A # 90, 10; 5898250
  1528. NAME = 'Tx.Select'
  1529. def __init__(self):
  1530. pass
  1531. @property
  1532. def synchronous(self):
  1533. return True
  1534. def decode(self, encoded, offset=0):
  1535. return self
  1536. def encode(self):
  1537. pieces = list()
  1538. return pieces
  1539. class SelectOk(amqp_object.Method):
  1540. INDEX = 0x005A000B # 90, 11; 5898251
  1541. NAME = 'Tx.SelectOk'
  1542. def __init__(self):
  1543. pass
  1544. @property
  1545. def synchronous(self):
  1546. return False
  1547. def decode(self, encoded, offset=0):
  1548. return self
  1549. def encode(self):
  1550. pieces = list()
  1551. return pieces
  1552. class Commit(amqp_object.Method):
  1553. INDEX = 0x005A0014 # 90, 20; 5898260
  1554. NAME = 'Tx.Commit'
  1555. def __init__(self):
  1556. pass
  1557. @property
  1558. def synchronous(self):
  1559. return True
  1560. def decode(self, encoded, offset=0):
  1561. return self
  1562. def encode(self):
  1563. pieces = list()
  1564. return pieces
  1565. class CommitOk(amqp_object.Method):
  1566. INDEX = 0x005A0015 # 90, 21; 5898261
  1567. NAME = 'Tx.CommitOk'
  1568. def __init__(self):
  1569. pass
  1570. @property
  1571. def synchronous(self):
  1572. return False
  1573. def decode(self, encoded, offset=0):
  1574. return self
  1575. def encode(self):
  1576. pieces = list()
  1577. return pieces
  1578. class Rollback(amqp_object.Method):
  1579. INDEX = 0x005A001E # 90, 30; 5898270
  1580. NAME = 'Tx.Rollback'
  1581. def __init__(self):
  1582. pass
  1583. @property
  1584. def synchronous(self):
  1585. return True
  1586. def decode(self, encoded, offset=0):
  1587. return self
  1588. def encode(self):
  1589. pieces = list()
  1590. return pieces
  1591. class RollbackOk(amqp_object.Method):
  1592. INDEX = 0x005A001F # 90, 31; 5898271
  1593. NAME = 'Tx.RollbackOk'
  1594. def __init__(self):
  1595. pass
  1596. @property
  1597. def synchronous(self):
  1598. return False
  1599. def decode(self, encoded, offset=0):
  1600. return self
  1601. def encode(self):
  1602. pieces = list()
  1603. return pieces
  1604. class Confirm(amqp_object.Class):
  1605. INDEX = 0x0055 # 85
  1606. NAME = 'Confirm'
  1607. class Select(amqp_object.Method):
  1608. INDEX = 0x0055000A # 85, 10; 5570570
  1609. NAME = 'Confirm.Select'
  1610. def __init__(self, nowait=False):
  1611. self.nowait = nowait
  1612. @property
  1613. def synchronous(self):
  1614. return True
  1615. def decode(self, encoded, offset=0):
  1616. bit_buffer = struct.unpack_from('B', encoded, offset)[0]
  1617. offset += 1
  1618. self.nowait = (bit_buffer & (1 << 0)) != 0
  1619. return self
  1620. def encode(self):
  1621. pieces = list()
  1622. bit_buffer = 0
  1623. if self.nowait:
  1624. bit_buffer |= 1 << 0
  1625. pieces.append(struct.pack('B', bit_buffer))
  1626. return pieces
  1627. class SelectOk(amqp_object.Method):
  1628. INDEX = 0x0055000B # 85, 11; 5570571
  1629. NAME = 'Confirm.SelectOk'
  1630. def __init__(self):
  1631. pass
  1632. @property
  1633. def synchronous(self):
  1634. return False
  1635. def decode(self, encoded, offset=0):
  1636. return self
  1637. def encode(self):
  1638. pieces = list()
  1639. return pieces
  1640. class BasicProperties(amqp_object.Properties):
  1641. CLASS = Basic
  1642. INDEX = 0x003C # 60
  1643. NAME = 'BasicProperties'
  1644. FLAG_CONTENT_TYPE = (1 << 15)
  1645. FLAG_CONTENT_ENCODING = (1 << 14)
  1646. FLAG_HEADERS = (1 << 13)
  1647. FLAG_DELIVERY_MODE = (1 << 12)
  1648. FLAG_PRIORITY = (1 << 11)
  1649. FLAG_CORRELATION_ID = (1 << 10)
  1650. FLAG_REPLY_TO = (1 << 9)
  1651. FLAG_EXPIRATION = (1 << 8)
  1652. FLAG_MESSAGE_ID = (1 << 7)
  1653. FLAG_TIMESTAMP = (1 << 6)
  1654. FLAG_TYPE = (1 << 5)
  1655. FLAG_USER_ID = (1 << 4)
  1656. FLAG_APP_ID = (1 << 3)
  1657. FLAG_CLUSTER_ID = (1 << 2)
  1658. def __init__(self, content_type=None, content_encoding=None, headers=None, delivery_mode=None, priority=None, correlation_id=None, reply_to=None, expiration=None, message_id=None, timestamp=None, type=None, user_id=None, app_id=None, cluster_id=None):
  1659. self.content_type = content_type
  1660. self.content_encoding = content_encoding
  1661. self.headers = headers
  1662. self.delivery_mode = delivery_mode
  1663. self.priority = priority
  1664. self.correlation_id = correlation_id
  1665. self.reply_to = reply_to
  1666. self.expiration = expiration
  1667. self.message_id = message_id
  1668. self.timestamp = timestamp
  1669. self.type = type
  1670. self.user_id = user_id
  1671. self.app_id = app_id
  1672. self.cluster_id = cluster_id
  1673. def decode(self, encoded, offset=0):
  1674. flags = 0
  1675. flagword_index = 0
  1676. while True:
  1677. partial_flags = struct.unpack_from('>H', encoded, offset)[0]
  1678. offset += 2
  1679. flags = flags | (partial_flags << (flagword_index * 16))
  1680. if not (partial_flags & 1):
  1681. break
  1682. flagword_index += 1
  1683. if flags & BasicProperties.FLAG_CONTENT_TYPE:
  1684. self.content_type, offset = data.decode_short_string(encoded, offset)
  1685. else:
  1686. self.content_type = None
  1687. if flags & BasicProperties.FLAG_CONTENT_ENCODING:
  1688. self.content_encoding, offset = data.decode_short_string(encoded, offset)
  1689. else:
  1690. self.content_encoding = None
  1691. if flags & BasicProperties.FLAG_HEADERS:
  1692. (self.headers, offset) = data.decode_table(encoded, offset)
  1693. else:
  1694. self.headers = None
  1695. if flags & BasicProperties.FLAG_DELIVERY_MODE:
  1696. self.delivery_mode = struct.unpack_from('B', encoded, offset)[0]
  1697. offset += 1
  1698. else:
  1699. self.delivery_mode = None
  1700. if flags & BasicProperties.FLAG_PRIORITY:
  1701. self.priority = struct.unpack_from('B', encoded, offset)[0]
  1702. offset += 1
  1703. else:
  1704. self.priority = None
  1705. if flags & BasicProperties.FLAG_CORRELATION_ID:
  1706. self.correlation_id, offset = data.decode_short_string(encoded, offset)
  1707. else:
  1708. self.correlation_id = None
  1709. if flags & BasicProperties.FLAG_REPLY_TO:
  1710. self.reply_to, offset = data.decode_short_string(encoded, offset)
  1711. else:
  1712. self.reply_to = None
  1713. if flags & BasicProperties.FLAG_EXPIRATION:
  1714. self.expiration, offset = data.decode_short_string(encoded, offset)
  1715. else:
  1716. self.expiration = None
  1717. if flags & BasicProperties.FLAG_MESSAGE_ID:
  1718. self.message_id, offset = data.decode_short_string(encoded, offset)
  1719. else:
  1720. self.message_id = None
  1721. if flags & BasicProperties.FLAG_TIMESTAMP:
  1722. self.timestamp = struct.unpack_from('>Q', encoded, offset)[0]
  1723. offset += 8
  1724. else:
  1725. self.timestamp = None
  1726. if flags & BasicProperties.FLAG_TYPE:
  1727. self.type, offset = data.decode_short_string(encoded, offset)
  1728. else:
  1729. self.type = None
  1730. if flags & BasicProperties.FLAG_USER_ID:
  1731. self.user_id, offset = data.decode_short_string(encoded, offset)
  1732. else:
  1733. self.user_id = None
  1734. if flags & BasicProperties.FLAG_APP_ID:
  1735. self.app_id, offset = data.decode_short_string(encoded, offset)
  1736. else:
  1737. self.app_id = None
  1738. if flags & BasicProperties.FLAG_CLUSTER_ID:
  1739. self.cluster_id, offset = data.decode_short_string(encoded, offset)
  1740. else:
  1741. self.cluster_id = None
  1742. return self
  1743. def encode(self):
  1744. pieces = list()
  1745. flags = 0
  1746. if self.content_type is not None:
  1747. flags = flags | BasicProperties.FLAG_CONTENT_TYPE
  1748. assert isinstance(self.content_type, str_or_bytes),\
  1749. 'A non-string value was supplied for self.content_type'
  1750. data.encode_short_string(pieces, self.content_type)
  1751. if self.content_encoding is not None:
  1752. flags = flags | BasicProperties.FLAG_CONTENT_ENCODING
  1753. assert isinstance(self.content_encoding, str_or_bytes),\
  1754. 'A non-string value was supplied for self.content_encoding'
  1755. data.encode_short_string(pieces, self.content_encoding)
  1756. if self.headers is not None:
  1757. flags = flags | BasicProperties.FLAG_HEADERS
  1758. data.encode_table(pieces, self.headers)
  1759. if self.delivery_mode is not None:
  1760. flags = flags | BasicProperties.FLAG_DELIVERY_MODE
  1761. pieces.append(struct.pack('B', self.delivery_mode))
  1762. if self.priority is not None:
  1763. flags = flags | BasicProperties.FLAG_PRIORITY
  1764. pieces.append(struct.pack('B', self.priority))
  1765. if self.correlation_id is not None:
  1766. flags = flags | BasicProperties.FLAG_CORRELATION_ID
  1767. assert isinstance(self.correlation_id, str_or_bytes),\
  1768. 'A non-string value was supplied for self.correlation_id'
  1769. data.encode_short_string(pieces, self.correlation_id)
  1770. if self.reply_to is not None:
  1771. flags = flags | BasicProperties.FLAG_REPLY_TO
  1772. assert isinstance(self.reply_to, str_or_bytes),\
  1773. 'A non-string value was supplied for self.reply_to'
  1774. data.encode_short_string(pieces, self.reply_to)
  1775. if self.expiration is not None:
  1776. flags = flags | BasicProperties.FLAG_EXPIRATION
  1777. assert isinstance(self.expiration, str_or_bytes),\
  1778. 'A non-string value was supplied for self.expiration'
  1779. data.encode_short_string(pieces, self.expiration)
  1780. if self.message_id is not None:
  1781. flags = flags | BasicProperties.FLAG_MESSAGE_ID
  1782. assert isinstance(self.message_id, str_or_bytes),\
  1783. 'A non-string value was supplied for self.message_id'
  1784. data.encode_short_string(pieces, self.message_id)
  1785. if self.timestamp is not None:
  1786. flags = flags | BasicProperties.FLAG_TIMESTAMP
  1787. pieces.append(struct.pack('>Q', self.timestamp))
  1788. if self.type is not None:
  1789. flags = flags | BasicProperties.FLAG_TYPE
  1790. assert isinstance(self.type, str_or_bytes),\
  1791. 'A non-string value was supplied for self.type'
  1792. data.encode_short_string(pieces, self.type)
  1793. if self.user_id is not None:
  1794. flags = flags | BasicProperties.FLAG_USER_ID
  1795. assert isinstance(self.user_id, str_or_bytes),\
  1796. 'A non-string value was supplied for self.user_id'
  1797. data.encode_short_string(pieces, self.user_id)
  1798. if self.app_id is not None:
  1799. flags = flags | BasicProperties.FLAG_APP_ID
  1800. assert isinstance(self.app_id, str_or_bytes),\
  1801. 'A non-string value was supplied for self.app_id'
  1802. data.encode_short_string(pieces, self.app_id)
  1803. if self.cluster_id is not None:
  1804. flags = flags | BasicProperties.FLAG_CLUSTER_ID
  1805. assert isinstance(self.cluster_id, str_or_bytes),\
  1806. 'A non-string value was supplied for self.cluster_id'
  1807. data.encode_short_string(pieces, self.cluster_id)
  1808. flag_pieces = list()
  1809. while True:
  1810. remainder = flags >> 16
  1811. partial_flags = flags & 0xFFFE
  1812. if remainder != 0:
  1813. partial_flags |= 1
  1814. flag_pieces.append(struct.pack('>H', partial_flags))
  1815. flags = remainder
  1816. if not flags:
  1817. break
  1818. return flag_pieces + pieces
  1819. methods = {
  1820. 0x000A000A: Connection.Start,
  1821. 0x000A000B: Connection.StartOk,
  1822. 0x000A0014: Connection.Secure,
  1823. 0x000A0015: Connection.SecureOk,
  1824. 0x000A001E: Connection.Tune,
  1825. 0x000A001F: Connection.TuneOk,
  1826. 0x000A0028: Connection.Open,
  1827. 0x000A0029: Connection.OpenOk,
  1828. 0x000A0032: Connection.Close,
  1829. 0x000A0033: Connection.CloseOk,
  1830. 0x000A003C: Connection.Blocked,
  1831. 0x000A003D: Connection.Unblocked,
  1832. 0x0014000A: Channel.Open,
  1833. 0x0014000B: Channel.OpenOk,
  1834. 0x00140014: Channel.Flow,
  1835. 0x00140015: Channel.FlowOk,
  1836. 0x00140028: Channel.Close,
  1837. 0x00140029: Channel.CloseOk,
  1838. 0x001E000A: Access.Request,
  1839. 0x001E000B: Access.RequestOk,
  1840. 0x0028000A: Exchange.Declare,
  1841. 0x0028000B: Exchange.DeclareOk,
  1842. 0x00280014: Exchange.Delete,
  1843. 0x00280015: Exchange.DeleteOk,
  1844. 0x0028001E: Exchange.Bind,
  1845. 0x0028001F: Exchange.BindOk,
  1846. 0x00280028: Exchange.Unbind,
  1847. 0x00280033: Exchange.UnbindOk,
  1848. 0x0032000A: Queue.Declare,
  1849. 0x0032000B: Queue.DeclareOk,
  1850. 0x00320014: Queue.Bind,
  1851. 0x00320015: Queue.BindOk,
  1852. 0x0032001E: Queue.Purge,
  1853. 0x0032001F: Queue.PurgeOk,
  1854. 0x00320028: Queue.Delete,
  1855. 0x00320029: Queue.DeleteOk,
  1856. 0x00320032: Queue.Unbind,
  1857. 0x00320033: Queue.UnbindOk,
  1858. 0x003C000A: Basic.Qos,
  1859. 0x003C000B: Basic.QosOk,
  1860. 0x003C0014: Basic.Consume,
  1861. 0x003C0015: Basic.ConsumeOk,
  1862. 0x003C001E: Basic.Cancel,
  1863. 0x003C001F: Basic.CancelOk,
  1864. 0x003C0028: Basic.Publish,
  1865. 0x003C0032: Basic.Return,
  1866. 0x003C003C: Basic.Deliver,
  1867. 0x003C0046: Basic.Get,
  1868. 0x003C0047: Basic.GetOk,
  1869. 0x003C0048: Basic.GetEmpty,
  1870. 0x003C0050: Basic.Ack,
  1871. 0x003C005A: Basic.Reject,
  1872. 0x003C0064: Basic.RecoverAsync,
  1873. 0x003C006E: Basic.Recover,
  1874. 0x003C006F: Basic.RecoverOk,
  1875. 0x003C0078: Basic.Nack,
  1876. 0x005A000A: Tx.Select,
  1877. 0x005A000B: Tx.SelectOk,
  1878. 0x005A0014: Tx.Commit,
  1879. 0x005A0015: Tx.CommitOk,
  1880. 0x005A001E: Tx.Rollback,
  1881. 0x005A001F: Tx.RollbackOk,
  1882. 0x0055000A: Confirm.Select,
  1883. 0x0055000B: Confirm.SelectOk
  1884. }
  1885. props = {
  1886. 0x003C: BasicProperties
  1887. }
  1888. def has_content(methodNumber):
  1889. return methodNumber in (
  1890. Basic.Publish.INDEX,
  1891. Basic.Return.INDEX,
  1892. Basic.Deliver.INDEX,
  1893. Basic.GetOk.INDEX,
  1894. )