|
| 1 | +from plivo import exceptions |
1 | 2 | from plivo.utils.validators import * |
2 | | -from plivo.xml import ( |
3 | | - PlivoXMLElement, |
4 | | - map_type |
5 | | -) |
| 3 | +from plivo.xml import PlivoXMLElement, map_type |
| 4 | +import six |
6 | 5 |
|
7 | 6 |
|
8 | 7 | class StreamElement(PlivoXMLElement): |
9 | 8 | _name = 'Stream' |
10 | | - _nestable = [ |
11 | | - ] |
| 9 | + _nestable = [] |
| 10 | + |
| 11 | + ALLOWED_AUDIO_TRACKS = ['inbound', 'outbound', 'both'] |
| 12 | + ALLOWED_CALLBACK_METHODS = ['GET', 'POST'] |
| 13 | + |
| 14 | + @property |
| 15 | + def bidirectional(self): |
| 16 | + return self.__bidirectional |
| 17 | + |
| 18 | + @bidirectional.setter |
| 19 | + def bidirectional(self, value): |
| 20 | + if value is not None: |
| 21 | + if not isinstance(value, bool): |
| 22 | + raise exceptions.ValidationError("bidirectional must be a boolean value.") |
| 23 | + self.__bidirectional = value |
| 24 | + |
| 25 | + @validate_args( |
| 26 | + value=[of_type(bool)] |
| 27 | + ) |
| 28 | + def set_bidirectional(self, value): |
| 29 | + self.bidirectional = value |
| 30 | + return self |
| 31 | + |
| 32 | + @property |
| 33 | + def audioTrack(self): |
| 34 | + return self.__audioTrack |
| 35 | + |
| 36 | + @audioTrack.setter |
| 37 | + def audioTrack(self, value): |
| 38 | + if value is not None: |
| 39 | + if value not in self.ALLOWED_AUDIO_TRACKS: |
| 40 | + raise exceptions.ValidationError(f"audioTrack must be one of {self.ALLOWED_AUDIO_TRACKS}.") |
| 41 | + self.__audioTrack = value |
| 42 | + |
| 43 | + @validate_args( |
| 44 | + value=[of_type(str)] |
| 45 | + ) |
| 46 | + def set_audioTrack(self, value): |
| 47 | + self.audioTrack = value |
| 48 | + return self |
| 49 | + |
| 50 | + @property |
| 51 | + def statusCallbackMethod(self): |
| 52 | + return self.__statusCallbackMethod |
| 53 | + |
| 54 | + @statusCallbackMethod.setter |
| 55 | + def statusCallbackMethod(self, value): |
| 56 | + if value is not None: |
| 57 | + if value not in self.ALLOWED_CALLBACK_METHODS: |
| 58 | + raise exceptions.ValidationError(f"statusCallbackMethod must be one of {self.ALLOWED_CALLBACK_METHODS}.") |
| 59 | + self.__statusCallbackMethod = value |
| 60 | + |
| 61 | + @validate_args( |
| 62 | + value=[of_type(str)] |
| 63 | + ) |
| 64 | + def set_statusCallbackMethod(self, value): |
| 65 | + self.statusCallbackMethod = value |
| 66 | + return self |
| 67 | + |
| 68 | + @property |
| 69 | + def keepCallAlive(self): |
| 70 | + return self.__keepCallAlive |
| 71 | + |
| 72 | + @keepCallAlive.setter |
| 73 | + def keepCallAlive(self, value): |
| 74 | + if value is not None: |
| 75 | + if not isinstance(value, bool): |
| 76 | + raise exceptions.ValidationError("keepCallAlive must be a boolean value.") |
| 77 | + self.__keepCallAlive = value |
| 78 | + |
| 79 | + @validate_args( |
| 80 | + value=[of_type(bool)] |
| 81 | + ) |
| 82 | + def set_keepCallAlive(self, value): |
| 83 | + self.keepCallAlive = value |
| 84 | + return self |
12 | 85 |
|
13 | 86 | def __init__( |
14 | 87 | self, |
|
0 commit comments