Skip to content

Commit

Permalink
Housekeeping updates
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aaronsegura committed Aug 28, 2022
1 parent 162a684 commit c145046
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 22 deletions.
73 changes: 55 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -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']
----
This project is not endorsed or recognized in any way by the NextCloud
project.
3 changes: 3 additions & 0 deletions nextcloud_async/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions nextcloud_async/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ 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"
]
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"

0 comments on commit c145046

Please sign in to comment.