kanboard-1.0.1/0000755000175000017500000000000013027240445014135 5ustar travistravis00000000000000kanboard-1.0.1/kanboard/0000755000175000017500000000000013027240445015716 5ustar travistravis00000000000000kanboard-1.0.1/kanboard/tests/0000755000175000017500000000000013027240445017060 5ustar travistravis00000000000000kanboard-1.0.1/kanboard/tests/__init__.py0000644000175000017500000000000013027240360021153 0ustar travistravis00000000000000kanboard-1.0.1/kanboard/tests/test_kanboard.py0000644000175000017500000000317513027240360022254 0ustar travistravis00000000000000import mock import sys import unittest from kanboard import client from kanboard import exceptions class TestKanboard(unittest.TestCase): def setUp(self): self.url = 'some api url' self.client = client.Kanboard(self.url, 'username', 'password') self.request, self.urlopen = self._create_mocks() def test_api_call(self): body = b'{"jsonrpc": "2.0", "result": true, "id": 123}' self.urlopen.return_value.read.return_value = body self.assertEquals(True, self.client.remote_procedure()) self.request.assert_called_once_with(self.url, data=mock.ANY, headers=mock.ANY) def test_http_error(self): self.urlopen.side_effect = Exception() with self.assertRaises(exceptions.KanboardClientException): self.client.remote_procedure() def test_application_error(self): body = b'{"jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error"}, "id": 123}' self.urlopen.return_value.read.return_value = body with self.assertRaises(exceptions.KanboardClientException, msg='Internal error'): self.client.remote_procedure() @staticmethod def _create_mocks(): if sys.version_info[0] < 3: urlopen_patcher = mock.patch('urllib2.urlopen') request_patcher = mock.patch('urllib2.Request') else: request_patcher = mock.patch('urllib.request.Request') urlopen_patcher = mock.patch('urllib.request.urlopen') return request_patcher.start(), urlopen_patcher.start() kanboard-1.0.1/kanboard/__init__.py0000644000175000017500000000003513027240360020021 0ustar travistravis00000000000000from .client import Kanboard kanboard-1.0.1/kanboard/client.py0000644000175000017500000000545713027240360017555 0ustar travistravis00000000000000import json import base64 from kanboard import exceptions try: from urllib import request as http except ImportError: import urllib2 as http class Kanboard(object): """ Kanboard API client Example: from kanboard import Kanboard kb = Kanboard(url="http://localhost/jsonrpc.php", username="jsonrpc", password="your_api_token") project_id = kb.create_project(name="My project") """ def __init__(self, url, username, password, auth_header='Authorization'): """ Constructor Args: url: API url endpoint username: API username or real username password: API token or user password auth_header: API HTTP header """ self._url = url self._username = username self._password = password self._auth_header = auth_header def __getattr__(self, name): def function(*args, **kwargs): return self.execute(method=self._to_camel_case(name), **kwargs) return function @staticmethod def _to_camel_case(snake_str): components = snake_str.split('_') return components[0] + ''.join(x.title() for x in components[1:]) @staticmethod def _parse_response(response): try: body = json.loads(response.decode()) if 'error' in body: message = body.get('error').get('message') raise exceptions.KanboardClientException(message) return body.get('result') except ValueError: return None def _do_request(self, headers, body): try: request = http.Request(self._url, headers=headers, data=json.dumps(body).encode()) response = http.urlopen(request).read() except Exception as e: raise exceptions.KanboardClientException(str(e)) return self._parse_response(response) def execute(self, method, **kwargs): """ Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.error.HTTPError: Any HTTP error (Python 3) """ payload = { 'id': 1, 'jsonrpc': '2.0', 'method': method, 'params': kwargs } credentials = base64.b64encode('{}:{}'.format(self._username, self._password).encode()) headers = { self._auth_header: 'Basic {}'.format(credentials.decode()), 'Content-Type': 'application/json', } return self._do_request(headers, payload) kanboard-1.0.1/kanboard/exceptions.py0000644000175000017500000000006313027240360020444 0ustar travistravis00000000000000class KanboardClientException(Exception): pass kanboard-1.0.1/kanboard.egg-info/0000755000175000017500000000000013027240445017410 5ustar travistravis00000000000000kanboard-1.0.1/kanboard.egg-info/PKG-INFO0000644000175000017500000000524513027240444020512 0ustar travistravis00000000000000Metadata-Version: 1.1 Name: kanboard Version: 1.0.1 Summary: Kanboard API client Home-page: https://github.com/kanboard/kanboard-api-python Author: Frédéric Guillot Author-email: fred@kanboard.net License: MIT Description: ============================== Python API Client for Kanboard ============================== .. image:: https://travis-ci.org/kanboard/kanboard-api-python.svg?branch=master :target: https://travis-ci.org/kanboard/kanboard-api-python Minimalist Kanboard Python client. - Author: Frédéric Guillot - License: MIT Installation ============ .. code-block:: bash pip install kanboard This library is compatible with Python 2.7, Python 3.4 and 3.5. Examples ======== The methods and arguments are the same as the JSON-RPC procedures described in the `official documentation `_. Python methods are dynamically mapped to the API procedures. You must use named arguments. Create a new team project ------------------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') Authenticate as user -------------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'admin', 'admin') kb.get_my_projects() Create a new task ----------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') task_id = kb.create_task(project_id=project_id, title='My task title') See the `official API documentation `_ for the complete list of methods and arguments. Keywords: kanboard api Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Information Technology Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 kanboard-1.0.1/kanboard.egg-info/SOURCES.txt0000644000175000017500000000070513027240445021276 0ustar travistravis00000000000000.travis.yml AUTHORS ChangeLog LICENSE README.rst requirements.txt setup.cfg setup.py test-requirements.txt tox.ini kanboard/__init__.py kanboard/client.py kanboard/exceptions.py kanboard.egg-info/PKG-INFO kanboard.egg-info/SOURCES.txt kanboard.egg-info/dependency_links.txt kanboard.egg-info/not-zip-safe kanboard.egg-info/pbr.json kanboard.egg-info/requires.txt kanboard.egg-info/top_level.txt kanboard/tests/__init__.py kanboard/tests/test_kanboard.pykanboard-1.0.1/kanboard.egg-info/dependency_links.txt0000644000175000017500000000000113027240444023455 0ustar travistravis00000000000000 kanboard-1.0.1/kanboard.egg-info/not-zip-safe0000644000175000017500000000000113027240373021636 0ustar travistravis00000000000000 kanboard-1.0.1/kanboard.egg-info/pbr.json0000644000175000017500000000005613027240444021066 0ustar travistravis00000000000000{"git_version": "131eef3", "is_release": true}kanboard-1.0.1/kanboard.egg-info/requires.txt0000644000175000017500000000004313027240444022004 0ustar travistravis00000000000000pbr>=1.8 setuptools>=16.0,!=24.0.0 kanboard-1.0.1/kanboard.egg-info/top_level.txt0000644000175000017500000000001113027240444022131 0ustar travistravis00000000000000kanboard kanboard-1.0.1/.travis.yml0000644000175000017500000000174313027240360016247 0ustar travistravis00000000000000language: python python: - '3.5' install: - pip install --upgrade setuptools - pip install --upgrade pip - pip install tox script: - tox deploy: provider: pypi user: fguillot password: secure: d9LwxCuaY/gpaGtFBbtL+Fya2Bw7o2HGw8jUTqOJwGdMCpWgnKk7HwBb0p9Xehu+xsaqhV3+z36OHpyESNQBgJMb78J8eyGbuNRrIxB+Lo6PRExHhq+n2ZXaCVu93Z0g400EyOVrNr74XYLfFHqSE5Uw2pD+SEzFQTrnDuZTY28lfT0glLvYW0zdBVNiWQaTqAoMUo+n//D7gE5HCrGmLhapvRljAULzMSg+fkzbHb9uUVNfQiur7O+l67egegfnIJms6eaeHzx3dikxWdJuJUc+i0/QIBb0UiLwea8o/syOpYqscmwpeD2smGdA9Go+Cgr0kfRKKO/3QzEPOHgxMc3fxVLntR+mgyb4qfSIIMEtNQ/WdW2+AtyBoxSK5sERwPiaSLP3zVvF/sPs2DTDSvtAl5MlPorEu5P9hJeuK4RE8MlOFNsAzN/cTbXVFwkDSzKfprBA+wspcii+x84cp3PkDgRXUdXUMyJn28vRGcJI0NdgRwkLBlxnTHPk9ea5Xz6ieuhlX7qcwnDQW9illflKEXMmNqvQoJSl/mSL+AZg5T5fnfvitug2Nlc6eiYFhdzsQ5pxYZ/a7K0JMDbdHcYhB/eLPrFkPh2yB295mmKY5R3y9vN7BeTw6++UdyTgAlpCo8FplixvsV53xhfRMKob/KHSTZEV0GM0bY0vEjA= on: tags: true distributions: sdist bdist_wheel repo: kanboard/kanboard-api-python kanboard-1.0.1/AUTHORS0000644000175000017500000000004513027240444015203 0ustar travistravis00000000000000Frederic Guillot kanboard-1.0.1/ChangeLog0000644000175000017500000000071513027240444015711 0ustar travistravis00000000000000CHANGES ======= 1.0.1 ----- * Upgrade setuptools and pip on travis * Update tox.ini * Switch to pbr * Update password for pypi deployment config * Add travis pypi deployment config * Remove Dockerfile * Add travis badge * Improve travis.yml * Add more Python versions in travis.yml * Add travis.yml * Handle exceptions * Add tox.ini and unit tests * Add Dockerfile 1.0.0 ----- * Add setup.py * Convert README to RST format * Add license file * First commit kanboard-1.0.1/LICENSE0000644000175000017500000000207313027240360015140 0ustar travistravis00000000000000The MIT License (MIT) Copyright (c) 2016 Frederic Guillot Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. kanboard-1.0.1/README.rst0000644000175000017500000000312013027240360015614 0ustar travistravis00000000000000============================== Python API Client for Kanboard ============================== .. image:: https://travis-ci.org/kanboard/kanboard-api-python.svg?branch=master :target: https://travis-ci.org/kanboard/kanboard-api-python Minimalist Kanboard Python client. - Author: Frédéric Guillot - License: MIT Installation ============ .. code-block:: bash pip install kanboard This library is compatible with Python 2.7, Python 3.4 and 3.5. Examples ======== The methods and arguments are the same as the JSON-RPC procedures described in the `official documentation `_. Python methods are dynamically mapped to the API procedures. You must use named arguments. Create a new team project ------------------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') Authenticate as user -------------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'admin', 'admin') kb.get_my_projects() Create a new task ----------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') task_id = kb.create_task(project_id=project_id, title='My task title') See the `official API documentation `_ for the complete list of methods and arguments. kanboard-1.0.1/requirements.txt0000644000175000017500000000007313027240360017415 0ustar travistravis00000000000000pbr>=1.8 # Apache-2.0 setuptools>=16.0,!=24.0.0 # PSF/ZPLkanboard-1.0.1/setup.cfg0000644000175000017500000000114613027240445015760 0ustar travistravis00000000000000[metadata] name = kanboard author = Frédéric Guillot author-email = fred@kanboard.net summary = Kanboard API client description-file = README.rst home-page = https://github.com/kanboard/kanboard-api-python license = MIT classifier = Intended Audience :: Developers Intended Audience :: Information Technology License :: OSI Approved :: MIT License Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 3 keywords = kanboard api [files] packages = kanboard [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 kanboard-1.0.1/setup.py0000644000175000017500000000020113027240360015634 0ustar travistravis00000000000000#!/usr/bin/env python from setuptools import setup setup( setup_requires=['pbr>=1.9', 'setuptools>=17.1'], pbr=True, ) kanboard-1.0.1/test-requirements.txt0000644000175000017500000000011413027240360020366 0ustar travistravis00000000000000flake8>=2.5.4,<2.6.0 # MIT mock>=2.0 # BSD nose # LGPL pep8==1.5.7 # MITkanboard-1.0.1/tox.ini0000644000175000017500000000061413027240360015445 0ustar travistravis00000000000000[tox] envlist = py27,py34,py35,pep8 [testenv] deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = nosetests --tests kanboard.tests [testenv:venv] commands = {posargs} [testenv:pep8] commands = flake8 {posargs} [flake8] ignore = E125,E123,E129 show-source = True max-line-length = 120 exclude = .git,.venv,.tox,build,dist,*egg,kanboard/__init__.py kanboard-1.0.1/PKG-INFO0000644000175000017500000000524513027240445015240 0ustar travistravis00000000000000Metadata-Version: 1.1 Name: kanboard Version: 1.0.1 Summary: Kanboard API client Home-page: https://github.com/kanboard/kanboard-api-python Author: Frédéric Guillot Author-email: fred@kanboard.net License: MIT Description: ============================== Python API Client for Kanboard ============================== .. image:: https://travis-ci.org/kanboard/kanboard-api-python.svg?branch=master :target: https://travis-ci.org/kanboard/kanboard-api-python Minimalist Kanboard Python client. - Author: Frédéric Guillot - License: MIT Installation ============ .. code-block:: bash pip install kanboard This library is compatible with Python 2.7, Python 3.4 and 3.5. Examples ======== The methods and arguments are the same as the JSON-RPC procedures described in the `official documentation `_. Python methods are dynamically mapped to the API procedures. You must use named arguments. Create a new team project ------------------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') Authenticate as user -------------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'admin', 'admin') kb.get_my_projects() Create a new task ----------------- .. code-block:: python from kanboard import Kanboard kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') task_id = kb.create_task(project_id=project_id, title='My task title') See the `official API documentation `_ for the complete list of methods and arguments. Keywords: kanboard api Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Information Technology Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3