コード例 #1
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
 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)
コード例 #2
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
 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)
コード例 #3
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
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)
コード例 #4
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
 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)
コード例 #5
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
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)
コード例 #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
コード例 #7
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
    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)
コード例 #8
0
ファイル: confd.py プロジェクト: sammymdp/wazo-calld
    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)