Skip to content

Commit

Permalink
Added new recording params and filters (#234)
Browse files Browse the repository at this point in the history
* Initial commit

* removed add_time from recording filters

* fixed UT fixtures

* added version update files
  • Loading branch information
anindya-plivo authored May 31, 2023
1 parent 206e847 commit 7e1f258
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [4.35.0](https://github.com/plivo/plivo-python/tree/v4.35.0) (2023-05-29)
- Added `monthly_recording_storage_amount`, `recording_storage_rate`, `rounded_recording_duration`, and `recording_storage_duration` parameters to the response for [get single recording API](https://www.plivo.com/docs/voice/api/recording#retrieve-a-recording) and [get all recordings API](https://www.plivo.com/docs/voice/api/recording#list-all-recordings)
- Added `recording_storage_duration` parameter as a filter option for [get all recordings API](https://www.plivo.com/docs/voice/api/recording#list-all-recordings)

## [4.34.0](https://github.com/plivo/plivo-python/tree/v4.34.0) (2023-05-04)
- Add New Param `renewalDate` to the response of the [list all numbers API], [list single number API]
- Add 3 new filters to AccountPhoneNumber - list all my numbers API:`renewal_date`, `renewal_date__gt`, `renewal_date__gte`,`renewal_date__lt` and `renewal_date__lte` (https://www.plivo.com/docs/numbers/api/account-phone-number#list-all-my-numbers)
Expand Down
14 changes: 10 additions & 4 deletions plivo/resources/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class Recordings(PlivoResourceInterface):
mpc_uuid=[optional(of_type(six.text_type))],
subaccount=[optional(is_subaccount())],
call_uuid=[optional(of_type(six.text_type))],
recording_storage_duration=[optional(of_type(*six.integer_types))],
recording_storage_duration__gt=[optional(of_type(*six.integer_types))],
recording_storage_duration__gte=[optional(of_type(*six.integer_types))],
recording_storage_duration__lt=[optional(of_type(*six.integer_types))],
recording_storage_duration__lte=[optional(of_type(*six.integer_types))],
limit=[
optional(
all_of(
Expand All @@ -52,7 +57,11 @@ def list(self,
add_time__gte=None,
add_time__lt=None,
add_time__lte=None,
add_time=None,
recording_storage_duration__gt=None,
recording_storage_duration__gte=None,
recording_storage_duration__lt=None,
recording_storage_duration__lte=None,
recording_storage_duration=None,
limit=20,
offset=0,
callback_url=None,
Expand Down Expand Up @@ -80,9 +89,6 @@ def list(self,
if add_time__lte and is_valid_time_comparison(add_time__lte):
add_time__lte = str(add_time__lte)

if add_time and is_valid_time_comparison(add_time):
add_time = str(add_time)

if not callback_url:
return self.client.request(
'GET',
Expand Down
2 changes: 1 addition & 1 deletion plivo/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '4.34.0'
__version__ = '4.35.0'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='plivo',
version='4.34.0',
version='4.35.0',
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
long_description=long_description,
url='https://github.com/plivo/plivo-python',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
"call_uuid":"f72eea2a-446b-4412-a17f-3b17083bd25a",
"conference_name":"",
"from_number":"+919768368717",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms":"7560.00000",
"recording_end_ms":"1649759930398.00000",
"recording_format":"mp3",
"recording_id":"d405c4eb-d562-4399-af32-6ff3c57fa55x",
"recording_start_ms":"1649759922838.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type":"call",
"recording_url":"https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559.mp3",
"resource_uri":"/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559/",
"to_number":"sip:ajay6121801985815245533110@phone.plivo.com"
"to_number":"sip:ajay6121801985815245533110@phone.plivo.com",
"rounded_recording_duration": 120
}
6 changes: 5 additions & 1 deletion tests/resources/fixtures/recordingGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
"api_id": "7abf0744-1ca0-11e4-a2d1-22000ac5040c",
"call_uuid": "c2c128e2-1c8c-11e4-9bff-1db8a9db0432",
"conference_name": "noname",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "345100.00000",
"recording_end_ms": "1407235509007.00000",
"recording_format": "mp3",
"recording_id": "c2186400-1c8c-11e4-a664-0026b945b52x",
"recording_start_ms": "1407235163907.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "conference",
"recording_url": "http://s3.amazonaws.com/recordings_2013/c2186400-1c8c-11e4-a664-0026b945b52x.mp3",
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/c2186400-1c8c-11e4-a664-0026b945b52x/"
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/c2186400-1c8c-11e4-a664-0026b945b52x/",
"rounded_recording_duration": 120
}
18 changes: 15 additions & 3 deletions tests/resources/fixtures/recordingListFromFilterResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,57 @@
"call_uuid": "f72eea2a-446b-4412-a17f-3b17083bd25a",
"conference_name": "",
"from_number": "+919768368717",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "7560.00000",
"recording_end_ms": "1649759930398.00000",
"recording_format": "mp3",
"recording_id": "d405c4eb-d562-4399-af32-6ff3c57fa559",
"recording_start_ms": "1649759922838.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "call",
"recording_url": "https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559.mp3",
"resource_uri": "/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559/",
"to_number": "sip:ajay6121801985815245533110@phone.plivo.com"
"to_number": "sip:ajay6121801985815245533110@phone.plivo.com",
"rounded_recording_duration": 120
},
{
"add_time": "2022-04-12 13:49:19.579419+05:30",
"call_uuid": "b5e575b4-721c-425d-8da5-6c5cf6494487",
"conference_name": "",
"from_number": "+919768368712",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "25020.00000",
"recording_end_ms": "1649751556401.00000",
"recording_format": "mp3",
"recording_id": "7ed2395e-e08a-4448-86b1-9770331d94f3",
"recording_start_ms": "1649751531381.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "call",
"recording_url": "https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3.mp3",
"resource_uri": "/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3/",
"to_number": "sip:ajay6121801985815245533110@phone.plivo.com"
"to_number": "sip:ajay6121801985815245533110@phone.plivo.com",
"rounded_recording_duration": 120
},
{
"add_time": "2022-04-12 13:49:19.579419+05:30",
"call_uuid": "b5e575b4-721c-425d-8da5-6c5cf6494487",
"conference_name": "",
"from_number": "+919768368711",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "25020.00000",
"recording_end_ms": "1649751556401.00000",
"recording_format": "mp3",
"recording_id": "7ed2395e-e08a-4448-86b1-9770331d94f3",
"recording_start_ms": "1649751531381.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "call",
"recording_url": "https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3.mp3",
"resource_uri": "/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3/",
"to_number": "sip:ajay6121801985815245533110@phone.plivo.com"
"to_number": "sip:ajay6121801985815245533110@phone.plivo.com",
"rounded_recording_duration": 120
}
]
}
18 changes: 15 additions & 3 deletions tests/resources/fixtures/recordingListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,52 @@
"add_time": "2014-08-05 16:15:15.852059+05:30",
"call_uuid": "c2c128e2-1c8c-11e4-9bff-1db8a9db0432",
"conference_name": "noname",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "345100.00000",
"recording_end_ms": "1407235509007.00000",
"recording_format": "mp3",
"recording_id": "c2186400-1c8c-1124-a664-0026b945b522",
"recording_start_ms": "1407235163907.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "conference",
"recording_url": "http://s3.amazonaws.com/recordings_2013/c2186400-1c8c-1124-a664-0026b945b522.mp3",
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/c2186400-1c8c-1124-a664-0026b945b522/"
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/c2186400-1c8c-1124-a664-0026b945b522/",
"rounded_recording_duration": 120
},
{
"add_time": "2014-08-05 16:05:21.993853+05:30",
"call_uuid": "fc773e88-1c8b-11e4-b25a-0fe7bcc54670",
"conference_name": "noname",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "90700.00000",
"recording_end_ms": "1407234920253.00000",
"recording_format": "mp3",
"recording_id": "fc2716b0-1c8b-11e4-bwad-842b2b17453e",
"recording_start_ms": "1407234829553.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "conference",
"recording_url": "http://s3.amazonaws.com/recordings_2013/fc2716b0-1c8b-11e4-bwad-842b2b17453e.mp3",
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/fc2716b0-1c8b-11e4-bwad-842b2b17453e/"
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/fc2716b0-1c8b-11e4-bwad-842b2b17453e/",
"rounded_recording_duration": 120
},
{
"add_time": "2014-08-05 15:51:56.582492+05:30",
"call_uuid": "3eb4c16e-1c8a-11e4-978e-0fe7bcc54670",
"conference_name": "noname",
"monthly_recording_storage_amount": 0.0008,
"recording_duration_ms": "34100.00000",
"recording_end_ms": "1407234115543.00000",
"recording_format": "mp3",
"recording_id": "3e701c9e-1c8a-11e4-bwad-842b2b17453e",
"recording_start_ms": "1407234081443.00000",
"recording_storage_duration": 209,
"recording_storage_rate": 0.0004,
"recording_type": "conference",
"recording_url": "http://s3.amazonaws.com/recordings_2013/3e701c9e-1c8a-11e4-bwad-842b2b17453e.mp3",
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/3e701c9e-1c8a-11e4-bwad-842b2b17453e/"
"resource_uri": "/v1/Account/MANWVLYTK4ZWU1YTY4ZT/Recording/3e701c9e-1c8a-11e4-bwad-842b2b17453e/",
"rounded_recording_duration": 120
}
]
}
8 changes: 6 additions & 2 deletions tests/resources/test_recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,16 @@ def test_get_added_filter(self):
def test_list_from_filter(self):
recordings = self.client.recordings.list(
call_uuid="f72eea2a-446b-4412-a17f-3b17083bd25a",
from_number="919768368717"
from_number="919768368717",
recording_storage_duration__lte=120,
recording_storage_duration__gte=100
)

# Verifying the endpoint hit
self.assertUrlEqual(
'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Recording/?call_uuid=f72eea2a-446b-4412-a17f-3b17083bd25a&from_number=919768368717&limit=20&offset=0',
'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Recording/?call_uuid=f72eea2a-446b-4412-a17f'
'-3b17083bd25a&from_number=919768368717&limit=20&offset=0&recording_storage_duration__lte=120'
'&recording_storage_duration__gte=100',
self.client.current_request.url)

# Verifying if the Account specific changes and parsing happened
Expand Down

0 comments on commit 7e1f258

Please sign in to comment.