From c145046d650bb71abad9b02b69e11943fb769704 Mon Sep 17 00:00:00 2001 From: Aaron Segura Date: Sat, 27 Aug 2022 15:37:11 -0500 Subject: [PATCH] Housekeeping updates * Documentation updates. * Fix broken classifier. * Set license in pyproject.toml for better pypi * Handle 400 exception * Better usage example * Fix broken project links * Add federated share link --- README.md | 73 +++++++++++++++++++++++++-------- nextcloud_async/__init__.py | 3 ++ nextcloud_async/api/__init__.py | 2 + pyproject.toml | 8 ++-- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 8775b3f..7c338b1 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,58 @@ -## Nextcloud Asynchronous Client -###### +# nextcloud-async +## Asynchronous Nextcloud Client -This project is not endorsed or recognized in any way by the NextCloud -project. +This module provides an asyncio-friendly interface to public NextCloud APIs. + +### Covered APIs +* File Management API +* User Management API +* Group Management API +* App Management API +* LDAP Configuration API +* Status API +* Share API (except Federated shares) +* Talk/spreed API +* Notifications API +* Login Flow v2 API +* Remote Wipe API +* Maps API + +### APIs To Do +* Sharee API +* Reaction API +* User Preferences API +* Federated Shares API +* Cookbook API +* Passwords API +* Notes API +* Deck API + +If you know of any APIs missing from this list, please open an issue at +https://github.com/aaronsegura/nextcloud-async/issues with a link to +the API documentation so it can be added. This project aims to eventually +cover any API provided by NextCloud and commonly used NextCloud apps. + +### Example Usage + import httpx + import asyncio + from nextcloud_async import NextCloudAsync + + nca = NextCloudAsync( + client=httpx.AsyncClient(), + endpoint='http://localhost:8181', + user='user', + password='password') + + async def main(): + users = await nca.get_users() + tasks = [nca.get_user(user) for user in users] + results = await asyncio.gather(*tasks) + for user_info in results: + print(user_info) + + if __name__ == "__main__": + asyncio.run(main()) ---- -### Example usage: - - > from nextcloud_async import NextCloudAsync - > import httpx, asyncio - - > u = 'user' - > p = 'password' - > e = 'https://cloud.example.com' - > c = httpx.AsyncClient() - > nca = NextCloudAsync(client=c, user=u, password=p, endpoint=e) - > users = asyncio.run(nca.get_users()) - > print(users) - ['admin', 'slippinjimmy', 'chunks', 'flipper', 'squishface'] ----- \ No newline at end of file +This project is not endorsed or recognized in any way by the NextCloud +project. diff --git a/nextcloud_async/__init__.py b/nextcloud_async/__init__.py index c04b9c6..971487c 100644 --- a/nextcloud_async/__init__.py +++ b/nextcloud_async/__init__.py @@ -18,12 +18,14 @@ https://github.com/nextcloud/maps/blob/master/openapi.yml # TODO: +https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html#federated-cloud-shares https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-sharee-api.html https://nextcloud-talk.readthedocs.io/en/latest/reaction/ https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-user-preferences-api.html https://github.com/nextcloud/cookbook/blob/0360f7184b0dee58a6dc1ec6068d40685756d1e0/docs/dev/api/0.0.4/openapi-cookbook.yaml https://git.mdns.eu/nextcloud/passwords/-/wikis/Developers/Index https://github.com/nextcloud/notes/tree/master/docs/api +https://deck.readthedocs.io/en/latest/API/ """ from nextcloud_async.api.ocs import NextCloudOCSAPI @@ -88,6 +90,7 @@ class NextCloudAsync( Cookbook API Passwords API Notes API + Deck API Please open an issue if I am missing any APIs so they can be added: https://github.com/aaronsegura/nextcloud_async/issues diff --git a/nextcloud_async/api/__init__.py b/nextcloud_async/api/__init__.py index 61700ba..0690e85 100644 --- a/nextcloud_async/api/__init__.py +++ b/nextcloud_async/api/__init__.py @@ -100,6 +100,8 @@ async def request( match response.status_code: case 304: raise NextCloudNotModified() + case 400: + raise NextCloudBadRequest() case 401: raise NextCloudUnauthorized() case 403: diff --git a/pyproject.toml b/pyproject.toml index 2119497..7a85010 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ authors = [ ] description = "Asynchronous client library for Nextcloud" readme = "README.md" -license = { file="LICENSE" } +license = { text="License :: OSI Approved :: GNU General Public License v3 (GPLv3)" } requires-python = ">=3.10" classifiers = [ "Development Status :: 3 - Alpha", "Framework :: Flake8", "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v3", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Programming Language :: Python :: 3.10" ] @@ -24,5 +24,5 @@ keywords = ["nextcloud", "asynchronous", "spreed"] dependencies = ["httpx", "xmltodict", "platformdirs"] [project.urls] -"Homepage" = "https://github.com/aaronsegura/nextcloud_async" -"Bug Tracker" = "https://github.com/aaronsegura/nextcloud_async/issues" +"Homepage" = "https://github.com/aaronsegura/nextcloud-async" +"Bug Tracker" = "https://github.com/aaronsegura/nextcloud-async/issues"