Exemplo n.º 1
0
 def __init__(self, channel, message):
     """
     `channel` is the channel along which to send `message`.
     """
     _Request.__init__(self, "SendText")
     self['Channel'] = channel
     self['Message'] = message
Exemplo n.º 2
0
 def __init__(self, queue=None):
     """
     Summarizes all queues in the system, unless `queue` is given, which limits the scope to one.
     """
     _Request.__init__(self, "QueueSummary")
     if not queue is None:
         self['Queue'] = queue
Exemplo n.º 3
0
 def __init__(self, interface, queue):
     """
     Removes the device identified by `interface` from the given `queue`.
     """
     _Request.__init__(self, "QueueRemove")
     self['Queue'] = queue
     self['Interface'] = interface
Exemplo n.º 4
0
 def __init__(self, channel, digit):
     """
     `channel` is the channel to be affected, and `digit` is the tone to play.
     """
     _Request.__init__(self, 'PlayDTMF')
     self['Channel'] = channel
     self['Digit'] = str(digit)
Exemplo n.º 5
0
 def __init__(self, channel, user_field):
     """
     `channel` is the channel to be affected, and `user_field` is the value to set.
     """
     _Request.__init__(self, 'SetCDRUserField')
     self['Channel'] = channel
     self['UserField'] = user_field
Exemplo n.º 6
0
 def __init__(self, conference, channel):
     """
     `channel` is the channel to be kicked from `conference`.
     """
     _Request.__init__(self, 'ConfbridgeKick')
     self['Conference'] = conference
     self['Channel'] = channel
Exemplo n.º 7
0
 def __init__(self, dahdi_channel, number):
     """
     `dahdi_channel` is the channel to use and `number` is the number to dial.
     """
     _Request.__init__(self, 'DAHDIDialOffhook')
     self['DAHDIChannel'] = dahdi_channel
     self['Number'] = number
Exemplo n.º 8
0
 def __init__(self, channel, user_field):
     """
     `channel` is the channel to be affected, and `user_field` is the value to set.
     """
     _Request.__init__(self, 'SetCDRUserField')
     self['Channel'] = channel
     self['UserField'] = user_field
Exemplo n.º 9
0
 def __init__(self, family, key):
     """
     `family` and `key` are specifiers to select the value to retrieve.
     """
     _Request.__init__(self, 'DBGet')
     self['Family'] = family
     self['Key'] = key
Exemplo n.º 10
0
 def __init__(self, conference, channel):
     """
     `channel` is the video source in `conference`.
     """
     _Request.__init__(self, 'ConfbridgeSetSingleVideoSource')
     self['Conference'] = conference
     self['Channel'] = channel
Exemplo n.º 11
0
 def __init__(self, channel, digit):
     """
     `channel` is the channel to be affected, and `digit` is the tone to play.
     """
     _Request.__init__(self, "PlayDTMF")
     self["Channel"] = channel
     self["Digit"] = str(digit)
Exemplo n.º 12
0
 def __init__(self, dahdi_channel, number):
     """
     `dahdi_channel` is the channel to use and `number` is the number to dial.
     """
     _Request.__init__(self, "DAHDIDialOffhook")
     self["DAHDIChannel"] = dahdi_channel
     self["Number"] = number
Exemplo n.º 13
0
 def __init__(self, interface, queue):
     """
     Removes the device identified by `interface` from the given `queue`.
     """
     _Request.__init__(self, "QueueRemove")
     self["Queue"] = queue
     self["Interface"] = interface
Exemplo n.º 14
0
 def __init__(self, queue=None):
     """
     Describes all queues in the system, unless `queue` is given, which limits the scope to one.
     """
     _Request.__init__(self, "QueueStatus")
     if not queue is None:
         self["Queue"] = queue
Exemplo n.º 15
0
 def __init__(self, channel, digit):
     """
     `channel` is the channel to be affected, and `digit` is the tone to play.
     """
     _Request.__init__(self, 'PlayDTMF')
     self['Channel'] = channel
     self['Digit'] = str(digit)
