8000 Merge branch 'queues' of github.com:twilio/twilio-python into queues · Stackdriver/twilio-python@adeeeb9 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.

Commit adeeeb9

Browse files
committed
Merge branch 'queues' of github.com:twilio/twilio-python into queues
2 parents 1287dfa + aeefacc commit adeeeb9

File tree

3 files changed

+101
-5
lines changed

3 files changed

+101
-5
lines changed

docs/api/rest/resources.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,74 @@ Phone Numbers
603603
.. attribute:: iso_country
604604

605605

606+
Queues
607+
>>>>>>>>>>>
608+
609+
.. autoclass:: twilio.rest.resources.Queues
610+
:members:
611+
:exclude-members: instance
612+
613+
.. autoclass:: twilio.rest.resources.Queue
614+
:members:
615+
616+
.. attribute:: sid
617+
618+
A 34 character string that uniquely identifies this queue.
619+
620+
.. attribute:: friendly_name
621+
622+
A user-provided string that identifies this queue.
623+
624+
.. attribute:: current_size
625+
626+
The count of calls currently in the queue.
627+
628+
.. attribute:: max_size
629+
630+
The upper limit of calls allowed to be in the queue.
631+
`unlimited` is an option. The default is 100.
632+
633+
.. attribute:: average_wait_time
634+
635+
The average wait time of the members of this queue in seconds.
636+
This is calculated at the time of the request.
637+
638+
.. attribute:: uri
639+
640+
The URI for this resource, relative to https://api.twilio.com.
641+
642+
643+
Queue Members
644+
>>>>>>>>>>>>>>
645+
646+
.. autoclass:: twilio.rest.resources.Members
647+
:members:
648+
:exclude-members: instance
649+
650+
.. autoclass:: twilio.rest.resources.Member
651+
:members:
652+
653+
.. attribute:: call_sid
654+
655+
A 34 character string that uniquely identifies the call that is enqueued.
656+
657+
.. attribute:: date_enqueued
658+
659+
The date that the member was enqueued, given in RFC 2822 format.
660+
661+
.. attribute:: wait_time
662+
663+
The number of seconds the member has been in the queue.
664+
665+
.. attribute:: position
666+
667+
This member’s current position in the queue.
668+
669+
.. attribute:: uri
670+
671+
The URI for this resource, relative to https://api.twilio.com.
672+
673+
606674
Recordings
607675
>>>>>>>>>>>
608676

tests/test_base_resource.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
"""
2-
Test the base Resource class
3-
"""
1+
# -*- coding: utf-8 -*-
2+
from __future__ import with_statement
43
import sys
4+
55
if sys.version_info < (2, 7):
66
import unittest2 as unittest
77
else:
88
import unittest
9+
910
from mock import Mock, patch
1011
from nose.tools import assert_equals
1112
from nose.tools import raises

twilio/rest/resources.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
from twilio import TwilioException
66
from twilio import TwilioRestException
77
from urllib import urlencode
8-
from urlparse import urlparse, parse_qs
8+
from urlparse import urlparse
9+
10+
try:
11+
from urlparse import parse_qs
12+
except ImportError:
13+
from cgi import parse_qs
914

1015
# import json
1116
try:
@@ -1180,6 +1185,7 @@ class Queue(InstanceResource):
11801185
def update(self, **kwargs):
11811186
"""
11821187
Update this queue
1188+
11831189
:param friendly_name: A new friendly name for this queue
11841190
:param max_size: A new max size. Changing a max size to less than the
11851191
current size results in the queue rejecting incoming
@@ -1207,13 +1213,34 @@ def list(self, **kwargs):
12071213

12081214
def create(self, name, **kwargs):
12091215
""" Create an :class:`Queue` with any of these optional parameters.
1216+
12101217
:param name: A human readable description of the application,
12111218
with maximum length 64 characters.
12121219
:param max_size: The limit on calls allowed into the queue (optional)
12131220 1E0A
"""
12141221
kwargs['friendly_name'] = name
12151222
return self.create_instance(kwargs)
12161223

1224+
def update(self, sid, **kwargs):
1225+
"""
1226+
Update a :class:`Queue`
1227+
1228+
:param sid: String identifier for a Queue resource
1229+
:param friendly_name: A new friendly name for this queue
1230+
:param max_size: A new max size. Changing a max size to less than the
1231+
current size results in the queue rejecting incoming
1232+
requests until it shrinks below the new max size
1233+
"""
1234+
return self.update_instance(sid, kwargs)
1235+
1236+
def delete(self, sid):
1237+
"""
1238+
Delete a :class:`Queue`. Can only be run on empty queues.
1239+
1240+
:param sid: String identifier for a Queue resource
1241+
"""
1242+
return self.delete_instance(sid)
1243+
12171244

12181245
class Application(InstanceResource):
12191246
""" An application resource """
@@ -1301,7 +1328,7 @@ def update(self, sid, **kwargs):
13011328

13021329
def delete(self, sid):
13031330
"""
1304-
Update an :class:`Application` with the given parameters.
1331+
Delete an :class:`Application`
13051332
"""
13061333
return self.delete_instance(sid)
13071334

0 commit comments

Comments
 (0)
0