コード例 #1
0
ファイル: api.py プロジェクト: gorocacher/payload
    def create_queue_member(
            self, queue_id, number, uuid=None, paused=0, status=1):
        timestamp = timeutils.utcnow_ts(microsecond=True)
        values = {
            'created_at': timeutils.iso8601_from_timestamp(
                timestamp, microsecond=True),
            'number': number,
            'paused': paused,
            'paused_at': timeutils.iso8601_from_timestamp(
                timestamp, microsecond=True),
            'queue_id': queue_id,
        }
        if uuid:
            values['uuid'] = uuid
        else:
            values['uuid'] = uuidutils.generate_uuid()

        key = self._get_members_namespace(queue_id=queue_id)
        self._session.zadd(key, timestamp, values['uuid'])

        member = '%s:%s' % (key, values['uuid'])
        self._session.hmset(member, values)

        self._create_queue_member_status(
            queue_id=queue_id, timestamp=timestamp, status=status,
            uuid=values['uuid'])

        res = self.get_queue_member(
            queue_id=queue_id, uuid=values['uuid'])

        _send_notification('member.create', res.__dict__)

        return res
コード例 #2
0
ファイル: api.py プロジェクト: kbehafarin/payload
    def create_queue_caller(self, queue_id, uuid=None, name=None, number=None):
        timestamp = timeutils.utcnow_ts()
        values = {
            'created_at': timeutils.iso8601_from_timestamp(timestamp),
            'name': name,
            'number': number,
            'queue_id': queue_id,
        }
        if uuid:
            values['uuid'] = uuid
        else:
            values['uuid'] = uuidutils.generate_uuid()

        key = self._get_callers_namespace(queue_id=queue_id)
        self._session.zadd(key, timestamp, values['uuid'])

        caller = '%s:%s' % (key, values['uuid'])
        self._session.hmset(caller, values)

        res = self.get_queue_caller(
            queue_id=queue_id, uuid=values['uuid'])

        _send_notification('caller.create', res.__dict__)

        return res
コード例 #3
0
ファイル: api.py プロジェクト: gorocacher/payload
    def update_queue_member(self,
                            queue_id,
                            uuid,
                            number=None,
                            paused=None,
                            status=None):
        timestamp = timeutils.utcnow_ts(microsecond=True)
        key = self._get_members_namespace(queue_id=queue_id)
        member = '%s:%s' % (key, uuid)
        data = dict()

        if number is not None:
            data['number'] = number
        if paused is not None:
            data['paused'] = paused
            data['paused_at'] = timeutils.iso8601_from_timestamp(
                timestamp, microsecond=True)
        if data:
            self._session.hmset(member, data)

        if status is not None:
            self._update_queue_member_status(queue_id=queue_id,
                                             status=status,
                                             timestamp=timestamp,
                                             uuid=uuid)

        res = self.get_queue_member(queue_id=queue_id, uuid=uuid)

        _send_notification('member.update', res.__dict__)
コード例 #4
0
ファイル: api.py プロジェクト: gorocacher/payload
    def update_queue_member(
            self, queue_id, uuid, number=None, paused=None, status=None):
        timestamp = timeutils.utcnow_ts(microsecond=True)
        key = self._get_members_namespace(queue_id=queue_id)
        member = '%s:%s' % (key, uuid)
        data = dict()

        if number is not None:
            data['number'] = number
        if paused is not None:
            data['paused'] = paused
            data['paused_at'] = timeutils.iso8601_from_timestamp(
                timestamp, microsecond=True)
        if data:
            self._session.hmset(member, data)

        if status is not None:
            self._update_queue_member_status(
                queue_id=queue_id, status=status, timestamp=timestamp,
                uuid=uuid)

        res = self.get_queue_member(
            queue_id=queue_id, uuid=uuid)

        _send_notification('member.update', res.__dict__)
コード例 #5
0
ファイル: api.py プロジェクト: gorocacher/payload
    def create_queue_member(self,
                            queue_id,
                            number,
                            uuid=None,
                            paused=0,
                            status=1):
        timestamp = timeutils.utcnow_ts(microsecond=True)
        values = {
            'created_at':
            timeutils.iso8601_from_timestamp(timestamp, microsecond=True),
            'number':
            number,
            'paused':
            paused,
            'paused_at':
            timeutils.iso8601_from_timestamp(timestamp, microsecond=True),
            'queue_id':
            queue_id,
        }
        if uuid:
            values['uuid'] = uuid
        else:
            values['uuid'] = uuidutils.generate_uuid()

        key = self._get_members_namespace(queue_id=queue_id)
        self._session.zadd(key, timestamp, values['uuid'])

        member = '%s:%s' % (key, values['uuid'])
        self._session.hmset(member, values)

        self._create_queue_member_status(queue_id=queue_id,
                                         timestamp=timestamp,
                                         status=status,
                                         uuid=values['uuid'])

        res = self.get_queue_member(queue_id=queue_id, uuid=values['uuid'])

        _send_notification('member.create', res.__dict__)

        return res
コード例 #6
0
ファイル: api.py プロジェクト: gorocacher/payload
    def _create_queue_member_status(self, queue_id, timestamp, status, uuid):
        values = {
            'status': status,
            'status_at': timeutils.iso8601_from_timestamp(
                timestamp, microsecond=True),
        }
        key = self._get_members_status_namespace(
            queue_id=queue_id, status=status)

        self._session.zadd(key, timestamp, uuid)

        key = self._get_members_namespace(queue_id=queue_id)
        member = '%s:%s' % (key, uuid)
        self._session.hmset(member, values)
コード例 #7
0
ファイル: api.py プロジェクト: gorocacher/payload
    def _create_queue_member_status(self, queue_id, timestamp, status, uuid):
        values = {
            'status':
            status,
            'status_at':
            timeutils.iso8601_from_timestamp(timestamp, microsecond=True),
        }
        key = self._get_members_status_namespace(queue_id=queue_id,
                                                 status=status)

        self._session.zadd(key, timestamp, uuid)

        key = self._get_members_namespace(queue_id=queue_id)
        member = '%s:%s' % (key, uuid)
        self._session.hmset(member, values)