Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileAPI for file and image access #40

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion farmOS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from oauthlib.oauth2 import InvalidGrantError, InvalidClientError, InvalidScopeError

from .session import OAuthSession
from .client import LogAPI, AssetAPI, TermAPI, AreaAPI, info
from .client import LogAPI, AssetAPI, TermAPI, AreaAPI, FileAPI, info

logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
Expand Down Expand Up @@ -125,6 +125,7 @@ def __init__(
self.asset = AssetAPI(self.session)
self.area = AreaAPI(self.session)
self.term = TermAPI(self.session)
self.file = FileAPI(self.session)
self.info = partial(info, self.session)

def authorize(self, username=None, password=None, scope="user_access"):
Expand Down
8 changes: 8 additions & 0 deletions farmOS/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ def get(self, filters=None):
return data


class FileAPI(BaseAPI):
"""API for interacting with farm files"""

def __init__(self, session):
# Define 'file' as the farmOS API entity endpoint
super().__init__(session=session, entity_type="file")


def info(session):
"""Retrieve info about the farmOS server."""

Expand Down