Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
b7ca6d78
Commit
b7ca6d78
authored
Mar 02, 2024
by
takatost
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add app copy api
parent
d0dc80bb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
app.py
api/controllers/console/app/app.py
+28
-1
app_service.py
api/services/app_service.py
+3
-2
No files found.
api/controllers/console/app/app.py
View file @
b7ca6d78
...
...
@@ -88,7 +88,7 @@ class AppImportApi(Resource):
args
=
parser
.
parse_args
()
app_service
=
AppService
()
app
=
app_service
.
import_app
(
current_user
.
current_tenant_id
,
args
,
current_user
)
app
=
app_service
.
import_app
(
current_user
.
current_tenant_id
,
args
[
'data'
],
args
,
current_user
)
return
app
,
201
...
...
@@ -138,6 +138,32 @@ class AppApi(Resource):
return
{
'result'
:
'success'
},
204
class
AppCopyApi
(
Resource
):
@
setup_required
@
login_required
@
account_initialization_required
@
get_app_model
@
marshal_with
(
app_detail_fields_with_site
)
def
post
(
self
,
app_model
):
"""Copy app"""
# The role of the current user in the ta table must be admin or owner
if
not
current_user
.
is_admin_or_owner
:
raise
Forbidden
()
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'name'
,
type
=
str
,
location
=
'json'
)
parser
.
add_argument
(
'description'
,
type
=
str
,
location
=
'json'
)
parser
.
add_argument
(
'icon'
,
type
=
str
,
location
=
'json'
)
parser
.
add_argument
(
'icon_background'
,
type
=
str
,
location
=
'json'
)
args
=
parser
.
parse_args
()
app_service
=
AppService
()
data
=
app_service
.
export_app
(
app_model
)
app
=
app_service
.
import_app
(
current_user
.
current_tenant_id
,
data
,
args
,
current_user
)
return
app
,
201
class
AppExportApi
(
Resource
):
@
setup_required
@
login_required
...
...
@@ -224,6 +250,7 @@ class AppApiStatus(Resource):
api
.
add_resource
(
AppListApi
,
'/apps'
)
api
.
add_resource
(
AppImportApi
,
'/apps/import'
)
api
.
add_resource
(
AppApi
,
'/apps/<uuid:app_id>'
)
api
.
add_resource
(
AppCopyApi
,
'/apps/<uuid:app_id>/copy'
)
api
.
add_resource
(
AppExportApi
,
'/apps/<uuid:app_id>/export'
)
api
.
add_resource
(
AppNameApi
,
'/apps/<uuid:app_id>/name'
)
api
.
add_resource
(
AppIconApi
,
'/apps/<uuid:app_id>/icon'
)
...
...
api/services/app_service.py
View file @
b7ca6d78
...
...
@@ -124,15 +124,16 @@ class AppService:
return
app
def
import_app
(
self
,
tenant_id
:
str
,
args
:
dict
,
account
:
Account
)
->
App
:
def
import_app
(
self
,
tenant_id
:
str
,
data
:
str
,
args
:
dict
,
account
:
Account
)
->
App
:
"""
Import app
:param tenant_id: tenant id
:param data: import data
:param args: request args
:param account: Account instance
"""
try
:
import_data
=
yaml
.
safe_load
(
args
[
'data'
]
)
import_data
=
yaml
.
safe_load
(
data
)
except
yaml
.
YAMLError
as
e
:
raise
ValueError
(
"Invalid YAML format in data argument."
)
...
...
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