docker基础:私库系列:再探Harbor:(6) restapi的使用
在前面的harbor架构的说明中我们提到过habor的后端使用了beego的框架,由于同时harbor提供了swagger的配置文件,在学习使用harbor的api时建议运行起swagger的设定更为简单,而这里我们直接确认beego.router也能起到整体api确认的效果。
·
在前面的harbor架构的说明中我们提到过habor的后端使用了beego的框架,由于同时harbor提供了swagger的配置文件,在学习使用harbor的api时建议运行起swagger的设定更为简单,而这里我们直接确认beego.router也能起到整体api确认的效果。
api信息
git clone下来harbor的代码,简单确认了一下,大概有90个左右的api的router信息
[root@liumiao harbor]# find . -name '*.go' |xargs grep beego.Router |grep -v _test |grep -v '://' |wc -l
90
[root@liumiao harbor]#
而api,目前基本统一在ui下进行管理
[root@liumiao harbor]# find . -name '*.go' |xargs grep beego.Router |grep -v _test |grep -v '://' |awk -F: '{print $1}' |sort |uniq -c
90 ./src/ui/router.go
[root@liumiao harbor]#
比如,在前面为了确认设定信息所使用过的api/systeminfo
[root@liumiao harbor]# find . -name '*.go' |xargs grep beego.Router |grep -v _test |grep -v '://' |grep systeminfo
./src/ui/router.go: beego.Router("/api/systeminfo", &api.SystemInfoAPI{}, "get:GetGeneralInfo")
./src/ui/router.go: beego.Router("/api/systeminfo/volumes", &api.SystemInfoAPI{}, "get:GetVolumeInfo")
./src/ui/router.go: beego.Router("/api/systeminfo/getcert", &api.SystemInfoAPI{}, "get:GetCert")
[root@liumiao harbor]#
获取一下volumes信息
api概要
[root@liumiao harbor]# find . -name '*.go' |xargs grep beego.Router |grep -v _test |grep -v '://'
./src/ui/router.go: beego.Router("/", &controllers.IndexController{})
./src/ui/router.go: beego.Router("/harbor/*", &controllers.IndexController{})
./src/ui/router.go: beego.Router("/reset_password", &controllers.IndexController{})
./src/ui/router.go: beego.Router("/login", &controllers.CommonController{}, "post:Login")
./src/ui/router.go: beego.Router("/log_out", &controllers.CommonController{}, "get:LogOut")
./src/ui/router.go: beego.Router("/reset", &controllers.CommonController{}, "post:ResetPassword")
./src/ui/router.go: beego.Router("/userExists", &controllers.CommonController{}, "post:UserExists")
./src/ui/router.go: beego.Router("/sendEmail", &controllers.CommonController{}, "get:SendResetEmail")
./src/ui/router.go: beego.Router("/api/projects/:pid([0-9]+)/members/?:pmid([0-9]+)", &api.ProjectMemberAPI{})
./src/ui/router.go: beego.Router("/api/projects/", &api.ProjectAPI{}, "head:Head")
./src/ui/router.go: beego.Router("/api/projects/:id([0-9]+)", &api.ProjectAPI{})
./src/ui/router.go: beego.Router("/api/users/:id", &api.UserAPI{}, "get:Get;delete:Delete;put:Put")
./src/ui/router.go: beego.Router("/api/users", &api.UserAPI{}, "get:List;post:Post")
./src/ui/router.go: beego.Router("/api/users/:id([0-9]+)/password", &api.UserAPI{}, "put:ChangePassword")
./src/ui/router.go: beego.Router("/api/users/:id/sysadmin", &api.UserAPI{}, "put:ToggleUserAdminRole")
./src/ui/router.go: beego.Router("/api/usergroups/?:ugid([0-9]+)", &api.UserGroupAPI{})
./src/ui/router.go: beego.Router("/api/ldap/ping", &api.LdapAPI{}, "post:Ping")
./src/ui/router.go: beego.Router("/api/ldap/users/search", &api.LdapAPI{}, "get:Search")
./src/ui/router.go: beego.Router("/api/ldap/groups/search", &api.LdapAPI{}, "get:SearchGroup")
./src/ui/router.go: beego.Router("/api/ldap/users/import", &api.LdapAPI{}, "post:ImportUser")
./src/ui/router.go: beego.Router("/api/email/ping", &api.EmailAPI{}, "post:Ping")
./src/ui/router.go: beego.Router("/api/ping", &api.SystemInfoAPI{}, "get:Ping")
./src/ui/router.go: beego.Router("/api/search", &api.SearchAPI{})
./src/ui/router.go: beego.Router("/api/projects/", &api.ProjectAPI{}, "get:List;post:Post")
./src/ui/router.go: beego.Router("/api/projects/:id([0-9]+)/logs", &api.ProjectAPI{}, "get:Logs")
./src/ui/router.go: beego.Router("/api/projects/:id([0-9]+)/_deletable", &api.ProjectAPI{}, "get:Deletable")
./src/ui/router.go: beego.Router("/api/projects/:id([0-9]+)/metadatas/?:name", &api.MetadataAPI{}, "get:Get")
./src/ui/router.go: beego.Router("/api/projects/:id([0-9]+)/metadatas/", &api.MetadataAPI{}, "post:Post")
./src/ui/router.go: beego.Router("/api/projects/:id([0-9]+)/metadatas/:name", &api.MetadataAPI{}, "put:Put;delete:Delete")
./src/ui/router.go: beego.Router("/api/repositories", &api.RepositoryAPI{}, "get:Get")
./src/ui/router.go: beego.Router("/api/repositories/scanAll", &api.RepositoryAPI{}, "post:ScanAll")
./src/ui/router.go: beego.Router("/api/repositories/*", &api.RepositoryAPI{}, "delete:Delete;put:Put")
./src/ui/router.go: beego.Router("/api/repositories/*/labels", &api.RepositoryLabelAPI{}, "get:GetOfRepository;post:AddToRepository")
./src/ui/router.go: beego.Router("/api/repositories/*/labels/:id([0-9]+)", &api.RepositoryLabelAPI{}, "delete:RemoveFromRepository")
./src/ui/router.go: beego.Router("/api/repositories/*/tags/:tag", &api.RepositoryAPI{}, "delete:Delete;get:GetTag")
./src/ui/router.go: beego.Router("/api/repositories/*/tags/:tag/labels", &api.RepositoryLabelAPI{}, "get:GetOfImage;post:AddToImage")
./src/ui/router.go: beego.Router("/api/repositories/*/tags/:tag/labels/:id([0-9]+)", &api.RepositoryLabelAPI{}, "delete:RemoveFromImage")
./src/ui/router.go: beego.Router("/api/repositories/*/tags", &api.RepositoryAPI{}, "get:GetTags")
./src/ui/router.go: beego.Router("/api/repositories/*/tags/:tag/scan", &api.RepositoryAPI{}, "post:ScanImage")
./src/ui/router.go: beego.Router("/api/repositories/*/tags/:tag/vulnerability/details", &api.RepositoryAPI{}, "Get:VulnerabilityDetails")
./src/ui/router.go: beego.Router("/api/repositories/*/tags/:tag/manifest", &api.RepositoryAPI{}, "get:GetManifests")
./src/ui/router.go: beego.Router("/api/repositories/*/signatures", &api.RepositoryAPI{}, "get:GetSignatures")
./src/ui/router.go: beego.Router("/api/repositories/top", &api.RepositoryAPI{}, "get:GetTopRepos")
./src/ui/router.go: beego.Router("/api/jobs/replication/", &api.RepJobAPI{}, "get:List;put:StopJobs")
./src/ui/router.go: beego.Router("/api/jobs/replication/:id([0-9]+)", &api.RepJobAPI{})
./src/ui/router.go: beego.Router("/api/jobs/replication/:id([0-9]+)/log", &api.RepJobAPI{}, "get:GetLog")
./src/ui/router.go: beego.Router("/api/jobs/scan/:id([0-9]+)/log", &api.ScanJobAPI{}, "get:GetLog")
./src/ui/router.go: beego.Router("/api/system/gc", &api.GCAPI{}, "get:List")
./src/ui/router.go: beego.Router("/api/system/gc/:id", &api.GCAPI{}, "get:GetGC")
./src/ui/router.go: beego.Router("/api/system/gc/:id([0-9]+)/log", &api.GCAPI{}, "get:GetLog")
./src/ui/router.go: beego.Router("/api/system/gc/schedule", &api.GCAPI{}, "get:Get;put:Put;post:Post")
./src/ui/router.go: beego.Router("/api/policies/replication/:id([0-9]+)", &api.RepPolicyAPI{})
./src/ui/router.go: beego.Router("/api/policies/replication", &api.RepPolicyAPI{}, "get:List")
./src/ui/router.go: beego.Router("/api/policies/replication", &api.RepPolicyAPI{}, "post:Post")
./src/ui/router.go: beego.Router("/api/targets/", &api.TargetAPI{}, "get:List")
./src/ui/router.go: beego.Router("/api/targets/", &api.TargetAPI{}, "post:Post")
./src/ui/router.go: beego.Router("/api/targets/:id([0-9]+)", &api.TargetAPI{})
./src/ui/router.go: beego.Router("/api/targets/:id([0-9]+)/policies/", &api.TargetAPI{}, "get:ListPolicies")
./src/ui/router.go: beego.Router("/api/targets/ping", &api.TargetAPI{}, "post:Ping")
./src/ui/router.go: beego.Router("/api/logs", &api.LogAPI{})
./src/ui/router.go: beego.Router("/api/configurations", &api.ConfigAPI{})
./src/ui/router.go: beego.Router("/api/configurations/reset", &api.ConfigAPI{}, "post:Reset")
./src/ui/router.go: beego.Router("/api/statistics", &api.StatisticAPI{})
./src/ui/router.go: beego.Router("/api/replications", &api.ReplicationAPI{})
./src/ui/router.go: beego.Router("/api/labels", &api.LabelAPI{}, "post:Post;get:List")
./src/ui/router.go: beego.Router("/api/labels/:id([0-9]+)", &api.LabelAPI{}, "get:Get;put:Put;delete:Delete")
./src/ui/router.go: beego.Router("/api/labels/:id([0-9]+)/resources", &api.LabelAPI{}, "get:ListResources")
./src/ui/router.go: beego.Router("/api/systeminfo", &api.SystemInfoAPI{}, "get:GetGeneralInfo")
./src/ui/router.go: beego.Router("/api/systeminfo/volumes", &api.SystemInfoAPI{}, "get:GetVolumeInfo")
./src/ui/router.go: beego.Router("/api/systeminfo/getcert", &api.SystemInfoAPI{}, "get:GetCert")
./src/ui/router.go: beego.Router("/api/internal/syncregistry", &api.InternalAPI{}, "post:SyncRegistry")
./src/ui/router.go: beego.Router("/api/internal/renameadmin", &api.InternalAPI{}, "post:RenameAdmin")
./src/ui/router.go: beego.Router("/service/notifications", ®istry.NotificationHandler{})
./src/ui/router.go: beego.Router("/service/notifications/clair", &clair.Handler{}, "post:Handle")
./src/ui/router.go: beego.Router("/service/notifications/jobs/scan/:id([0-9]+)", &jobs.Handler{}, "post:HandleScan")
./src/ui/router.go: beego.Router("/service/notifications/jobs/replication/:id([0-9]+)", &jobs.Handler{}, "post:HandleReplication")
./src/ui/router.go: beego.Router("/service/notifications/jobs/adminjob/:id([0-9]+)", &admin.Handler{}, "post:HandleAdminJob")
./src/ui/router.go: beego.Router("/service/token", &token.Handler{})
./src/ui/router.go: beego.Router("/v2/*", &controllers.RegistryProxy{}, "*:Handle")
./src/ui/router.go: beego.Router("/api/chartrepo/health", chartRepositoryAPIType, "get:GetHealthStatus")
./src/ui/router.go: beego.Router("/api/chartrepo/:repo/charts", chartRepositoryAPIType, "get:ListCharts")
./src/ui/router.go: beego.Router("/api/chartrepo/:repo/charts/:name", chartRepositoryAPIType, "get:ListChartVersions")
./src/ui/router.go: beego.Router("/api/chartrepo/:repo/charts/:name/:version", chartRepositoryAPIType, "get:GetChartVersion")
./src/ui/router.go: beego.Router("/api/chartrepo/:repo/charts/:name/:version", chartRepositoryAPIType, "delete:DeleteChartVersion")
./src/ui/router.go: beego.Router("/api/chartrepo/:repo/charts", chartRepositoryAPIType, "post:UploadChartVersion")
./src/ui/router.go: beego.Router("/api/chartrepo/:repo/prov", chartRepositoryAPIType, "post:UploadChartProvFile")
./src/ui/router.go: beego.Router("/api/chartrepo/charts", chartRepositoryAPIType, "post:UploadChartVersion")
./src/ui/router.go: beego.Router("/chartrepo/:repo/index.yaml", chartRepositoryAPIType, "get:GetIndexByRepo")
./src/ui/router.go: beego.Router("/chartrepo/index.yaml", chartRepositoryAPIType, "get:GetIndex")
./src/ui/router.go: beego.Router("/chartrepo/:repo/charts/:filename", chartRepositoryAPIType, "get:DownloadChart")
[root@liumiao harbor]#
harbor的swagger
使用habor的swagger设定文件,最简单的方式莫过于直接将yaml文件贴到http://editor.swagger.io/里面了,harbor的swagger文件:
更多推荐
已为社区贡献51条内容
所有评论(0)