Exemplo n.º 16
0
    def __init__(self, username, secret, events=True, challenge=None, authtype=AUTHTYPE_MD5):
        """
        `username` and `secret` are the credentials used to authenticate.
        
        `events` may be set to `False` to prevent unsolicited events from being received. This is
        normally not desireable, so leaving it `True` is usually a good idea.
        
        If given, `challenge` is a challenge string provided by Asterisk after sending a `Challenge`
        action, used with `authtype` to determine how to authenticate. `authtype` is ignored if the
        `challenge` parameter is unset.
        """
        _Request.__init__(self, "Login")
        self["Username"] = username

        if not challenge is None and authtype:
            self["AuthType"] = authtype
            if authtype == AUTHTYPE_MD5:
                self["Key"] = hashlib.md5(challenge + secret).hexdigest()
            else:
                raise ManagerAuthError("Invalid AuthType specified: %(authtype)s" % {"authtype": authtype})
        else:
            self["Secret"] = secret

        if not events:
            self["Events"] = "off"
Exemplo n.º 17
0
 def __init__(self, zap_channel, number):
     """
     `zap_channel` is the channel to use and `number` is the number to dial.
     """
     _Request.__init__(self, 'ZapDialOffhook')
     self['ZapChannel'] = zap_channel
     self['Number'] = number
Exemplo n.º 18
0
 def __init__(self, channel, user_field):
     """
     `channel` is the channel to be affected, and `user_field` is the value to set.
     """
     _Request.__init__(self, "SetCDRUserField")
     self["Channel"] = channel
     self["UserField"] = user_field
Exemplo n.º 19
0
 def __init__(self, conference, channel):
     """
     `channel` is the channel to which MoH should be stopped in `conference`.
     """
     _Request.__init__(self, 'ConfbridgeMoHOff')
     self['Conference'] = conference
     self['Channel'] = channel
Exemplo n.º 20
0
 def __init__(self, dahdi_channel, number):
     """
     `dahdi_channel` is the channel to use and `number` is the number to dial.
     """
     _Request.__init__(self, 'DAHDIDialOffhook')
     self['DAHDIChannel'] = dahdi_channel
     self['Number'] = number
Exemplo n.º 21
0
 def __init__(self, conference=None):
     """
     `conference` is the optional identifier of the bridge.
     """
     _Request.__init__(self, 'MeetmeList')
     if not conference is None:
         self['Conference'] = conference
Exemplo n.º 22
0
 def __init__(self, conference, channel):
     """
     `channel` is the channel to be unmuted in `conference`.
     """
     _Request.__init__(self, 'ConfbridgeUnmute')
     self['Conference'] = conference
     self['Channel'] = channel
Exemplo n.º 23
0
 def __init__(self, family, key):
     """
     `family` and `key` are specifiers to select the value to remove.
     """
     _Request.__init__(self, 'DBDel')
     self['Family'] = family
     self['Key'] = key
Exemplo n.º 24
0
 def __init__(self, username, secret, events=True, challenge=None, authtype=AUTHTYPE_MD5):
     """
     `username` and `secret` are the credentials used to authenticate.
     
     `events` may be set to `False` to prevent unsolicited events from being received. This is
     normally not desireable, so leaving it `True` is usually a good idea.
     
     If given, `challenge` is a challenge string provided by Asterisk after sending a `Challenge`
     action, used with `authtype` to determine how to authenticate. `authtype` is ignored if the
     `challenge` parameter is unset.
     """
     _Request.__init__(self, 'Login')
     self['Username'] = username
     
     if not challenge is None and authtype:
         self['AuthType'] = authtype
         if authtype == AUTHTYPE_MD5:
             self['Key'] = hashlib.md5(challenge + secret).hexdigest()
         else:
             raise ManagerAuthError("Invalid AuthType specified: %(authtype)s" % {
              'authtype': authtype,
             })
     else:
         self['Secret'] = secret
         
     if not events:
         self['Events'] = 'off'
Exemplo n.º 25
0
 def __init__(self, family, key):
     """
     `family` and `key` are specifiers to select the value to retrieve.
     """
     _Request.__init__(self, "DBGet")
     self["Family"] = family
     self["Key"] = key
Exemplo n.º 26
0
 def __init__(self, channel, message):
     """
     `channel` is the channel along which to send `message`.
     """
     _Request.__init__(self, "SendText")
     self["Channel"] = channel
     self["Message"] = message
