agentleFS
Aidas-devAidas-dev/k8s-agent-skills/skills/harbor-api/SKILL.md

harbor-api

Skill4 starsChanged 5 months agoMITView on GitHub

Use when working with the Harbor REST API v2 — project management, artifact operations, robot accounts, replication, vulnerability scanning, OIDC/LDAP config, garbage collection, and general API automation with curl.

  • Sends data out

The file

Files
SKILL.md

Harbor REST API v2

Base: /api/v2.0. Latest stable: Harbor v2.15.1 (May 2026). API spec: Swagger 2.0 at api/v2.0/swagger.yaml. Built-in Swagger UI: https://<harbor>/devcenter-api-2.0.

Authentication

MethodHeader / UsageUse Case
Basic Auth-u username:passwordDirect admin/developer API access
Bearer TokenAuthorization: Bearer <token>Obtained from /service/token per Docker Registry v2 spec
Robot Account-u robot$<prefix><name>:<secret>Automated CI/CD with scoped permissions
OIDC ID TokenAuthorization: Bearer <oidc_id_token>OIDC-authenticated users (basic auth not supported for OIDC)

Bearer Token Flow

# Get token for push/pull access to a repo
TOKEN=$(curl -s -u "username:password" \
  "https://harbor.example.com/service/token?service=harbor-registry&scope=repository:project/repo:pull,push" \
  | jq -r '.token')

# Use for registry operations
curl -H "Authorization: Bearer $TOKEN" https://harbor.example.com/v2/_catalog

Robot Account Notes

  • Secret shown only once at creation — Harbor does not store it
  • Username format: robot$<prefix><account_name>
  • System-level (v2.2.0+) or project-level scope
  • Permissions: granular RBAC (push, pull, create, read, delete, list, etc.)

Key Endpoints

Health & Status

MethodEndpointPurpose
GET/healthComponent health (no auth)
GET/statisticsProject & repo statistics
GET/search?q=<query>Search projects, repos, helm charts

Project Management

MethodEndpointPurpose
GET/projectsList projects (filter: name, public, owner)
POST/projectsCreate project
HEAD/projectsCheck project name exists
GET/projects/{name_or_id}Get project
PUT/projects/{name_or_id}Update project
DELETE/projects/{name_or_id}Delete project
GET/projects/{name_or_id}/_deletableCheck if deletable
GET/projects/{name_or_id}/summaryProject summary
GET/projects/{name_or_id}/metadatasList metadata
POST/projects/{name_or_id}/metadatasAdd metadata
GET/PUT/DELETE/projects/{name_or_id}/metadatas/{meta_name}CRUD metadata entry
GET/projects/{name_or_id}/membersList members
POST/projects/{name_or_id}/membersAdd member
GET/PUT/DELETE/projects/{name_or_id}/members/{mid}CRUD member

Repository Management

MethodEndpointPurpose
GET/repositoriesList all authorized repos
GET/projects/{project}/repositoriesList repos in project
GET/projects/{project}/repositories/{repo}Get repo
PUT/projects/{project}/repositories/{repo}Update repo description
DELETE/projects/{project}/repositories/{repo}Delete repo

Artifact Management

MethodEndpointPurpose
GET/projects/{proj}/repositories/{repo}/artifactsList artifacts (?q=tags=*, labels, etc.)
POST/projects/{proj}/repositories/{repo}/artifactsCopy artifact
GET/projects/{proj}/repositories/{repo}/artifacts/{ref}Get artifact by digest or tag
DELETE/projects/{proj}/repositories/{repo}/artifacts/{ref}Delete artifact
PUT/projects/{proj}/repositories/{repo}/artifacts/{ref}/add-labelAdd label
DELETE/projects/{proj}/repositories/{repo}/artifacts/{ref}/labels/{label_id}Remove label
GET/projects/{proj}/repositories/{repo}/artifacts/{ref}/tagsList tags
POST/projects/{proj}/repositories/{repo}/artifacts/{ref}/tagsCreate tag
DELETE/projects/{proj}/repositories/{repo}/artifacts/{ref}/tags/{tag}Delete tag

Vulnerability Scanning

MethodEndpointPurpose
POST/projects/{proj}/repositories/{repo}/artifacts/{ref}/scanTrigger scan
POST/projects/{proj}/repositories/{repo}/artifacts/{ref}/scan/stopStop scan
GET/scannersList scanners
GET/scanners/{id}Get scanner metadata
POST/scanners/pingPing scanner adapter
GET/projects/{proj}/repositories/{repo}/artifacts/{ref}/scan/{report_id}Get scan report

