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"

1.2     搜索镜像

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

1.3     删除项目

 

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

1.4     创建项目

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

}

1.5     查看项目日志

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"

}

2       账号管理

2.1     创建账号

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

}

2.2     获取用户信息

 

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

 

2.3     获取当前用户信息 

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

2.4     删除用户

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

2.5     修改用户密码

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"

}

3       用户权限管理

3.1     查看项目相关角色

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

3.2     项目添加角色

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"

}

 用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

 

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}"

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

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

3.5     修改当前用户角色

has_admin_role :0  普通用户

has_admin_role :1  管理员

 

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

}

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"

 

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"

 

转载于:https://www.cnblogs.com/guigujun/p/8352983.html

GitHub 加速计划 / ha / harbor
23.24 K
4.68 K
下载
Harbor 是一个开源的容器镜像仓库,用于存储和管理 Docker 镜像和其他容器镜像。 * 容器镜像仓库、存储和管理 Docker 镜像和其他容器镜像 * 有什么特点:支持多种镜像格式、易于使用、安全性和访问控制
最近提交(Master分支:2 个月前 )
9e55afbb pull image from registry.goharbor.io instead of dockerhub Update testcase to support Docker Image Can Be Pulled With Credential Change gitlab project name when user changed. Update permissions count and permission count total Change webhook_endpoint_ui Signed-off-by: stonezdj <stone.zhang@broadcom.com> Co-authored-by: Wang Yan <wangyan@vmware.com> 14 天前
3dbfd422 Signed-off-by: wang yan <wangyan@vmware.com> 14 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