2019-12-05 07:09:25 +00:00
|
|
|
# coding:utf-8
|
|
|
|
|
|
|
|
from django.urls import path, include
|
|
|
|
from rest_framework_bulk.routes import BulkRouter
|
2020-08-16 15:08:58 +00:00
|
|
|
|
2019-12-05 07:09:25 +00:00
|
|
|
from .. import api
|
|
|
|
|
|
|
|
router = BulkRouter()
|
|
|
|
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
|
|
|
|
router.register('asset-permissions-users-relations', api.AssetPermissionUserRelationViewSet, 'asset-permissions-users-relation')
|
|
|
|
router.register('asset-permissions-user-groups-relations', api.AssetPermissionUserGroupRelationViewSet, 'asset-permissions-user-groups-relation')
|
|
|
|
router.register('asset-permissions-assets-relations', api.AssetPermissionAssetRelationViewSet, 'asset-permissions-assets-relation')
|
|
|
|
router.register('asset-permissions-nodes-relations', api.AssetPermissionNodeRelationViewSet, 'asset-permissions-nodes-relation')
|
|
|
|
|
|
|
|
user_permission_urlpatterns = [
|
2020-08-16 15:08:58 +00:00
|
|
|
# 以 serializer 格式返回
|
2020-10-20 02:45:23 +00:00
|
|
|
path('<uuid:pk>/assets/', api.UserAllGrantedAssetsApi.as_view(), name='user-assets'),
|
2020-11-22 08:50:48 +00:00
|
|
|
path('assets/', api.MyAllGrantedAssetsApi.as_view(), name='my-assets'),
|
2020-08-16 15:08:58 +00:00
|
|
|
# Tree Node 的数据格式返回
|
2022-09-13 07:41:39 +00:00
|
|
|
path('<uuid:pk>/assets/tree/', api.UserDirectGrantedAssetsAsTreeApi.as_view(), name='user-assets-as-tree'),
|
2020-08-16 15:08:58 +00:00
|
|
|
path('assets/tree/', api.MyAllAssetsAsTreeApi.as_view(), name='my-assets-as-tree'),
|
|
|
|
path('ungroup/assets/tree/', api.MyUngroupAssetsAsTreeApi.as_view(), name='my-ungroup-assets-as-tree'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2020-08-16 15:08:58 +00:00
|
|
|
# 获取用户所有`直接授权的节点`与`直接授权资产`关联的节点
|
|
|
|
# 以 serializer 格式返回
|
2022-09-15 02:46:57 +00:00
|
|
|
path('<uuid:pk>/nodes/', api.UserGrantedNodesApi.as_view(), name='user-nodes'),
|
2020-08-16 15:08:58 +00:00
|
|
|
path('nodes/', api.MyGrantedNodesApi.as_view(), name='my-nodes'),
|
|
|
|
# 以 Tree Node 的数据格式返回
|
|
|
|
path('<uuid:pk>/nodes/tree/', api.MyGrantedNodesAsTreeApi.as_view(), name='user-nodes-as-tree'),
|
|
|
|
path('nodes/tree/', api.MyGrantedNodesAsTreeApi.as_view(), name='my-nodes-as-tree'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2020-08-16 15:08:58 +00:00
|
|
|
# 一层一层的获取用户授权的节点,
|
|
|
|
# 以 Serializer 的数据格式返回
|
|
|
|
path('<uuid:pk>/nodes/children/', api.UserGrantedNodeChildrenForAdminApi.as_view(), name='user-nodes-children'),
|
|
|
|
path('nodes/children/', api.MyGrantedNodeChildrenApi.as_view(), name='my-nodes-children'),
|
|
|
|
# 以 Tree Node 的数据格式返回
|
|
|
|
path('<uuid:pk>/nodes/children/tree/', api.UserGrantedNodeChildrenAsTreeForAdminApi.as_view(), name='user-nodes-children-as-tree'),
|
|
|
|
# 部分调用位置
|
|
|
|
# - 普通用户 -> 我的资产 -> 展开节点 时调用
|
|
|
|
path('nodes/children/tree/', api.MyGrantedNodeChildrenAsTreeApi.as_view(), name='my-nodes-children-as-tree'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2020-08-16 15:08:58 +00:00
|
|
|
# 此接口会返回整棵树
|
|
|
|
# 普通用户 -> 命令执行 -> 左侧树
|
|
|
|
path('nodes-with-assets/tree/', api.MyGrantedNodesWithAssetsAsTreeApi.as_view(), name='my-nodes-with-assets-as-tree'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2020-09-27 08:02:44 +00:00
|
|
|
# 主要用于 luna 页面,带资产的节点树
|
2020-12-08 07:33:24 +00:00
|
|
|
path('<uuid:pk>/nodes/children-with-assets/tree/', api.UserGrantedNodeChildrenWithAssetsAsTreeApi.as_view(), name='user-nodes-children-with-assets-as-tree'),
|
2020-08-16 15:08:58 +00:00
|
|
|
path('nodes/children-with-assets/tree/', api.MyGrantedNodeChildrenWithAssetsAsTreeApi.as_view(), name='my-nodes-children-with-assets-as-tree'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2020-09-27 08:02:44 +00:00
|
|
|
# 查询授权树上某个节点的所有资产
|
2022-09-13 07:41:39 +00:00
|
|
|
path('<uuid:pk>/nodes/<uuid:node_id>/assets/', api.UserGrantedNodeAssetsApi.as_view(), name='user-node-assets'),
|
2020-08-16 15:08:58 +00:00
|
|
|
path('nodes/<uuid:node_id>/assets/', api.MyGrantedNodeAssetsApi.as_view(), name='my-node-assets'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2020-09-27 08:02:44 +00:00
|
|
|
# 未分组的资产
|
2022-09-13 07:41:39 +00:00
|
|
|
path('<uuid:pk>/nodes/ungrouped/assets/', api.UserDirectGrantedAssetsApi.as_view(), name='user-ungrouped-assets'),
|
2020-09-27 08:02:44 +00:00
|
|
|
path('nodes/ungrouped/assets/', api.MyDirectGrantedAssetsApi.as_view(), name='my-ungrouped-assets'),
|
|
|
|
|
|
|
|
# 收藏的资产
|
2022-09-13 07:41:39 +00:00
|
|
|
path('<uuid:pk>/nodes/favorite/assets/', api.UserFavoriteGrantedAssetsApi.as_view(), name='user-ungrouped-assets'),
|
2020-09-27 08:02:44 +00:00
|
|
|
path('nodes/favorite/assets/', api.MyFavoriteGrantedAssetsApi.as_view(), name='my-ungrouped-assets'),
|
2022-09-28 10:40:33 +00:00
|
|
|
# v3 中上面的 API 基本不用动
|
2020-09-27 08:02:44 +00:00
|
|
|
|
2022-09-28 10:40:33 +00:00
|
|
|
# Todo: v3 删除
|
2019-12-05 07:09:25 +00:00
|
|
|
# Asset System users
|
2020-08-16 15:08:58 +00:00
|
|
|
path('<uuid:pk>/assets/<uuid:asset_id>/system-users/', api.UserGrantedAssetSystemUsersForAdminApi.as_view(), name='user-asset-system-users'),
|
|
|
|
path('assets/<uuid:asset_id>/system-users/', api.MyGrantedAssetSystemUsersApi.as_view(), name='my-asset-system-users'),
|
2022-09-15 02:46:57 +00:00
|
|
|
|
2022-09-28 10:40:33 +00:00
|
|
|
# Todo: v3 增加
|
|
|
|
# 获取所有和资产-用户关联的账号列表
|
2022-09-15 02:46:57 +00:00
|
|
|
path('<uuid:pk>/assets/<uuid:asset_id>/accounts/', api.UserGrantedAssetAccounts.as_view(), name='user-asset-accounts'),
|
|
|
|
path('assets/<uuid:asset_id>/accounts/', api.MyGrantedAssetAccounts.as_view(), name='my-asset-accounts')
|
2019-12-05 07:09:25 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
user_group_permission_urlpatterns = [
|
|
|
|
# 查询某个用户组授权的资产和资产组
|
2019-12-16 08:53:29 +00:00
|
|
|
path('<uuid:pk>/assets/', api.UserGroupGrantedAssetsApi.as_view(), name='user-group-assets'),
|
|
|
|
path('<uuid:pk>/nodes/', api.UserGroupGrantedNodesApi.as_view(), name='user-group-nodes'),
|
|
|
|
path('<uuid:pk>/nodes/children/', api.UserGroupGrantedNodesApi.as_view(), name='user-group-nodes-children'),
|
|
|
|
path('<uuid:pk>/nodes/children/tree/', api.UserGroupGrantedNodeChildrenAsTreeApi.as_view(), name='user-group-nodes-children-as-tree'),
|
|
|
|
path('<uuid:pk>/nodes/<uuid:node_id>/assets/', api.UserGroupGrantedNodeAssetsApi.as_view(), name='user-group-node-assets'),
|
2022-09-28 10:40:33 +00:00
|
|
|
|
|
|
|
# Todo: v3 删除
|
2019-12-16 08:53:29 +00:00
|
|
|
path('<uuid:pk>/assets/<uuid:asset_id>/system-users/', api.UserGroupGrantedAssetSystemUsersApi.as_view(), name='user-group-asset-system-users'),
|
2022-09-28 10:40:33 +00:00
|
|
|
# Todo: v3 增加
|
|
|
|
# 获取所有和资产-用户组关联的账号列表
|
|
|
|
path('<uuid:pk>/assets/<uuid:asset_id>/accounts/', api.UserGrantedAssetAccounts.as_view(), name='user-asset-accounts'),
|
2019-12-05 07:09:25 +00:00
|
|
|
]
|
|
|
|
|
2019-12-16 08:53:29 +00:00
|
|
|
permission_urlpatterns = [
|
2019-12-05 07:09:25 +00:00
|
|
|
# 授权规则中授权的资产
|
2019-12-16 08:53:29 +00:00
|
|
|
path('<uuid:pk>/assets/all/', api.AssetPermissionAllAssetListApi.as_view(), name='asset-permission-all-assets'),
|
|
|
|
path('<uuid:pk>/users/all/', api.AssetPermissionAllUserListApi.as_view(), name='asset-permission-all-users'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
|
|
|
# 验证用户是否有某个资产和系统用户的权限
|
2022-09-28 10:40:33 +00:00
|
|
|
# Todo: API 需要修改,验证用户有某个账号的权限
|
2019-12-16 08:53:29 +00:00
|
|
|
path('user/validate/', api.ValidateUserAssetPermissionApi.as_view(), name='validate-user-asset-permission'),
|
|
|
|
path('user/actions/', api.GetUserAssetPermissionActionsApi.as_view(), name='get-user-asset-permission-actions'),
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2019-12-16 08:53:29 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
asset_permission_urlpatterns = [
|
|
|
|
# Assets
|
|
|
|
path('users/', include(user_permission_urlpatterns)),
|
|
|
|
path('user-groups/', include(user_group_permission_urlpatterns)),
|
|
|
|
path('asset-permissions/', include(permission_urlpatterns)),
|
2019-12-05 07:09:25 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
asset_permission_urlpatterns += router.urls
|