Robot Accounts

MethodEndpointPurpose
GET/robotsList robot accounts
POST/robotsCreate robot account
GET/robots/{id}Get robot
PUT/robots/{id}Update robot
DELETE/robots/{id}Delete robot
PATCH/robots/{id}Refresh robot secret

Replication

MethodEndpointPurpose
GET/replication/policiesList policies
POST/replication/policiesCreate policy
GET/PUT/DELETE/replication/policies/{id}CRUD policy
GET/replication/executionsList executions
POST/replication/executionsStart replication
GET/replication/executions/{id}Get execution status
GET/replication/executions/{id}/tasksList execution tasks
GET/registriesList registries
POST/registriesCreate registry endpoint
GET/PUT/DELETE/registries/{id}CRUD registry
POST/registries/pingPing registry endpoint

Garbage Collection

MethodEndpointPurpose
GET/system/gcList GC schedules
POST/system/gcCreate GC schedule
GET/system/gc/{id}Get GC job
GET/system/gc/{id}/logGet GC log

OIDC / LDAP

MethodEndpointPurpose
POST/ldap/pingPing LDAP
GET/ldap/users/searchSearch LDAP users
POST/ldap/users/importImport LDAP users
GET/ldap/groups/searchSearch LDAP groups
POST/system/oidc/pingPing OIDC provider
GET/configurationsGet system config (auth_mode, oidc, ldap)
PUT/configurationsUpdate system config

System & Admin

MethodEndpointPurpose
GET/systeminfoSystem info
GET/systeminfo/volumesStorage volume info
GET/internalconfigInternal config (admin only)
GET/labelsList labels
POST/labelsCreate label
GET/PUT/DELETE/labels/{id}CRUD label
GET/usergroupsList user groups
POST/usergroupsCreate user group
GET/PUT/DELETE/usergroups/{id}CRUD user group
GET/preheat/policiesList preheat policies
POST/preheat/policiesCreate preheat policy
GET/preheat/instancesList preheat instances
POST/preheat/instancesCreate preheat instance
GET/audit-logsList audit logs
GET/quotaList storage quotas

Examples

# Create a project
curl -X POST https://harbor.example.com/api/v2.0/projects \
  -u "admin:Harbor12345" \
  -H "Content-Type: application/json" \
  -d '{"project_name": "myapp", "public": false, "storage_limit": -1}'

# Create a robot account (system-level)
curl -X POST https://harbor.example.com/api/v2.0/robots \
  -u "admin:Harbor12345" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ci-deploy",
    "description": "CI/CD deployment robot",
    "level": "system",
    "permissions": [{
      "kind": "project",
      "namespace": "myapp",
      "access": [
        {"resource": "repository", "action": "pull"},
        {"resource": "repository", "action": "push"}
      ]
    }]
  }'

# Trigger artifact scan
curl -X POST "https://harbor.example.com/api/v2.0/projects/myapp/repositories/nginx/artifacts/latest/scan" \
  -u "admin:Harbor12345"

# Create a replication rule
curl -X POST https://harbor.example.com/api/v2.0/replication/policies \
  -u "admin:Harbor12345" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "backup-to-dr",
    "description": "Replicate to DR site",
    "trigger": {"type": "event_based"},
    "dest_registry": {"id": 2},
    "filters": [{"type": "name", "value": "myapp/**"}],
    "deletion": true,
    "override": true
  }'

# Search across Harbor
curl -s "https://harbor.example.com/api/v2.0/search?q=nginx" \
  -u "admin:Harbor12345"

# Trigger garbage collection
curl -X POST https://harbor.example.com/api/v2.0/system/gc \
  -u "admin:Harbor12345" \
  -H "Content-Type: application/json" \
  -d '{"schedule": {"type": "Weekly", "weekday": 0, "offtime": 0}}'

Common Mistakes

  • Robot secret not saved — Secret is only returned on creation. Store it immediately.
  • API version path — Always use /api/v2.0/, not /api/ (v1.x legacy path).
  • OIDC users can't use basic auth — Must use OIDC ID token as Bearer token.
  • Robot tokens auto-expire — Set duration in days on creation (default: no expiry).
  • Scan reports deleted on v2.2 upgrade — Schema migration clears old scan data. Re-scan after upgrade.
  • Bearer token scope — Token is scoped to the scope param in the /service/token request. Use repository:*:pull for read-only, repository:*:pull,push for write.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.