Exemplo n.º 27
0
 def __init__(self, extension, context):
     """
     `extension` is the extension to be checked and `context` is the container in which it
     resides.
     """
     _Request.__init__(self, 'ExtensionState')
     self['Exten'] = extension
     self['Context'] = context
Exemplo n.º 28
0
 def __init__(self, module=None):
     """
     If given, `module` limits the scope of the reload to a specific module, named without
     extension.
     """
     _Request.__init__(self, "Reload")
     if not module is None:
         self['Module'] = module
Exemplo n.º 29
0
 def __init__(self, extension, context):
     """
     `extension` is the extension to be checked and `context` is the container in which it
     resides.
     """
     _Request.__init__(self, 'ExtensionState')
     self['Exten'] = extension
     self['Context'] = context
Exemplo n.º 30
0
 def __init__(self, family, key=None):
     """
     `family` and `key` (optional) are specifiers to select the values to remove.
     """
     _Request.__init__(self, 'DBDelTree')
     self['Family'] = family
     if not key is None:
         self['Key'] = key
Exemplo n.º 31
0
 def __init__(self, **kwargs):
     """
     Any keyword-arguments passed will be present in the generated event, making this usable as a
     crude form of message-passing between AMI clients.
     """
     _Request.__init__(self, 'UserEvent')
     for (key, value) in kwargs.items():
         self[key] = value
Exemplo n.º 32
0
 def __init__(self, extension, context):
     """
     `extension` is the extension to be checked and `context` is the container in which it
     resides.
     """
     _Request.__init__(self, "ExtensionState")
     self["Exten"] = extension
     self["Context"] = context
Exemplo n.º 33
0
 def __init__(self, family, key, value):
     """
     `family` and `key` are specifiers for where to place `value`.
     """
     _Request.__init__(self, "DBPut")
     self["Family"] = family
     self["Key"] = key
     self["Val"] = value
Exemplo n.º 34
0
 def __init__(self, family, key=None):
     """
     `family` and `key` (optional) are specifiers to select the values to remove.
     """
     _Request.__init__(self, "DBDelTree")
     self["Family"] = family
     if not key is None:
         self["Key"] = key
Exemplo n.º 35
0
 def __init__(self, channel, filename):
     """
     `channel` is the channel to be affected and `filename` is the new target filename, without
     extension, as either an auto-resolved or absolute path.
     """
     _Request.__init__(self, "ChangeMonitor")
     self["Channel"] = channel
     self["File"] = filename
Exemplo n.º 36
0
 def __init__(self, **kwargs):
     """
     Any keyword-arguments passed will be present in the generated event, making this a crude
     form of message-passing.
     """
     _Request.__init__(self, "UserEvent")
     for (key, value) in kwargs.items():
         self[key] = value
Exemplo n.º 37
0
 def __init__(self, channel, filename):
     """
     `channel` is the channel to be affected and `filename` is the new target filename, without
     extension, as either an auto-resolved or absolute path.
     """
     _Request.__init__(self, 'ChangeMonitor')
     self['Channel'] = channel
     self['File'] = filename
Exemplo n.º 38
0
 def __init__(self, channel, seconds=0):
     """
     Causes the call on `channel` to be hung up after `seconds` have elapsed, defaulting to
     disabling auto-hangup.
     """
     _Request.__init__(self, "AbsoluteTimeout")
     self["Channel"] = channel
     self["Timeout"] = str(int(seconds))
Exemplo n.º 39
0
 def __init__(self, family, key, value):
     """
     `family` and `key` are specifiers for where to place `value`.
     """
     _Request.__init__(self, 'DBPut')
     self['Family'] = family
     self['Key'] = key
     self['Val'] = value
Exemplo n.º 40
0
 def __init__(self, module=None):
     """
     If given, `module` limits the scope of the reload to a specific module, named without
     extension.
     """
     _Request.__init__(self, "Reload")
     if not module is None:
         self["Module"] = module
Exemplo n.º 41
0
 def __init__(self, channel, seconds=0):
     """
     Causes the call on `channel` to be hung up after `seconds` have elapsed, defaulting to
     disabling auto-hangup.
     """
     _Request.__init__(self, 'AbsoluteTimeout')
     self['Channel'] = channel
     self['Timeout'] = str(int(seconds))
