Documentation
¶
Overview ¶
Package api contains all Harbor REST API interfaces
Index ¶
- func DelPrjByPrjID(baseURL string)
- func DelReplJobByID(baseURL string)
- func DelRepoByRepoName(baseURL string)
- func DelTaginfoOfRepo(baseURL string)
- func DeleteLabel(baseURL string)
- func DeletePrjMemberDel(baseURL string)
- func DeletePrjMetadataDelByName(baseURL string)
- func DeleteRepoImageLabel(baseURL string)
- func DeleteRepoLabel(baseURL string)
- func DeleteTargetsByID(baseURL string)
- func DeleteUser(baseURL string)
- func DeleteUsergroup(baseURL string)
- func GetLabel(baseURL string)
- func GetLabels(baseURL string)
- func GetOPLogs(baseURL string)
- func GetPoliciesByID(baseURL string)
- func GetPoliciesList(baseURL string)
- func GetPolicyByID(baseURL string)
- func GetPrjAllMembers(baseURL string)
- func GetPrjByPrjID(baseURL string)
- func GetPrjLogs(baseURL string)
- func GetPrjMember(baseURL string)
- func GetPrjMetadata(baseURL string)
- func GetPrjMetadataGetByName(baseURL string)
- func GetPrjsList(baseURL string)
- func GetReplListByFilters(baseURL string)
- func GetReplLogByID(baseURL string)
- func GetRepoImageLabel(baseURL string)
- func GetRepoImageManifest(baseURL string)
- func GetRepoLabels(baseURL string)
- func GetRepoSignature(baseURL string)
- func GetReposByPrjID(baseURL string)
- func GetScanLogByID(baseURL string)
- func GetStats(baseURL string)
- func GetSysConfig(baseURL string)
- func GetSysGeneral(baseURL string)
- func GetSysRootCert(baseURL string)
- func GetSysVolumes(baseURL string)
- func GetTaginfoOfRepo(baseURL string)
- func GetTagsByRepoName(baseURL string)
- func GetTargetsByID(baseURL string)
- func GetTargetsList(baseURL string)
- func GetTopRepos(baseURL string)
- func GetUserCurrent(baseURL string)
- func GetUserProfile(baseURL string)
- func GetUsergroup(baseURL string)
- func GetUsergroupsList(baseURL string)
- func GetUsersSearch(baseURL string)
- func LoginHarbor(baseURL string)
- func LogoutHarbor(baseURL string)
- func PostEmailPing(baseURL string)
- func PostLabelCreate(baseURL string)
- func PostPolicyCreate(baseURL string)
- func PostPrjCreate(baseURL string)
- func PostPrjMemberCreate(baseURL string)
- func PostPrjMetadataAdd(baseURL string)
- func PostReplTriByID(baseURL string)
- func PostRepoImageLabelAdd(baseURL string)
- func PostRepoLabelAdd(baseURL string)
- func PostSyncRegistry(baseURL string)
- func PostSysConfigReset(baseURL string)
- func PostTargetsCreate(baseURL string)
- func PostTargetsPing(baseURL string)
- func PostTargetsPingByID(baseURL string)
- func PostUserCreate(baseURL string)
- func PostUsergroupCreate(baseURL string)
- func PutLabelUpdate(baseURL string)
- func PutPolicyUpdateByID(baseURL string)
- func PutPrjMemberUpdate(baseURL string)
- func PutPrjMetadataUpdateByName(baseURL string)
- func PutPrjUpdate(baseURL string)
- func PutReplStopByPolicy(baseURL string)
- func PutRepoDescriptionUpdate(baseURL string)
- func PutSysConfigCreate(baseURL string)
- func PutUserUpdate(baseURL string)
- func PutUserUpdatePassword(baseURL string)
- func PutUserUpdateRole(baseURL string)
- func PutUsergroup(baseURL string)
- func SearchPrjAndRepo(baseURL string)
- func UpdateTargetsByID(baseURL string)
- type ProjectMember
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelPrjByPrjID ¶
func DelPrjByPrjID(baseURL string)
DelPrjByPrjID is aimed to delete project by project ID
params:
project_id - (REQUIRED) Project ID of project which will be deleted.
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/projects/100'
func DelReplJobByID ¶ added in v0.6.0
func DelReplJobByID(baseURL string)
DelReplJobByID is aimed to remove job with specific ID from jobservice.
params:
id - (REQUIRED) Replication job ID to delete.
operation format:
DELETE /jobs/replication/{id}
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/jobs/replication/1'
func DelRepoByRepoName ¶
func DelRepoByRepoName(baseURL string)
DelRepoByRepoName let user delete a repository with name.
params:
repo_name - (REQUIRED) The name of repository which will be deleted.
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/repositories/prj1%2Fhello-world'
func DelTaginfoOfRepo ¶
func DelTaginfoOfRepo(baseURL string)
DelTaginfoOfRepo let user delete tags with repo name and tag.
params:
repo_name - (REQUIRED) The name of repository which will be deleted. tag - (REQUIRED) Tag of a repository.
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/repositories/prj2%2Fphoton/tags/v2'
func DeleteLabel ¶ added in v0.9.6
func DeleteLabel(baseURL string)
DeleteLabel deletes the label specified by ID.
params:
id - Label ID.
operation format:
DELETE /labels/{id}
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/labels/100'
func DeletePrjMemberDel ¶ added in v0.9.3
func DeletePrjMemberDel(baseURL string)
DeletePrjMemberDel deletes a member of the project.
params:
project_id - (REQUIRED) The ID of project. mid - (REQUIRED) Member ID.
format:
DELETE /projects/{project_id}/members/{mid}
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/projects/86/members/86'
func DeletePrjMetadataDelByName ¶ added in v0.9.3
func DeletePrjMetadataDelByName(baseURL string)
DeletePrjMetadataDelByName is aimed to delete metadata of a project.
params:
project_id - (REQUIRED) The ID of project. meta_name - (REQUIRED) The name of metadata.
format:
DELETE /projects/{project_id}/metadatas/{meta_name}
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/projects/86/metadatas/metaname-new'
func DeleteRepoImageLabel ¶ added in v0.9.2
func DeleteRepoImageLabel(baseURL string)
DeleteRepoImageLabel deletes the label from the image specified by the repo_name and tag.
params:
repo_name - (REQUIRED) The name of repository. tag - (REQUIRED) The tag of the image. id - (REQUIRED) The ID of label.
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/repositories/temp_3%2Fhello-world/tags/v1/labels/2'
func DeleteRepoLabel ¶ added in v0.9.2
func DeleteRepoLabel(baseURL string)
DeleteRepoLabel deletes the label from the repository specified by the repo_name.
params:
repo_name - (REQUIRED) The name of repository that you want to delete a label from. id - (REQUIRED) The ID of label.
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/repositories/temp_3%2Fhello-world/labels/2'
func DeleteTargetsByID ¶
func DeleteTargetsByID(baseURL string)
DeleteTargetsByID is for to delete specific replication's target.
params:
id - (REQUIRED) The replication's target ID.
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/targets/2'
func DeleteUser ¶ added in v0.9.0
func DeleteUser(baseURL string)
DeleteUser let administrator of Harbor mark a registered user as be removed.It actually won't be deleted from DB.
params:
id - (REQUIRED) User ID for marking as to be removed.
format:
DELETE /users/{user_id}
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/users/1'
func DeleteUsergroup ¶ added in v1.0.0
func DeleteUsergroup(baseURL string)
DeleteUsergroup delete user group
params:
id - (REQUIRED) The ID of the user group
e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/usergroups/1'
func GetLabel ¶ added in v0.9.6
func GetLabel(baseURL string)
GetLabel gets the label specified by ID.
params:
id - Label ID.
operation format:
GET /labels/{id}
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/labels/100'
func GetLabels ¶ added in v0.9.6
func GetLabels(baseURL string)
GetLabels let user list labels by name, scope and project_id
params:
name - The label name. scope - (REQUIRED) The label scope. Valid values are g and p. g for global labels and p for project labels. project_id - Relevant project ID, required when scope is p. page - The page nubmer, default is 1. page_size - The size of per page, default is 10, maximum is 100.
operation format:
GET /labels
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/labels?scope=g&page=1&page_size=10'
func GetOPLogs ¶
func GetOPLogs(baseURL string)
GetOPLogs ...
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/logs?username=admin&repository=prj2%2Fphoton&tag=v3&operation=push&begin_timestamp=20171102&page=1&page_size=10'
func GetPoliciesByID ¶
func GetPoliciesByID(baseURL string)
GetPoliciesByID lists policies filter with specific replication's target ID.
params:
id - (REQUIRED) The replication's target ID.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/targets/1/policies/'
func GetPoliciesList ¶ added in v0.9.4
func GetPoliciesList(baseURL string)
GetPoliciesList let user list filters policies by name and project_id, if name and project_id are nil, list returns all policies.
params:
name - The replication's policy name. project_id - The ID of project. page - The page nubmer, default is 1. page_size - The size of per page, default is 10, maximum is 100.
format:
GET /policies/replication
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/policies/replication?name=repl_policy_name&project_id=86&page=1&page_size=10'
func GetPolicyByID ¶ added in v0.9.4
func GetPolicyByID(baseURL string)
GetPolicyByID let user search replication policy by specific ID.
params:
id - (REQUIRED) policy ID
format:
GET /policies/replication/{id}
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/policies/replication/1'
func GetPrjAllMembers ¶ added in v0.9.3
func GetPrjAllMembers(baseURL string)
GetPrjAllMembers gets all members information of the project.
params:
project_id - (REQUIRED) The ID of project. entityname - The entity name to search (filter).
format:
GET /projects/{project_id}/members
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/projects/86/members?entityname=admin'
func GetPrjByPrjID ¶
func GetPrjByPrjID(baseURL string)
GetPrjByPrjID returns specific project information by project ID.
params:
project_id - (REQUIRED) Project ID of project which will be get.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/projects/100'
func GetPrjLogs ¶ added in v0.9.3
func GetPrjLogs(baseURL string)
GetPrjLogs lets user search access logs filtered by operations and date time ranges.
params:
project_id - (REQUIRED) Project ID of project which will be get. username - Username of the operator repository - The name of repository tag - The name of tag operation - The operation, ether 'pull' or 'push'. begin_timestamp - The begin timestamp, time format is unknown. end_timestamp - The end timestamp, time format is unknown. page - The page nubmer, default is 1. page_size - The size of per page, default is 10, maximum is 100.
format:
GET /projects/{project_id}/logs
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/projects/86/logs?username=admin&repository=temp_5&tag=v6&operation=pull&page=1&page_size=10'
func GetPrjMember ¶ added in v0.9.3
func GetPrjMember(baseURL string)
GetPrjMember gets a member of the project.
params:
project_id - (REQUIRED) The ID of project. mid - (REQUIRED) Member ID.
format:
GET /projects/{project_id}/members/{mid}
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/projects/86/members/86'
func GetPrjMetadata ¶ added in v0.9.3
func GetPrjMetadata(baseURL string)
GetPrjMetadata returns metadata of the project specified by project ID.
params:
project_id - (REQUIRED) The ID of project.
format:
GET /projects/{project_id}/metadatas
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/projects/86/metadatas'
func GetPrjMetadataGetByName ¶ added in v0.9.3
func GetPrjMetadataGetByName(baseURL string)
GetPrjMetadataGetByName returns specified metadata of a project.
params:
project_id - (REQUIRED) The ID of project. meta_name - (REQUIRED) The name of metadata.
format:
GET /projects/{project_id}/metadatas/{meta_name}
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/projects/86/metadatas/metaname_new'
func GetPrjsList ¶
func GetPrjsList(baseURL string)
GetPrjsList returns all projects created by Harbor, and can be filtered by project name.
params:
name - The name of project. public - The project is public or private. default is "", return both public and private prjs. owner - The name of project owner. page - The page nubmer, default is 1. page_size - The size of per page, default is 10, maximum is 100.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/projects?name=prj&public=true&owner=moooofly&page=1&page_size=10'
func GetReplListByFilters ¶ added in v0.6.0
func GetReplListByFilters(baseURL string)
GetReplListByFilters list filtered jobs according to the policy and repository
params:
policy_id - (REQUIRED) The ID of the policy that triggered this job.
num - The return list length number.
end_time - The end time of jobs done. (Timestamp)
start_time - The start time of jobs. (Timestamp)
repository - The jobs list filtered by repository name.
status - The jobs list filtered by status.
status must be one of [running|error|pending|retrying|stopped|finished|canceled].
If not set, means 'all' by default.
page - The page nubmer, default is 1.
page_size - The size of per page, default is 10, maximum is 100.
operation format:
GET /jobs/replication/{id}/log
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/jobs/replication?page=1&page_size=15&status=finished&start_time=1529884800&end_time=1530057600&policy_id=6'
func GetReplLogByID ¶ added in v0.6.0
func GetReplLogByID(baseURL string)
GetReplLogByID let user search job logs filtered by specific ID.
params:
id - (REQUIRED) Relevant job ID.
operation format:
GET /jobs/replication/{id}/log
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/jobs/replication/1/log'
func GetRepoImageLabel ¶ added in v0.9.2
func GetRepoImageLabel(baseURL string)
GetRepoImageLabel gets labels of an image specified by the repo_name and tag.
params:
repo_name - (REQUIRED) The name of repository. tag - (REQUIRED) The tag of the image.
format:
GET /repositories/{repo_name}/tags/{tag}/labels
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories/temp_3%2Fhello-world/tags/v1/labels'
func GetRepoImageManifest ¶ added in v0.9.2
func GetRepoImageManifest(baseURL string)
GetRepoImageManifest aims to retrieve manifests from a relevant repository.
params:
repo_name - (REQUIRED) The name of repository. tag - (REQUIRED) The tag of the image. version - The version of manifest, valid value are "v1" and "v2", default is "v2"" default:"v2"
format:
GET /repositories/{repo_name}/tags/{tag}/manifest
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories/temp_3%2Fhello-world/tags/v1/manifest?version=v2'
func GetRepoLabels ¶ added in v0.9.2
func GetRepoLabels(baseURL string)
GetRepoLabels get labels of a repository specified by the repo_name.
params:
repo_name - (REQUIRED) The name of repository.
format:
GET /repositories/{repo_name}/labels
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories/temp_5%2Fhello-world/labels'
func GetRepoSignature ¶ added in v0.9.2
func GetRepoSignature(baseURL string)
GetRepoSignature aims to retrieve signature information of a repository, the data is from the nested notary instance of Harbor.
params:
repo_name - (REQUIRED) The name of repository.
format:
GET /repositories/{repo_name}/signatures
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/repositories/temp_3%2Fhello-world/signatures'
func GetReposByPrjID ¶
func GetReposByPrjID(baseURL string)
GetReposByPrjID let user search repositories accompanying with relevant project ID and repo name.
params:
project_id - (REQUIRED) Relevant project ID. q - Repo name for filtering results. label_id - The ID of label used to filter the result. page - The page nubmer, default is 1. pageSize - The size of per page, default is 10, maximum is 100.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories?project_id=1&q=prj&label_id=100&page=1&page_size=10'
func GetScanLogByID ¶ added in v0.6.0
func GetScanLogByID(baseURL string)
GetScanLogByID let user get scan job logs filtered by specific ID.
params:
id - (REQUIRED) Relevant job ID.
operation format:
GET /jobs/scan/{id}/log
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/jobs/scan/1/log'
func GetStats ¶
func GetStats(baseURL string)
GetStats is aimed to statistic all of the projects number and repositories number relevant to the logined user, also the public projects number and repositories number. If the user is admin, he can also get total projects number and total repositories number.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/statistics'
func GetSysConfig ¶
func GetSysConfig(baseURL string)
GetSysConfig is for retrieving system configurations that only provides for admin user.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/configurations'
func GetSysGeneral ¶
func GetSysGeneral(baseURL string)
GetSysGeneral is for retrieving general system info, this can be called by anonymous request.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/systeminfo'
func GetSysRootCert ¶
func GetSysRootCert(baseURL string)
GetSysRootCert is for downloading a default root certificate that only provides for admin user under OVA deployment.
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/systeminfo/getcert'
func GetSysVolumes ¶
func GetSysVolumes(baseURL string)
GetSysVolumes is for retrieving system volume info that only provides for admin user.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/systeminfo/volumes'
func GetTaginfoOfRepo ¶
func GetTaginfoOfRepo(baseURL string)
GetTaginfoOfRepo aims to retrieve the tag of the repository. If deployed with Notary, the signature property of response represents whether the image is singed or not. If the property is null, the image is unsigned.
params:
repo_name - (REQUIRED) Relevant repository name. tag - (REQUIRED) Tag of the repository.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories/prj2%2Fphoton/tags/v2'
func GetTagsByRepoName ¶
func GetTagsByRepoName(baseURL string)
GetTagsByRepoName aims to retrieve tags from a relevant repository. If deployed with Notary, the signature property of response represents whether the image is singed or not. If the property is null, the image is unsigned.
params:
repo_name - (REQUIRED) Relevant repository name.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories/prj2%2Fphoton/tags'
func GetTargetsByID ¶
func GetTargetsByID(baseURL string)
GetTargetsByID is for get specific replication's target.
params:
id - (REQUIRED) The replication's target ID.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/targets/1'
func GetTargetsList ¶
func GetTargetsList(baseURL string)
GetTargetsList let user list filters targets by name, if name is nil, list returns all targets.
params:
name - The replication's target name (for filter).
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/targets?name=remote'
func GetTopRepos ¶
func GetTopRepos(baseURL string)
GetTopRepos aims to let users see the most popular public repositories
params:
count - The number of the requested public repositories, default is 10 if not provided.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/repositories/top?count=3'
func GetUserCurrent ¶ added in v0.9.0
func GetUserCurrent(baseURL string)
GetUserCurrent gets the current user information.
format:
GET /users/current
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/users/current?api_key=top'
func GetUserProfile ¶ added in v0.9.0
func GetUserProfile(baseURL string)
GetUserProfile gets user's profile with user id.
params:
id - (REQUIRED) Registered user ID.
format:
GET /users/{user_id}
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/users/1'
func GetUsergroup ¶ added in v1.0.0
func GetUsergroup(baseURL string)
GetUsergroup get user group information
params:
id - (REQUIRED) The ID of the user group
e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/usergroups/1'
func GetUsergroupsList ¶ added in v1.0.0
func GetUsergroupsList(baseURL string)
GetUsergroupsList get all user groups information
params:
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/usergroups'
func GetUsersSearch ¶ added in v0.9.0
func GetUsersSearch(baseURL string)
GetUsersSearch Get registered users of Harbor.
params:
username - Username for filtering results. email - Email for filtering results. page - The page nubmer, default is 1. page_size - The size of per page, default is 10.
format:
GET /users
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/users?username=san.zhang&email=san.zhang@163.com&page=1&page_size=10'
func LoginHarbor ¶
func LoginHarbor(baseURL string)
LoginHarbor log in to Harbor.
params:
username - Current login username. password - Current login password.
e.g. curl -X POST --header 'Content-Type: application/x-www-form-urlencoded;param=value' 'https://localhost/login' -i -k -d "principal=admin&password=Harbor12345"
func LogoutHarbor ¶
func LogoutHarbor(baseURL string)
LogoutHarbor log out from Harbor.
params:
e.g. curl -X GET 'https://localhost/log_out' -i -k
func PostEmailPing ¶ added in v1.0.0
func PostEmailPing(baseURL string)
PostEmailPing tests connection and authentication with email server.
params:
email_host - The host of email server. email_port - The port of email server. email_username - The username of email server. email_password - The password of email server. email_ssl - Use ssl/tls or not. email_identity - The dentity of email server.
format:
POST /email/ping
e.g.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"email_host": "string", \
"email_port": 0, \
"email_username": "string", \
"email_password": "string", \
"email_ssl": true, \
"email_identity": "string" \
}' 'https://localhost/api/email/ping'
)
func PostLabelCreate ¶ added in v0.9.6
func PostLabelCreate(baseURL string)
PostLabelCreate let user creates a label.
params:
id - The ID of label.
name - (REQUIRED) The name of label.
description - (REQUIRED) The description of label.
color - The color code of label. (e.g. Format: #A9B6BE)
scope - The scope of label. ('p' indicates project scope, 'g' indicates global scope)
project_id - Which project id this label belongs to when created. ('0' indicates global label, others indicate specific project)
creation_time - The creation time of label. default time.Now()
update_time - The update time of label. default time.Now()
deleted - not sure
format:
POST /labels
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"id": 100, \
"name": "label-name-100", \
"description": "label-description-100", \
"color": "#000000", \
"scope": "g", \
"project_id": 0, \
"deleted": true \
}' 'https://localhost/api/labels'
func PostPolicyCreate ¶ added in v0.9.4
func PostPolicyCreate(baseURL string)
PostPolicyCreate let user creates a policy, and if it is enabled, the replication will be triggered right now.
params: format:
e.g.
func PostPrjCreate ¶
func PostPrjCreate(baseURL string)
PostPrjCreate is for user to create a new project.
params:
project_name - The name of the project. public - The public status of the project, public(1) or private(0). enable_content_trust - Whether content trust is enabled or not. If it is enabled, user cann't pull unsigned images from this project. prevent_vulnerable_images_from_running - Whether prevent the vulnerable images from running. prevent_vulnerable_images_from_running_severity - If the vulnerability is high than severity defined here, the images cann't be pulled. automatically_scan_images_on_push - Whether scan images automatically when pushing.
e.g.
curl -X POST --header 'Content-Type: text/plain' --header 'Accept: text/plain' -d '{
"project_name": "t1",
"public": 0,
"enable_content_trust": false,
"prevent_vulnerable_images_from_running": false,
"prevent_vulnerable_images_from_running_severity": "",
"automatically_scan_images_on_push": false
}' 'https://localhost/api/projects'
func PostPrjMemberCreate ¶ added in v0.9.3
func PostPrjMemberCreate(baseURL string)
PostPrjMemberCreate creates project member relationship, the member can be one of the user_member and group_member, The user_member need to specify user_id or username. If the user already exist in harbor DB, specify the user_id, If does not exist in harbor DB, it will SearchAndOnBoard the user. The group_member need to specify id or ldap_group_dn. If the group already exist in harbor DB. specify the user group's id, If does not exist, it will SearchAndOnBoard the group.
params:
project_id - (REQUIRED) The ID of project. mid - (REQUIRED) Member ID.
format:
POST /projects/{project_id}/members
e.g.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"role_id": 3, \
"member_user": { \
"username": "fei.sun" \
} \
}' 'https://localhost/api/projects/86/members'
func PostPrjMetadataAdd ¶ added in v0.9.3
func PostPrjMetadataAdd(baseURL string)
PostPrjMetadataAdd is aimed to add metadata of a project.
params:
project_id - (REQUIRED) The ID of project. public - The public status of the project, public(1) or private(0). enable_content_trust - Whether content trust is enabled or not. If it is enabled, user cann't pull unsigned images from this project. prevent_vulnerable_images_from_running - Whether prevent the vulnerable images from running. prevent_vulnerable_images_from_running_severity - If the vulnerability is high than severity defined here, the images cann't be pulled. automatically_scan_images_on_push - Whether scan images automatically when pushing.
format:
POST /projects/{project_id}/metadatas
e.g.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"public": "false" \
}' 'https://localhost/api/projects/86/metadatas'
func PostReplTriByID ¶ added in v1.0.0
func PostReplTriByID(baseURL string)
PostReplTriByID is used to trigger a replication.
params:
policy_id - (REQUIRED) The ID of replication policy
format:
POST /replications
e.g.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"policy_id": 1 \
}' 'https://localhost/api/replications'
func PostRepoImageLabelAdd ¶ added in v0.9.2
func PostRepoImageLabelAdd(baseURL string)
PostRepoImageLabelAdd adds a label to the image under specific repository.
params:
repo_name - (REQUIRED) The name of repository that you want to add a label.
tag - (REQUIRED) The tag of the image.
id - (REQUIRED) The ID of the already existing label.
name - The name of this label.
description - The description of this label.
color - The color code of this label. (e.g. Format: #A9B6BE)
scope - The scope of this label. ('p' indicates project scope, 'g' indicates global scope)
project_id - Which project (id) this label belongs to when created. ('0' indicates global label, others indicate specific project)
creation_time - The creation time of this label. default time.Now()
update_time - The update time of this label. default time.Now()
deleted - not sure
format:
POST /repositories/{repo_name}/tags/{tag}/labels
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"id": 3, \
"name": "test-name", \
"description": "test-description", \
"color": "test-color", \
"scope": "test-scope", \
"project_id": 10, \
"deleted": true \
}' 'https://localhost/api/repositories/temp_3%2Fhello-world/tags/v1/labels'
func PostRepoLabelAdd ¶ added in v0.9.2
func PostRepoLabelAdd(baseURL string)
PostRepoLabelAdd add a label to the repository.
params:
repo_name - (REQUIRED) The name of repository that you want to add a label.
id - (REQUIRED) The ID of the already existing label.
name - The name of this label.
description - The description of this label.
color - The color code of this label. (e.g. Format: #A9B6BE)
scope - The scope of this label. ('p' indicates project scope, 'g' indicates global scope)
project_id - Which project (id) this label belongs to when created. ('0' indicates global label, others indicate specific project)
creation_time - The creation time of this label. default time.Now()
update_time - The update time of this label. default time.Now()
deleted - not sure
format:
POST /repositories/{repo_name}/labels
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"id": 2, \
"name": "test-name", \
"description": "test-description", \
"color": "test-color", \
"scope": "test-scope", \
"project_id": 10, \
"deleted": true \
}' 'https://localhost/api/repositories/temp_5%2Fhello-world/labels'
func PostSyncRegistry ¶ added in v1.0.0
func PostSyncRegistry(baseURL string)
PostSyncRegistry is for syncing all repositories of registry with database.
params:
format:
POST /internal/syncregistry
e.g. curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' 'https://localhost/api/internal/syncregistry'
func PostSysConfigReset ¶
func PostSysConfigReset(baseURL string)
PostSysConfigReset resets system configurations from environment variables. Can only be accessed by admin user.
e.g. curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' 'https://localhost/api/configurations/reset'
func PostTargetsCreate ¶
func PostTargetsCreate(baseURL string)
PostTargetsCreate is for user to create a new replication target.
params:
endpoint - The target address URL string name - The target name. username - The target server username. password - The target server password. insecure - Whether or not the certificate will be verified when Harbor tries to access the server.
e.g.
curl -X POST --header 'Content-Type: text/plain' --header 'Accept: text/plain' -d '{
"endpoint": "https://11.11.11.14",
"name": "rule4",
"username": "admin",
"password": "Harbor12345",
"insecure": true
}' 'https://localhost/api/targets'
func PostTargetsPing ¶
func PostTargetsPing(baseURL string)
PostTargetsPing is for ping validates whether the target is reachable and whether the credential is valid.
params:
endpoint - The target address URL string username - The target server username. password - The target server password. insecure - Whether or not the certificate will be verified when Harbor tries to access the server.
e.g.
curl -X POST --header 'Content-Type: text/plain' --header 'Accept: text/plain' -d '{
"endpoint": "https://11.11.11.11",
"username": "admin",
"password": "Harbor12345",
"insecure": true
}' 'https://localhost/api/targets/ping'
func PostTargetsPingByID ¶
func PostTargetsPingByID(baseURL string)
PostTargetsPingByID is for ping target.
params:
id - (REQUIRED) The replication's target ID.
e.g. curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' 'https://localhost/api/targets/1/ping'
func PostUserCreate ¶ added in v0.9.0
func PostUserCreate(baseURL string)
PostUserCreate Creates a new user account.
params:
user_id - (REQUIRED) Registered user ID. Must be unique. username - (REQUIRED) User name. password - (REQUIRED) User password. (not support consealing here) email - (REQUIRED) User's email. has_admin_role - (REQUIRED) Mark a user whether is admin or not. realname - User's realname. comment - Custom comment. deleted - Deleted (no idea about this). role_name - User's role name. role_id - User's role id. reset_uuid - Reset UUID (no idea about this). salt - Salt for password encryption. creation_time - User's creation time. Default time.Now(). update_time - User's update time. Default time.Now().
format:
POST /users
e.g.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"user_id": 100, \
"username": "san.zhang", \
"email": "san.zhang%40163.com", \
"password": "Harbor12345", \
"realname": "san.zhang", \
"comment": "I%27m Zhang San", \
"deleted": 0, \
"role_name": "", \
"role_id": 0, \
"has_admin_role": 0, \
"reset_uuid": "", \
"Salt": "", \
"creation_time": "2018-07-23T05:59:26Z", \
"update_time": "2018-07-23T05:59:26Z" \
}' 'https://localhost/api/users'
func PostUsergroupCreate ¶ added in v1.0.0
func PostUsergroupCreate(baseURL string)
PostUsergroupCreate create user group information
params:
id - The ID of the user group group_name - The name of the user group group_type - The group type, 1 for LDAP group ldap_group_dn - The DN of the LDAP group if group type is 1 (LDAP group)
e.g.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"id": 100, \
"group_name": "tmp-group", \
"group_type": 1, \
"ldap_group_dn": "" \
}' 'https://localhost/api/usergroups'
func PutLabelUpdate ¶ added in v0.9.6
func PutLabelUpdate(baseURL string)
PutLabelUpdate let user update label properties.
params:
id - The ID of label.
name - (REQUIRED) The name of label.
description - (REQUIRED) The description of label.
color - The color code of label. (e.g. Format: #A9B6BE)
scope - The scope of label. ('p' indicates project scope, 'g' indicates global scope)
project_id - Which project id this label belongs to when created. ('0' indicates global label, others indicate specific project)
creation_time - The creation time of label. default time.Now()
update_time - The update time of label. default time.Now()
deleted - not sure
operation format:
PUT /labels/{id}
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"id": 0, \
"name": "label-name-100", \
"description": "label-description-100", \
"color": "#000000", \
"scope": "g", \
"project_id": 0, \
"deleted": true \
}' 'https://localhost/api/labels/100'
func PutPolicyUpdateByID ¶ added in v0.9.4
func PutPolicyUpdateByID(baseURL string)
PutPolicyUpdateByID let user update policy name, description, target and enablement.
params: format:
e.g.
func PutPrjMemberUpdate ¶ added in v0.9.3
func PutPrjMemberUpdate(baseURL string)
PutPrjMemberUpdate updates a member of the project.
params:
project_id - (REQUIRED) The ID of project. mid - (REQUIRED) Member ID. role_id - (REQUIRED) Role ID.
format:
PUT /projects/{project_id}/members/{mid}
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"role_id": 1 \
}' 'https://localhost/api/projects/86/members/86'
func PutPrjMetadataUpdateByName ¶ added in v0.9.3
func PutPrjMetadataUpdateByName(baseURL string)
PutPrjMetadataUpdateByName is aimed to update the metadata of a project.
params:
project_id - (REQUIRED) The ID of project. meta_name - (REQUIRED) The name of metadata.
format:
PUT /projects/{project_id}/metadatas/{meta_name}
e.g. curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' 'https://localhost/api/projects/86/metadatas/metaname_new'
func PutPrjUpdate ¶ added in v0.9.3
func PutPrjUpdate(baseURL string)
PutPrjUpdate is aimed to update the properties of a project.
params:
project_id - (REQUIRED) Project ID of project which will be get. project_name - The name of the project. public - The public status of the project, public(1) or private(0). enable_content_trust - Whether content trust is enabled or not. If it is enabled, user cann't pull unsigned images from this project. prevent_vulnerable_images_from_running - Whether prevent the vulnerable images from running. prevent_vulnerable_images_from_running_severity - If the vulnerability is high than severity defined here, the images cann't be pulled. automatically_scan_images_on_push - Whether scan images automatically when pushing.
format:
PUT /projects/{project_id}
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"project_name": "t1", \
"public": 1, \
"enable_content_trust": false, \
"prevent_vulnerable_images_from_running": false, \
"prevent_vulnerable_images_from_running_severity": "", \
"automatically_scan_images_on_push": false \
}' 'https://localhost/api/projects/92'
func PutReplStopByPolicy ¶ added in v0.6.0
func PutReplStopByPolicy(baseURL string)
PutReplStopByPolicy is used to stop the replication jobs of a policy.
params:
policy_id - (REQUIRED) The ID of replication policy. status - (REQUIRED) The status of jobs. The only valid value is "stop" for now.
operation format:
PUT /jobs/replication
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"policy_id": 1, \
"status": "stop" \
}' 'https://localhost/api/jobs/replication'
func PutRepoDescriptionUpdate ¶ added in v0.9.2
func PutRepoDescriptionUpdate(baseURL string)
PutRepoDescriptionUpdate is used to update description of the repository.
params:
repo_name - (REQUIRED) The name of repository which will be deleted. description - (REQUIRED) The description of the repository.
format:
PUT /repositories/{repo_name}
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"description": "change" \
}' 'https://localhost/api/repositories/temp_5%2Fhello-world'
func PutSysConfigCreate ¶
func PutSysConfigCreate(baseURL string)
PutSysConfigCreate is for modifying system configurations that only provides for admin user.
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{
"auth_mode": "db_auth",
"email_from": "admin <sample_admin@mydomain.com>",
"email_host": "smtp.mydomain.com",
"email_port": 1200,
"email_identity": "",
"email_username": "sample_admin@mydomain.com",
"email_ssl": false,
"email_insecure": true,
"ldap_url": "ldaps://ldap.mydomain.com",
"ldap_base_dn": "ou=people,dc=mydomain,dc=com",
"ldap_filter": "",
"ldap_scope": 3,
"ldap_uid": "uid",
"ldap_search_dn": "",
"ldap_timeout": 5,
"project_creation_restriction": "everyone",
"self_registration": true,
"token_expiration": 30,
"verify_remote_cert": true,
"scan_all_policy": {
"type": "daily",
"parameter": {
"daily_time": 0
}
}
}' 'https://localhost/api/configurations'
func PutUserUpdate ¶ added in v0.9.0
func PutUserUpdate(baseURL string)
PutUserUpdate let a registered user change his profile.
params:
id - (REQUIRED) Registered user ID. email - (REQUIRED) User email. realname - (REQUIRED) User's realname. comment - (REQUIRED) Custom comment.
format:
PUT /users/{user_id}
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"email": "si.li%40163.com", \
"realname": "si.li", \
"comment": "I'm Li Si" \
}' 'https://localhost/api/users/1'
func PutUserUpdatePassword ¶ added in v0.9.0
func PutUserUpdatePassword(baseURL string)
PutUserUpdatePassword is for user to update password. Users with the admin role can change any user's password. Guest users can change only their own password.
params:
id - (REQUIRED) Registered user ID. old_password - (REQUIRED) Old password. new_password - (REQUIRED) New password.
format:
PUT /users/{user_id}/password
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"old_password": "old password", \
"new_password": "new password" \
}' 'https://localhost/api/users/1/password'
func PutUserUpdateRole ¶ added in v0.9.0
func PutUserUpdateRole(baseURL string)
PutUserUpdateRole let a registered user change to be an administrator of Harbor.
params:
id - (REQUIRED) Registered user ID. has_admin_role - (REQUIRED) Toggle a user to admin or not.
format:
PUT /users/{user_id}/password
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"has_admin_role": 1 \
}' 'https://localhost/api/users/1/sysadmin'
func PutUsergroup ¶ added in v1.0.0
func PutUsergroup(baseURL string)
PutUsergroup update user group information
params:
id - The ID of the user group group_name - The name of the user group group_type - The group type, 1 for LDAP group ldap_group_dn - The DN of the LDAP group if group type is 1 (LDAP group)
e.g.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"id": 1, \
"group_name": "tmp-group", \
"group_type": 1, \
"ldap_group_dn": "" \
}' 'https://localhost/api/usergroups/1'
func SearchPrjAndRepo ¶
func SearchPrjAndRepo(baseURL string)
SearchPrjAndRepo returns information about the projects and repositories offered at public status or related to the current logged in user. The response includes the project and repository list in a proper display order.
e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/search?q=hello-world'
func UpdateTargetsByID ¶
func UpdateTargetsByID(baseURL string)
UpdateTargetsByID is for update specific replication's target.
params:
id - (REQUIRED) The replication's target ID. endpoint - The target address URL string name - The target name. username - The target server username. password - The target server password. insecure - Whether or not the certificate will be verified when Harbor tries to access the server.
e.g.
curl -X PUT --header 'Content-Type: text/plain' --header 'Accept: text/plain' -d '{
"endpoint": "https://11.11.11.14",
"name": "change from rule4 to RULE4",
"username": "admin",
"password": "12345",
"insecure": true
}' 'https://localhost/api/targets/4'
Types ¶
type ProjectMember ¶ added in v0.9.3
type ProjectMember struct {
RoleID int `json:"role_id,omitempty"`
MemberUser struct {
UserID int `json:"user_id,omitempty,omitempty"`
Username string `json:"username,omitempty"`
} `json:"member_user,omitempty"`
MemberGroup struct {
ID int `json:"id,omitempty"`
GroupName string `json:"group_name,omitempty"`
GroupType int `json:"group_type,omitempty"`
LdapGroupDn string `json:"ldap_group_dn,omitempty"`
} `json:"member_group,omitempty"`
}
ProjectMember defines the member settings of a project.