def caller_id_name(self, value): if value is None: if self.endpoint_sip_uuid or self.endpoint_sccp_id or self.endpoint_custom_id: raise InputError("Cannot set caller id to None") return if self.endpoint_sip_uuid: self._set_sip_caller_id_name(value) elif self.endpoint_sccp_id: self._set_sccp_caller_id_name(value) elif self.endpoint_custom_id: raise InputError( "Cannot set caller id on endpoint of type 'custom'") else: raise InputError("Cannot set caller id if no endpoint associated")
def mode(self, value): if value == 'allow': self.authorization = 1 elif value == 'deny': self.authorization = 0 else: raise InputError( "cannot set mode to {}. Only 'allow' or 'deny' are authorized". format(value))
def set_options(self, values): for name, value in values: if name == "cid_name": self.cid_name = value elif name == "cid_num": self.cid_num = value elif name == "allow": self.allow = value elif name == "disallow": self.disallow = value else: raise InputError("Unknown SCCP options: {}".format(name))
def _validate_regexp(self, regexp, value): if regexp.match(value) is None: raise InputError("exten: ['String does not match expected pattern.']")
def invalid_choice(field, choices, **metadata): template = "'{field}' must be one of ({choices})" message = template.format(field=field, choices=_format_list(choices)) error = format_error('Input Error', message, metadata) return InputError(error)
def unknown(*params): template = "unknown parameters: {params}" message = template.format(params=_format_list(params)) error = format_error('Input Error', message) return InputError(error)
def missing(*params): template = "missing parameters: {params}" message = template.format(params=_format_list(params)) error = format_error('Input Error', message) return InputError(error)