Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
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
ops
koko
Commits
aa1c9a11
Commit
aa1c9a11
authored
Apr 23, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wrapper client request method
parent
c9b7f9a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
14 deletions
+52
-14
client.go
pkg/sdk/client.go
+38
-0
urls.go
pkg/sdk/urls.go
+14
-14
No files found.
pkg/sdk/client.go
View file @
aa1c9a11
...
@@ -44,7 +44,45 @@ func (c *WrapperClient) CheckAuth() error {
...
@@ -44,7 +44,45 @@ func (c *WrapperClient) CheckAuth() error {
func
(
c
*
WrapperClient
)
Get
(
url
string
,
res
interface
{},
needAuth
bool
)
error
{
func
(
c
*
WrapperClient
)
Get
(
url
string
,
res
interface
{},
needAuth
bool
)
error
{
if
needAuth
{
if
needAuth
{
c
.
Http
.
SetAuth
(
c
.
Auth
.
Sign
())
c
.
Http
.
SetAuth
(
c
.
Auth
.
Sign
())
}
else
{
c
.
Http
.
SetAuth
(
""
)
}
}
return
c
.
Http
.
Get
(
c
.
BaseHost
+
url
,
res
)
return
c
.
Http
.
Get
(
c
.
BaseHost
+
url
,
res
)
}
}
func
(
c
*
WrapperClient
)
Post
(
url
string
,
data
interface
{},
res
interface
{},
needAuth
bool
)
error
{
if
needAuth
{
c
.
Http
.
SetAuth
(
c
.
Auth
.
Sign
())
}
else
{
c
.
Http
.
SetAuth
(
""
)
}
return
c
.
Http
.
Post
(
url
,
data
,
res
)
}
func
(
c
*
WrapperClient
)
Delete
(
url
string
,
res
interface
{},
needAuth
bool
)
error
{
if
needAuth
{
c
.
Http
.
SetAuth
(
c
.
Auth
.
Sign
())
}
else
{
c
.
Http
.
SetAuth
(
""
)
}
return
c
.
Http
.
Delete
(
url
,
res
)
}
func
(
c
*
WrapperClient
)
Put
(
url
string
,
data
interface
{},
res
interface
{},
needAuth
bool
)
error
{
if
needAuth
{
c
.
Http
.
SetAuth
(
c
.
Auth
.
Sign
())
}
else
{
c
.
Http
.
SetAuth
(
""
)
}
return
c
.
Http
.
Put
(
url
,
data
,
res
)
}
func
(
c
*
WrapperClient
)
Patch
(
url
string
,
data
interface
{},
res
interface
{},
needAuth
bool
)
error
{
if
needAuth
{
c
.
Http
.
SetAuth
(
c
.
Auth
.
Sign
())
}
else
{
c
.
Http
.
SetAuth
(
""
)
}
return
c
.
Http
.
Patch
(
url
,
data
,
res
)
}
pkg/sdk/urls.go
View file @
aa1c9a11
package
sdk
package
sdk
var
urls
=
map
[
string
]
string
{
const
(
"UserAuthUrl"
:
"/api/users/v1/auth/"
,
// post 验证用户登陆
UserAuthURL
=
"/api/users/v1/auth/"
// post 验证用户登陆
"UserProfileUrl"
:
"/api/users/v1/profile/"
,
// 获取当前用户的基本信息
UserProfileURL
=
"/api/users/v1/profile/"
// 获取当前用户的基本信息
"SystemUserAssetAuthUrl"
:
"/api/assets/v1/system-user/%s/asset/%s/auth-info/"
,
// 该系统用户对某资产的授权
SystemUserAssetAuthURL
=
"/api/assets/v1/system-user/%s/asset/%s/auth-info/"
// 该系统用户对某资产的授权
"SystemUserAuthInfo"
:
"/api/assets/v1/system-user/%s/auth-info/"
,
// 该系统用户的授权
SystemUserAuthInfoURL
=
"/api/assets/v1/system-user/%s/auth-info/"
// 该系统用户的授权
"TerminalRegisterUrl"
:
"/api/terminal/v2/terminal-registrations/"
,
// 注册当前coco
TerminalRegisterURL
=
"/api/terminal/v2/terminal-registrations/"
// 注册当前coco
"TerminalConfigUrl"
:
"/api/terminal/v1/terminal/config/"
,
// 从jumpserver获取coco的配置
TerminalConfigURL
=
"/api/terminal/v1/terminal/config/"
// 从jumpserver获取coco的配置
"SessionList"
:
"/api/terminal/v1/sessions/"
,
//上传创建的资产会话session id
SessionListURL
=
"/api/terminal/v1/sessions/"
//上传创建的资产会话session id
"SessionDetail"
:
"/api/terminal/v1/sessions/%s/"
,
// finish session的时候发送
SessionDetailURL
=
"/api/terminal/v1/sessions/%s/"
// finish session的时候发送
"SessionReplay"
:
"/api/terminal/v1/sessions/%s/replay/"
,
//上传录像
SessionReplayURL
=
"/api/terminal/v1/sessions/%s/replay/"
//上传录像
"UserAssetsUrl"
:
"/api/perms/v1/user/%s/assets/"
,
//获取用户授权的所有资产
UserAssetsURL
=
"/api/perms/v1/user/%s/assets/"
//获取用户授权的所有资产
"UserNodesAssetsUrl"
:
"/api/perms/v1/user/%s/nodes-assets/"
,
// 获取用户授权的所有节点信息 节点分组
UserNodesAssetsURL
=
"/api/perms/v1/user/%s/nodes-assets/"
// 获取用户授权的所有节点信息 节点分组
"ValidateUserAssetPermission"
:
"/api/perms/v1/asset-permission/user/validate/"
,
//0不使用缓存 1 使用缓存 2 刷新缓存
ValidateUserAssetPermissionURL
=
"/api/perms/v1/asset-permission/user/validate/"
//0不使用缓存 1 使用缓存 2 刷新缓存
}
)
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