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
Branches
Branches containing commit
Tags
Tags containing commit
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
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
)
->
D
ict
[
str
,
Any
]:
def
import_site
(
site
:
SiteImportModel
)
->
d
ict
[
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
)
->
D
ict
[
str
,
Any
]:
def
import_router
(
router_data
:
RouterImportModel
)
->
d
ict
[
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
)
->
D
ict
[
str
,
Any
]:
def
import_iptrunk
(
iptrunk_data
:
IptrunkImportModel
)
->
d
ict
[
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
())
...
...
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(
...
@@ -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
)
...
...
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