Debian Codegraph @

pamqp/commands.py

raw
1 """
2 The classes inside :mod:`pamqp.commands` allow for the automatic marshaling
3 and unmarshaling of AMQP method frames and
4 :class:`Basic.Properties <pamqp.commands.Basic.Properties>`. In addition the
5 command classes contain information that designates if they are synchronous
6 commands and if so, what the expected responses are. Each commands arguments
7 are detailed in the class and are listed in the attributes property.
8
9 .. note:: All AMQ classes and methods extend :class:`pamqp.base.Frame`.
10
11 """
12 # Auto-generated, do not edit this file.
13 import datetime
14 import typing
15 import warnings
16
17 from pamqp import base, common, constants
18
19
20 class Connection:
21 """Work with socket connections
22
23 The connection class provides methods for a client to establish a network
24 connection to a server, and for both peers to operate the connection
25 thereafter.
26
27 """
28 __slots__: typing.ClassVar[list[str]] = []
29
30 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
31 index: typing.ClassVar[int] = 0x000A0000 # pamqp Mapping Index
32
33 class Start(base.Frame):
34 """Start connection negotiation
35
36 This method starts the connection negotiation process by telling the
37 client the protocol version that the server proposes, along with a list
38 of security mechanisms which the client can use for authentication.
39
40 :param version_major: Protocol major version
41 - Default: ``0``
42 :param version_minor: Protocol minor version
43 - Default: ``9``
44 :param server_properties: Server properties
45 - Default: ``{}``
46 :type server_properties: :const:`~pamqp.common.FieldTable`
47 :param mechanisms: Available security mechanisms
48 - Default: ``PLAIN``
49 :param locales: Available message locales
50 - Default: ``en_US``
51
52 """
53 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
54 'version_major', 'version_minor', 'server_properties',
55 'mechanisms', 'locales'
56 ]
57
58 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
59 index: typing.ClassVar[int] = 0x000A000A # pamqp Mapping Index
60 name: typing.ClassVar[str] = 'Connection.Start'
61 synchronous: typing.ClassVar[
62 bool] = True # Indicates if this is a synchronous AMQP method
63 # Valid responses to this method
64 valid_responses: typing.ClassVar[list[str]] = ['Connection.StartOk']
65
66 # Class Attribute Types for unmarshaling
67 _version_major = 'octet'
68 _version_minor = 'octet'
69 _server_properties = 'table'
70 _mechanisms = 'longstr'
71 _locales = 'longstr'
72
73 def __init__(self,
74 version_major: int = 0,
75 version_minor: int = 9,
76 server_properties: common.FieldTable | None = None,
77 mechanisms: str = 'PLAIN',
78 locales: str = 'en_US') -> None:
79 """Initialize the :class:`Connection.Start` class"""
80 self.version_major = version_major
81 self.version_minor = version_minor
82 self.server_properties = server_properties or {}
83 self.mechanisms = mechanisms
84 self.locales = locales
85
86 class StartOk(base.Frame):
87 """Select security mechanism and locale
88
89 This method selects a SASL security mechanism.
90
91 :param client_properties: Client properties
92 - Default: ``{}``
93 :type client_properties: :const:`~pamqp.common.FieldTable`
94 :param mechanism: Selected security mechanism
95 - Default: ``PLAIN``
96 :param response: Security response data
97 - Default: ``''``
98 :param locale: Selected message locale
99 - Default: ``en_US``
100
101 """
102 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
103 'client_properties', 'mechanism', 'response', 'locale'
104 ]
105
106 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
107 index: typing.ClassVar[int] = 0x000A000B # pamqp Mapping Index
108 name: typing.ClassVar[str] = 'Connection.StartOk'
109 synchronous: typing.ClassVar[
110 bool] = False # Indicates if this is a synchronous AMQP method
111
112 # Class Attribute Types for unmarshaling
113 _client_properties = 'table'
114 _mechanism = 'shortstr'
115 _response = 'longstr'
116 _locale = 'shortstr'
117
118 def __init__(self,
119 client_properties: common.FieldTable | None = None,
120 mechanism: str = 'PLAIN',
121 response: str = '',
122 locale: str = 'en_US') -> None:
123 """Initialize the :class:`Connection.StartOk` class"""
124 self.client_properties = client_properties or {}
125 self.mechanism = mechanism
126 self.response = response
127 self.locale = locale
128
129 class Secure(base.Frame):
130 """Security mechanism challenge
131
132 The SASL protocol works by exchanging challenges and responses until
133 both peers have received sufficient information to authenticate each
134 other. This method challenges the client to provide more information.
135
136 :param challenge: Security challenge data
137
138 """
139 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
140 'challenge'
141 ]
142
143 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
144 index: typing.ClassVar[int] = 0x000A0014 # pamqp Mapping Index
145 name: typing.ClassVar[str] = 'Connection.Secure'
146 synchronous: typing.ClassVar[
147 bool] = True # Indicates if this is a synchronous AMQP method
148 # Valid responses to this method
149 valid_responses: typing.ClassVar[list[str]] = ['Connection.SecureOk']
150
151 # Class Attribute Types for unmarshaling
152 _challenge = 'longstr'
153
154 def __init__(self, challenge: str | None = None) -> None:
155 """Initialize the :class:`Connection.Secure` class"""
156 self.challenge = challenge
157
158 class SecureOk(base.Frame):
159 """Security mechanism response
160
161 This method attempts to authenticate, passing a block of SASL data for
162 the security mechanism at the server side.
163
164 :param response: Security response data
165
166 """
167 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
168 'response'
169 ]
170
171 frame_id: typing.ClassVar[int] = 21 # AMQP Frame ID
172 index: typing.ClassVar[int] = 0x000A0015 # pamqp Mapping Index
173 name: typing.ClassVar[str] = 'Connection.SecureOk'
174 synchronous: typing.ClassVar[
175 bool] = False # Indicates if this is a synchronous AMQP method
176
177 # Class Attribute Types for unmarshaling
178 _response = 'longstr'
179
180 def __init__(self, response: str | None = None) -> None:
181 """Initialize the :class:`Connection.SecureOk` class"""
182 self.response = response
183
184 class Tune(base.Frame):
185 """Propose connection tuning parameters
186
187 This method proposes a set of connection configuration values to the
188 client. The client can accept and/or adjust these.
189
190 :param channel_max: Proposed maximum channels
191 - Default: ``0``
192 :param frame_max: Proposed maximum frame size
193 - Default: ``0``
194 :param heartbeat: Desired heartbeat delay
195 - Default: ``0``
196
197 """
198 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
199 'channel_max', 'frame_max', 'heartbeat'
200 ]
201
202 frame_id: typing.ClassVar[int] = 30 # AMQP Frame ID
203 index: typing.ClassVar[int] = 0x000A001E # pamqp Mapping Index
204 name: typing.ClassVar[str] = 'Connection.Tune'
205 synchronous: typing.ClassVar[
206 bool] = True # Indicates if this is a synchronous AMQP method
207 # Valid responses to this method
208 valid_responses: typing.ClassVar[list[str]] = ['Connection.TuneOk']
209
210 # Class Attribute Types for unmarshaling
211 _channel_max = 'short'
212 _frame_max = 'long'
213 _heartbeat = 'short'
214
215 def __init__(self,
216 channel_max: int = 0,
217 frame_max: int = 0,
218 heartbeat: int = 0) -> None:
219 """Initialize the :class:`Connection.Tune` class"""
220 self.channel_max = channel_max
221 self.frame_max = frame_max
222 self.heartbeat = heartbeat
223
224 class TuneOk(base.Frame):
225 """Negotiate connection tuning parameters
226
227 This method sends the client's connection tuning parameters to the
228 server. Certain fields are negotiated, others provide capability
229 information.
230
231 :param channel_max: Negotiated maximum channels
232 - Default: ``0``
233 :param frame_max: Negotiated maximum frame size
234 - Default: ``0``
235 :param heartbeat: Desired heartbeat delay
236 - Default: ``0``
237
238 """
239 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
240 'channel_max', 'frame_max', 'heartbeat'
241 ]
242
243 frame_id: typing.ClassVar[int] = 31 # AMQP Frame ID
244 index: typing.ClassVar[int] = 0x000A001F # pamqp Mapping Index
245 name: typing.ClassVar[str] = 'Connection.TuneOk'
246 synchronous: typing.ClassVar[
247 bool] = False # Indicates if this is a synchronous AMQP method
248
249 # Class Attribute Types for unmarshaling
250 _channel_max = 'short'
251 _frame_max = 'long'
252 _heartbeat = 'short'
253
254 def __init__(self,
255 channel_max: int = 0,
256 frame_max: int = 0,
257 heartbeat: int = 0) -> None:
258 """Initialize the :class:`Connection.TuneOk` class"""
259 self.channel_max = channel_max
260 self.frame_max = frame_max
261 self.heartbeat = heartbeat
262
263 class Open(base.Frame):
264 """Open connection to virtual host
265
266 This method opens a connection to a virtual host, which is a collection
267 of resources, and acts to separate multiple application domains within
268 a server. The server may apply arbitrary limits per virtual host, such
269 as the number of each type of entity that may be used, per connection
270 and/or in total.
271
272 :param virtual_host: Virtual host name
273 - Default: ``/``
274 :param capabilities: Deprecated, must be empty
275 - Default: ``''``
276 :param insist: Deprecated, must be ``False``
277 - Default: ``False``
278 :raises ValueError: when an argument fails to validate
279
280 """
281 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
282 'virtual_host', 'capabilities', 'insist'
283 ]
284
285 frame_id: typing.ClassVar[int] = 40 # AMQP Frame ID
286 index: typing.ClassVar[int] = 0x000A0028 # pamqp Mapping Index
287 name: typing.ClassVar[str] = 'Connection.Open'
288 synchronous: typing.ClassVar[
289 bool] = True # Indicates if this is a synchronous AMQP method
290 # Valid responses to this method
291 valid_responses: typing.ClassVar[list[str]] = ['Connection.OpenOk']
292
293 # Class Attribute Types for unmarshaling
294 _virtual_host = 'shortstr'
295 _capabilities = 'shortstr'
296 _insist = 'bit'
297
298 def __init__(self,
299 virtual_host: str = '/',
300 capabilities: str = '',
301 insist: bool = False) -> None:
302 """Initialize the :class:`Connection.Open` class"""
303 self.virtual_host = virtual_host
304 self.capabilities = capabilities
305 self.insist = insist
306 self.validate()
307
308 def validate(self) -> None:
309 """Validate the frame data ensuring all domains or attributes
310 adhere to the protocol specification.
311
312 :raises ValueError: on validation error
313
314 """
315 if self.virtual_host is not None and len(self.virtual_host) > 127:
316 raise ValueError('Max length exceeded for virtual_host')
317 if self.capabilities is not None and self.capabilities != '':
318 raise ValueError('capabilities must be empty')
319 if self.insist is not None and self.insist is not False:
320 raise ValueError('insist must be False')
321
322 class OpenOk(base.Frame):
323 """Signal that connection is ready
324
325 This method signals to the client that the connection is ready for use.
326
327 :param known_hosts: Deprecated, must be empty
328 - Default: ``''``
329
330 """
331 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
332 'known_hosts'
333 ]
334
335 frame_id: typing.ClassVar[int] = 41 # AMQP Frame ID
336 index: typing.ClassVar[int] = 0x000A0029 # pamqp Mapping Index
337 name: typing.ClassVar[str] = 'Connection.OpenOk'
338 synchronous: typing.ClassVar[
339 bool] = False # Indicates if this is a synchronous AMQP method
340
341 # Class Attribute Types for unmarshaling
342 _known_hosts = 'shortstr'
343
344 def __init__(self, known_hosts: str = '') -> None:
345 """Initialize the :class:`Connection.OpenOk` class"""
346 self.known_hosts = known_hosts
347 self.validate()
348
349 def validate(self) -> None:
350 """Validate the frame data ensuring all domains or attributes
351 adhere to the protocol specification.
352
353 :raises ValueError: on validation error
354
355 """
356 if self.known_hosts is not None and self.known_hosts != '':
357 raise ValueError('known_hosts must be empty')
358
359 class Close(base.Frame):
360 """Request a connection close
361
362 This method indicates that the sender wants to close the connection.
363 This may be due to internal conditions (e.g. a forced shut-down) or due
364 to an error handling a specific method, i.e. an exception. When a close
365 is due to an exception, the sender provides the class and method id of
366 the method which caused the exception.
367
368 :param reply_code: Reply code from server
369 :param reply_text: Localised reply text
370 - Default: ``''``
371 :param class_id: Failing method class
372 :param method_id: Failing method ID
373
374 """
375 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
376 'reply_code', 'reply_text', 'class_id', 'method_id'
377 ]
378
379 frame_id: typing.ClassVar[int] = 50 # AMQP Frame ID
380 index: typing.ClassVar[int] = 0x000A0032 # pamqp Mapping Index
381 name: typing.ClassVar[str] = 'Connection.Close'
382 synchronous: typing.ClassVar[
383 bool] = True # Indicates if this is a synchronous AMQP method
384 # Valid responses to this method
385 valid_responses: typing.ClassVar[list[str]] = ['Connection.CloseOk']
386
387 # Class Attribute Types for unmarshaling
388 _reply_code = 'short'
389 _reply_text = 'shortstr'
390 _class_id = 'short'
391 _method_id = 'short'
392
393 def __init__(self,
394 reply_code: int | None = None,
395 reply_text: str = '',
396 class_id: int | None = None,
397 method_id: int | None = None) -> None:
398 """Initialize the :class:`Connection.Close` class"""
399 self.reply_code = reply_code
400 self.reply_text = reply_text or ''
401 self.class_id = class_id
402 self.method_id = method_id
403
404 class CloseOk(base.Frame):
405 """Confirm a connection close
406
407 This method confirms a :class:`Connection.Close` method and tells the
408 recipient that it is safe to release resources for the connection and
409 close the socket.
410
411 """
412 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
413
414 frame_id: typing.ClassVar[int] = 51 # AMQP Frame ID
415 index: typing.ClassVar[int] = 0x000A0033 # pamqp Mapping Index
416 name: typing.ClassVar[str] = 'Connection.CloseOk'
417 synchronous: typing.ClassVar[
418 bool] = False # Indicates if this is a synchronous AMQP method
419
420 class Blocked(base.Frame):
421 """Indicate that connection is blocked
422
423 This method indicates that a connection has been blocked and does not
424 accept new publishes.
425
426 :param reason: Block reason
427 - Default: ``''``
428
429 """
430 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
431 'reason'
432 ]
433
434 frame_id: typing.ClassVar[int] = 60 # AMQP Frame ID
435 index: typing.ClassVar[int] = 0x000A003C # pamqp Mapping Index
436 name: typing.ClassVar[str] = 'Connection.Blocked'
437 synchronous: typing.ClassVar[
438 bool] = False # Indicates if this is a synchronous AMQP method
439
440 # Class Attribute Types for unmarshaling
441 _reason = 'shortstr'
442
443 def __init__(self, reason: str = '') -> None:
444 """Initialize the :class:`Connection.Blocked` class"""
445 self.reason = reason
446
447 class Unblocked(base.Frame):
448 """Indicate that connection is unblocked
449
450 This method indicates that a connection has been unblocked and now
451 accepts publishes.
452
453 """
454 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
455
456 frame_id: typing.ClassVar[int] = 61 # AMQP Frame ID
457 index: typing.ClassVar[int] = 0x000A003D # pamqp Mapping Index
458 name: typing.ClassVar[str] = 'Connection.Unblocked'
459 synchronous: typing.ClassVar[
460 bool] = False # Indicates if this is a synchronous AMQP method
461
462 class UpdateSecret(base.Frame):
463 """Update secret
464
465 This method updates the secret used to authenticate this connection. It
466 is used when secrets have an expiration date and need to be renewed,
467 like OAuth 2 tokens.
468
469 :param new_secret: New secret
470 :param reason: Reason
471
472 """
473 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
474 'new_secret', 'reason'
475 ]
476
477 frame_id: typing.ClassVar[int] = 70 # AMQP Frame ID
478 index: typing.ClassVar[int] = 0x000A0046 # pamqp Mapping Index
479 name: typing.ClassVar[str] = 'Connection.UpdateSecret'
480 synchronous: typing.ClassVar[
481 bool] = True # Indicates if this is a synchronous AMQP method
482 # Valid responses to this method
483 valid_responses: typing.ClassVar[list[str]] = [
484 'Connection.UpdateSecretOk'
485 ]
486
487 # Class Attribute Types for unmarshaling
488 _new_secret = 'longstr'
489 _reason = 'shortstr'
490
491 def __init__(self,
492 new_secret: str | None = None,
493 reason: str | None = None) -> None:
494 """Initialize the :class:`Connection.UpdateSecret` class"""
495 self.new_secret = new_secret
496 self.reason = reason
497
498 class UpdateSecretOk(base.Frame):
499 """Update secret response
500
501 This method confirms the updated secret is valid.
502
503 """
504 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
505
506 frame_id: typing.ClassVar[int] = 71 # AMQP Frame ID
507 index: typing.ClassVar[int] = 0x000A0047 # pamqp Mapping Index
508 name: typing.ClassVar[str] = 'Connection.UpdateSecretOk'
509 synchronous: typing.ClassVar[
510 bool] = False # Indicates if this is a synchronous AMQP method
511
512
513 class Channel:
514 """Work with channels
515
516 The channel class provides methods for a client to establish a channel to a
517 server and for both peers to operate the channel thereafter.
518
519 """
520 __slots__: typing.ClassVar[list[str]] = []
521
522 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
523 index: typing.ClassVar[int] = 0x00140000 # pamqp Mapping Index
524
525 class Open(base.Frame):
526 """Open a channel for use
527
528 This method opens a channel to the server.
529
530 :param out_of_band: Protocol level field, do not use, must be ``0``.
531 - Default: ``0``
532
533 """
534 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
535 'out_of_band'
536 ]
537
538 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
539 index: typing.ClassVar[int] = 0x0014000A # pamqp Mapping Index
540 name: typing.ClassVar[str] = 'Channel.Open'
541 synchronous: typing.ClassVar[
542 bool] = True # Indicates if this is a synchronous AMQP method
543 # Valid responses to this method
544 valid_responses: typing.ClassVar[list[str]] = ['Channel.OpenOk']
545
546 # Class Attribute Types for unmarshaling
547 _out_of_band = 'shortstr'
548
549 def __init__(self, out_of_band: str = '0') -> None:
550 """Initialize the :class:`Channel.Open` class"""
551 self.out_of_band = out_of_band
552 self.validate()
553
554 def validate(self) -> None:
555 """Validate the frame data ensuring all domains or attributes
556 adhere to the protocol specification.
557
558 :raises ValueError: on validation error
559
560 """
561 if self.out_of_band is not None and self.out_of_band != '0':
562 raise ValueError('out_of_band must be 0')
563
564 class OpenOk(base.Frame):
565 """Signal that the channel is ready
566
567 This method signals to the client that the channel is ready for use.
568
569 :param channel_id: Deprecated, must be ``0``
570 - Default: ``0``
571
572 """
573 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
574 'channel_id'
575 ]
576
577 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
578 index: typing.ClassVar[int] = 0x0014000B # pamqp Mapping Index
579 name: typing.ClassVar[str] = 'Channel.OpenOk'
580 synchronous: typing.ClassVar[
581 bool] = False # Indicates if this is a synchronous AMQP method
582
583 # Class Attribute Types for unmarshaling
584 _channel_id = 'longstr'
585
586 def __init__(self, channel_id: str = '0') -> None:
587 """Initialize the :class:`Channel.OpenOk` class"""
588 self.channel_id = channel_id
589 self.validate()
590
591 def validate(self) -> None:
592 """Validate the frame data ensuring all domains or attributes
593 adhere to the protocol specification.
594
595 :raises ValueError: on validation error
596
597 """
598 if self.channel_id is not None and self.channel_id != '0':
599 raise ValueError('channel_id must be 0')
600
601 class Flow(base.Frame):
602 """Enable/disable flow from peer
603
604 This method asks the peer to pause or restart the flow of content data
605 sent by a consumer. This is a simple flow-control mechanism that a peer
606 can use to avoid overflowing its queues or otherwise finding itself
607 receiving more messages than it can process. Note that this method is
608 not intended for window control. It does not affect contents returned
609 by :class:`Basic.GetOk` methods.
610
611 :param active: Start/stop content frames
612
613 """
614 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
615 'active'
616 ]
617
618 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
619 index: typing.ClassVar[int] = 0x00140014 # pamqp Mapping Index
620 name: typing.ClassVar[str] = 'Channel.Flow'
621 synchronous: typing.ClassVar[
622 bool] = True # Indicates if this is a synchronous AMQP method
623 # Valid responses to this method
624 valid_responses: typing.ClassVar[list[str]] = ['Channel.FlowOk']
625
626 # Class Attribute Types for unmarshaling
627 _active = 'bit'
628
629 def __init__(self, active: bool | None = None) -> None:
630 """Initialize the :class:`Channel.Flow` class"""
631 self.active = active
632
633 class FlowOk(base.Frame):
634 """Confirm a flow method
635
636 Confirms to the peer that a flow command was received and processed.
637
638 :param active: Current flow setting
639
640 """
641 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
642 'active'
643 ]
644
645 frame_id: typing.ClassVar[int] = 21 # AMQP Frame ID
646 index: typing.ClassVar[int] = 0x00140015 # pamqp Mapping Index
647 name: typing.ClassVar[str] = 'Channel.FlowOk'
648 synchronous: typing.ClassVar[
649 bool] = False # Indicates if this is a synchronous AMQP method
650
651 # Class Attribute Types for unmarshaling
652 _active = 'bit'
653
654 def __init__(self, active: bool | None = None) -> None:
655 """Initialize the :class:`Channel.FlowOk` class"""
656 self.active = active
657
658 class Close(base.Frame):
659 """Request a channel close
660
661 This method indicates that the sender wants to close the channel. This
662 may be due to internal conditions (e.g. a forced shut-down) or due to
663 an error handling a specific method, i.e. an exception. When a close is
664 due to an exception, the sender provides the class and method id of the
665 method which caused the exception.
666
667 :param reply_code: Reply code from server
668 :param reply_text: Localised reply text
669 - Default: ``''``
670 :param class_id: Failing method class
671 :param method_id: Failing method ID
672
673 """
674 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
675 'reply_code', 'reply_text', 'class_id', 'method_id'
676 ]
677
678 frame_id: typing.ClassVar[int] = 40 # AMQP Frame ID
679 index: typing.ClassVar[int] = 0x00140028 # pamqp Mapping Index
680 name: typing.ClassVar[str] = 'Channel.Close'
681 synchronous: typing.ClassVar[
682 bool] = True # Indicates if this is a synchronous AMQP method
683 # Valid responses to this method
684 valid_responses: typing.ClassVar[list[str]] = ['Channel.CloseOk']
685
686 # Class Attribute Types for unmarshaling
687 _reply_code = 'short'
688 _reply_text = 'shortstr'
689 _class_id = 'short'
690 _method_id = 'short'
691
692 def __init__(self,
693 reply_code: int | None = None,
694 reply_text: str = '',
695 class_id: int | None = None,
696 method_id: int | None = None) -> None:
697 """Initialize the :class:`Channel.Close` class"""
698 self.reply_code = reply_code
699 self.reply_text = reply_text or ''
700 self.class_id = class_id
701 self.method_id = method_id
702
703 class CloseOk(base.Frame):
704 """Confirm a channel close
705
706 This method confirms a :class:`Channel.Close` method and tells the
707 recipient that it is safe to release resources for the channel.
708
709 """
710 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
711
712 frame_id: typing.ClassVar[int] = 41 # AMQP Frame ID
713 index: typing.ClassVar[int] = 0x00140029 # pamqp Mapping Index
714 name: typing.ClassVar[str] = 'Channel.CloseOk'
715 synchronous: typing.ClassVar[
716 bool] = False # Indicates if this is a synchronous AMQP method
717
718
719 class Exchange:
720 """Work with exchanges
721
722 Exchanges match and distribute messages across queues. Exchanges can be
723 configured in the server or declared at runtime.
724
725 """
726 __slots__: typing.ClassVar[list[str]] = []
727
728 frame_id: typing.ClassVar[int] = 40 # AMQP Frame ID
729 index: typing.ClassVar[int] = 0x00280000 # pamqp Mapping Index
730
731 class Declare(base.Frame):
732 """Verify exchange exists, create if needed
733
734 This method creates an exchange if it does not already exist, and if
735 the exchange exists, verifies that it is of the correct and expected
736 class.
737
738 .. note:: The AMQP type argument is referred to as "exchange_type" to
739 not conflict with the Python type keyword.
740
741 :param ticket: Deprecated, must be ``0``
742 - Default: ``0``
743 :param exchange: exchange name
744 - Default: ``''``
745 :param exchange_type: Exchange type
746 - Default: ``direct``
747 :param passive: Do not create exchange
748 - Default: ``False``
749 :param durable: Request a durable exchange
750 - Default: ``False``
751 :param auto_delete: Auto-delete when unused
752 - Default: ``False``
753 :param internal: Create internal exchange
754 - Default: ``False``
755 :param nowait: Do not send a reply method
756 - Default: ``False``
757 :param arguments: Arguments for declaration
758 - Default: ``{}``
759 :type arguments: :const:`~pamqp.common.Arguments`
760 :raises ValueError: when an argument fails to validate
761
762 """
763 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
764 'ticket', 'exchange', 'exchange_type', 'passive', 'durable',
765 'auto_delete', 'internal', 'nowait', 'arguments'
766 ]
767
768 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
769 index: typing.ClassVar[int] = 0x0028000A # pamqp Mapping Index
770 name: typing.ClassVar[str] = 'Exchange.Declare'
771 synchronous: typing.ClassVar[
772 bool] = True # Indicates if this is a synchronous AMQP method
773 # Valid responses to this method
774 valid_responses: typing.ClassVar[list[str]] = ['Exchange.DeclareOk']
775
776 # Class Attribute Types for unmarshaling
777 _ticket = 'short'
778 _exchange = 'shortstr'
779 _exchange_type = 'shortstr'
780 _passive = 'bit'
781 _durable = 'bit'
782 _auto_delete = 'bit'
783 _internal = 'bit'
784 _nowait = 'bit'
785 _arguments = 'table'
786
787 def __init__(self,
788 ticket: int = 0,
789 exchange: str = '',
790 exchange_type: str = 'direct',
791 passive: bool = False,
792 durable: bool = False,
793 auto_delete: bool = False,
794 internal: bool = False,
795 nowait: bool = False,
796 arguments: common.Arguments | None = None) -> None:
797 """Initialize the :class:`Exchange.Declare` class"""
798 self.ticket = ticket
799 self.exchange = exchange
800 self.exchange_type = exchange_type
801 self.passive = passive
802 self.durable = durable
803 self.auto_delete = auto_delete
804 self.internal = internal
805 self.nowait = nowait
806 self.arguments = arguments or {}
807 self.validate()
808
809 def validate(self) -> None:
810 """Validate the frame data ensuring all domains or attributes
811 adhere to the protocol specification.
812
813 :raises ValueError: on validation error
814
815 """
816 if self.ticket is not None and self.ticket != 0:
817 raise ValueError('ticket must be 0')
818 if self.exchange is not None and len(self.exchange) > 127:
819 raise ValueError('Max length exceeded for exchange')
820 if self.exchange is not None and not constants.DOMAIN_REGEX[
821 'exchange-name'].fullmatch(self.exchange):
822 raise ValueError('Invalid value for exchange')
823
824 class DeclareOk(base.Frame):
825 """Confirm exchange declaration
826
827 This method confirms a Declare method and confirms the name of the
828 exchange, essential for automatically-named exchanges.
829
830 """
831 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
832
833 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
834 index: typing.ClassVar[int] = 0x0028000B # pamqp Mapping Index
835 name: typing.ClassVar[str] = 'Exchange.DeclareOk'
836 synchronous: typing.ClassVar[
837 bool] = False # Indicates if this is a synchronous AMQP method
838
839 class Delete(base.Frame):
840 """Delete an exchange
841
842 This method deletes an exchange. When an exchange is deleted all queue
843 bindings on the exchange are cancelled.
844
845 :param ticket: Deprecated, must be ``0``
846 - Default: ``0``
847 :param exchange: exchange name
848 - Default: ``''``
849 :param if_unused: Delete only if unused
850 - Default: ``False``
851 :param nowait: Do not send a reply method
852 - Default: ``False``
853 :raises ValueError: when an argument fails to validate
854
855 """
856 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
857 'ticket', 'exchange', 'if_unused', 'nowait'
858 ]
859
860 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
861 index: typing.ClassVar[int] = 0x00280014 # pamqp Mapping Index
862 name: typing.ClassVar[str] = 'Exchange.Delete'
863 synchronous: typing.ClassVar[
864 bool] = True # Indicates if this is a synchronous AMQP method
865 # Valid responses to this method
866 valid_responses: typing.ClassVar[list[str]] = ['Exchange.DeleteOk']
867
868 # Class Attribute Types for unmarshaling
869 _ticket = 'short'
870 _exchange = 'shortstr'
871 _if_unused = 'bit'
872 _nowait = 'bit'
873
874 def __init__(self,
875 ticket: int = 0,
876 exchange: str = '',
877 if_unused: bool = False,
878 nowait: bool = False) -> None:
879 """Initialize the :class:`Exchange.Delete` class"""
880 self.ticket = ticket
881 self.exchange = exchange
882 self.if_unused = if_unused
883 self.nowait = nowait
884 self.validate()
885
886 def validate(self) -> None:
887 """Validate the frame data ensuring all domains or attributes
888 adhere to the protocol specification.
889
890 :raises ValueError: on validation error
891
892 """
893 if self.ticket is not None and self.ticket != 0:
894 raise ValueError('ticket must be 0')
895 if self.exchange is not None and len(self.exchange) > 127:
896 raise ValueError('Max length exceeded for exchange')
897 if self.exchange is not None and not constants.DOMAIN_REGEX[
898 'exchange-name'].fullmatch(self.exchange):
899 raise ValueError('Invalid value for exchange')
900
901 class DeleteOk(base.Frame):
902 """Confirm deletion of an exchange
903
904 This method confirms the deletion of an exchange.
905
906 """
907 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
908
909 frame_id: typing.ClassVar[int] = 21 # AMQP Frame ID
910 index: typing.ClassVar[int] = 0x00280015 # pamqp Mapping Index
911 name: typing.ClassVar[str] = 'Exchange.DeleteOk'
912 synchronous: typing.ClassVar[
913 bool] = False # Indicates if this is a synchronous AMQP method
914
915 class Bind(base.Frame):
916 """Bind exchange to an exchange
917
918 This method binds an exchange to an exchange.
919
920 :param ticket: Deprecated, must be ``0``
921 - Default: ``0``
922 :param destination: Name of the destination exchange to bind to
923 - Default: ``''``
924 :param source: Name of the source exchange to bind to
925 - Default: ``''``
926 :param routing_key: Message routing key
927 - Default: ``''``
928 :param nowait: Do not send a reply method
929 - Default: ``False``
930 :param arguments: Arguments for binding
931 - Default: ``{}``
932 :type arguments: :const:`~pamqp.common.Arguments`
933 :raises ValueError: when an argument fails to validate
934
935 """
936 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
937 'ticket', 'destination', 'source', 'routing_key', 'nowait',
938 'arguments'
939 ]
940
941 frame_id: typing.ClassVar[int] = 30 # AMQP Frame ID
942 index: typing.ClassVar[int] = 0x0028001E # pamqp Mapping Index
943 name: typing.ClassVar[str] = 'Exchange.Bind'
944 synchronous: typing.ClassVar[
945 bool] = True # Indicates if this is a synchronous AMQP method
946 # Valid responses to this method
947 valid_responses: typing.ClassVar[list[str]] = ['Exchange.BindOk']
948
949 # Class Attribute Types for unmarshaling
950 _ticket = 'short'
951 _destination = 'shortstr'
952 _source = 'shortstr'
953 _routing_key = 'shortstr'
954 _nowait = 'bit'
955 _arguments = 'table'
956
957 def __init__(self,
958 ticket: int = 0,
959 destination: str = '',
960 source: str = '',
961 routing_key: str = '',
962 nowait: bool = False,
963 arguments: common.Arguments | None = None) -> None:
964 """Initialize the :class:`Exchange.Bind` class"""
965 self.ticket = ticket
966 self.destination = destination
967 self.source = source
968 self.routing_key = routing_key
969 self.nowait = nowait
970 self.arguments = arguments or {}
971 self.validate()
972
973 def validate(self) -> None:
974 """Validate the frame data ensuring all domains or attributes
975 adhere to the protocol specification.
976
977 :raises ValueError: on validation error
978
979 """
980 if self.ticket is not None and self.ticket != 0:
981 raise ValueError('ticket must be 0')
982 if self.destination is not None and len(self.destination) > 127:
983 raise ValueError('Max length exceeded for destination')
984 if self.destination is not None and not constants.DOMAIN_REGEX[
985 'exchange-name'].fullmatch(self.destination):
986 raise ValueError('Invalid value for destination')
987 if self.source is not None and len(self.source) > 127:
988 raise ValueError('Max length exceeded for source')
989 if self.source is not None and not constants.DOMAIN_REGEX[
990 'exchange-name'].fullmatch(self.source):
991 raise ValueError('Invalid value for source')
992
993 class BindOk(base.Frame):
994 """Confirm bind successful
995
996 This method confirms that the bind was successful.
997
998 """
999 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
1000
1001 frame_id: typing.ClassVar[int] = 31 # AMQP Frame ID
1002 index: typing.ClassVar[int] = 0x0028001F # pamqp Mapping Index
1003 name: typing.ClassVar[str] = 'Exchange.BindOk'
1004 synchronous: typing.ClassVar[
1005 bool] = False # Indicates if this is a synchronous AMQP method
1006
1007 class Unbind(base.Frame):
1008 """Unbind an exchange from an exchange
1009
1010 This method unbinds an exchange from an exchange.
1011
1012 :param ticket: Deprecated, must be ``0``
1013 - Default: ``0``
1014 :param destination: Specifies the name of the destination exchange to
1015 unbind.
1016 - Default: ``''``
1017 :param source: Specifies the name of the source exchange to unbind.
1018 - Default: ``''``
1019 :param routing_key: Routing key of binding
1020 - Default: ``''``
1021 :param nowait: Do not send a reply method
1022 - Default: ``False``
1023 :param arguments: Arguments of binding
1024 - Default: ``{}``
1025 :type arguments: :const:`~pamqp.common.Arguments`
1026 :raises ValueError: when an argument fails to validate
1027
1028 """
1029 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1030 'ticket', 'destination', 'source', 'routing_key', 'nowait',
1031 'arguments'
1032 ]
1033
1034 frame_id: typing.ClassVar[int] = 40 # AMQP Frame ID
1035 index: typing.ClassVar[int] = 0x00280028 # pamqp Mapping Index
1036 name: typing.ClassVar[str] = 'Exchange.Unbind'
1037 synchronous: typing.ClassVar[
1038 bool] = True # Indicates if this is a synchronous AMQP method
1039 # Valid responses to this method
1040 valid_responses: typing.ClassVar[list[str]] = ['Exchange.UnbindOk']
1041
1042 # Class Attribute Types for unmarshaling
1043 _ticket = 'short'
1044 _destination = 'shortstr'
1045 _source = 'shortstr'
1046 _routing_key = 'shortstr'
1047 _nowait = 'bit'
1048 _arguments = 'table'
1049
1050 def __init__(self,
1051 ticket: int = 0,
1052 destination: str = '',
1053 source: str = '',
1054 routing_key: str = '',
1055 nowait: bool = False,
1056 arguments: common.Arguments | None = None) -> None:
1057 """Initialize the :class:`Exchange.Unbind` class"""
1058 self.ticket = ticket
1059 self.destination = destination
1060 self.source = source
1061 self.routing_key = routing_key
1062 self.nowait = nowait
1063 self.arguments = arguments or {}
1064 self.validate()
1065
1066 def validate(self) -> None:
1067 """Validate the frame data ensuring all domains or attributes
1068 adhere to the protocol specification.
1069
1070 :raises ValueError: on validation error
1071
1072 """
1073 if self.ticket is not None and self.ticket != 0:
1074 raise ValueError('ticket must be 0')
1075 if self.destination is not None and len(self.destination) > 127:
1076 raise ValueError('Max length exceeded for destination')
1077 if self.destination is not None and not constants.DOMAIN_REGEX[
1078 'exchange-name'].fullmatch(self.destination):
1079 raise ValueError('Invalid value for destination')
1080 if self.source is not None and len(self.source) > 127:
1081 raise ValueError('Max length exceeded for source')
1082 if self.source is not None and not constants.DOMAIN_REGEX[
1083 'exchange-name'].fullmatch(self.source):
1084 raise ValueError('Invalid value for source')
1085
1086 class UnbindOk(base.Frame):
1087 """Confirm unbind successful
1088
1089 This method confirms that the unbind was successful.
1090
1091 """
1092 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
1093
1094 frame_id: typing.ClassVar[int] = 51 # AMQP Frame ID
1095 index: typing.ClassVar[int] = 0x00280033 # pamqp Mapping Index
1096 name: typing.ClassVar[str] = 'Exchange.UnbindOk'
1097 synchronous: typing.ClassVar[
1098 bool] = False # Indicates if this is a synchronous AMQP method
1099
1100
1101 class Queue:
1102 """Work with queues
1103
1104 Queues store and forward messages. Queues can be configured in the server
1105 or created at runtime. Queues must be attached to at least one exchange in
1106 order to receive messages from publishers.
1107
1108 """
1109 __slots__: typing.ClassVar[list[str]] = []
1110
1111 frame_id: typing.ClassVar[int] = 50 # AMQP Frame ID
1112 index: typing.ClassVar[int] = 0x00320000 # pamqp Mapping Index
1113
1114 class Declare(base.Frame):
1115 """Declare queue, create if needed
1116
1117 This method creates or checks a queue. When creating a new queue the
1118 client can specify various properties that control the durability of
1119 the queue and its contents, and the level of sharing for the queue.
1120
1121 :param ticket: Deprecated, must be ``0``
1122 - Default: ``0``
1123 :param queue: queue name
1124 - Default: ``''``
1125 :param passive: Do not create queue
1126 - Default: ``False``
1127 :param durable: Request a durable queue
1128 - Default: ``False``
1129 :param exclusive: Request an exclusive queue
1130 - Default: ``False``
1131 :param auto_delete: Auto-delete queue when unused
1132 - Default: ``False``
1133 :param nowait: Do not send a reply method
1134 - Default: ``False``
1135 :param arguments: Arguments for declaration
1136 - Default: ``{}``
1137 :type arguments: :const:`~pamqp.common.Arguments`
1138 :raises ValueError: when an argument fails to validate
1139
1140 """
1141 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1142 'ticket', 'queue', 'passive', 'durable', 'exclusive',
1143 'auto_delete', 'nowait', 'arguments'
1144 ]
1145
1146 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
1147 index: typing.ClassVar[int] = 0x0032000A # pamqp Mapping Index
1148 name: typing.ClassVar[str] = 'Queue.Declare'
1149 synchronous: typing.ClassVar[
1150 bool] = True # Indicates if this is a synchronous AMQP method
1151 # Valid responses to this method
1152 valid_responses: typing.ClassVar[list[str]] = ['Queue.DeclareOk']
1153
1154 # Class Attribute Types for unmarshaling
1155 _ticket = 'short'
1156 _queue = 'shortstr'
1157 _passive = 'bit'
1158 _durable = 'bit'
1159 _exclusive = 'bit'
1160 _auto_delete = 'bit'
1161 _nowait = 'bit'
1162 _arguments = 'table'
1163
1164 def __init__(self,
1165 ticket: int = 0,
1166 queue: str = '',
1167 passive: bool = False,
1168 durable: bool = False,
1169 exclusive: bool = False,
1170 auto_delete: bool = False,
1171 nowait: bool = False,
1172 arguments: common.Arguments | None = None) -> None:
1173 """Initialize the :class:`Queue.Declare` class"""
1174 self.ticket = ticket
1175 self.queue = queue
1176 self.passive = passive
1177 self.durable = durable
1178 self.exclusive = exclusive
1179 self.auto_delete = auto_delete
1180 self.nowait = nowait
1181 self.arguments = arguments or {}
1182 self.validate()
1183
1184 def validate(self) -> None:
1185 """Validate the frame data ensuring all domains or attributes
1186 adhere to the protocol specification.
1187
1188 :raises ValueError: on validation error
1189
1190 """
1191 if self.ticket is not None and self.ticket != 0:
1192 raise ValueError('ticket must be 0')
1193 if self.queue is not None and len(self.queue) > 256:
1194 raise ValueError('Max length exceeded for queue')
1195 if self.queue is not None and not constants.DOMAIN_REGEX[
1196 'queue-name'].fullmatch(self.queue):
1197 raise ValueError('Invalid value for queue')
1198
1199 class DeclareOk(base.Frame):
1200 """Confirms a queue definition
1201
1202 This method confirms a Declare method and confirms the name of the
1203 queue, essential for automatically-named queues.
1204
1205 :param queue: Reports the name of the queue. If the server generated a
1206 queue name, this field contains that name.
1207 :param message_count: Number of messages in queue
1208 :param consumer_count: Number of consumers
1209 :raises ValueError: when an argument fails to validate
1210
1211 """
1212 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1213 'queue', 'message_count', 'consumer_count'
1214 ]
1215
1216 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
1217 index: typing.ClassVar[int] = 0x0032000B # pamqp Mapping Index
1218 name: typing.ClassVar[str] = 'Queue.DeclareOk'
1219 synchronous: typing.ClassVar[
1220 bool] = False # Indicates if this is a synchronous AMQP method
1221
1222 # Class Attribute Types for unmarshaling
1223 _queue = 'shortstr'
1224 _message_count = 'long'
1225 _consumer_count = 'long'
1226
1227 def __init__(self,
1228 queue: str | None = None,
1229 message_count: int | None = None,
1230 consumer_count: int | None = None) -> None:
1231 """Initialize the :class:`Queue.DeclareOk` class"""
1232 self.queue = queue
1233 self.message_count = message_count
1234 self.consumer_count = consumer_count
1235 self.validate()
1236
1237 def validate(self) -> None:
1238 """Validate the frame data ensuring all domains or attributes
1239 adhere to the protocol specification.
1240
1241 :raises ValueError: on validation error
1242
1243 """
1244 if self.queue is not None and len(self.queue) > 256:
1245 raise ValueError('Max length exceeded for queue')
1246 if self.queue is not None and not constants.DOMAIN_REGEX[
1247 'queue-name'].fullmatch(self.queue):
1248 raise ValueError('Invalid value for queue')
1249
1250 class Bind(base.Frame):
1251 """Bind queue to an exchange
1252
1253 This method binds a queue to an exchange. Until a queue is bound it
1254 will not receive any messages. In a classic messaging model, store-and-
1255 forward queues are bound to a direct exchange and subscription queues
1256 are bound to a topic exchange.
1257
1258 :param ticket: Deprecated, must be ``0``
1259 - Default: ``0``
1260 :param queue: Specifies the name of the queue to bind.
1261 - Default: ``''``
1262 :param exchange: Name of the exchange to bind to
1263 - Default: ``''``
1264 :param routing_key: Message routing key
1265 - Default: ``''``
1266 :param nowait: Do not send a reply method
1267 - Default: ``False``
1268 :param arguments: Arguments for binding
1269 - Default: ``{}``
1270 :type arguments: :const:`~pamqp.common.Arguments`
1271 :raises ValueError: when an argument fails to validate
1272
1273 """
1274 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1275 'ticket', 'queue', 'exchange', 'routing_key', 'nowait', 'arguments'
1276 ]
1277
1278 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
1279 index: typing.ClassVar[int] = 0x00320014 # pamqp Mapping Index
1280 name: typing.ClassVar[str] = 'Queue.Bind'
1281 synchronous: typing.ClassVar[
1282 bool] = True # Indicates if this is a synchronous AMQP method
1283 # Valid responses to this method
1284 valid_responses: typing.ClassVar[list[str]] = ['Queue.BindOk']
1285
1286 # Class Attribute Types for unmarshaling
1287 _ticket = 'short'
1288 _queue = 'shortstr'
1289 _exchange = 'shortstr'
1290 _routing_key = 'shortstr'
1291 _nowait = 'bit'
1292 _arguments = 'table'
1293
1294 def __init__(self,
1295 ticket: int = 0,
1296 queue: str = '',
1297 exchange: str = '',
1298 routing_key: str = '',
1299 nowait: bool = False,
1300 arguments: common.Arguments | None = None) -> None:
1301 """Initialize the :class:`Queue.Bind` class"""
1302 self.ticket = ticket
1303 self.queue = queue
1304 self.exchange = exchange
1305 self.routing_key = routing_key
1306 self.nowait = nowait
1307 self.arguments = arguments or {}
1308 self.validate()
1309
1310 def validate(self) -> None:
1311 """Validate the frame data ensuring all domains or attributes
1312 adhere to the protocol specification.
1313
1314 :raises ValueError: on validation error
1315
1316 """
1317 if self.ticket is not None and self.ticket != 0:
1318 raise ValueError('ticket must be 0')
1319 if self.queue is not None and len(self.queue) > 256:
1320 raise ValueError('Max length exceeded for queue')
1321 if self.queue is not None and not constants.DOMAIN_REGEX[
1322 'queue-name'].fullmatch(self.queue):
1323 raise ValueError('Invalid value for queue')
1324 if self.exchange is not None and len(self.exchange) > 127:
1325 raise ValueError('Max length exceeded for exchange')
1326 if self.exchange is not None and not constants.DOMAIN_REGEX[
1327 'exchange-name'].fullmatch(self.exchange):
1328 raise ValueError('Invalid value for exchange')
1329
1330 class BindOk(base.Frame):
1331 """Confirm bind successful
1332
1333 This method confirms that the bind was successful.
1334
1335 """
1336 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
1337
1338 frame_id: typing.ClassVar[int] = 21 # AMQP Frame ID
1339 index: typing.ClassVar[int] = 0x00320015 # pamqp Mapping Index
1340 name: typing.ClassVar[str] = 'Queue.BindOk'
1341 synchronous: typing.ClassVar[
1342 bool] = False # Indicates if this is a synchronous AMQP method
1343
1344 class Purge(base.Frame):
1345 """Purge a queue
1346
1347 This method removes all messages from a queue which are not awaiting
1348 acknowledgment.
1349
1350 :param ticket: Deprecated, must be ``0``
1351 - Default: ``0``
1352 :param queue: Specifies the name of the queue to purge.
1353 - Default: ``''``
1354 :param nowait: Do not send a reply method
1355 - Default: ``False``
1356 :raises ValueError: when an argument fails to validate
1357
1358 """
1359 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1360 'ticket', 'queue', 'nowait'
1361 ]
1362
1363 frame_id: typing.ClassVar[int] = 30 # AMQP Frame ID
1364 index: typing.ClassVar[int] = 0x0032001E # pamqp Mapping Index
1365 name: typing.ClassVar[str] = 'Queue.Purge'
1366 synchronous: typing.ClassVar[
1367 bool] = True # Indicates if this is a synchronous AMQP method
1368 # Valid responses to this method
1369 valid_responses: typing.ClassVar[list[str]] = ['Queue.PurgeOk']
1370
1371 # Class Attribute Types for unmarshaling
1372 _ticket = 'short'
1373 _queue = 'shortstr'
1374 _nowait = 'bit'
1375
1376 def __init__(self,
1377 ticket: int = 0,
1378 queue: str = '',
1379 nowait: bool = False) -> None:
1380 """Initialize the :class:`Queue.Purge` class"""
1381 self.ticket = ticket
1382 self.queue = queue
1383 self.nowait = nowait
1384 self.validate()
1385
1386 def validate(self) -> None:
1387 """Validate the frame data ensuring all domains or attributes
1388 adhere to the protocol specification.
1389
1390 :raises ValueError: on validation error
1391
1392 """
1393 if self.ticket is not None and self.ticket != 0:
1394 raise ValueError('ticket must be 0')
1395 if self.queue is not None and len(self.queue) > 256:
1396 raise ValueError('Max length exceeded for queue')
1397 if self.queue is not None and not constants.DOMAIN_REGEX[
1398 'queue-name'].fullmatch(self.queue):
1399 raise ValueError('Invalid value for queue')
1400
1401 class PurgeOk(base.Frame):
1402 """Confirms a queue purge
1403
1404 This method confirms the purge of a queue.
1405
1406 :param message_count: Reports the number of messages purged.
1407
1408 """
1409 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1410 'message_count'
1411 ]
1412
1413 frame_id: typing.ClassVar[int] = 31 # AMQP Frame ID
1414 index: typing.ClassVar[int] = 0x0032001F # pamqp Mapping Index
1415 name: typing.ClassVar[str] = 'Queue.PurgeOk'
1416 synchronous: typing.ClassVar[
1417 bool] = False # Indicates if this is a synchronous AMQP method
1418
1419 # Class Attribute Types for unmarshaling
1420 _message_count = 'long'
1421
1422 def __init__(self, message_count: int | None = None) -> None:
1423 """Initialize the :class:`Queue.PurgeOk` class"""
1424 self.message_count = message_count
1425
1426 class Delete(base.Frame):
1427 """Delete a queue
1428
1429 This method deletes a queue. When a queue is deleted any pending
1430 messages are sent to a dead-letter queue if this is defined in the
1431 server configuration, and all consumers on the queue are cancelled.
1432
1433 :param ticket: Deprecated, must be ``0``
1434 - Default: ``0``
1435 :param queue: Specifies the name of the queue to delete.
1436 - Default: ``''``
1437 :param if_unused: Delete only if unused
1438 - Default: ``False``
1439 :param if_empty: Delete only if empty
1440 - Default: ``False``
1441 :param nowait: Do not send a reply method
1442 - Default: ``False``
1443 :raises ValueError: when an argument fails to validate
1444
1445 """
1446 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1447 'ticket', 'queue', 'if_unused', 'if_empty', 'nowait'
1448 ]
1449
1450 frame_id: typing.ClassVar[int] = 40 # AMQP Frame ID
1451 index: typing.ClassVar[int] = 0x00320028 # pamqp Mapping Index
1452 name: typing.ClassVar[str] = 'Queue.Delete'
1453 synchronous: typing.ClassVar[
1454 bool] = True # Indicates if this is a synchronous AMQP method
1455 # Valid responses to this method
1456 valid_responses: typing.ClassVar[list[str]] = ['Queue.DeleteOk']
1457
1458 # Class Attribute Types for unmarshaling
1459 _ticket = 'short'
1460 _queue = 'shortstr'
1461 _if_unused = 'bit'
1462 _if_empty = 'bit'
1463 _nowait = 'bit'
1464
1465 def __init__(self,
1466 ticket: int = 0,
1467 queue: str = '',
1468 if_unused: bool = False,
1469 if_empty: bool = False,
1470 nowait: bool = False) -> None:
1471 """Initialize the :class:`Queue.Delete` class"""
1472 self.ticket = ticket
1473 self.queue = queue
1474 self.if_unused = if_unused
1475 self.if_empty = if_empty
1476 self.nowait = nowait
1477 self.validate()
1478
1479 def validate(self) -> None:
1480 """Validate the frame data ensuring all domains or attributes
1481 adhere to the protocol specification.
1482
1483 :raises ValueError: on validation error
1484
1485 """
1486 if self.ticket is not None and self.ticket != 0:
1487 raise ValueError('ticket must be 0')
1488 if self.queue is not None and len(self.queue) > 256:
1489 raise ValueError('Max length exceeded for queue')
1490 if self.queue is not None and not constants.DOMAIN_REGEX[
1491 'queue-name'].fullmatch(self.queue):
1492 raise ValueError('Invalid value for queue')
1493
1494 class DeleteOk(base.Frame):
1495 """Confirm deletion of a queue
1496
1497 This method confirms the deletion of a queue.
1498
1499 :param message_count: Reports the number of messages deleted.
1500
1501 """
1502 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1503 'message_count'
1504 ]
1505
1506 frame_id: typing.ClassVar[int] = 41 # AMQP Frame ID
1507 index: typing.ClassVar[int] = 0x00320029 # pamqp Mapping Index
1508 name: typing.ClassVar[str] = 'Queue.DeleteOk'
1509 synchronous: typing.ClassVar[
1510 bool] = False # Indicates if this is a synchronous AMQP method
1511
1512 # Class Attribute Types for unmarshaling
1513 _message_count = 'long'
1514
1515 def __init__(self, message_count: int | None = None) -> None:
1516 """Initialize the :class:`Queue.DeleteOk` class"""
1517 self.message_count = message_count
1518
1519 class Unbind(base.Frame):
1520 """Unbind a queue from an exchange
1521
1522 This method unbinds a queue from an exchange.
1523
1524 :param ticket: Deprecated, must be ``0``
1525 - Default: ``0``
1526 :param queue: Specifies the name of the queue to unbind.
1527 - Default: ``''``
1528 :param exchange: The name of the exchange to unbind from.
1529 - Default: ``''``
1530 :param routing_key: Routing key of binding
1531 - Default: ``''``
1532 :param arguments: Arguments of binding
1533 - Default: ``{}``
1534 :type arguments: :const:`~pamqp.common.Arguments`
1535 :raises ValueError: when an argument fails to validate
1536
1537 """
1538 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1539 'ticket', 'queue', 'exchange', 'routing_key', 'arguments'
1540 ]
1541
1542 frame_id: typing.ClassVar[int] = 50 # AMQP Frame ID
1543 index: typing.ClassVar[int] = 0x00320032 # pamqp Mapping Index
1544 name: typing.ClassVar[str] = 'Queue.Unbind'
1545 synchronous: typing.ClassVar[
1546 bool] = True # Indicates if this is a synchronous AMQP method
1547 # Valid responses to this method
1548 valid_responses: typing.ClassVar[list[str]] = ['Queue.UnbindOk']
1549
1550 # Class Attribute Types for unmarshaling
1551 _ticket = 'short'
1552 _queue = 'shortstr'
1553 _exchange = 'shortstr'
1554 _routing_key = 'shortstr'
1555 _arguments = 'table'
1556
1557 def __init__(self,
1558 ticket: int = 0,
1559 queue: str = '',
1560 exchange: str = '',
1561 routing_key: str = '',
1562 arguments: common.Arguments | None = None) -> None:
1563 """Initialize the :class:`Queue.Unbind` class"""
1564 self.ticket = ticket
1565 self.queue = queue
1566 self.exchange = exchange
1567 self.routing_key = routing_key
1568 self.arguments = arguments or {}
1569 self.validate()
1570
1571 def validate(self) -> None:
1572 """Validate the frame data ensuring all domains or attributes
1573 adhere to the protocol specification.
1574
1575 :raises ValueError: on validation error
1576
1577 """
1578 if self.ticket is not None and self.ticket != 0:
1579 raise ValueError('ticket must be 0')
1580 if self.queue is not None and len(self.queue) > 256:
1581 raise ValueError('Max length exceeded for queue')
1582 if self.queue is not None and not constants.DOMAIN_REGEX[
1583 'queue-name'].fullmatch(self.queue):
1584 raise ValueError('Invalid value for queue')
1585 if self.exchange is not None and len(self.exchange) > 127:
1586 raise ValueError('Max length exceeded for exchange')
1587 if self.exchange is not None and not constants.DOMAIN_REGEX[
1588 'exchange-name'].fullmatch(self.exchange):
1589 raise ValueError('Invalid value for exchange')
1590
1591 class UnbindOk(base.Frame):
1592 """Confirm unbind successful
1593
1594 This method confirms that the unbind was successful.
1595
1596 """
1597 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
1598
1599 frame_id: typing.ClassVar[int] = 51 # AMQP Frame ID
1600 index: typing.ClassVar[int] = 0x00320033 # pamqp Mapping Index
1601 name: typing.ClassVar[str] = 'Queue.UnbindOk'
1602 synchronous: typing.ClassVar[
1603 bool] = False # Indicates if this is a synchronous AMQP method
1604
1605
1606 class Basic:
1607 """Work with basic content
1608
1609 The Basic class provides methods that support an industry-standard
1610 messaging model.
1611
1612 """
1613 __slots__: typing.ClassVar[list[str]] = []
1614
1615 frame_id: typing.ClassVar[int] = 60 # AMQP Frame ID
1616 index: typing.ClassVar[int] = 0x003C0000 # pamqp Mapping Index
1617
1618 class Qos(base.Frame):
1619 """Specify quality of service
1620
1621 This method requests a specific quality of service. The QoS can be
1622 specified for the current channel or for all channels on the
1623 connection. The particular properties and semantics of a qos method
1624 always depend on the content class semantics. Though the qos method
1625 could in principle apply to both peers, it is currently meaningful only
1626 for the server.
1627
1628 :param prefetch_size: Prefetch window in octets
1629 - Default: ``0``
1630 :param prefetch_count: Prefetch window in messages
1631 - Default: ``0``
1632 :param global_: Apply to entire connection
1633 - Default: ``False``
1634
1635 """
1636 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1637 'prefetch_size', 'prefetch_count', 'global_'
1638 ]
1639
1640 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
1641 index: typing.ClassVar[int] = 0x003C000A # pamqp Mapping Index
1642 name: typing.ClassVar[str] = 'Basic.Qos'
1643 synchronous: typing.ClassVar[
1644 bool] = True # Indicates if this is a synchronous AMQP method
1645 # Valid responses to this method
1646 valid_responses: typing.ClassVar[list[str]] = ['Basic.QosOk']
1647
1648 # Class Attribute Types for unmarshaling
1649 _prefetch_size = 'long'
1650 _prefetch_count = 'short'
1651 _global_ = 'bit'
1652
1653 def __init__(self,
1654 prefetch_size: int = 0,
1655 prefetch_count: int = 0,
1656 global_: bool = False) -> None:
1657 """Initialize the :class:`Basic.Qos` class"""
1658 self.prefetch_size = prefetch_size
1659 self.prefetch_count = prefetch_count
1660 self.global_ = global_
1661
1662 class QosOk(base.Frame):
1663 """Confirm the requested qos
1664
1665 This method tells the client that the requested QoS levels could be
1666 handled by the server. The requested QoS applies to all active
1667 consumers until a new QoS is defined.
1668
1669 """
1670 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
1671
1672 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
1673 index: typing.ClassVar[int] = 0x003C000B # pamqp Mapping Index
1674 name: typing.ClassVar[str] = 'Basic.QosOk'
1675 synchronous: typing.ClassVar[
1676 bool] = False # Indicates if this is a synchronous AMQP method
1677
1678 class Consume(base.Frame):
1679 """Start a queue consumer
1680
1681 This method asks the server to start a "consumer", which is a transient
1682 request for messages from a specific queue. Consumers last as long as
1683 the channel they were declared on, or until the client cancels them.
1684
1685 :param ticket: Deprecated, must be ``0``
1686 - Default: ``0``
1687 :param queue: Specifies the name of the queue to consume from.
1688 - Default: ``''``
1689 :param consumer_tag: Specifies the identifier for the consumer. The
1690 consumer tag is local to a channel, so two clients can use the same
1691 consumer tags. If this field is empty the server will generate a
1692 unique tag.
1693 - Default: ``''``
1694 :param no_local: Do not deliver own messages
1695 - Default: ``False``
1696 :param no_ack: No acknowledgement needed
1697 - Default: ``False``
1698 :param exclusive: Request exclusive access
1699 - Default: ``False``
1700 :param nowait: Do not send a reply method
1701 - Default: ``False``
1702 :param arguments: Arguments for declaration
1703 - Default: ``{}``
1704 :type arguments: :const:`~pamqp.common.Arguments`
1705 :raises ValueError: when an argument fails to validate
1706
1707 """
1708 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1709 'ticket', 'queue', 'consumer_tag', 'no_local', 'no_ack',
1710 'exclusive', 'nowait', 'arguments'
1711 ]
1712
1713 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
1714 index: typing.ClassVar[int] = 0x003C0014 # pamqp Mapping Index
1715 name: typing.ClassVar[str] = 'Basic.Consume'
1716 synchronous: typing.ClassVar[
1717 bool] = True # Indicates if this is a synchronous AMQP method
1718 # Valid responses to this method
1719 valid_responses: typing.ClassVar[list[str]] = ['Basic.ConsumeOk']
1720
1721 # Class Attribute Types for unmarshaling
1722 _ticket = 'short'
1723 _queue = 'shortstr'
1724 _consumer_tag = 'shortstr'
1725 _no_local = 'bit'
1726 _no_ack = 'bit'
1727 _exclusive = 'bit'
1728 _nowait = 'bit'
1729 _arguments = 'table'
1730
1731 def __init__(self,
1732 ticket: int = 0,
1733 queue: str = '',
1734 consumer_tag: str = '',
1735 no_local: bool = False,
1736 no_ack: bool = False,
1737 exclusive: bool = False,
1738 nowait: bool = False,
1739 arguments: common.Arguments | None = None) -> None:
1740 """Initialize the :class:`Basic.Consume` class"""
1741 self.ticket = ticket
1742 self.queue = queue
1743 self.consumer_tag = consumer_tag
1744 self.no_local = no_local
1745 self.no_ack = no_ack
1746 self.exclusive = exclusive
1747 self.nowait = nowait
1748 self.arguments = arguments or {}
1749 self.validate()
1750
1751 def validate(self) -> None:
1752 """Validate the frame data ensuring all domains or attributes
1753 adhere to the protocol specification.
1754
1755 :raises ValueError: on validation error
1756
1757 """
1758 if self.ticket is not None and self.ticket != 0:
1759 raise ValueError('ticket must be 0')
1760 if self.queue is not None and len(self.queue) > 256:
1761 raise ValueError('Max length exceeded for queue')
1762 if self.queue is not None and not constants.DOMAIN_REGEX[
1763 'queue-name'].fullmatch(self.queue):
1764 raise ValueError('Invalid value for queue')
1765
1766 class ConsumeOk(base.Frame):
1767 """Confirm a new consumer
1768
1769 The server provides the client with a consumer tag, which is used by
1770 the client for methods called on the consumer at a later stage.
1771
1772 :param consumer_tag: Holds the consumer tag specified by the client or
1773 provided by the server.
1774
1775 """
1776 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1777 'consumer_tag'
1778 ]
1779
1780 frame_id: typing.ClassVar[int] = 21 # AMQP Frame ID
1781 index: typing.ClassVar[int] = 0x003C0015 # pamqp Mapping Index
1782 name: typing.ClassVar[str] = 'Basic.ConsumeOk'
1783 synchronous: typing.ClassVar[
1784 bool] = False # Indicates if this is a synchronous AMQP method
1785
1786 # Class Attribute Types for unmarshaling
1787 _consumer_tag = 'shortstr'
1788
1789 def __init__(self, consumer_tag: str | None = None) -> None:
1790 """Initialize the :class:`Basic.ConsumeOk` class"""
1791 self.consumer_tag = consumer_tag
1792
1793 class Cancel(base.Frame):
1794 """End a queue consumer
1795
1796 This method cancels a consumer. This does not affect already delivered
1797 messages, but it does mean the server will not send any more messages
1798 for that consumer. The client may receive an arbitrary number of
1799 messages in between sending the cancel method and receiving the cancel-
1800 ok reply. It may also be sent from the server to the client in the
1801 event of the consumer being unexpectedly cancelled (i.e. cancelled for
1802 any reason other than the server receiving the corresponding
1803 basic.cancel from the client). This allows clients to be notified of
1804 the loss of consumers due to events such as queue deletion. Note that
1805 as it is not a MUST for clients to accept this method from the server,
1806 it is advisable for the broker to be able to identify those clients
1807 that are capable of accepting the method, through some means of
1808 capability negotiation.
1809
1810 :param consumer_tag: Consumer tag
1811 :param nowait: Do not send a reply method
1812 - Default: ``False``
1813
1814 """
1815 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1816 'consumer_tag', 'nowait'
1817 ]
1818
1819 frame_id: typing.ClassVar[int] = 30 # AMQP Frame ID
1820 index: typing.ClassVar[int] = 0x003C001E # pamqp Mapping Index
1821 name: typing.ClassVar[str] = 'Basic.Cancel'
1822 synchronous: typing.ClassVar[
1823 bool] = True # Indicates if this is a synchronous AMQP method
1824 # Valid responses to this method
1825 valid_responses: typing.ClassVar[list[str]] = ['Basic.CancelOk']
1826
1827 # Class Attribute Types for unmarshaling
1828 _consumer_tag = 'shortstr'
1829 _nowait = 'bit'
1830
1831 def __init__(self,
1832 consumer_tag: str | None = None,
1833 nowait: bool = False) -> None:
1834 """Initialize the :class:`Basic.Cancel` class"""
1835 self.consumer_tag = consumer_tag
1836 self.nowait = nowait if nowait is not None else False
1837
1838 class CancelOk(base.Frame):
1839 """Confirm a cancelled consumer
1840
1841 This method confirms that the cancellation was completed.
1842
1843 :param consumer_tag: Consumer tag
1844
1845 """
1846 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1847 'consumer_tag'
1848 ]
1849
1850 frame_id: typing.ClassVar[int] = 31 # AMQP Frame ID
1851 index: typing.ClassVar[int] = 0x003C001F # pamqp Mapping Index
1852 name: typing.ClassVar[str] = 'Basic.CancelOk'
1853 synchronous: typing.ClassVar[
1854 bool] = False # Indicates if this is a synchronous AMQP method
1855
1856 # Class Attribute Types for unmarshaling
1857 _consumer_tag = 'shortstr'
1858
1859 def __init__(self, consumer_tag: str | None = None) -> None:
1860 """Initialize the :class:`Basic.CancelOk` class"""
1861 self.consumer_tag = consumer_tag
1862
1863 class Publish(base.Frame):
1864 """Publish a message
1865
1866 This method publishes a message to a specific exchange. The message
1867 will be routed to queues as defined by the exchange configuration and
1868 distributed to any active consumers when the transaction, if any, is
1869 committed.
1870
1871 :param ticket: Deprecated, must be ``0``
1872 - Default: ``0``
1873 :param exchange: Specifies the name of the exchange to publish to. The
1874 exchange name can be empty, meaning the default exchange. If the
1875 exchange name is specified, and that exchange does not exist, the
1876 server will raise a channel exception.
1877 - Default: ``''``
1878 :param routing_key: Message routing key
1879 - Default: ``''``
1880 :param mandatory: Indicate mandatory routing
1881 - Default: ``False``
1882 :param immediate: Request immediate delivery
1883 - Default: ``False``
1884 :raises ValueError: when an argument fails to validate
1885
1886 """
1887 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1888 'ticket', 'exchange', 'routing_key', 'mandatory', 'immediate'
1889 ]
1890
1891 frame_id: typing.ClassVar[int] = 40 # AMQP Frame ID
1892 index: typing.ClassVar[int] = 0x003C0028 # pamqp Mapping Index
1893 name: typing.ClassVar[str] = 'Basic.Publish'
1894 synchronous: typing.ClassVar[
1895 bool] = False # Indicates if this is a synchronous AMQP method
1896
1897 # Class Attribute Types for unmarshaling
1898 _ticket = 'short'
1899 _exchange = 'shortstr'
1900 _routing_key = 'shortstr'
1901 _mandatory = 'bit'
1902 _immediate = 'bit'
1903
1904 def __init__(self,
1905 ticket: int = 0,
1906 exchange: str = '',
1907 routing_key: str = '',
1908 mandatory: bool = False,
1909 immediate: bool = False) -> None:
1910 """Initialize the :class:`Basic.Publish` class"""
1911 self.ticket = ticket
1912 self.exchange = exchange
1913 self.routing_key = routing_key
1914 self.mandatory = mandatory
1915 self.immediate = immediate
1916 self.validate()
1917
1918 def validate(self) -> None:
1919 """Validate the frame data ensuring all domains or attributes
1920 adhere to the protocol specification.
1921
1922 :raises ValueError: on validation error
1923
1924 """
1925 if self.ticket is not None and self.ticket != 0:
1926 raise ValueError('ticket must be 0')
1927 if self.exchange is not None and len(self.exchange) > 127:
1928 raise ValueError('Max length exceeded for exchange')
1929 if self.exchange is not None and not constants.DOMAIN_REGEX[
1930 'exchange-name'].fullmatch(self.exchange):
1931 raise ValueError('Invalid value for exchange')
1932
1933 class Return(base.Frame):
1934 """Return a failed message
1935
1936 This method returns an undeliverable message that was published with
1937 the "immediate" flag set, or an unroutable message published with the
1938 "mandatory" flag set. The reply code and text provide information about
1939 the reason that the message was undeliverable.
1940
1941 :param reply_code: Reply code from server
1942 :param reply_text: Localised reply text
1943 - Default: ``''``
1944 :param exchange: Specifies the name of the exchange that the message
1945 was originally published to. May be empty, meaning the default
1946 exchange.
1947 - Default: ``''``
1948 :param routing_key: Message routing key
1949 :raises ValueError: when an argument fails to validate
1950
1951 """
1952 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
1953 'reply_code', 'reply_text', 'exchange', 'routing_key'
1954 ]
1955
1956 frame_id: typing.ClassVar[int] = 50 # AMQP Frame ID
1957 index: typing.ClassVar[int] = 0x003C0032 # pamqp Mapping Index
1958 name: typing.ClassVar[str] = 'Basic.Return'
1959 synchronous: typing.ClassVar[
1960 bool] = False # Indicates if this is a synchronous AMQP method
1961
1962 # Class Attribute Types for unmarshaling
1963 _reply_code = 'short'
1964 _reply_text = 'shortstr'
1965 _exchange = 'shortstr'
1966 _routing_key = 'shortstr'
1967
1968 def __init__(self,
1969 reply_code: int | None = None,
1970 reply_text: str = '',
1971 exchange: str = '',
1972 routing_key: str | None = None) -> None:
1973 """Initialize the :class:`Basic.Return` class"""
1974 self.reply_code = reply_code
1975 self.reply_text = reply_text or ''
1976 self.exchange = exchange or ''
1977 self.routing_key = routing_key
1978 self.validate()
1979
1980 def validate(self) -> None:
1981 """Validate the frame data ensuring all domains or attributes
1982 adhere to the protocol specification.
1983
1984 :raises ValueError: on validation error
1985
1986 """
1987 if self.exchange is not None and len(self.exchange) > 127:
1988 raise ValueError('Max length exceeded for exchange')
1989 if self.exchange is not None and not constants.DOMAIN_REGEX[
1990 'exchange-name'].fullmatch(self.exchange):
1991 raise ValueError('Invalid value for exchange')
1992
1993 class Deliver(base.Frame):
1994 """Notify the client of a consumer message
1995
1996 This method delivers a message to the client, via a consumer. In the
1997 asynchronous message delivery model, the client starts a consumer using
1998 the Consume method, then the server responds with Deliver methods as
1999 and when messages arrive for that consumer.
2000
2001 :param consumer_tag: Consumer tag
2002 :param delivery_tag: Server-assigned delivery tag
2003 :param redelivered: Message is being redelivered
2004 - Default: ``False``
2005 :param exchange: Specifies the name of the exchange that the message
2006 was originally published to. May be empty, indicating the default
2007 exchange.
2008 - Default: ``''``
2009 :param routing_key: Message routing key
2010 :raises ValueError: when an argument fails to validate
2011
2012 """
2013 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2014 'consumer_tag', 'delivery_tag', 'redelivered', 'exchange',
2015 'routing_key'
2016 ]
2017
2018 frame_id: typing.ClassVar[int] = 60 # AMQP Frame ID
2019 index: typing.ClassVar[int] = 0x003C003C # pamqp Mapping Index
2020 name: typing.ClassVar[str] = 'Basic.Deliver'
2021 synchronous: typing.ClassVar[
2022 bool] = False # Indicates if this is a synchronous AMQP method
2023
2024 # Class Attribute Types for unmarshaling
2025 _consumer_tag = 'shortstr'
2026 _delivery_tag = 'longlong'
2027 _redelivered = 'bit'
2028 _exchange = 'shortstr'
2029 _routing_key = 'shortstr'
2030
2031 def __init__(self,
2032 consumer_tag: str | None = None,
2033 delivery_tag: int | None = None,
2034 redelivered: bool = False,
2035 exchange: str = '',
2036 routing_key: str | None = None) -> None:
2037 """Initialize the :class:`Basic.Deliver` class"""
2038 self.consumer_tag = consumer_tag
2039 self.delivery_tag = delivery_tag
2040 self.redelivered = redelivered if redelivered is not None else False
2041 self.exchange = exchange or ''
2042 self.routing_key = routing_key
2043 self.validate()
2044
2045 def validate(self) -> None:
2046 """Validate the frame data ensuring all domains or attributes
2047 adhere to the protocol specification.
2048
2049 :raises ValueError: on validation error
2050
2051 """
2052 if self.exchange is not None and len(self.exchange) > 127:
2053 raise ValueError('Max length exceeded for exchange')
2054 if self.exchange is not None and not constants.DOMAIN_REGEX[
2055 'exchange-name'].fullmatch(self.exchange):
2056 raise ValueError('Invalid value for exchange')
2057
2058 class Get(base.Frame):
2059 """Direct access to a queue
2060
2061 This method provides a direct access to the messages in a queue using a
2062 synchronous dialogue that is designed for specific types of application
2063 where synchronous functionality is more important than performance.
2064
2065 :param ticket: Deprecated, must be ``0``
2066 - Default: ``0``
2067 :param queue: Specifies the name of the queue to get a message from.
2068 - Default: ``''``
2069 :param no_ack: No acknowledgement needed
2070 - Default: ``False``
2071 :raises ValueError: when an argument fails to validate
2072
2073 """
2074 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2075 'ticket', 'queue', 'no_ack'
2076 ]
2077
2078 frame_id: typing.ClassVar[int] = 70 # AMQP Frame ID
2079 index: typing.ClassVar[int] = 0x003C0046 # pamqp Mapping Index
2080 name: typing.ClassVar[str] = 'Basic.Get'
2081 synchronous: typing.ClassVar[
2082 bool] = True # Indicates if this is a synchronous AMQP method
2083 # Valid responses to this method
2084 valid_responses: typing.ClassVar[list[str]] = [
2085 'Basic.GetOk', 'Basic.GetEmpty'
2086 ]
2087
2088 # Class Attribute Types for unmarshaling
2089 _ticket = 'short'
2090 _queue = 'shortstr'
2091 _no_ack = 'bit'
2092
2093 def __init__(self,
2094 ticket: int = 0,
2095 queue: str = '',
2096 no_ack: bool = False) -> None:
2097 """Initialize the :class:`Basic.Get` class"""
2098 self.ticket = ticket
2099 self.queue = queue
2100 self.no_ack = no_ack
2101 self.validate()
2102
2103 def validate(self) -> None:
2104 """Validate the frame data ensuring all domains or attributes
2105 adhere to the protocol specification.
2106
2107 :raises ValueError: on validation error
2108
2109 """
2110 if self.ticket is not None and self.ticket != 0:
2111 raise ValueError('ticket must be 0')
2112 if self.queue is not None and len(self.queue) > 256:
2113 raise ValueError('Max length exceeded for queue')
2114 if self.queue is not None and not constants.DOMAIN_REGEX[
2115 'queue-name'].fullmatch(self.queue):
2116 raise ValueError('Invalid value for queue')
2117
2118 class GetOk(base.Frame):
2119 """Provide client with a message
2120
2121 This method delivers a message to the client following a get method. A
2122 message delivered by 'get-ok' must be acknowledged unless the no-ack
2123 option was set in the get method.
2124
2125 :param delivery_tag: Server-assigned delivery tag
2126 :param redelivered: Message is being redelivered
2127 - Default: ``False``
2128 :param exchange: Specifies the name of the exchange that the message
2129 was originally published to. If empty, the message was published to
2130 the default exchange.
2131 - Default: ``''``
2132 :param routing_key: Message routing key
2133 :param message_count: Number of messages in queue
2134 :raises ValueError: when an argument fails to validate
2135
2136 """
2137 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2138 'delivery_tag', 'redelivered', 'exchange', 'routing_key',
2139 'message_count'
2140 ]
2141
2142 frame_id: typing.ClassVar[int] = 71 # AMQP Frame ID
2143 index: typing.ClassVar[int] = 0x003C0047 # pamqp Mapping Index
2144 name: typing.ClassVar[str] = 'Basic.GetOk'
2145 synchronous: typing.ClassVar[
2146 bool] = False # Indicates if this is a synchronous AMQP method
2147
2148 # Class Attribute Types for unmarshaling
2149 _delivery_tag = 'longlong'
2150 _redelivered = 'bit'
2151 _exchange = 'shortstr'
2152 _routing_key = 'shortstr'
2153 _message_count = 'long'
2154
2155 def __init__(self,
2156 delivery_tag: int | None = None,
2157 redelivered: bool = False,
2158 exchange: str = '',
2159 routing_key: str | None = None,
2160 message_count: int | None = None) -> None:
2161 """Initialize the :class:`Basic.GetOk` class"""
2162 self.delivery_tag = delivery_tag
2163 self.redelivered = redelivered if redelivered is not None else False
2164 self.exchange = exchange or ''
2165 self.routing_key = routing_key
2166 self.message_count = message_count
2167 self.validate()
2168
2169 def validate(self) -> None:
2170 """Validate the frame data ensuring all domains or attributes
2171 adhere to the protocol specification.
2172
2173 :raises ValueError: on validation error
2174
2175 """
2176 if self.exchange is not None and len(self.exchange) > 127:
2177 raise ValueError('Max length exceeded for exchange')
2178 if self.exchange is not None and not constants.DOMAIN_REGEX[
2179 'exchange-name'].fullmatch(self.exchange):
2180 raise ValueError('Invalid value for exchange')
2181
2182 class GetEmpty(base.Frame):
2183 """Indicate no messages available
2184
2185 This method tells the client that the queue has no messages available
2186 for the client.
2187
2188 :param cluster_id: Deprecated, must be empty
2189 - Default: ``''``
2190
2191 """
2192 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2193 'cluster_id'
2194 ]
2195
2196 frame_id: typing.ClassVar[int] = 72 # AMQP Frame ID
2197 index: typing.ClassVar[int] = 0x003C0048 # pamqp Mapping Index
2198 name: typing.ClassVar[str] = 'Basic.GetEmpty'
2199 synchronous: typing.ClassVar[
2200 bool] = False # Indicates if this is a synchronous AMQP method
2201
2202 # Class Attribute Types for unmarshaling
2203 _cluster_id = 'shortstr'
2204
2205 def __init__(self, cluster_id: str = '') -> None:
2206 """Initialize the :class:`Basic.GetEmpty` class"""
2207 self.cluster_id = cluster_id
2208 self.validate()
2209
2210 def validate(self) -> None:
2211 """Validate the frame data ensuring all domains or attributes
2212 adhere to the protocol specification.
2213
2214 :raises ValueError: on validation error
2215
2216 """
2217 if self.cluster_id is not None and self.cluster_id != '':
2218 raise ValueError('cluster_id must be empty')
2219
2220 class Ack(base.Frame):
2221 """Acknowledge one or more messages
2222
2223 When sent by the client, this method acknowledges one or more messages
2224 delivered via the Deliver or Get-Ok methods. When sent by server, this
2225 method acknowledges one or more messages published with the Publish
2226 method on a channel in confirm mode. The acknowledgement can be for a
2227 single message or a set of messages up to and including a specific
2228 message.
2229
2230 :param delivery_tag: Server-assigned delivery tag
2231 - Default: ``0``
2232 :param multiple: Acknowledge multiple messages
2233 - Default: ``False``
2234
2235 """
2236 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2237 'delivery_tag', 'multiple'
2238 ]
2239
2240 frame_id: typing.ClassVar[int] = 80 # AMQP Frame ID
2241 index: typing.ClassVar[int] = 0x003C0050 # pamqp Mapping Index
2242 name: typing.ClassVar[str] = 'Basic.Ack'
2243 synchronous: typing.ClassVar[
2244 bool] = False # Indicates if this is a synchronous AMQP method
2245
2246 # Class Attribute Types for unmarshaling
2247 _delivery_tag = 'longlong'
2248 _multiple = 'bit'
2249
2250 def __init__(self,
2251 delivery_tag: int = 0,
2252 multiple: bool = False) -> None:
2253 """Initialize the :class:`Basic.Ack` class"""
2254 self.delivery_tag = delivery_tag
2255 self.multiple = multiple
2256
2257 class Reject(base.Frame):
2258 """Reject an incoming message
2259
2260 This method allows a client to reject a message. It can be used to
2261 interrupt and cancel large incoming messages, or return untreatable
2262 messages to their original queue.
2263
2264 :param delivery_tag: Server-assigned delivery tag
2265 :param requeue: Requeue the message
2266 - Default: ``True``
2267
2268 """
2269 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2270 'delivery_tag', 'requeue'
2271 ]
2272
2273 frame_id: typing.ClassVar[int] = 90 # AMQP Frame ID
2274 index: typing.ClassVar[int] = 0x003C005A # pamqp Mapping Index
2275 name: typing.ClassVar[str] = 'Basic.Reject'
2276 synchronous: typing.ClassVar[
2277 bool] = False # Indicates if this is a synchronous AMQP method
2278
2279 # Class Attribute Types for unmarshaling
2280 _delivery_tag = 'longlong'
2281 _requeue = 'bit'
2282
2283 def __init__(self,
2284 delivery_tag: int | None = None,
2285 requeue: bool = True) -> None:
2286 """Initialize the :class:`Basic.Reject` class"""
2287 self.delivery_tag = delivery_tag
2288 self.requeue = requeue if requeue is not None else True
2289
2290 class RecoverAsync(base.Frame):
2291 """Redeliver unacknowledged messages
2292
2293 This method asks the server to redeliver all unacknowledged messages on
2294 a specified channel. Zero or more messages may be redelivered. This
2295 method is deprecated in favour of the synchronous Recover/Recover-Ok.
2296
2297 .. deprecated:: This command is deprecated in AMQP 0-9-1
2298
2299 :param requeue: Requeue the message
2300 - Default: ``False``
2301
2302 """
2303 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2304 'requeue'
2305 ]
2306
2307 frame_id: typing.ClassVar[int] = 100 # AMQP Frame ID
2308 index: typing.ClassVar[int] = 0x003C0064 # pamqp Mapping Index
2309 name: typing.ClassVar[str] = 'Basic.RecoverAsync'
2310 synchronous: typing.ClassVar[
2311 bool] = False # Indicates if this is a synchronous AMQP method
2312
2313 # Class Attribute Types for unmarshaling
2314 _requeue = 'bit'
2315
2316 def __init__(self, requeue: bool = False) -> None:
2317 """Initialize the :class:`Basic.RecoverAsync` class"""
2318 self.requeue = requeue
2319 warnings.warn(constants.DEPRECATION_WARNING,
2320 category=DeprecationWarning)
2321
2322 class Recover(base.Frame):
2323 """Redeliver unacknowledged messages
2324
2325 This method asks the server to redeliver all unacknowledged messages on
2326 a specified channel. Zero or more messages may be redelivered. This
2327 method replaces the asynchronous Recover.
2328
2329 :param requeue: Requeue the message
2330 - Default: ``False``
2331
2332 """
2333 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2334 'requeue'
2335 ]
2336
2337 frame_id: typing.ClassVar[int] = 110 # AMQP Frame ID
2338 index: typing.ClassVar[int] = 0x003C006E # pamqp Mapping Index
2339 name: typing.ClassVar[str] = 'Basic.Recover'
2340 synchronous: typing.ClassVar[
2341 bool] = True # Indicates if this is a synchronous AMQP method
2342 # Valid responses to this method
2343 valid_responses: typing.ClassVar[list[str]] = ['Basic.RecoverOk']
2344
2345 # Class Attribute Types for unmarshaling
2346 _requeue = 'bit'
2347
2348 def __init__(self, requeue: bool = False) -> None:
2349 """Initialize the :class:`Basic.Recover` class"""
2350 self.requeue = requeue
2351
2352 class RecoverOk(base.Frame):
2353 """Confirm recovery
2354
2355 This method acknowledges a :class:`Basic.Recover` method.
2356
2357 """
2358 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2359
2360 frame_id: typing.ClassVar[int] = 111 # AMQP Frame ID
2361 index: typing.ClassVar[int] = 0x003C006F # pamqp Mapping Index
2362 name: typing.ClassVar[str] = 'Basic.RecoverOk'
2363 synchronous: typing.ClassVar[
2364 bool] = False # Indicates if this is a synchronous AMQP method
2365
2366 class Nack(base.Frame):
2367 """Reject one or more incoming messages
2368
2369 This method allows a client to reject one or more incoming messages. It
2370 can be used to interrupt and cancel large incoming messages, or return
2371 untreatable messages to their original queue. This method is also used
2372 by the server to inform publishers on channels in confirm mode of
2373 unhandled messages. If a publisher receives this method, it probably
2374 needs to republish the offending messages.
2375
2376 :param delivery_tag: Server-assigned delivery tag
2377 - Default: ``0``
2378 :param multiple: Reject multiple messages
2379 - Default: ``False``
2380 :param requeue: Requeue the message
2381 - Default: ``True``
2382
2383 """
2384 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2385 'delivery_tag', 'multiple', 'requeue'
2386 ]
2387
2388 frame_id: typing.ClassVar[int] = 120 # AMQP Frame ID
2389 index: typing.ClassVar[int] = 0x003C0078 # pamqp Mapping Index
2390 name: typing.ClassVar[str] = 'Basic.Nack'
2391 synchronous: typing.ClassVar[
2392 bool] = False # Indicates if this is a synchronous AMQP method
2393
2394 # Class Attribute Types for unmarshaling
2395 _delivery_tag = 'longlong'
2396 _multiple = 'bit'
2397 _requeue = 'bit'
2398
2399 def __init__(self,
2400 delivery_tag: int = 0,
2401 multiple: bool = False,
2402 requeue: bool = True) -> None:
2403 """Initialize the :class:`Basic.Nack` class"""
2404 self.delivery_tag = delivery_tag
2405 self.multiple = multiple
2406 self.requeue = requeue
2407
2408 class Properties(base.BasicProperties):
2409 """Content Properties
2410
2411 .. Note:: The AMQP property type is named ``message_type`` as to not
2412 conflict with the Python ``type`` keyword
2413
2414 :param content_type: MIME content type
2415 :param content_encoding: MIME content encoding
2416 :param headers: Message header field table
2417 :type headers: typing.Optional[:const:`~pamqp.common.FieldTable`]
2418 :param delivery_mode: Non-persistent (1) or persistent (2)
2419 :param priority: Message priority, 0 to 9
2420 :param correlation_id: Application correlation identifier
2421 :param reply_to: Address to reply to
2422 :param expiration: Message expiration specification
2423 :param message_id: Application message identifier
2424 :param timestamp: Message timestamp
2425 :param message_type: Message type name
2426 :param user_id: Creating user id
2427 :param app_id: Creating application id
2428 :param cluster_id: Deprecated, must be empty
2429 :raises: ValueError
2430
2431 """
2432 __slots__: typing.ClassVar[list[str]] = [ # AMQ Properties Attributes
2433 'content_type', 'content_encoding', 'headers', 'delivery_mode',
2434 'priority', 'correlation_id', 'reply_to', 'expiration',
2435 'message_id', 'timestamp', 'message_type', 'user_id', 'app_id',
2436 'cluster_id'
2437 ]
2438
2439 # Flag values for marshaling / unmarshaling
2440 flags: typing.ClassVar[dict[str, int]] = {
2441 'content_type': 32768,
2442 'content_encoding': 16384,
2443 'headers': 8192,
2444 'delivery_mode': 4096,
2445 'priority': 2048,
2446 'correlation_id': 1024,
2447 'reply_to': 512,
2448 'expiration': 256,
2449 'message_id': 128,
2450 'timestamp': 64,
2451 'message_type': 32,
2452 'user_id': 16,
2453 'app_id': 8,
2454 'cluster_id': 4
2455 }
2456
2457 frame_id: typing.ClassVar[int] = 60 # AMQP Frame ID
2458 index: typing.ClassVar[int] = 0x003C # pamqp Mapping Index
2459 name: typing.ClassVar[str] = 'Basic.Properties'
2460
2461 # Class Attribute Types for unmarshaling
2462 _content_type = 'shortstr'
2463 _content_encoding = 'shortstr'
2464 _headers = 'table'
2465 _delivery_mode = 'octet'
2466 _priority = 'octet'
2467 _correlation_id = 'shortstr'
2468 _reply_to = 'shortstr'
2469 _expiration = 'shortstr'
2470 _message_id = 'shortstr'
2471 _timestamp = 'timestamp'
2472 _message_type = 'shortstr'
2473 _user_id = 'shortstr'
2474 _app_id = 'shortstr'
2475 _cluster_id = 'shortstr'
2476
2477 def __init__(self,
2478 content_type: str | None = None,
2479 content_encoding: str | None = None,
2480 headers: common.FieldTable | None = None,
2481 delivery_mode: int | None = None,
2482 priority: int | None = None,
2483 correlation_id: str | None = None,
2484 reply_to: str | None = None,
2485 expiration: str | None = None,
2486 message_id: str | None = None,
2487 timestamp: datetime.datetime | None = None,
2488 message_type: str | None = None,
2489 user_id: str | None = None,
2490 app_id: str | None = None,
2491 cluster_id: str = '') -> None:
2492 """Initialize the Basic.Properties class"""
2493 self.content_type = content_type
2494 self.content_encoding = content_encoding
2495 self.headers = headers
2496 self.delivery_mode = delivery_mode
2497 self.priority = priority
2498 self.correlation_id = correlation_id
2499 self.reply_to = reply_to
2500 self.expiration = expiration
2501 self.message_id = message_id
2502 self.timestamp = timestamp
2503 self.message_type = message_type
2504 self.user_id = user_id
2505 self.app_id = app_id
2506 self.cluster_id = cluster_id
2507 self.validate()
2508
2509
2510 class Tx:
2511 """Work with transactions
2512
2513 The Tx class allows publish and ack operations to be batched into atomic
2514 units of work. The intention is that all publish and ack requests issued
2515 within a transaction will complete successfully or none of them will.
2516 Servers SHOULD implement atomic transactions at least where all publish or
2517 ack requests affect a single queue. Transactions that cover multiple
2518 queues may be non-atomic, given that queues can be created and destroyed
2519 asynchronously, and such events do not form part of any transaction.
2520 Further, the behaviour of transactions with respect to the immediate and
2521 mandatory flags on :class:`Basic.Publish` methods is not defined.
2522
2523 """
2524 __slots__: typing.ClassVar[list[str]] = []
2525
2526 frame_id: typing.ClassVar[int] = 90 # AMQP Frame ID
2527 index: typing.ClassVar[int] = 0x005A0000 # pamqp Mapping Index
2528
2529 class Select(base.Frame):
2530 """Select standard transaction mode
2531
2532 This method sets the channel to use standard transactions. The client
2533 must use this method at least once on a channel before using the Commit
2534 or Rollback methods.
2535
2536 """
2537 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2538
2539 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
2540 index: typing.ClassVar[int] = 0x005A000A # pamqp Mapping Index
2541 name: typing.ClassVar[str] = 'Tx.Select'
2542 synchronous: typing.ClassVar[
2543 bool] = True # Indicates if this is a synchronous AMQP method
2544 # Valid responses to this method
2545 valid_responses: typing.ClassVar[list[str]] = ['Tx.SelectOk']
2546
2547 class SelectOk(base.Frame):
2548 """Confirm transaction mode
2549
2550 This method confirms to the client that the channel was successfully
2551 set to use standard transactions.
2552
2553 """
2554 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2555
2556 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
2557 index: typing.ClassVar[int] = 0x005A000B # pamqp Mapping Index
2558 name: typing.ClassVar[str] = 'Tx.SelectOk'
2559 synchronous: typing.ClassVar[
2560 bool] = False # Indicates if this is a synchronous AMQP method
2561
2562 class Commit(base.Frame):
2563 """Commit the current transaction
2564
2565 This method commits all message publications and acknowledgments
2566 performed in the current transaction. A new transaction starts
2567 immediately after a commit.
2568
2569 """
2570 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2571
2572 frame_id: typing.ClassVar[int] = 20 # AMQP Frame ID
2573 index: typing.ClassVar[int] = 0x005A0014 # pamqp Mapping Index
2574 name: typing.ClassVar[str] = 'Tx.Commit'
2575 synchronous: typing.ClassVar[
2576 bool] = True # Indicates if this is a synchronous AMQP method
2577 # Valid responses to this method
2578 valid_responses: typing.ClassVar[list[str]] = ['Tx.CommitOk']
2579
2580 class CommitOk(base.Frame):
2581 """Confirm a successful commit
2582
2583 This method confirms to the client that the commit succeeded. Note that
2584 if a commit fails, the server raises a channel exception.
2585
2586 """
2587 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2588
2589 frame_id: typing.ClassVar[int] = 21 # AMQP Frame ID
2590 index: typing.ClassVar[int] = 0x005A0015 # pamqp Mapping Index
2591 name: typing.ClassVar[str] = 'Tx.CommitOk'
2592 synchronous: typing.ClassVar[
2593 bool] = False # Indicates if this is a synchronous AMQP method
2594
2595 class Rollback(base.Frame):
2596 """Abandon the current transaction
2597
2598 This method abandons all message publications and acknowledgments
2599 performed in the current transaction. A new transaction starts
2600 immediately after a rollback. Note that unacked messages will not be
2601 automatically redelivered by rollback; if that is required an explicit
2602 recover call should be issued.
2603
2604 """
2605 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2606
2607 frame_id: typing.ClassVar[int] = 30 # AMQP Frame ID
2608 index: typing.ClassVar[int] = 0x005A001E # pamqp Mapping Index
2609 name: typing.ClassVar[str] = 'Tx.Rollback'
2610 synchronous: typing.ClassVar[
2611 bool] = True # Indicates if this is a synchronous AMQP method
2612 # Valid responses to this method
2613 valid_responses: typing.ClassVar[list[str]] = ['Tx.RollbackOk']
2614
2615 class RollbackOk(base.Frame):
2616 """Confirm successful rollback
2617
2618 This method confirms to the client that the rollback succeeded. Note
2619 that if an rollback fails, the server raises a channel exception.
2620
2621 """
2622 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2623
2624 frame_id: typing.ClassVar[int] = 31 # AMQP Frame ID
2625 index: typing.ClassVar[int] = 0x005A001F # pamqp Mapping Index
2626 name: typing.ClassVar[str] = 'Tx.RollbackOk'
2627 synchronous: typing.ClassVar[
2628 bool] = False # Indicates if this is a synchronous AMQP method
2629
2630
2631 class Confirm:
2632 """Work with confirms
2633
2634 The Confirm class allows publishers to put the channel in confirm mode and
2635 subsequently be notified when messages have been handled by the broker.
2636 The intention is that all messages published on a channel in confirm mode
2637 will be acknowledged at some point. By acknowledging a message the broker
2638 assumes responsibility for it and indicates that it has done something it
2639 deems reasonable with it. Unroutable mandatory or immediate messages are
2640 acknowledged right after the :class:`Basic.Return` method. Messages are
2641 acknowledged when all queues to which the message has been routed have
2642 either delivered the message and received an acknowledgement (if required),
2643 or enqueued the message (and persisted it if required). Published messages
2644 are assigned ascending sequence numbers, starting at 1 with the first
2645 :class:`Confirm.Select` method. The server confirms messages by sending
2646 :class:`Basic.Ack` methods referring to these sequence numbers.
2647
2648 """
2649 __slots__: typing.ClassVar[list[str]] = []
2650
2651 frame_id: typing.ClassVar[int] = 85 # AMQP Frame ID
2652 index: typing.ClassVar[int] = 0x00550000 # pamqp Mapping Index
2653
2654 class Select(base.Frame):
2655 """Select confirm mode (i.e. enable publisher acknowledgements)
2656
2657 This method sets the channel to use publisher acknowledgements. The
2658 client can only use this method on a non-transactional channel.
2659
2660 :param nowait: Do not send a reply method
2661 - Default: ``False``
2662
2663 """
2664 __slots__: typing.ClassVar[list[str]] = [ # AMQ Method Attributes
2665 'nowait'
2666 ]
2667
2668 frame_id: typing.ClassVar[int] = 10 # AMQP Frame ID
2669 index: typing.ClassVar[int] = 0x0055000A # pamqp Mapping Index
2670 name: typing.ClassVar[str] = 'Confirm.Select'
2671 synchronous: typing.ClassVar[
2672 bool] = True # Indicates if this is a synchronous AMQP method
2673 # Valid responses to this method
2674 valid_responses: typing.ClassVar[list[str]] = ['Confirm.SelectOk']
2675
2676 # Class Attribute Types for unmarshaling
2677 _nowait = 'bit'
2678
2679 def __init__(self, nowait: bool = False) -> None:
2680 """Initialize the :class:`Confirm.Select` class"""
2681 self.nowait = nowait
2682
2683 class SelectOk(base.Frame):
2684 """Acknowledge confirm mode
2685
2686 This method confirms to the client that the channel was successfully
2687 set to use publisher acknowledgements.
2688
2689 """
2690 __slots__: typing.ClassVar[list[str]] = [] # AMQ Method Attributes
2691
2692 frame_id: typing.ClassVar[int] = 11 # AMQP Frame ID
2693 index: typing.ClassVar[int] = 0x0055000B # pamqp Mapping Index
2694 name: typing.ClassVar[str] = 'Confirm.SelectOk'
2695 synchronous: typing.ClassVar[
2696 bool] = False # Indicates if this is a synchronous AMQP method
2697
2698
2699 # AMQP Class.Method Index Mapping
2700 INDEX_MAPPING = {
2701 0x000A000A: Connection.Start,
2702 0x000A000B: Connection.StartOk,
2703 0x000A0014: Connection.Secure,
2704 0x000A0015: Connection.SecureOk,
2705 0x000A001E: Connection.Tune,
2706 0x000A001F: Connection.TuneOk,
2707 0x000A0028: Connection.Open,
2708 0x000A0029: Connection.OpenOk,
2709 0x000A0032: Connection.Close,
2710 0x000A0033: Connection.CloseOk,
2711 0x000A003C: Connection.Blocked,
2712 0x000A003D: Connection.Unblocked,
2713 0x000A0046: Connection.UpdateSecret,
2714 0x000A0047: Connection.UpdateSecretOk,
2715 0x0014000A: Channel.Open,
2716 0x0014000B: Channel.OpenOk,
2717 0x00140014: Channel.Flow,
2718 0x00140015: Channel.FlowOk,
2719 0x00140028: Channel.Close,
2720 0x00140029: Channel.CloseOk,
2721 0x0028000A: Exchange.Declare,
2722 0x0028000B: Exchange.DeclareOk,
2723 0x00280014: Exchange.Delete,
2724 0x00280015: Exchange.DeleteOk,
2725 0x0028001E: Exchange.Bind,
2726 0x0028001F: Exchange.BindOk,
2727 0x00280028: Exchange.Unbind,
2728 0x00280033: Exchange.UnbindOk,
2729 0x0032000A: Queue.Declare,
2730 0x0032000B: Queue.DeclareOk,
2731 0x00320014: Queue.Bind,
2732 0x00320015: Queue.BindOk,
2733 0x0032001E: Queue.Purge,
2734 0x0032001F: Queue.PurgeOk,
2735 0x00320028: Queue.Delete,
2736 0x00320029: Queue.DeleteOk,
2737 0x00320032: Queue.Unbind,
2738 0x00320033: Queue.UnbindOk,
2739 0x003C000A: Basic.Qos,
2740 0x003C000B: Basic.QosOk,
2741 0x003C0014: Basic.Consume,
2742 0x003C0015: Basic.ConsumeOk,
2743 0x003C001E: Basic.Cancel,
2744 0x003C001F: Basic.CancelOk,
2745 0x003C0028: Basic.Publish,
2746 0x003C0032: Basic.Return,
2747 0x003C003C: Basic.Deliver,
2748 0x003C0046: Basic.Get,
2749 0x003C0047: Basic.GetOk,
2750 0x003C0048: Basic.GetEmpty,
2751 0x003C0050: Basic.Ack,
2752 0x003C005A: Basic.Reject,
2753 0x003C0064: Basic.RecoverAsync,
2754 0x003C006E: Basic.Recover,
2755 0x003C006F: Basic.RecoverOk,
2756 0x003C0078: Basic.Nack,
2757 0x005A000A: Tx.Select,
2758 0x005A000B: Tx.SelectOk,
2759 0x005A0014: Tx.Commit,
2760 0x005A0015: Tx.CommitOk,
2761 0x005A001E: Tx.Rollback,
2762 0x005A001F: Tx.RollbackOk,
2763 0x0055000A: Confirm.Select,
2764 0x0055000B: Confirm.SelectOk
2765 }