Example #1
0
 def _get(self):
     try:
         return self._confd.lines.get(self.id, tenant_uuid=self.tenant_uuid)
     except HTTPError:
         raise
     except RequestException as e:
         raise XiVOConfdUnreachable(self._confd, e)
Example #2
0
 def exists(self):
     try:
         conferences = self._confd.conferences.list(
             tenant_uuid=self.tenant_uuid, recurse=True)['items']
     except RequestException as e:
         raise XiVOConfdUnreachable(self._confd, e)
     return self.conference_id in (conference['id']
                                   for conference in conferences)
Example #3
0
def get_voicemail(voicemail_id, confd_client):
    try:
        return confd_client.voicemails.get(voicemail_id)
    except HTTPError as e:
        if not_found(e):
            raise NoSuchVoicemail(voicemail_id)
        raise
    except RequestException as e:
        raise XiVOConfdUnreachable(confd_client, e)
Example #4
0
 def mobile_phone_number(self):
     try:
         return self._confd.users.get(
             self.uuid, tenant_uuid=self.tenant_uuid)['mobile_phone_number']
     except HTTPError as e:
         if not_found(e):
             raise InvalidUserUUID(self.uuid)
         raise
     except RequestException as e:
         raise XiVOConfdUnreachable(self._confd, e)
Example #5
0
def get_user_voicemail(user_uuid, confd_client):
    try:
        return confd_client.users.get(user_uuid)['voicemail']
    except IndexError:
        raise NoSuchUserVoicemail(user_uuid)
    except HTTPError as e:
        if not_found(e):
            raise NoSuchUserVoicemail(user_uuid)
        raise
    except RequestException as e:
        raise XiVOConfdUnreachable(confd_client, e)
Example #6
0
 def exists(self):
     try:
         self._confd.switchboards.get(self.uuid,
                                      tenant_uuid=self.tenant_uuid)
     except HTTPError as e:
         if not_found(e):
             return False
         raise
     except RequestException as e:
         raise XiVOConfdUnreachable(self._confd, e)
     else:
         return True
Example #7
0
    def line(self, line_id):
        try:
            lines = self._confd.users.get(
                self.uuid, tenant_uuid=self.tenant_uuid)['lines']
        except HTTPError as e:
            if not_found(e):
                raise InvalidUserUUID(self.uuid)
            raise
        except RequestException as e:
            raise XiVOConfdUnreachable(self._confd, e)

        valid_line_ids = [line['id'] for line in lines]
        if line_id not in valid_line_ids:
            raise InvalidUserLine(self.uuid, line_id)

        return Line(line_id, self._confd, tenant_uuid=self.tenant_uuid)
Example #8
0
    def main_line(self):
        try:
            lines = self._confd.users.get(
                self.uuid, tenant_uuid=self.tenant_uuid)['lines']
        except HTTPError as e:
            if not_found(e):
                raise InvalidUserUUID(self.uuid)
            raise
        except RequestException as e:
            raise XiVOConfdUnreachable(self._confd, e)

        try:
            main_line_id = lines[0]['id']
        except IndexError:
            raise UserMissingMainLine(self.uuid)
        return Line(main_line_id, self._confd, tenant_uuid=self.tenant_uuid)