Exemplo n.º 42
0
 def __init__(self, family, key, value):
     """
     `family` and `key` are specifiers for where to place `value`.
     """
     _Request.__init__(self, 'DBPut')
     self['Family'] = family
     self['Key'] = key
     self['Val'] = value
Exemplo n.º 43
0
 def __init__(self, channel_1, channel_2, tone=False):
     """
     `channel_1` is the channel to which `channel_2` will be connected. `tone`, if `True`, will
     cause a sound to be played on `channel_2`.
     """
     _Request.__init__(self, "Bridge")
     self['Channel1'] = channel_1
     self['Channel2'] = channel_2
     self['Tone'] = tone and 'yes' or 'no'
Exemplo n.º 44
0
 def __init__(self, meetme, usernum):
     """
     `meetme` is the identifier of the bridge and `usernum` is the participant ID of the user to
     be unmuted, which is associated with a channel by the 'MeetmeJoin' event. If successful,
     this request will trigger a 'MeetmeMute' event.
     """
     _Request.__init__(self, 'MeetmeUnmute')
     self['Meetme'] = meetme
     self['Usernum'] = usernum
Exemplo n.º 45
0
 def __init__(self, variable, channel=None):
     """
     `variable` is the name of the variable to retrieve. `channel` is optional; if not specified,
     a global variable is retrieved.
     """
     _Request.__init__(self, 'Getvar')
     self['Variable'] = variable
     if not channel is None:
         self['Channel'] = channel
Exemplo n.º 46
0
 def __init__(self, conference, filename=None):
     """
     `conference` is the room to be recorded, and `filename`, optional, is the path,
     Asterisk-resolved or absolute, of the file to write.
     """
     _Request.__init__(self, 'ConfbridgeStartRecord')
     self['Conference'] = conference
     if filename:
         self['RecordFile'] = filename
Exemplo n.º 47
0
 def __init__(self, meetme, usernum):
     """
     `meetme` is the identifier of the bridge and `usernum` is the participant ID of the user to
     be unmuted, which is associated with a channel by the 'MeetmeJoin' event. If successful,
     this request will trigger a 'MeetmeMute' event.
     """
     _Request.__init__(self, 'MeetmeUnmute')
     self['Meetme'] = meetme
     self['Usernum'] = usernum
Exemplo n.º 48
0
 def __init__(self, interface, paused, queue=None):
     """
     `interface` is the device to be affected, and `queue` optionally limits the scope to a
     single queue. `paused` must be `True` or `False`, to control the action being taken.
     """
     _Request.__init__(self, "QueuePause")
     self['Interface'] = interface
     self['Paused'] = paused and 'true' or 'false'
     if not queue is None:
         self['Queue'] = queue
Exemplo n.º 49
0
 def __init__(self, interface, penalty, queue=None):
     """
     Changes the `penalty` value associated with `interface` in all queues, unless `queue` is
     defined, limiting it to one.
     """
     _Request.__init__(self, "QueuePenalty")
     self['Interface'] = interface
     self['Penalty'] = str(penalty)
     if not queue is None:
         self['Queue'] = queue
Exemplo n.º 50
0
    def __init__(self, channel, headers={}):
        """
        `channel` is the channel along which to send the NOTIFY.

        `headers` is a dictionary of key-value pairs to be inserted as SIP headers.
        """
        _Request.__init__(self, "SIPnotify")
        self['Channel'] = channel
        if headers:
            self['Variable'] = tuple(['%(key)s=%(value)s' % {'key': key, 'value': value,} for (key, value) in headers.items()])
Exemplo n.º 51
0
 def __init__(self, file, conference, channel=None):
     """
     `file`, resolved like other Asterisk media, is played to `conference`
     or, if specified, a specific `channel` therein.
     """
     _Request.__init__(self, 'ConfbridgePlayFile')
     self['Conference'] = conference
     if channel:
         self['Channel'] = channel
     self['File'] = file
Exemplo n.º 52
0
 def __init__(self, variable, value, channel=None):
     """
     `value` is the value to be set under `variable`.
     
     `channel` is the channel to be affected, or `None`, the default, if the variable is global.
     """
     _Request.__init__(self, 'Setvar')
     if channel:
         self['Channel'] = channel
     self['Variable'] = variable
     self['Value'] = value
