adding docs for a whole bunch more stuff
Some checks failed
Pylint / Pylint (3.12) (push) Failing after 36s

This commit is contained in:
Seaswimmer 2023-12-20 18:13:55 -05:00
parent b774ecdc0a
commit bd4a90a6be
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE
8 changed files with 106 additions and 89 deletions

3
docs/ref/errors.md Normal file
View file

@ -0,0 +1,3 @@
# Exceptions
::: pyzipline.errors

3
docs/ref/models.md Normal file
View file

@ -0,0 +1,3 @@
# Models Reference
::: pyzipline.models

3
docs/ref/rest_adapter.md Normal file
View file

@ -0,0 +1,3 @@
# Rest Adapter
::: pyzipline.rest_adapter.RestAdapter

3
docs/ref/utils.md Normal file
View file

@ -0,0 +1,3 @@
# Utilities
::: pyzipline.utils

View file

@ -13,7 +13,12 @@ nav:
- Getting Started: - Getting Started:
- Installation: getting-started/installation.md - Installation: getting-started/installation.md
- Usage: getting-started/usage.md - Usage: getting-started/usage.md
- Reference: ref/zipline.md - Reference:
- Zipline: ref/zipline.md
- Utilities: ref/utils.md
- Exceptions: ref/exceptions.md
- Models: ref/models.md
- Rest Adapter: ref/rest_adapter.md
plugins: plugins:
- git-revision-date-localized: - git-revision-date-localized:
@ -29,6 +34,7 @@ plugins:
options: options:
docstring_options: docstring_options:
ignore_imit_summary: true ignore_imit_summary: true
summary: true
markdown_extensions: markdown_extensions:
- abbr - abbr

View file

@ -1,16 +1,9 @@
"""This is a list of all the models used in PyZipline. They are used to represent the data returned from the Zipline API."""
from typing import List, Dict, Union from typing import List, Dict, Union
from datetime import datetime from datetime import datetime
class Embed: class Embed:
def __init__(
self,
color: str,
title: str,
siteName: str,
description: str,
**kwargs
):
"""Embed object used for checking embeds """Embed object used for checking embeds
Args: Args:
@ -19,7 +12,14 @@ class Embed:
siteName (str): String of the embed's site name siteName (str): String of the embed's site name
description (str): String of the embed's description description (str): String of the embed's description
""" """
def __init__(
self,
color: str,
title: str,
siteName: str,
description: str,
**kwargs
):
self.color = color self.color = color
self.title = title self.title = title
self.siteName = siteName self.siteName = siteName
@ -28,23 +28,6 @@ class Embed:
class File: class File:
def __init__(
self,
createdAt: datetime,
id: int,
mimetype: str,
views: int,
name: str,
size: int,
favorite: bool,
originalName: str = None,
url: str = None,
maxViews: int = None,
expiredAt: Union[datetime, None] = None,
thumbnail: str = None,
folderId: int = None,
**kwargs
):
"""File object used for uploading files to Zipline """File object used for uploading files to Zipline
Args: Args:
@ -62,7 +45,23 @@ class File:
thumbnail (str = None): (optional) String of the file's thumbnail URL thumbnail (str = None): (optional) String of the file's thumbnail URL
folderId (int = None): (optional) Integer of the file's folder ID folderId (int = None): (optional) Integer of the file's folder ID
""" """
def __init__(
self,
createdAt: datetime,
id: int,
mimetype: str,
views: int,
name: str,
size: int,
favorite: bool,
originalName: str = None,
url: str = None,
maxViews: int = None,
expiredAt: Union[datetime, None] = None,
thumbnail: str = None,
folderId: int = None,
**kwargs
):
self.createdAt = createdAt self.createdAt = createdAt
self.id = id self.id = id
self.mimetype = mimetype self.mimetype = mimetype
@ -80,7 +79,6 @@ class File:
class Result: class Result:
def __init__(self, success: bool, status_code: int, message: str = '', data: List[Dict] = None):
"""Result returned from low-level RestAdapter """Result returned from low-level RestAdapter
Args: Args:
@ -89,6 +87,7 @@ class Result:
message (str = ''): Human readable result message (str = ''): Human readable result
data (List[Dict] = None): Python List of Dictionaries (or maybe just a single Dictionary on error) data (List[Dict] = None): Python List of Dictionaries (or maybe just a single Dictionary on error)
""" """
def __init__(self, success: bool, status_code: int, message: str = '', data: List[Dict] = None):
self.success = success self.success = success
self.status_code = status_code self.status_code = status_code
self.message = message self.message = message
@ -96,16 +95,6 @@ class Result:
class Invite: class Invite:
def __init__(
self,
id: int,
code: str,
createdAt: datetime,
expiredAt: datetime,
used: bool,
createdById: int,
**kwargs
):
"""Invite object used for managing invites """Invite object used for managing invites
Args: Args:
@ -116,6 +105,16 @@ class Invite:
used (bool): Boolean of whether the invite has been used used (bool): Boolean of whether the invite has been used
createdById (int): Integer ID of the user who created the invite createdById (int): Integer ID of the user who created the invite
""" """
def __init__(
self,
id: int,
code: str,
createdAt: datetime,
expiredAt: datetime,
used: bool,
createdById: int,
**kwargs
):
self.id = id self.id = id
self.code = code self.code = code
self.createdAt = createdAt self.createdAt = createdAt
@ -126,17 +125,6 @@ class Invite:
class OAuth: class OAuth:
def __init__(
self,
id: int,
provider: str,
userId: int,
providerId: str,
username: str,
token: str,
refresh: str,
**kwargs
):
"""OAuth object used for managing OAuth """OAuth object used for managing OAuth
Args: Args:
@ -148,6 +136,17 @@ class OAuth:
token (str): String of the OAuth's access token token (str): String of the OAuth's access token
refresh (str): String of the OAuth's refresh token refresh (str): String of the OAuth's refresh token
""" """
def __init__(
self,
id: int,
provider: str,
userId: int,
providerId: str,
username: str,
token: str,
refresh: str,
**kwargs
):
self.id = id self.id = id
self.provider = provider self.provider = provider
self.userId = userId self.userId = userId
@ -159,23 +158,6 @@ class OAuth:
class User: class User:
def __init__(
self,
id: int,
uuid: str,
username: str,
avatar: str,
token: str,
administrator: bool,
superAdmin: bool,
systemTheme: str,
embed: Embed,
totpSecret: str,
domains: List[str],
oauth: Union[List['OAuth'], None] = None,
ratelimit: [datetime, None] = None,
**kwargs
):
"""User object used for managing users """User object used for managing users
Args: Args:
@ -193,6 +175,23 @@ class User:
oauth (List[OAuth] = None): (optional) List of OAuth objects oauth (List[OAuth] = None): (optional) List of OAuth objects
ratelimit (datetime = None): (optional) Datetime object of when the user's ratelimit expires ratelimit (datetime = None): (optional) Datetime object of when the user's ratelimit expires
""" """
def __init__(
self,
id: int,
uuid: str,
username: str,
avatar: str,
token: str,
administrator: bool,
superAdmin: bool,
systemTheme: str,
embed: Embed,
totpSecret: str,
domains: List[str],
oauth: Union[List['OAuth'], None] = None,
ratelimit: [datetime, None] = None,
**kwargs
):
self.id = id self.id = id
self.uuid = uuid self.uuid = uuid
self.username = username self.username = username

