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:
- Installation: getting-started/installation.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:
- git-revision-date-localized:
@ -29,6 +34,7 @@ plugins:
options:
docstring_options:
ignore_imit_summary: true
summary: true
markdown_extensions:
- 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 datetime import datetime
class Embed:
def __init__(
self,
color: str,
title: str,
siteName: str,
description: str,
**kwargs
):
"""Embed object used for checking embeds
Args:
@ -19,7 +12,14 @@ class Embed:
siteName (str): String of the embed's site name
description (str): String of the embed's description
"""
def __init__(
self,
color: str,
title: str,
siteName: str,
description: str,
**kwargs
):
self.color = color
self.title = title
self.siteName = siteName
@ -28,23 +28,6 @@ class Embed:
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
Args:
@ -62,7 +45,23 @@ class File:
thumbnail (str = None): (optional) String of the file's thumbnail URL
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.id = id
self.mimetype = mimetype
@ -80,7 +79,6 @@ class File:
class Result:
def __init__(self, success: bool, status_code: int, message: str = '', data: List[Dict] = None):
"""Result returned from low-level RestAdapter
Args:
@ -89,6 +87,7 @@ class Result:
message (str = ''): Human readable result
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.status_code = status_code
self.message = message
@ -96,16 +95,6 @@ class Result:
class Invite:
def __init__(
self,
id: int,
code: str,
createdAt: datetime,
expiredAt: datetime,
used: bool,
createdById: int,
**kwargs
):
"""Invite object used for managing invites
Args:
@ -116,6 +105,16 @@ class Invite:
used (bool): Boolean of whether the invite has been used
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.code = code
self.createdAt = createdAt
@ -126,17 +125,6 @@ class Invite:
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
Args:
@ -148,6 +136,17 @@ class OAuth:
token (str): String of the OAuth's access 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.provider = provider
self.userId = userId
@ -159,23 +158,6 @@ class OAuth:
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
Args:
@ -193,6 +175,23 @@ class User:
oauth (List[OAuth] = None): (optional) List of OAuth objects
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.uuid = uuid
self.username = username

View file

@ -5,11 +5,10 @@ from json import JSONDecodeError
import requests
from urllib3 import disable_warnings
from pyzipline.errors import KwargConflict, HTTPFailure, PyZiplineError
from pyzipline.errors import HTTPFailure, PyZiplineError
from pyzipline.models import Result
class RestAdapter:
def __init__(self, hostname: str, token: str = '', ssl: bool = True, enforced_signing: bool = True, logger: logging.Logger = None):
"""Constructor for RestAdapter
Args:
@ -17,11 +16,12 @@ class RestAdapter:
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.
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:
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._token = token
self._ssl = ssl

View file

@ -1,12 +1,12 @@
from datetime import 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:
date_string (str): String to convert
Returns:
datetime.datetime: Datetime object
datetime (datetime): Datetime object
"""
return datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')