Skip to main content

Async Harbor API v2.0 client

Project description

harborapi

PyPI - Version PyPI - Python Version


Python async client for the Harbor REST API v2.0.

Features

  • Async API
  • Extensive type hint coverage
  • Data validation with Pydantic
  • Built-in retry functionality with backoff
  • Extensive test coverage powered by Hypothesis
  • Optional rich support

Installation

pip install harborapi

Quick Start

import asyncio
from harborapi import HarborAsyncClient

client = HarborAsyncClient(
    url="https://demo.goharbor.io/api/v2.0/",
    username="username",
    secret="secret",
    # OR
    credentials="base64-basic-auth-credentials",
    # OR
    credentials_file="path/to/robot-credentials-file.json",
)


async def main() -> None:
    # Get all projects
    projects = await client.get_projects()
    for project in projects:
        print(project.name)

    # If you have rich installed:
    import rich

    for project in projects:
        rich.print(project)


asyncio.run(main())

Documentation

Documentation is available here

Implemented endpoints

  • user
  • gc
  • scanAll
  • configure
  • usergroup
  • preheat
  • replication
  • label
  • robot
  • webhookjob
  • icon
  • project
  • webhook
  • scan
  • member
  • ldap
  • registry
  • search
  • artifact
  • immutable
  • retention
  • scanner
  • systeminfo**
  • statistic
  • quota
  • repository
  • ping
  • oidc
  • SystemCVEAllowlist
  • Health
  • robotv1
  • projectMetadata
  • auditlog

** /systeminfo/getcert NYI

0.8.0 - 2023-02-08

Added

  • limit parameter for all methods that return a list of items. This parameter is used to limit the number of items returned by the API. See the docs for more details.

Removed

  • retrieve_all parameter for all methods that return a list of items. Use the new limit parameter to control the number of results to retrieve. Passing retrieve_all to these methods will be silently ignored. In the future this will raise a DeprecationWarning.

0.7.1 - 2023-02-07

Added

  • New parameters raw and validate to HarborAsyncClient and HarborClient to control whether the client returns the raw data from the API, and whether the client validates the data from the API, respectively. See the docs for more details.

0.7.0 - 2023-02-06

Added

Changed

  • Updated models from 2022-11-28 spec update.
  • Generated models are now defined in models._models and models._scanner, and the overrides for these models are defined in models.models and models.scanner respectively. This is to make it easier to regenerate the models in the future while keeping the extended functionality (such as Repository.project_name, ScanOverview.__new__, etc.) for these classes intact, since that is now declared separately from the generated models. Furthermore, models.models and models.scanner both re-export all the generated models so that the API remains unchanged. See the Justfile for more details on how the models are generated.

Fixed

  • HarborAsyncClient.search() raising an error when finding Helm Charts with an empty engine field.

Removed

  • BREAKING: HarborAsyncClient.get_internal_config(). This endpoint is meant for internal usage only, and the new model definitions don't seem to play well with it. If you need this endpoint, please open an issue.

0.6.0 - 2023-01-30

Changed

  • BREAKING: The max_depth parameter of the as_table() and as_panel() methods on all models now starts counting from 1 instead of 0.
    • max_depth=0 now means "no limit", and max_depth=1 means "only show the top level" (previously max_depth=0 meant "only show the top level" and max_depth=1 meant "show the top level and one level below")

0.5.0 - 2023-01-17

Added

  • Changelog
  • Rich as optional dependency: pip install harborapi[rich]

Changed

  • Use Hatch as build system.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harborapi-0.8.0.tar.gz (124.1 kB view hashes)

Uploaded Source

Built Distribution

harborapi-0.8.0-py3-none-any.whl (87.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page