Exemplo n.º 53
0
 def __init__(self, channel, command, command_id=None):
     """
     `channel` is the call in which to execute `command`, the value passed to the AGI dialplan
     application. `command_id` is an optional value that will be present in the resulting event,
     and can reasonably be set to a sequential digit or UUID in your application for tracking
     purposes.
     """
     _Request.__init__(self, 'AGI')
     self['Channel'] = channel
     self['Command'] = command
     if not command_id is None:
         self['CommandID'] = str(command_id)
Exemplo n.º 54
0
    def __init__(self, channel, context, extension, priority):
        """
        `channel` is the destination to be redirected.

        `context`, `extension`, and `priority`, must match a triple known to Asterisk internally. No
        validation is performed, so specifying an invalid target will terminate the call
        immediately.
        """
        _Request.__init__(self, "Redirect")
        self['Channel'] = channel
        self['Context'] = context
        self['Exten'] = extension
        self['Priority'] = priority
Exemplo n.º 55
0
    def __init__(self, channel, channel_callback, timeout=None):
        """
        `channel` is the channel to be parked and `channel_callback` is the channel to which parking
        information is announced.

        If `timeout`, a number of milliseconds, is given, then `channel_callback` is given `channel`
        if the call was not previously retrieved.
        """
        _Request.__init__(self, "Park")
        self['Channel'] = channel
        self['Channel2'] = channel_callback
        if timeout:
            self['Timeout'] = str(timeout)
Exemplo n.º 56
0
    def __init__(self, interface, queue, membername=None, penalty=0, paused=False):
        """
        Adds the device identified by `interface` to the given `queue`.

        `membername` optionally provides a friendly name for logging purposes, `penalty` establishes
        a priority structure (lower priorities first, defaulintg to 0) for call escalation, and
        `paused` optinally allows the interface to start in a disabled state.
        """
        _Request.__init__(self, "QueueAdd")
        self['Queue'] = queue
        self['Interface'] = interface
        self['Penalty'] = str(penalty)
        self['Paused'] = paused and 'yes' or 'no'
        if membername:
            self['MemberName'] = membername
Exemplo n.º 57
0
    def __init__(self, channel, direction, mute):
        """
        `channel` is the channel to operate on.

        `direction` is one of the following:
        
        * 'read': voice originating on the `channel`
        * 'write': voice delivered to the `channel`
        * 'both': all audio on the `channel`

        `mute` is `True` to muste the audio.
        """
        _Request.__init__(self, 'MixMonitorMute')
        self['Channel'] = channel
        self['Direction'] = direction
        self['State'] = mute and '1' or '0'
Exemplo n.º 58
0
class _Originate(_Request):
    """
    Provides the common base for originated calls.
    
    Requires call
    """
    def __init__(self,
                 channel,
                 timeout=None,
                 callerid=None,
                 variables={},
                 account=None,
                 async=True):
        """
        Sets common parameters for originated calls.

        `channel` is the destination to be called, expressed as a fully qualified Asterisk channel,
        like "SIP/[email protected]".

        `timeout`, if given, is the number of milliseconds to wait before dropping an unanwsered
        call. If set, the request's timeout value will be set to this number + 2 seconds, removing
        the need to set both variables. If not set, the request's timeout value will be set to ten
        minutes.

        `callerid` is an optinal string of the form "name"<number>, where 'name' is the name to be
        displayed (on supporting channels) and 'number' is the source identifier, typically a string
        of digits on most channels that may interact with the PSTN.

        `variables` is an oprional dictionary of key-value variable pairs to be set as part of the
        channel's namespace.

        `account` is an optional account code to be associated with the channel, useful for tracking
        billing information.

        `async` should always be `True`. If not, only one unanswered call can be active at a time.
        """
        _Request.__init__(self, "Originate")
        self['Channel'] = channel
        self['Async'] = async and 'true' or 'false'

        if timeout and timeout > 0:
            self['Timeout'] = str(timeout)
            self.timeout = timeout + 2000  #Timeout + 2s
        else:
            self.timeout = 10 * 60 * 1000  #Ten minutes

        if callerid:
            self['CallerID'] = callerid

        if variables:
            self['Variable'] = tuple([
                '%(key)s=%(value)s' % {
                    'key': key,
                    'value': value,
                } for (key, value) in variables.items()
            ])

        if account:
            self['Account'] = account