Skip to content

Commit

Permalink
Regroup APIs + Notifications API (#59)
Browse files Browse the repository at this point in the history
Related to this:
nextcloud/app_api#25

Added Notification API + start grouping APIs

---------

Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 authored Aug 2, 2023
1 parent f149e52 commit ff10d39
Show file tree
Hide file tree
Showing 42 changed files with 896 additions and 589 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/analysis-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ jobs:
repository: nextcloud/server
ref: "master"

- name: Checkout Notifications
uses: actions/checkout@v3
with:
repository: nextcloud/notifications
ref: "master"
path: apps/notifications

- name: Set up & run Nextcloud
env:
DB_PORT: 4444
Expand All @@ -463,6 +470,7 @@ jobs:
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
./occ app:enable notifications
php -S localhost:8080 &
- name: Checkout NcPyApi
Expand Down Expand Up @@ -566,6 +574,13 @@ jobs:
repository: nextcloud/server
ref: "master"

- name: Checkout Notifications
uses: actions/checkout@v3
with:
repository: nextcloud/notifications
ref: "master"
path: apps/notifications

- name: Set up & run Nextcloud
env:
DB_PORT: 4444
Expand All @@ -577,6 +592,7 @@ jobs:
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
./occ app:enable notifications
php -S localhost:8080 &
- name: Checkout NcPyApi
Expand Down Expand Up @@ -648,6 +664,13 @@ jobs:
repository: nextcloud/server
ref: ${{ matrix.nextcloud }}

- name: Checkout Notifications
uses: actions/checkout@v3
with:
repository: nextcloud/notifications
ref: ${{ matrix.nextcloud }}
path: apps/notifications

- name: Set up & run Nextcloud
env:
DB_PORT: 4444
Expand All @@ -659,6 +682,7 @@ jobs:
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
./occ app:enable notifications
php -S localhost:8080 &
- name: Checkout NcPyApi
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

All notable changes to this project will be documented in this file.

## [0.0.27 - 2023-08-0x]
## [0.0.27 - 2023-08-03]

### Added

- `Notifications API`

### Changed

- Switched to `hatching` as a build system, now correct install optional dependencies.
- Renamed methods, attributes that was `shadowing a Python builtins`. Enabled additional `Ruff` linters checks.
- Regroup APIs, now Users related stuff starts with `user`, file related stuff with `file`.

## [0.0.26 - 2023-07-29]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Python library that provides a robust and well-documented API that allows develo
* Operations with Users and User Groups
* User status
* Weather status
* ~~Nextcloud notifications support~~
* Notifications support
* Shares support
* ~~Talk support~~

Expand Down
8 changes: 3 additions & 5 deletions docs/reference/Files.rst → docs/reference/Files/Files.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.. py:currentmodule:: nc_py_api.files
File System
===========

Expand All @@ -8,11 +6,11 @@ Refer to the **fs examples** to see how to use them nicely.

All File APIs are designed to work relative to the current user.

.. autoclass:: FsNodeInfo
.. autoclass:: nc_py_api.files_defs.FsNodeInfo
:members:

.. autoclass:: FsNode
.. autoclass:: nc_py_api.files_defs.FsNode
:members:

.. autoclass:: FilesAPI
.. autoclass:: nc_py_api.files.FilesAPI
:members:
6 changes: 2 additions & 4 deletions docs/reference/Shares.rst → docs/reference/Files/Shares.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
.. py:currentmodule:: nc_py_api.files_sharing
File Sharing
============

The Shares API is universal for both modes and provides all the necessary methods for working with the Nextcloud Shares system.
Refer to the **share examples** to see how to use them nicely.

.. autoclass:: Share
.. autoclass:: nc_py_api.files_defs.Share
:members:

.. autoclass:: FilesSharingAPI
.. autoclass:: nc_py_api.files_sharing.FilesSharingAPI
:members:
8 changes: 8 additions & 0 deletions docs/reference/Files/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Files API
=========

.. toctree::
:maxdepth: 2

Files
Shares
File renamed without changes.
8 changes: 8 additions & 0 deletions docs/reference/Users/UsersGroups.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
User Groups Management
----------------------

.. autoclass:: nc_py_api.users_groups.UserGroupsAPI
:members:

.. autoclass:: nc_py_api.users_defs.GroupDetails
:members:
17 changes: 17 additions & 0 deletions docs/reference/Users/UsersStatus.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
User Status
-----------

.. autoclass:: nc_py_api.users_status.UserStatusAPI
:members:

.. autoclass:: nc_py_api.users_defs.CurrentUserStatus
:members:

.. autoclass:: nc_py_api.users_defs.UserStatus
:members:

.. autoclass:: nc_py_api.users_defs.PredefinedStatus
:members:

.. autoclass:: nc_py_api.users_defs.ClearAt
:members:
11 changes: 11 additions & 0 deletions docs/reference/Users/WeatherStatus.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Weather Status
--------------

.. autoclass:: nc_py_api.users_weather.WeatherStatusAPI
:members:

.. autoclass:: nc_py_api.users_defs.WeatherLocation
:members:

.. autoclass:: nc_py_api.users_defs.WeatherLocationMode
:members:
10 changes: 10 additions & 0 deletions docs/reference/Users/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Users API
=========

.. toctree::
:maxdepth: 2

Users
UsersGroups
UsersStatus
WeatherStatus
10 changes: 0 additions & 10 deletions docs/reference/UsersGroups.rst

This file was deleted.

19 changes: 0 additions & 19 deletions docs/reference/UsersStatus.rst

This file was deleted.

13 changes: 0 additions & 13 deletions docs/reference/WeatherStatus.rst

This file was deleted.

8 changes: 2 additions & 6 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ Reference
.. toctree::
:maxdepth: 2

Files
Shares
Apps
Users
UsersGroups
UsersStatus
WeatherStatus
Files/index.rst
Users/index.rst
Session
Constants
Exceptions
2 changes: 1 addition & 1 deletion examples/to_gif/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ def initialization():
# environ["app_name"] = "test_app"
# ---------
urllib3.disable_warnings()
uvicorn.run("main:APP", host="0.0.0.0", port=9001, log_level='trace', reload=True)
uvicorn.run("main:APP", host="0.0.0.0", port=9001, log_level="trace", reload=True)
12 changes: 9 additions & 3 deletions nc_py_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
"""Import all possible stuff that can be used."""

from ._version import __version__
from .constants import ApiScope, LogLvl, SharePermissions, ShareStatus, ShareType
from .constants import ApiScope, LogLvl
from .exceptions import NextcloudException, NextcloudExceptionNotFound, check_error
from .files import FsNode, FsNodeInfo
from .files_sharing import Share
from .files_defs import (
FsNode,
FsNodeInfo,
Share,
SharePermissions,
ShareStatus,
ShareType,
)
from .integration_fastapi import (
enable_heartbeat,
nc_app,
Expand Down
4 changes: 2 additions & 2 deletions nc_py_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class ServerVersion(TypedDict):
"""Nextcloud version information"""
"""Nextcloud version information."""

major: int
"""Major version"""
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, **kwargs):

@dataclass
class AppConfig(BasicConfig):
"""Application configuration"""
"""Application configuration."""

ae_version: str
"""AppEcosystem version"""
Expand Down
4 changes: 2 additions & 2 deletions nc_py_api/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" Version of nc_py_api"""
""" Version of nc_py_api."""

__version__ = "0.0.27.dev0"
__version__ = "0.0.27.dev2"
2 changes: 1 addition & 1 deletion nc_py_api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class ExAppInfo(TypedDict):
"""Information about the External Application"""
"""Information about the External Application."""

id: str
"""`id` of the application"""
Expand Down
61 changes: 4 additions & 57 deletions nc_py_api/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Common constants. Do not use them directly, all public ones are imported to __init__.py"""
"""Common constants. Do not use them directly, all public ones are imported from __init__.py."""

from enum import IntEnum, IntFlag
from enum import IntEnum
from typing import TypedDict


class LogLvl(IntEnum):
"""Log levels"""
"""Log levels."""

DEBUG = 0
"""Debug log level"""
Expand All @@ -23,7 +23,7 @@ class LogLvl(IntEnum):


class ApiScope(IntEnum):
"""Default API scopes"""
"""Default API scopes."""

SYSTEM = 2
"""Allows access to the System APIs."""
Expand Down Expand Up @@ -51,56 +51,3 @@ class OCSRespond(IntEnum):
RESPOND_UNAUTHORISED = 997
RESPOND_NOT_FOUND = 998
RESPOND_UNKNOWN_ERROR = 999


class SharePermissions(IntFlag):
"""The share permissions to be set"""

PERMISSION_READ = 1
"""Access to read"""
PERMISSION_UPDATE = 2
"""Access to write"""
PERMISSION_CREATE = 4
"""Access to create new objects in the share"""
PERMISSION_DELETE = 8
"""Access to remove objects in the share"""
PERMISSION_SHARE = 16
"""Access to re-share objects in the share"""


class ShareType(IntEnum):
"""Type of the object that will receive share"""

TYPE_USER = 0
"""Share to the user"""
TYPE_GROUP = 1
"""Share to the group"""
TYPE_LINK = 3
"""Share by link"""
TYPE_EMAIL = 4
"""Share by the email"""
TYPE_REMOTE = 6
"""Share to the Federation"""
TYPE_CIRCLE = 7
"""Share to the Nextcloud Circle"""
TYPE_GUEST = 8
"""Share to `Guest`"""
TYPE_REMOTE_GROUP = 9
"""Share to the Federation group"""
TYPE_ROOM = 10
"""Share to the Talk room"""
TYPE_DECK = 11
"""Share to the Nextcloud Deck"""
TYPE_SCIENCE_MESH = 15
"""Share to the Reva instance(Science Mesh)"""


class ShareStatus(IntEnum):
"""Status of the share"""

STATUS_PENDING = 0
"""The share waits for acceptance"""
STATUS_ACCEPTED = 1
"""The share was for accepted"""
STATUS_REJECTED = 2
"""The share was for rejected"""
Loading

0 comments on commit ff10d39

Please sign in to comment.