Skip to content
Snippets Groups Projects
Commit cb2d99a6 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

convert google-style docstrings to pydoc strings

parent 3a6fa164
Branches
Tags
1 merge request!80Feature/update documentation
from typing import Any, Dict from typing import Any
from uuid import UUID from uuid import UUID
from fastapi import Depends, HTTPException, status from fastapi import Depends, HTTPException, status
...@@ -30,20 +30,16 @@ def _start_process(process_name: str, data: dict) -> UUID: ...@@ -30,20 +30,16 @@ def _start_process(process_name: str, data: dict) -> UUID:
@router.post("/sites", status_code=status.HTTP_201_CREATED, response_model=ImportResponseModel) @router.post("/sites", status_code=status.HTTP_201_CREATED, response_model=ImportResponseModel)
def import_site(site: SiteImportModel) -> Dict[str, Any]: def import_site(site: SiteImportModel) -> dict[str, Any]:
"""Import a site by running the import_site workflow. """Import a site by running the import_site workflow.
Args: :param site: The site information to be imported.
----- :type site: SiteImportModel
site (SiteImportModel): The site information to be imported.
Returns: :return: A dictionary containing the process id of the started process and detail message.
-------- :rtype: dict[str, Any]
dict: A dictionary containing the process id of the started process and detail message.
Raises: :raises HTTPException: If the site already exists or if there's an error in the process.
-------
HTTPException: If the site already exists or if there's an error in the process.
""" """
try: try:
subscription = subscriptions.retrieve_subscription_by_subscription_instance_value( subscription = subscriptions.retrieve_subscription_by_subscription_instance_value(
...@@ -59,20 +55,16 @@ def import_site(site: SiteImportModel) -> Dict[str, Any]: ...@@ -59,20 +55,16 @@ def import_site(site: SiteImportModel) -> Dict[str, Any]:
@router.post("/routers", status_code=status.HTTP_201_CREATED, response_model=ImportResponseModel) @router.post("/routers", status_code=status.HTTP_201_CREATED, response_model=ImportResponseModel)
def import_router(router_data: RouterImportModel) -> Dict[str, Any]: def import_router(router_data: RouterImportModel) -> dict[str, Any]:
"""Import a router by running the import_router workflow. """Import a router by running the import_router workflow.
Args: :param router_data: The router information to be imported.
----- :type router_data: RouterImportModel
router_data (RouterImportModel): The router information to be imported.
Returns: :return: A dictionary containing the process id of the started process and detail message.
-------- :rtype: dict[str, Any]
dict: A dictionary containing the process id of the started process and detail message.
Raises: :raises HTTPException: If there's an error in the process.
-------
HTTPException: If there's an error in the process.
""" """
pid = _start_process("import_router", router_data.dict()) pid = _start_process("import_router", router_data.dict())
...@@ -80,20 +72,16 @@ def import_router(router_data: RouterImportModel) -> Dict[str, Any]: ...@@ -80,20 +72,16 @@ def import_router(router_data: RouterImportModel) -> Dict[str, Any]:
@router.post("/iptrunks", status_code=status.HTTP_201_CREATED, response_model=ImportResponseModel) @router.post("/iptrunks", status_code=status.HTTP_201_CREATED, response_model=ImportResponseModel)
def import_iptrunk(iptrunk_data: IptrunkImportModel) -> Dict[str, Any]: def import_iptrunk(iptrunk_data: IptrunkImportModel) -> dict[str, Any]:
"""Import an iptrunk by running the import_iptrunk workflow. """Import an iptrunk by running the import_iptrunk workflow.
Args: :param iptrunk_data: The iptrunk information to be imported.
----- :type iptrunk_data: IptrunkImportModel
iptrunk_data (IptrunkImportModel): The iptrunk information to be imported.
Returns: :return: A dictionary containing the process id of the started process and detail message.
-------- :rtype: dict[str, Any]
dict: A dictionary containing the process id of the started process and detail message.
Raises: :raises HTTPException: If there's an error in the process.
-------
HTTPException: If there's an error in the process.
""" """
pid = _start_process("import_iptrunk", iptrunk_data.dict()) pid = _start_process("import_iptrunk", iptrunk_data.dict())
......
...@@ -18,14 +18,13 @@ def get_active_subscriptions( ...@@ -18,14 +18,13 @@ def get_active_subscriptions(
) -> list[Subscription]: ) -> list[Subscription]:
"""Retrieve active subscriptions for a specific product type. """Retrieve active subscriptions for a specific product type.
Args: :param product_type: The type of the product for which to retrieve subscriptions.
----- :type product_type: str
product_type (str): The type of the product for which to retrieve subscriptions. :param fields: List of fields to be included in the returned Subscription objects.
fields (list[str]): List of fields to be included in the returned Subscription objects. :type fields: list[str]
Returns: :return: A list of Subscription objects that match the query.
-------- :rtype: list[Subscription]
list[Subscription]: A list of Subscription objects that match the query.
""" """
dynamic_fields = [getattr(SubscriptionTable, field) for field in fields] dynamic_fields = [getattr(SubscriptionTable, field) for field in fields]
...@@ -43,13 +42,11 @@ def get_active_subscriptions( ...@@ -43,13 +42,11 @@ def get_active_subscriptions(
def get_active_site_subscriptions(fields: list[str]) -> list[Subscription]: def get_active_site_subscriptions(fields: list[str]) -> list[Subscription]:
"""Retrieve active subscriptions specifically for sites. """Retrieve active subscriptions specifically for sites.
Args: :param fields: The fields to be included in the returned Subscription objects.
----- :type fields: list[str]
fields (list[str]): The fields to be included in the returned Subscription objects.
Returns: :return: A list of Subscription objects for sites.
-------- :rtype: list[Subscription]
list[Subscription]: A list of Subscription objects for sites.
""" """
return get_active_subscriptions(ProductType.SITE, fields) return get_active_subscriptions(ProductType.SITE, fields)
...@@ -57,13 +54,11 @@ def get_active_site_subscriptions(fields: list[str]) -> list[Subscription]: ...@@ -57,13 +54,11 @@ def get_active_site_subscriptions(fields: list[str]) -> list[Subscription]:
def get_active_router_subscriptions(fields: list[str]) -> list[Subscription]: def get_active_router_subscriptions(fields: list[str]) -> list[Subscription]:
"""Retrieve active subscriptions specifically for routers. """Retrieve active subscriptions specifically for routers.
Args: :param fields: The fields to be included in the returned Subscription objects.
----- :type fields: list[str]
fields (list[str]): The fields to be included in the returned Subscription objects.
Returns: :return: A list of Subscription objects for routers.
-------- :rtype: list[Subscription]
list[Subscription]: A list of Subscription objects for routers.
""" """
return get_active_subscriptions(product_type=ProductType.ROUTER, fields=fields) return get_active_subscriptions(product_type=ProductType.ROUTER, fields=fields)
...@@ -71,13 +66,11 @@ def get_active_router_subscriptions(fields: list[str]) -> list[Subscription]: ...@@ -71,13 +66,11 @@ def get_active_router_subscriptions(fields: list[str]) -> list[Subscription]:
def get_product_id_by_name(product_name: ProductType) -> UUID: def get_product_id_by_name(product_name: ProductType) -> UUID:
"""Retrieve the :term:`UUID` of a product by its name. """Retrieve the :term:`UUID` of a product by its name.
Args: :param product_name: The name of the product.
----- :type product_name: ProductType
product_name (ProductType): The name of the product.
Returns: :return UUID: The :term:`UUID` of the product.
-------- :rtype: UUID
:term:`UUID`: The :term:`UUID` of the product.
""" """
return ProductTable.query.filter_by(name=product_name).first().product_id return ProductTable.query.filter_by(name=product_name).first().product_id
...@@ -85,13 +78,11 @@ def get_product_id_by_name(product_name: ProductType) -> UUID: ...@@ -85,13 +78,11 @@ def get_product_id_by_name(product_name: ProductType) -> UUID:
def get_active_site_subscription_by_name(site_name: str) -> Subscription: def get_active_site_subscription_by_name(site_name: str) -> Subscription:
"""Retrieve an active subscription for a site by the site's name. """Retrieve an active subscription for a site by the site's name.
Args: :param site_name: The name of the site for which to retrieve the subscription.
----- :type site_name: str
site_name (str): The name of the site for which to retrieve the subscription.
Returns: :return: The Subscription object for the site.
-------- :rtype: Subscription
Subscription: The Subscription object for the site.
""" """
return ( return (
SubscriptionTable.query.join(ProductTable) SubscriptionTable.query.join(ProductTable)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment