flownative / harbor-api-client
本软件包提供Harbor的API模型和客户端
v1.0.0
2024-06-26 16:16 UTC
Requires
- php: ^8.2
- jane-php/open-api-runtime: 7.6.*
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- jane-php/open-api-2: 7.6.*
README
Harbor OpenAPI客户端
本软件包为Harbor提供客户端。它基于Harbor API v2,由Jane自动生成。
功能覆盖
此库仅提供Harbor API提供资源的一部分。包含的API路径定义在.jane-openapi
中。如需进一步资源,您可以按需调整配置并重新构建客户端库。
重新构建客户端库
Jane提供生成客户端代码的命令。切换到该软件包目录并安装Composer依赖项。然后,您可以运行命令生成代码
composer update bin/jane-openapi-generate
用法
客户端使用create()
工厂方法实例化。以下示例展示了如何创建项目,并使用Harbor机器用户的用户名和密码进行认证
use Http\Client\Common\Plugin\AddHostPlugin; use Http\Client\Common\Plugin\AddPathPlugin; use Http\Client\Common\Plugin\AuthenticationPlugin; use Http\Message\Authentication\BasicAuth; use Flownative\Harbor\Api\Model\ProjectReq; … $client = \Flownative\Harbor\Api\Client::create( null, [ new AddHostPlugin( $endpointUri ), new AddPathPlugin( $endpointUri ), new AuthenticationPlugin( new BasicAuth( $username, $password, ) ) ] ); $projectRequest = new ProjectReq(); $projectRequest ->setProjectName((string)$projectName) ->setPublic(false); $client->createProject($projectRequest);