Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
cb2d99a6
Commit
cb2d99a6
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
convert google-style docstrings to pydoc strings
parent
3a6fa164
No related branches found
No related tags found
1 merge request
!80
Feature/update documentation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/api/v1/imports.py
+19
-31
19 additions, 31 deletions
gso/api/v1/imports.py
gso/services/subscriptions.py
+23
-32
23 additions, 32 deletions
gso/services/subscriptions.py
with
42 additions
and
63 deletions
gso/api/v1/imports.py
+
19
−
31
View file @
cb2d99a6
from
typing
import
Any
,
Dict
from
typing
import
Any
from
uuid
import
UUID
from
fastapi
import
Depends
,
HTTPException
,
status
...
...
@@ -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
)
def
import_site
(
site
:
SiteImportModel
)
->
D
ict
[
str
,
Any
]:
def
import_site
(
site
:
SiteImportModel
)
->
d
ict
[
str
,
Any
]:
"""
Import a site by running the import_site workflow.
Args:
-----
site (SiteImportModel): The site information to be imported.
:param site: The site information to be imported.
:type site: SiteImportModel
Returns:
--------
dict: A dictionary containing the process id of the started process and detail message.
:return: A dictionary containing the process id of the started process and detail message.
:rtype: dict[str, Any]
Raises:
-------
HTTPException: If the site already exists or if there
'
s an error in the process.
:raises HTTPException: If the site already exists or if there
'
s an error in the process.
"""
try
:
subscription
=
subscriptions
.
retrieve_subscription_by_subscription_instance_value
(
...
...
@@ -59,20 +55,16 @@ def import_site(site: SiteImportModel) -> Dict[str, Any]:
@router.post
(
"
/routers
"
,
status_code
=
status
.
HTTP_201_CREATED
,
response_model
=
ImportResponseModel
)
def
import_router
(
router_data
:
RouterImportModel
)
->
D
ict
[
str
,
Any
]:
def
import_router
(
router_data
:
RouterImportModel
)
->
d
ict
[
str
,
Any
]:
"""
Import a router by running the import_router workflow.
Args:
-----
router_data (RouterImportModel): The router information to be imported.
:param router_data: The router information to be imported.
:type router_data: RouterImportModel
Returns:
--------
dict: A dictionary containing the process id of the started process and detail message.
:return: A dictionary containing the process id of the started process and detail message.
:rtype: dict[str, Any]
Raises:
-------
HTTPException: If there
'
s an error in the process.
:raises HTTPException: If there
'
s an error in the process.
"""
pid
=
_start_process
(
"
import_router
"
,
router_data
.
dict
())
...
...
@@ -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
)
def
import_iptrunk
(
iptrunk_data
:
IptrunkImportModel
)
->
D
ict
[
str
,
Any
]:
def
import_iptrunk
(
iptrunk_data
:
IptrunkImportModel
)
->
d
ict
[
str
,
Any
]:
"""
Import an iptrunk by running the import_iptrunk workflow.
Args:
-----
iptrunk_data (IptrunkImportModel): The iptrunk information to be imported.
:param iptrunk_data: The iptrunk information to be imported.
:type iptrunk_data: IptrunkImportModel
Returns:
--------
dict: A dictionary containing the process id of the started process and detail message.
:return: A dictionary containing the process id of the started process and detail message.
:rtype: dict[str, Any]
Raises:
-------
HTTPException: If there
'
s an error in the process.
:raises HTTPException: If there
'
s an error in the process.
"""
pid
=
_start_process
(
"
import_iptrunk
"
,
iptrunk_data
.
dict
())
...
...
This diff is collapsed.
Click to expand it.
gso/services/subscriptions.py
+
23
−
32
View file @
cb2d99a6
...
...
@@ -18,14 +18,13 @@ def get_active_subscriptions(
)
->
list
[
Subscription
]:
"""
Retrieve active subscriptions for a specific product type.
Args:
-----
product_type (str): The type of the product for which to retrieve subscriptions.
fields (list[str]): List of fields to be included in the returned Subscription objects.
Returns:
--------
list[Subscription]: A list of Subscription objects that match the query.
:param product_type: The type of the product for which to retrieve subscriptions.
:type product_type: str
:param fields: List of fields to be included in the returned Subscription objects.
:type fields: list[str]
:return: A list of Subscription objects that match the query.
:rtype: list[Subscription]
"""
dynamic_fields
=
[
getattr
(
SubscriptionTable
,
field
)
for
field
in
fields
]
...
...
@@ -43,13 +42,11 @@ def get_active_subscriptions(
def
get_active_site_subscriptions
(
fields
:
list
[
str
])
->
list
[
Subscription
]:
"""
Retrieve active subscriptions specifically for sites.
Args:
-----
fields (list[str]): The fields to be included in the returned Subscription objects.
:param fields: The fields to be included in the returned Subscription objects.
:type fields: list[str]
Returns:
--------
list[Subscription]: A list of Subscription objects for sites.
:return: A list of Subscription objects for sites.
:rtype: list[Subscription]
"""
return
get_active_subscriptions
(
ProductType
.
SITE
,
fields
)
...
...
@@ -57,13 +54,11 @@ def get_active_site_subscriptions(fields: list[str]) -> list[Subscription]:
def
get_active_router_subscriptions
(
fields
:
list
[
str
])
->
list
[
Subscription
]:
"""
Retrieve active subscriptions specifically for routers.
Args:
-----
fields (list[str]): The fields to be included in the returned Subscription objects.
:param fields: The fields to be included in the returned Subscription objects.
:type fields: list[str]
Returns:
--------
list[Subscription]: A list of Subscription objects for routers.
:return: A list of Subscription objects for routers.
:rtype: list[Subscription]
"""
return
get_active_subscriptions
(
product_type
=
ProductType
.
ROUTER
,
fields
=
fields
)
...
...
@@ -71,13 +66,11 @@ def get_active_router_subscriptions(fields: list[str]) -> list[Subscription]:
def
get_product_id_by_name
(
product_name
:
ProductType
)
->
UUID
:
"""
Retrieve the :term:`UUID` of a product by its name.
Args:
-----
product_name (ProductType): The name of the product.
:param product_name: The name of the product.
:type product_name: ProductType
Returns:
--------
:term:`UUID`: The :term:`UUID` of the product.
:return UUID: The :term:`UUID` of the product.
:rtype: UUID
"""
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:
def
get_active_site_subscription_by_name
(
site_name
:
str
)
->
Subscription
:
"""
Retrieve an active subscription for a site by the site
'
s name.
Args:
-----
site_name (str): The name of the site for which to retrieve the subscription.
:param site_name: The name of the site for which to retrieve the subscription.
:type site_name: str
Returns:
--------
Subscription: The Subscription object for the site.
:return: The Subscription object for the site.
:rtype: Subscription
"""
return
(
SubscriptionTable
.
query
.
join
(
ProductTable
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment