Bolded returns

This commit is contained in:
hwelch-fle 2023-05-01 15:53:55 -04:00
parent 490649e41e
commit 970550e341

View file

@ -26,7 +26,7 @@ class Planka:
def deauthenticate(self) -> bool: def deauthenticate(self) -> bool:
"""Deletes the auth token from the Planka API """Deletes the auth token from the Planka API
- return: True if successful, False if not - **return:** True if successful, False if not
""" """
try: try:
self.request("DELETE", "/api/access-tokens/me") self.request("DELETE", "/api/access-tokens/me")
@ -37,7 +37,7 @@ class Planka:
def validate(self) -> bool: def validate(self) -> bool:
"""Validates the Planka API connection """Validates the Planka API connection
- return: True if successful, False if not - **return:** True if successful, False if not
""" """
try: try:
self.request("GET", "/*") self.request("GET", "/*")
@ -47,7 +47,7 @@ class Planka:
def authenticate(self) -> bool: def authenticate(self) -> bool:
"""Gets an auth token from the Planka API """Gets an auth token from the Planka API
- return: True if successful, False if not - **return:** True if successful, False if not
""" """
try: try:
request = requests.post(f"{self.url}/api/access-tokens", data={'emailOrUsername': self.username, 'password': self.password}) request = requests.post(f"{self.url}/api/access-tokens", data={'emailOrUsername': self.username, 'password': self.password})
@ -63,7 +63,7 @@ class Planka:
- method: HTTP method - method: HTTP method
- endpoint: API endpoint - endpoint: API endpoint
- data: Data to send with request (default: None) - data: Data to send with request (default: None)
- return: JSON response from Planka API - **return:** JSON response from Planka API
""" """
if not self.auth: if not self.auth:
self.authenticate() self.authenticate()
@ -89,7 +89,7 @@ class Planka:
def get_template(self, template:str) -> dict: def get_template(self, template:str) -> dict:
"""Returns a template from the templates.json file """Returns a template from the templates.json file
- template: Name of template to return - template: Name of template to return
- return: Template dictionary - **return:** Template dictionary
""" """
try: try:
return self.templates[template] return self.templates[template]
@ -108,19 +108,19 @@ class Controller():
def __str__(self) -> str: def __str__(self) -> str:
"""Returns a string representation of the controller object """Returns a string representation of the controller object
- return: String representation of controller object - **return:** String representation of controller object
""" """
return f"{type(self).__name__}:\n{json.dumps(self.data, sort_keys=True, indent=4)}" return f"{type(self).__name__}:\n{json.dumps(self.data, sort_keys=True, indent=4)}"
def __repr__(self) -> str: def __repr__(self) -> str:
"""Returns a string representation of the controller object """Returns a string representation of the controller object
- return: String representation of controller object - **return:** String representation of controller object
""" """
return f"<{type(self).__name__}({self.__class__.__bases__[0].__name__})>{self.__str__()}" return f"<{type(self).__name__}({self.__class__.__bases__[0].__name__})>{self.__str__()}"
def build(self, **kwargs) -> dict: def build(self, **kwargs) -> dict:
"""Builds the controller data """Builds the controller data
- return: Controller data dictionary - **return:** Controller data dictionary
""" """
if not kwargs: if not kwargs:
return kwargs return kwargs
@ -132,7 +132,7 @@ class Controller():
def create(self, route:str, data:dict=None) -> dict: def create(self, route:str, data:dict=None) -> dict:
"""Creates a new controller object (POST) """Creates a new controller object (POST)
- route: Route for controller object POST request - route: Route for controller object POST request
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -144,7 +144,7 @@ class Controller():
def get(self, route:str) -> dict: def get(self, route:str) -> dict:
"""Gets a controller object (GET) """Gets a controller object (GET)
- route: Route for controller object GET request - route: Route for controller object GET request
- return: GET response dictionary - **return:** GET response dictionary
""" """
return self.instance.request("GET", route) return self.instance.request("GET", route)
@ -152,7 +152,7 @@ class Controller():
"""Updates a controller object (PATCH) """Updates a controller object (PATCH)
- route: Route for controller object PATCH request - route: Route for controller object PATCH request
- oid: ID of controller object - oid: ID of controller object
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -165,13 +165,13 @@ class Controller():
"""Deletes a controller object (DELETE) """Deletes a controller object (DELETE)
- route: Route for controller object DELETE request - route: Route for controller object DELETE request
- oid: ID of controller object - oid: ID of controller object
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
return self.instance.request("DELETE", route) return self.instance.request("DELETE", route)
def last_response(self) -> dict: def last_response(self) -> dict:
"""Returns the last response from the controller object """Returns the last response from the controller object
- return: Last response dictionary - **return:** Last response dictionary
""" """
return self.response return self.response
@ -185,7 +185,7 @@ class Project(Controller):
"""Gets a project by name """Gets a project by name
- oid: ID of project to get (optional) - oid: ID of project to get (optional)
- name: Name of project if None returns all projects - name: Name of project if None returns all projects
- return: GET response dictionary - **return:** GET response dictionary
""" """
if oid: if oid:
return super().get(f"/api/projects/{oid}") return super().get(f"/api/projects/{oid}")
@ -200,13 +200,13 @@ class Project(Controller):
def get_project_names(self) -> list: def get_project_names(self) -> list:
"""Gets a list of project names """Gets a list of project names
- return: List of project names - **return:** List of project names
""" """
return [prj["name"] for prj in self.get()['items']] return [prj["name"] for prj in self.get()['items']]
def create(self) -> dict: def create(self) -> dict:
"""Creates a new project """Creates a new project
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not self.data: if not self.data:
raise InvalidToken(f"Please Build a {type(self).__name__} before creating") raise InvalidToken(f"Please Build a {type(self).__name__} before creating")
@ -217,7 +217,7 @@ class Project(Controller):
def update(self, name:str) -> dict: def update(self, name:str) -> dict:
"""Updates a project """Updates a project
- name: Name of project to update - name: Name of project to update
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
prj_id = prj_id = self.get(name)['item']['id'] prj_id = prj_id = self.get(name)['item']['id']
return super().update(f"/api/projects/{prj_id}") return super().update(f"/api/projects/{prj_id}")
@ -225,7 +225,7 @@ class Project(Controller):
def delete(self, name:str) -> dict: def delete(self, name:str) -> dict:
"""Deletes a project """Deletes a project
- name: Name of project to delete - name: Name of project to delete
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
prj_id = self.get(name)['item']['id'] prj_id = self.get(name)['item']['id']
return super().delete(f"/api/projects/{prj_id}") return super().delete(f"/api/projects/{prj_id}")
@ -241,7 +241,7 @@ class Board(Controller):
- oid: ID of board to get (optonal) - oid: ID of board to get (optonal)
- name: Name of board if None returns all boards - name: Name of board if None returns all boards
- project_name: Name of project to get boards from - project_name: Name of project to get boards from
- return: GET response dictionary - **return:** GET response dictionary
""" """
if oid: if oid:
return super().get(f"/api/boards/{oid}") return super().get(f"/api/boards/{oid}")
@ -261,7 +261,7 @@ class Board(Controller):
def create(self, project_name:str) -> dict: def create(self, project_name:str) -> dict:
"""Creates a new board """Creates a new board
- prj_name: Name of project to create board in - prj_name: Name of project to create board in
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not self.data: if not self.data:
raise InvalidToken(f"Please Build a {type(self).__name__} before creating") raise InvalidToken(f"Please Build a {type(self).__name__} before creating")
@ -274,7 +274,7 @@ class Board(Controller):
- oid: ID of board to update (optional) - oid: ID of board to update (optional)
- project_name: Name of project to update board in - project_name: Name of project to update board in
- board_name: Name of board to update - board_name: Name of board to update
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -292,7 +292,7 @@ class Board(Controller):
- oid: ID of board to delete (optional) - oid: ID of board to delete (optional)
- project_name: Name of project to delete board in - project_name: Name of project to delete board in
- board_name: Name of board to delete - board_name: Name of board to delete
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if oid: if oid:
return super().delete(f"/api/boards/{oid}") return super().delete(f"/api/boards/{oid}")
@ -315,7 +315,7 @@ class List(Controller):
- project_name: Name of project to get list from - project_name: Name of project to get list from
- board_name: Name of board to get list from - board_name: Name of board to get list from
- list_name: Name of list to get - list_name: Name of list to get
- return: GET response dictionary - **return:** GET response dictionary
""" """
if not (project_name and board_name): if not (project_name and board_name):
raise InvalidToken("Please provide project and board names") raise InvalidToken("Please provide project and board names")
@ -333,7 +333,7 @@ class List(Controller):
"""Creates a new list """Creates a new list
- project_name: Name of project to create list in - project_name: Name of project to create list in
- board_name: Name of board to create list in - board_name: Name of board to create list in
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -351,7 +351,7 @@ class List(Controller):
- project_name: Name of project to update list in - project_name: Name of project to update list in
- board_name: Name of board to update list in - board_name: Name of board to update list in
- list_name: Name of list to update - list_name: Name of list to update
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -370,7 +370,7 @@ class List(Controller):
- project_name: Name of project to delete list in - project_name: Name of project to delete list in
- board_name: Name of board to delete list in - board_name: Name of board to delete list in
- list_name: Name of list to delete - list_name: Name of list to delete
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if oid: if oid:
return super().delete(f"/api/lists/{oid}") return super().delete(f"/api/lists/{oid}")
@ -392,7 +392,7 @@ class Card(Controller):
- board_name: Name of board to get card from - board_name: Name of board to get card from
- list_name: Name of list to get card from - list_name: Name of list to get card from
- card_name: Name of card to get - card_name: Name of card to get
- return: GET response dictionary - **return:** GET response dictionary
""" """
if oid != None: if oid != None:
return super().get(f"/api/cards/{oid}") return super().get(f"/api/cards/{oid}")
@ -415,7 +415,7 @@ class Card(Controller):
- project_name: Name of project to create card in - project_name: Name of project to create card in
- board_name: Name of board to create card in - board_name: Name of board to create card in
- list_name: Name of list to create card in - list_name: Name of list to create card in
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -435,7 +435,7 @@ class Card(Controller):
- board_name: Name of board to delete card in - board_name: Name of board to delete card in
- list_name: Name of list to delete card in - list_name: Name of list to delete card in
- card_name: Name of card to delete - card_name: Name of card to delete
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if oid != None: if oid != None:
return super().delete(f"/api/cards/{oid}") return super().delete(f"/api/cards/{oid}")
@ -451,7 +451,7 @@ class Card(Controller):
- board_name: Name of board to update card in - board_name: Name of board to update card in
- list_name: Name of list to update card in - list_name: Name of list to update card in
- card_name: Name of card to update - card_name: Name of card to update
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -471,7 +471,7 @@ class Card(Controller):
- board_name: Name of board to get card from - board_name: Name of board to get card from
- list_name: Name of list to get card from - list_name: Name of list to get card from
- card_name: Name of card to get - card_name: Name of card to get
- return: GET response dictionary - **return:** GET response dictionary
""" """
if oid: if oid:
return self.get(oid=oid)['included']['cardLabels'] return self.get(oid=oid)['included']['cardLabels']
@ -495,7 +495,7 @@ class Label(Controller):
- project_name: Name of project to get label from - project_name: Name of project to get label from
- board_name: Name of board to get label from - board_name: Name of board to get label from
- label_name: Name of label to get - label_name: Name of label to get
- return: GET response dictionary - **return:** GET response dictionary
""" """
if not (project_name and board_name): if not (project_name and board_name):
raise InvalidToken("Please provide project and board names") raise InvalidToken("Please provide project and board names")
@ -513,7 +513,7 @@ class Label(Controller):
"""Creates a new label """Creates a new label
- project_name: Name of project to create label in - project_name: Name of project to create label in
- board_name: Name of board to create label in - board_name: Name of board to create label in
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -531,7 +531,7 @@ class Label(Controller):
- project_name: Name of project to delete label from - project_name: Name of project to delete label from
- board_name: Name of board to delete label from - board_name: Name of board to delete label from
- label_name: Name of label to delete - label_name: Name of label to delete
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if oid: if oid:
return super().delete(f"/api/labels/{oid}") return super().delete(f"/api/labels/{oid}")
@ -547,7 +547,7 @@ class Label(Controller):
- label_name: Name of label to add to card - label_name: Name of label to add to card
- card_name: Name of card to add label to - card_name: Name of card to add label to
- list_name: Name of list to add label to card in - list_name: Name of list to add label to card in
- return: POST response dictionary - **return:** POST response dictionary
""" """
if label_id and card_id: if label_id and card_id:
return super().create(f"/api/cards/{card_id}/labels", data={"labelId":label_id}) return super().create(f"/api/cards/{card_id}/labels", data={"labelId":label_id})
@ -570,7 +570,7 @@ class Label(Controller):
- label_name: Name of label to remove from card - label_name: Name of label to remove from card
- card_name: Name of card to remove label from - card_name: Name of card to remove label from
- list_name: Name of list to remove label from card in - list_name: Name of list to remove label from card in
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if label_id and card_id: if label_id and card_id:
return super().delete(f"/api/cards/{card_id}/labels/{label_id}") return super().delete(f"/api/cards/{card_id}/labels/{label_id}")
@ -600,7 +600,7 @@ class Task(Controller):
- list_name: Name of list to get task from - list_name: Name of list to get task from
- card_name: Name of card to get task from - card_name: Name of card to get task from
- task_name: Name of task to get - task_name: Name of task to get
- return: GET response dictionary - **return:** GET response dictionary
""" """
if not (project_name and board_name and list_name and card_name): if not (project_name and board_name and list_name and card_name):
raise InvalidToken("Please provide project, board, list, and card names") raise InvalidToken("Please provide project, board, list, and card names")
@ -624,7 +624,7 @@ class Task(Controller):
- board_name: Name of board to create task in - board_name: Name of board to create task in
- list_name: Name of list to create task in - list_name: Name of list to create task in
- card_name: Name of card to create task in - card_name: Name of card to create task in
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -649,7 +649,7 @@ class Task(Controller):
- list_name: Name of list to update task in - list_name: Name of list to update task in
- card_name: Name of card to update task in - card_name: Name of card to update task in
- task_name: Name of task to update - task_name: Name of task to update
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -670,7 +670,7 @@ class Task(Controller):
- list_name: Name of list to delete task from - list_name: Name of list to delete task from
- card_name: Name of card to delete task from - card_name: Name of card to delete task from
- task_name: Name of task to delete - task_name: Name of task to delete
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if oid: if oid:
return super().delete(f"/api/tasks/{id}") return super().delete(f"/api/tasks/{id}")
@ -700,14 +700,14 @@ class Background(Controller):
def gradients(self) -> dict: def gradients(self) -> dict:
"""Gets all gradients """Gets all gradients
- return: GET response dictionary - **return:** GET response dictionary
""" """
return self.options return self.options
def apply(self, prj_name:str): def apply(self, prj_name:str):
"""Applies a gradient to a project """Applies a gradient to a project
- project: Name of project to apply gradient to - project: Name of project to apply gradient to
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
project = Project(self.instance) project = Project(self.instance)
prj_id = project.get(prj_name)["item"]["id"] prj_id = project.get(prj_name)["item"]["id"]
@ -720,7 +720,7 @@ class Background(Controller):
def clear(self, prj_name:str): def clear(self, prj_name:str):
"""Clears a gradient from a project """Clears a gradient from a project
- project: Name of project to clear gradient from - project: Name of project to clear gradient from
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
project = Project(self.instance) project = Project(self.instance)
prj_id = project.get(prj_name)["item"]["id"] prj_id = project.get(prj_name)["item"]["id"]
@ -750,7 +750,7 @@ class User(Controller):
def get(self, username:str=None): def get(self, username:str=None):
"""Gets a user """Gets a user
- username: Username of user to get (all if not provided) - username: Username of user to get (all if not provided)
- return: GET response dictionary - **return:** GET response dictionary
""" """
if not username: if not username:
return super().get("/api/users")["items"] return super().get("/api/users")["items"]
@ -763,7 +763,7 @@ class User(Controller):
def create(self, data:dict=None): def create(self, data:dict=None):
"""Creates a user """Creates a user
- data: Data dictionary to create user with (optional) - data: Data dictionary to create user with (optional)
- return: POST response dictionary - **return:** POST response dictionary
""" """
if not data: if not data:
data = self.data data = self.data
@ -777,7 +777,7 @@ class User(Controller):
"""Deletes a user """Deletes a user
- username: Username of user to delete - username: Username of user to delete
- oid: ID of user to delete (Use this if you already have the ID) - oid: ID of user to delete (Use this if you already have the ID)
- return: DELETE response dictionary - **return:** DELETE response dictionary
""" """
if oid: if oid:
return super().delete(f"/api/users/{oid}") return super().delete(f"/api/users/{oid}")
@ -790,7 +790,7 @@ class User(Controller):
- username: Username of user to update - username: Username of user to update
- oid: ID of user to update (Use this if you already have the ID) - oid: ID of user to update (Use this if you already have the ID)
- data: Data dictionary to update user with (optional) - data: Data dictionary to update user with (optional)
- return: PATCH response dictionary - **return:** PATCH response dictionary
""" """
user = self.get(username) user = self.get(username)
if not data: if not data: