Oleksiy Petrenko | 2652ac1 | 2018-04-16 17:40:13 +0300 | [diff] [blame] | 1 | try: |
| 2 | from urllib.parse import urlencode |
| 3 | except ImportError: |
| 4 | from urllib import urlencode |
| 5 | from glancev2.common import send |
| 6 | |
| 7 | |
| 8 | @send('post') |
| 9 | def task_create(task_type, task_input, **kwargs): |
Oleh Hryhorov | 6de49c9 | 2018-05-21 12:53:59 +0000 | [diff] [blame] | 10 | url = '/tasks' |
Oleksiy Petrenko | 2652ac1 | 2018-04-16 17:40:13 +0300 | [diff] [blame] | 11 | json = { |
| 12 | 'type': task_type, |
| 13 | 'input': task_input |
| 14 | } |
| 15 | return url, {'json': json} |
| 16 | |
| 17 | |
| 18 | @send('get') |
| 19 | def task_list(**kwargs): |
Oleh Hryhorov | 6de49c9 | 2018-05-21 12:53:59 +0000 | [diff] [blame] | 20 | url = '/tasks?{}'.format(urlencode(kwargs)) |
Oleksiy Petrenko | 2652ac1 | 2018-04-16 17:40:13 +0300 | [diff] [blame] | 21 | return url, {} |
| 22 | |
| 23 | |
| 24 | @send('get') |
| 25 | def task_show(task_id, **kwargs): |
Oleh Hryhorov | 6de49c9 | 2018-05-21 12:53:59 +0000 | [diff] [blame] | 26 | url = '/tasks/{}'.format(task_id) |
Oleksiy Petrenko | 2652ac1 | 2018-04-16 17:40:13 +0300 | [diff] [blame] | 27 | return url, {} |