View file

@ -5,11 +5,10 @@ from json import JSONDecodeError
import requests import requests
from urllib3 import disable_warnings from urllib3 import disable_warnings
from pyzipline.errors import KwargConflict, HTTPFailure, PyZiplineError from pyzipline.errors import HTTPFailure, PyZiplineError
from pyzipline.models import Result from pyzipline.models import Result
class RestAdapter: class RestAdapter:
def __init__(self, hostname: str, token: str = '', ssl: bool = True, enforced_signing: bool = True, logger: logging.Logger = None):
"""Constructor for RestAdapter """Constructor for RestAdapter
Args: Args:
@ -17,11 +16,12 @@ class RestAdapter:
token (str = None): String used for authentication when making requests. token (str = None): String used for authentication when making requests.
ssl (bool = True): Normally set to True, but if your Zipline instance doesn't use SSL/TLS, set this to False. ssl (bool = True): Normally set to True, but if your Zipline instance doesn't use SSL/TLS, set this to False.
enforced_signing (bool = True): Normally set to True, but if having SSL/TLS cert validation issues, can turn off with False. enforced_signing (bool = True): Normally set to True, but if having SSL/TLS cert validation issues, can turn off with False.
logger (logging.Logger = None) If your app has a logger, pass it in here. logger (logging.Logger = None): If your app has a logger, pass it in here.
Raises: Raises:
ValueError: Raised when the keyword arguments passed to the class constructor conflict. ValueError: Raised when the keyword arguments passed to the class constructor conflict.
""" """
def __init__(self, hostname: str, token: str = '', ssl: bool = True, enforced_signing: bool = True, logger: logging.Logger = None):
self._url = f"http{'s' if ssl else ''}://{hostname}/api/" self._url = f"http{'s' if ssl else ''}://{hostname}/api/"
self._token = token self._token = token
self._ssl = ssl self._ssl = ssl

View file

@ -1,12 +1,12 @@
from datetime import datetime from datetime import datetime
def convert_str_to_datetime(date_string: str) -> datetime: def convert_str_to_datetime(date_string: str) -> datetime:
"""Converts a string to a datetime object """Converts a Zipline date string to a datetime object
Args: Args:
date_string (str): String to convert date_string (str): String to convert
Returns: Returns:
datetime.datetime: Datetime object datetime (datetime): Datetime object
""" """
return datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ') return datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')