Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
webomagic-auth
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Pratik Shrivastava
webomagic-auth
Commits
bca40558
Commit
bca40558
authored
Jul 14, 2024
by
deepdey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add api to sync web-api with redis
parent
176c2cc3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
2 deletions
+48
-2
app/app_config/constant.py
app/app_config/constant.py
+8
-1
app/routes/web_api/__init__.py
app/routes/web_api/__init__.py
+18
-0
app/routes/web_api/web_api_dao_service.py
app/routes/web_api/web_api_dao_service.py
+13
-1
app/routes/web_api/web_api_response.py
app/routes/web_api/web_api_response.py
+9
-0
No files found.
app/app_config/constant.py
View file @
bca40558
...
...
@@ -9,3 +9,10 @@ class RoleTypeEnum(Enum):
PROJECT_ADMIN
=
'PROJECT_ADMIN'
PROJECT_STAFF
=
'PROJECT_STAFF'
PROJECT_USER
=
'PROJECT_USER'
class
EndpointTagEnum
(
Enum
):
P
=
'P'
V
=
'V'
SU
=
'SU'
PV
=
'PV'
RA
=
'RA'
\ No newline at end of file
app/routes/web_api/__init__.py
View file @
bca40558
...
...
@@ -106,3 +106,21 @@ class GetWebApi(Resource):
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/sync-redis'
,
methods
=
[
'GET'
])
class
SyncRedisWebApi
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
response
(
*
sync_web_api_response
())
@
sanitized
()
def
get
(
self
):
try
:
synced
:
bool
=
sync_web_api
()
return
prepare_api_response
(
SUCCESS_CODE
,
SUCCESS_MESSAGE
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
\ No newline at end of file
app/routes/web_api/web_api_dao_service.py
View file @
bca40558
from
app
import
orm
as
ORM
from
app
import
db
from
app.app_config.constant
import
EndpointTagEnum
from
app.utils
import
redis
def
get_web_api_by_endpoint
(
endpoint
:
str
)
->
ORM
.
Api
|
None
:
return
ORM
.
Api
.
query
.
filter_by
(
endpoint
=
endpoint
)
.
first
()
...
...
@@ -63,3 +65,13 @@ def update_web_api(web_api_info: dict) -> bool:
def
get_web_api_list
()
->
list
:
web_api_list
=
ORM
.
Api
.
query
.
all
()
return
web_api_list
def
sync_web_api
()
->
bool
:
web_api_list
=
ORM
.
Api
.
query
.
all
()
for
web_api
in
web_api_list
:
if
web_api
.
tag
==
EndpointTagEnum
.
RA
.
value
:
redis
.
set_value
(
web_api
.
endpoint
,
web_api
.
id
)
else
:
redis
.
set_value
(
web_api
.
endpoint
,
web_api
.
tag
)
return
True
\ No newline at end of file
app/routes/web_api/web_api_response.py
View file @
bca40558
...
...
@@ -45,3 +45,12 @@ def get_web_api_list_response() -> any:
model_name
=
'getWebApiList Response'
,
data
=
fields
.
List
(
fields
.
Nested
(
WEB_API_MODE
))
)
def
sync_web_api_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
SUCCESS_MESSAGE
,
model_name
=
'syncWebApi Response'
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment