Skip to content

Commit bccfc56

Browse files
committed
added additional properties to sb class
1 parent 0ca53b3 commit bccfc56

File tree

4 files changed

+363
-1
lines changed

4 files changed

+363
-1
lines changed

azure/functions/_abc.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ class ServiceBusMessage(abc.ABC):
447447
def get_body(self) -> typing.Union[str, bytes]:
448448
pass
449449

450+
@property
451+
@abc.abstractmethod
452+
def application_properties(self) -> typing.Dict[str, typing.Any]:
453+
pass
454+
450455
@property
451456
@abc.abstractmethod
452457
def content_type(self) -> typing.Optional[str]:
@@ -457,6 +462,16 @@ def content_type(self) -> typing.Optional[str]:
457462
def correlation_id(self) -> typing.Optional[str]:
458463
pass
459464

465+
@property
466+
@abc.abstractmethod
467+
def dead_letter_error_description(self) -> typing.Optional[str]:
468+
pass
469+
470+
@property
471+
@abc.abstractmethod
472+
def dead_letter_reason(self) -> typing.Optional[str]:
473+
pass
474+
460475
@property
461476
@abc.abstractmethod
462477
def dead_letter_source(self) -> typing.Optional[str]:
@@ -467,6 +482,11 @@ def dead_letter_source(self) -> typing.Optional[str]:
467482
def delivery_count(self) -> typing.Optional[int]:
468483
pass
469484

485+
@property
486+
@abc.abstractmethod
487+
def enqueued_sequence_number(self) -> typing.Optional[int]:
488+
pass
489+
470490
@property
471491
@abc.abstractmethod
472492
def enqueued_time_utc(self) -> typing.Optional[datetime.datetime]:
@@ -488,6 +508,11 @@ def expiration_time(self) -> typing.Optional[datetime.datetime]:
488508
def label(self) -> typing.Optional[str]:
489509
pass
490510

511+
@property
512+
@abc.abstractmethod
513+
def locked_until(self) -> typing.Optional[datetime.datetime]:
514+
pass
515+
491516
@property
492517
@abc.abstractmethod
493518
def lock_token(self) -> typing.Optional[str]:
@@ -534,6 +559,16 @@ def sequence_number(self) -> typing.Optional[int]:
534559
def session_id(self) -> typing.Optional[str]:
535560
pass
536561

562+
@property
563+
@abc.abstractmethod
564+
def state(self) -> typing.Optional[int]:
565+
pass
566+
567+
@property
568+
@abc.abstractmethod
569+
def subject(self) -> typing.Optional[str]:
570+
pass
571+
537572
@property
538573
@abc.abstractmethod
539574
def time_to_live(self) -> typing.Optional[datetime.timedelta]:
@@ -544,6 +579,11 @@ def time_to_live(self) -> typing.Optional[datetime.timedelta]:
544579
def to(self) -> typing.Optional[str]:
545580
pass
546581

582+
@property
583+
@abc.abstractmethod
584+
def transaction_partition_key(self) -> typing.Optional[str]:
585+
pass
586+
547587
@property
548588
@abc.abstractmethod
549589
def user_properties(self) -> typing.Dict[str, typing.Any]:

azure/functions/_servicebus.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ def __init__(self, *,
3333
if body is not None:
3434
self.__set_body(body)
3535

36+
@property
37+
def application_properties(self) -> Dict[str, Any]:
38+
"""Gets the application properties bag, which can be used for
39+
custom message metadata.
40+
41+
Returns:
42+
--------
43+
Dict[str, Any]:
44+
If user has set application properties for the message,
45+
returns a dictionary.
46+
If nothing is set, returns an empty dictionary.
47+
"""
48+
return {}
49+
3650
@property
3751
def content_type(self) -> Optional[str]:
3852
"""Optionally describes the payload of the message,
@@ -59,6 +73,30 @@ def correlation_id(self) -> Optional[str]:
5973
"""
6074
return self.__correlation_id
6175

76+
@property
77+
def dead_letter_error_description(self) -> Optional[str]:
78+
"""Optionally describes the dead letter error description for the message.
79+
80+
Returns:
81+
--------
82+
Optional[str]
83+
If dead letter error description is set, returns a string.
84+
Otherwise, returns None.
85+
"""
86+
return None
87+
88+
@property
89+
def dead_letter_reason(self) -> Optional[str]:
90+
"""Optionally describes the dead letter reason description for the message.
91+
92+
Returns:
93+
--------
94+
Optional[str]
95+
If dead letter reason description is set, returns a string.
96+
Otherwise, returns None.
97+
"""
98+
return None
99+
62100
@property
63101
def dead_letter_source(self) -> Optional[str]:
64102
"""Only set in messages that have been dead-lettered and subsequently
@@ -89,6 +127,21 @@ def delivery_count(self) -> Optional[int]:
89127
"""
90128
return None
91129

130+
@property
131+
def enqueued_sequence_number(self) -> Optional[int]:
132+
"""For messages that have been auto-forwarded, this property reflects
133+
the sequence number that had first been assigned to the message at its
134+
original point of submission. This property is read-only. Optionally
135+
describes the enqueued sequence number of the message.
136+
137+
Returns:
138+
--------
139+
Optional[int]
140+
If enqueued sequence number is set, returns an integer.
141+
Otherwise, returns None.
142+
"""
143+
return None
144+
92145
@property
93146
def enqueued_time_utc(self) -> Optional[datetime.datetime]:
94147
"""The UTC instant at which the message has been accepted and stored
@@ -138,6 +191,24 @@ def label(self) -> Optional[str]:
138191
"""
139192
return None
140193

194+
@property
195+
def locked_until(self) -> Optional[datetime.datetime]:
196+
"""For messages retrieved under a lock (peek-lock receive mode, not
197+
pre-settled) this property reflects the UTC instant until which the
198+
message is held locked in the queue/subscription. When the lock
199+
expires, the DeliveryCount is incremented and the message is again
200+
available for retrieval. This property is read-only.Optionally
201+
describes the date and time in UTC until which the message will be
202+
locked in the queue/subscription.
203+
204+
Returns:
205+
--------
206+
Optional[datetime.datetime]
207+
If locked until is set, returns a datetime.
208+
Otherwise, returns None.
209+
"""
210+
return None
211+
141212
@property
142213
def lock_token(self) -> Optional[str]:
143214
""" The lock token is a reference to the lock that is being held by
@@ -267,6 +338,37 @@ def session_id(self) -> Optional[str]:
267338
"""
268339
return None
269340

341+
@property
342+
def state(self) -> Optional[int]:
343+
"""The state of the message can be Active, Deferred, or Scheduled.
344+
Deferred messages have Deferred state, scheduled messages have
345+
Scheduled state, all other messages have Active state. States are
346+
represented by corresponding integer values. Active = 0,
347+
Deferred = 1, Scheduled = 2.
348+
349+
Returns:
350+
--------
351+
Optional[int]
352+
If state is set, returns an integer.
353+
Otherwise, returns None.
354+
"""
355+
return None
356+
357+
@property
358+
def subject(self) -> Optional[str]:
359+
"""This property enables the application to indicate the purpose of the
360+
message to the receiver in a standardized fashion, similar to an email
361+
subject line. The mapped AMQP property is "subject". Optionally
362+
describes the application specific label.
363+
364+
Returns:
365+
--------
366+
Optional[str]
367+
If subject is set, returns a string.
368+
Otherwise, returns None.
369+
"""
370+
return None
371+
270372
@property
271373
def time_to_live(self) -> Optional[datetime.timedelta]:
272374
""" This value is the relative duration after which the message
@@ -300,6 +402,22 @@ def to(self) -> Optional[str]:
300402
"""
301403
return None
302404

405+
@property
406+
def transaction_partition_key(self) -> Optional[str]:
407+
"""If a message is sent via a transfer queue in the scope of a transaction,
408+
this value selects the transfer queue partition: This is functionally
409+
equivalent to PartitionKey and ensures that messages are kept together
410+
and in order as they are transferred. Optionally describes the
411+
partition key. Maximum length is 128 characters.
412+
413+
Returns:
414+
--------
415+
Optional[str]
416+
If transaction partition key is set, returns a string.
417+
Otherwise, returns None.
418+
"""
419+
return None
420+
303421
@property
304422
def user_properties(self) -> Dict[str, Any]:
305423
"""Contains user defined message properties.

0 commit comments

Comments
 (0)