Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the parental API #19

Merged
merged 3 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aiofreepybox/aiofreepybox.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from aiofreepybox.api.fs import Fs
from aiofreepybox.api.call import Call
from aiofreepybox.api.connection import Connection
from aiofreepybox.api.parental import Parental
from aiofreepybox.api.nat import Nat


Expand Down Expand Up @@ -74,6 +75,7 @@ async def open(self, host, port):
self.fs = Fs(self._access)
self.call = Call(self._access)
self.connection = Connection(self._access)
self.parental = Parental(self._access)
self.nat = Nat(self._access)

async def close(self):
Expand Down
59 changes: 59 additions & 0 deletions aiofreepybox/api/parental.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
class Parental:

def __init__(self, access):
self._access = access

# valid values are: allowed, denied or webonly
default_filter_mode = 'allowed'

parental_control_configuration_schema = {
'default_filter_mode': default_filter_mode
}

async def create_parental_filter(self, parental_filter):
'''
Create parental filter
'''
return await self._access.post('parental/filter/', parental_filter)

async def delete_parental_filter(self, filter_id):
'''
Delete parental filter
'''
return await self._access.delete(f'parental/filter/{filter_id}')

async def edit_parental_filter(self, filter_id, parental_filter):
'''
Edit parental filter
'''
return await self._access.put(f'parental/filter/{filter_id}', parental_filter)

async def edit_parental_filter_planning(self, filter_id, parental_filter_planning):
'''
Edit parental filter planning
'''
return await self._access.put(f'parental/filter/{filter_id}/planning/', parental_filter_planning)

async def get_parental_config(self):
'''
Get parental config
'''
return await self._access.get('parental/config/')

async def get_parental_filter_planning(self, filter_id):
'''
Get parental filter planning
'''
return await self._access.get(f'parental/filter/{filter_id}/planning/')

async def get_parental_filters(self):
'''
Get parental filters
'''
return await self._access.get('parental/filter/')

async def set_parental_control_configuration(self, parental_control_configuration=parental_control_configuration_schema):
'''
Set parental control configuration
'''
return await self._access.put('parental/config/', parental_control_configuration)