About this project
Soenneker.Docker.Hub.OpenApiClient is a Kiota-generated .NET client for the Docker Hub API. It is packaged for NuGet and can be added with `dotnet add package Soenneker.Docker.Hub.OpenApiClient`.
To create a client, the README shows constructing an `HttpClient`, setting a Bearer authorization header, creating a `HttpClientRequestAdapter` with an `AnonymousAuthenticationProvider` and the `HttpClient`, setting the base URL to `https://hub.docker.com`, and instantiating `DockerHubOpenApiClient` with the adapter. It advises keeping the token outside source control and reusing the `HttpClient`, adapter, and generated client. A companion package, `Soenneker.Docker.Hub.OpenApiClientUtil`, provides dependency-injection registration and cached construction.
The README includes an example of listing personal access tokens through `client.V2.AccessTokens.GetAsync`, setting `Page` and `PageSize` query parameters, and reading the `Results` collection from the response. Pagination is explicit: callers use `Next`, `Previous`, and `Count` from the response to decide which page to request next, and the client does not automatically enumerate all results.
Request builders follow the URL hierarchy, starting at `client.V2`, and collection indexers supply path parameters such as an access-token UUID or organization name. Kiota maps documented non-success responses to generated models deriving from `ApiException`; the exact error type depends on the endpoint. For example, listing access tokens maps `400` to `ValueError` and `401` to `Error`. The README recommends preserving those details when logging or translating failures and letting cancellation flow to the caller.
The client and models are generated, so the README warns against editing them directly because regeneration replaces those changes. Endpoint names, nullability, error mappings, and model shapes can change when Docker Hub's specification changes, so package updates should be reviewed before upgrading production consumers.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.