HARBOR 仓库 API功能接口

1       项目管理

1.1     查看仓库中项目详细信息

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/projects/{project_id}"

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/projects?project_name=guest"

HARBOR 仓库 API功能接口

1.2     搜索镜像

curl  -u "admin:Harbor12345"  -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/search?q=nginx"

HARBOR 仓库 API功能接口

1.3     删除项目

 

curl  -u "admin:Harbor12345"  -X DELETE  -H "Content-Type: application/json" "https://192.168.56.106/api/projects/{project_id}"

HARBOR 仓库 API功能接口

1.4     创建项目

HARBOR 仓库 API功能接口
curl -u "admin:Harbor12345" -X POST -H "Content-Type: application/json" "https://192.168.56.106/api/projects" -d @createproject.json

 

createproject.json例子

{

  "project_name": "testrpo",

  "public": 0

}
HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

1.5     查看项目日志

HARBOR 仓库 API功能接口
curl -u "admin:Harbor12345" -X POST -H "Content-Type: application/json" "https://192.168.56.106/api/projects/{project_id}/logs/filter" -d @log.json

 

[root@dcos-hub json]# cat log.json

{

  "username": "admin"

}
HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

2       账号管理

2.1     创建账号

HARBOR 仓库 API功能接口
curl -u "admin:Harbor12345" -X POST -H "Content-Type: application/json" "https://192.168.56.106/api/users" -d @user.json

 

[root@dcos-hub json]# cat >user.json

{

  "user_id": 5,

  "username": "xinju",

  "email": "xinju@gmail.com",

  "password": "Xinju12345",

  "realname": "xinju",

  "role_id": 2

}
HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

2.2     获取用户信息

 

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/users"

HARBOR 仓库 API功能接口

 

2.3     获取当前用户信息 

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/users/current"

HARBOR 仓库 API功能接口

2.4     删除用户

curl -u "admin:Harbor12345" -X DELETE  -H "Content-Type: application/json" "https://192.168.56.106/api/users/{user_id}"

HARBOR 仓库 API功能接口

2.5     修改用户密码

HARBOR 仓库 API功能接口
curl -u "admin:Harbor12345" -X PUT -H "Content-Type: application/json" "https://192.168.56.106/api/users/{user_id}/password" -d @uppwd.json

 

[root@dcos-hub json]# cat uppwd.json

{

  "old_password": "Harbor123456",

  "new_password": "Harbor12345"

}
HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

3       用户权限管理

3.1     查看项目相关角色

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/projects/{project_id}/members/"

HARBOR 仓库 API功能接口

3.2     项目添加角色

HARBOR 仓库 API功能接口
curl -u "jaymarco:Harbor123456" -X POST  -H "Content-Type: application/json" "https://192.168.56.106/api/projects/{project_id}/members/" -d @role.json

 

[root@dcos-hub json]# cat role.json

{

  "roles": [

    3

  ],

  "username": "guest"

}
HARBOR 仓库 API功能接口

 用jaymarco用户创建一个snc_dcos项目,并对snc_dcos加一个权限

curl -u "jaymarco:Harbor123456" -X POST -H "Content-Type: application/json" "https://192.168.56.106/api/projects" -d @createproject.json

 HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

3.3     删除项目中用户权限

curl -u "admin:Harbor12345" -X DELETE -H "Content-Type: application/json" "https://192.168.56.106/api/projects/{project_id}/members/{user_id}"

HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

3.4     获取与用户相关的项目编号和存储库编号

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/statistics"

HARBOR 仓库 API功能接口

3.5     修改当前用户角色

has_admin_role :0  普通用户

has_admin_role :1  管理员

 

HARBOR 仓库 API功能接口
curl -u "admin:Harbor12345" -X PUT -H "Content-Type: application/json" "https://192.168.56.106/api/users/{user_id}/sysadmin " -d @chgrole.json

[root@dcos-hub json]# cat >chgrole.json

{

  "has_admin_role": 1

}
HARBOR 仓库 API功能接口

HARBOR 仓库 API功能接口

4       镜像管理

4.1     查询镜像

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/repositories?project_id={project_id}&q=dcos%2Fcentos"

HARBOR 仓库 API功能接口

 

4.2    删除镜像

curl -u "admin:Harbor12345" -X DELETE -H "Content-Type: application/json" "https://192.168.56.106/api/repositories?repo_name=dcos%2Fetcd "

4.3     获取镜像标签

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "https://192.168.56.106/api/repositories/tags?repo_name=dcos%2Fcentos"

HARBOR 仓库 API功能接口

 

 

 

引用: https://www.cnblogs.com/guigujun/p/8352983.html

HARBOR 仓库 API功能接口

上一篇:windows下挂载NFS共享目录


下一篇:配置静态路由