From 1d14db7a4a5d8bac83e9105005cee486bc5e7203 Mon Sep 17 00:00:00 2001 From: Maksym Sadovnychyy Date: Sun, 18 Aug 2024 15:40:22 +0200 Subject: [PATCH] (refactor): LF and readme --- src/PodmanClient.DotNet.nuspec | Bin 1956 -> 1914 bytes src/PodmanClient/Models/AutoUserNsOptions.cs | 8 +- .../Container/CreateContainerRequest.cs | 7 +- src/PodmanClient/PodmanClientDotNet.csproj | 4 +- src/PodmanClient/README.md | 139 ++++++++++++++++++ src/README.md | 92 ------------ 6 files changed, 144 insertions(+), 106 deletions(-) create mode 100644 src/PodmanClient/README.md delete mode 100644 src/README.md diff --git a/src/PodmanClient.DotNet.nuspec b/src/PodmanClient.DotNet.nuspec index 34a6d3814fcb28c129ce782cbf44f7be50064af9..63e5286d8deb17fc62f7b994e94512761283b51a 100644 GIT binary patch delta 149 zcmZ3&|BG*e&O|*iNiGHjAhcn~Wk_WxVMt_10b&qsH!;z9;xem=k3uF}Fj`G6VXT|{ zg|TaL1JjhrV$6P%)0j6*mSBmRT*6{9c@>L{FwB@VhD?SWpi#vPc9ZY2+@5@oWy$0? kHZw47#cnpah+RyA3uv7_Ljll|WQJ@YnGRHM$H2t^0DN93&j0`b delta 187 zcmeyxw}gL!jwCMw7lRE$0Yf4~GD9|yOlL@CP++iQ;GO6w&B!}3+8Id9wFVN`Lm7D| zYcm3wlT#V%f#hSxZXlV~c6oAl%A&nuE qAqQxFG06PMg=|YFC$X9VRe@MGY!KFMu!|t-_0e=BvWv5TOalOgm?!E0 diff --git a/src/PodmanClient/Models/AutoUserNsOptions.cs b/src/PodmanClient/Models/AutoUserNsOptions.cs index 6cad328..ab93641 100644 --- a/src/PodmanClient/Models/AutoUserNsOptions.cs +++ b/src/PodmanClient/Models/AutoUserNsOptions.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace MaksIT.PodmanClientDotNet.Models { public class AutoUserNsOptions { public List AdditionalGIDMappings { get; set; } diff --git a/src/PodmanClient/Models/Container/CreateContainerRequest.cs b/src/PodmanClient/Models/Container/CreateContainerRequest.cs index 927d63a..d9a09cf 100644 --- a/src/PodmanClient/Models/Container/CreateContainerRequest.cs +++ b/src/PodmanClient/Models/Container/CreateContainerRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace MaksIT.PodmanClientDotNet.Models.Container { public class CreateContainerRequest { public Dictionary Annotations { get; set; } diff --git a/src/PodmanClient/PodmanClientDotNet.csproj b/src/PodmanClient/PodmanClientDotNet.csproj index 46b0db0..e5e44da 100644 --- a/src/PodmanClient/PodmanClientDotNet.csproj +++ b/src/PodmanClient/PodmanClientDotNet.csproj @@ -11,16 +11,18 @@ 1.0.3 Maksym Sadovnychyy MAKS-IT - PodmanClient + PodmanClient.DotNet Podman API client .NET implementation podman client dotnet https://github.com/MAKS-IT-COM/podman-client-dotnet MIT false + README.md + diff --git a/src/PodmanClient/README.md b/src/PodmanClient/README.md new file mode 100644 index 0000000..337feb1 --- /dev/null +++ b/src/PodmanClient/README.md @@ -0,0 +1,139 @@ +# PodmanClient.DotNet + +## Description + +`PodmanClient.DotNet` is a .NET library designed to provide seamless interaction with the Podman API, allowing developers to manage and control containers directly from their .NET applications. This client library wraps the Podman API endpoints, offering a .NET-friendly interface to perform common container operations such as creating, starting, stopping, deleting containers, and more. + +## Purpose + +The primary goal of `PodmanClient.DotNet` is to simplify the integration of Podman into .NET applications by providing a comprehensive, easy-to-use client library. Whether you're managing container lifecycles, executing commands inside containers, or manipulating container images, this library allows developers to interface with Podman using the familiar .NET development environment. + +## Key Features + +- **Container Management:** Create, start, stop, and delete containers with straightforward methods. +- **Image Operations:** Pull, tag, and manage images using the Podman API. +- **Exec Support:** Execute commands inside running containers, with support for attaching input/output streams. +- **Volume and Network Management:** Manage container volumes and networks as needed. +- **Streamlined Error Handling:** Provides detailed error handling, with informative responses based on HTTP status codes. +- **Customizable HTTP Client:** Easily configure and inject your own `HttpClient` instance for extended control and customization. +- **Logging Support:** Integrated logging support via `Microsoft.Extensions.Logging` for better observability. + +## Installation + +To include `PodmanClient.DotNet` in your .NET project, you can add the package via NuGet: + +```shell +dotnet add package PodmanClient.DotNet +``` + +## Usage Examples + +### Initialize the PodmanClient + +```csharp +using Microsoft.Extensions.Logging; +using MaksIT.PodmanClient.DotNet; + +var logger = LoggerFactory.Create(builder => builder.AddConsole()).CreateLogger(); +var podmanClient = new PodmanClient(logger, "http://localhost:8080", 5); +``` + +### Create and Start a Container + +```csharp +var createResponse = await podmanClient.CreateContainerAsync( + name: "my-container", + image: "alpine:latest", + command: new List { "/bin/sh" }, + env: new Dictionary { { "ENV_VAR", "value" } }, + remove: true +); + +await podmanClient.StartContainerAsync(createResponse.Id); +``` + +### Execute a Command in a Container + +```csharp +var execResponse = await podmanClient.CreateExecAsync(createResponse.Id, new[] { "echo", "Hello, World!" }); +await podmanClient.StartExecAsync(execResponse.Id); +``` + +### Pull an Image + +```csharp +await podmanClient.PullImageAsync("alpine:latest"); +``` + +### Tag an Image + +```csharp +await podmanClient.TagImageAsync("alpine:latest", "myrepo", "mytag"); +``` + +## Available Methods + +### `PodmanClient` + +- **Container Management** + - `Task CreateContainerAsync(...)`: Creates a new container. + - `Task StartContainerAsync(string containerId, string detachKeys = "ctrl-p,ctrl-q")`: Starts an existing container. + - `Task StopContainerAsync(string containerId, int timeout = 10, bool ignoreAlreadyStopped = false)`: Stops a running container. + - `Task DeleteContainerAsync(string containerId, bool depend = false, bool ignore = false, int timeout = 10)`: Deletes a container. + - `Task ForceDeleteContainerAsync(string containerId, bool deleteVolumes = false, int timeout = 10)`: Forcefully deletes a container, optionally removing associated volumes. + +- **Exec Management** + - `Task CreateExecAsync(...)`: Creates an exec instance in a running container. + - `Task StartExecAsync(string execId, bool detach = false, bool tty = false, int? height = null, int? width = null)`: Starts an exec instance. + - `Task InspectExecAsync(string execId)`: Inspects an exec instance to retrieve its details. + +- **Image Operations** + - `Task PullImageAsync(...)`: Pulls an image from a container registry. + - `Task TagImageAsync(string image, string repo, string tag)`: Tags an existing image with a new repository and tag. + +- **File Operations** + - `Task ExtractArchiveToContainerAsync(string containerId, Stream tarStream, string path, bool pause = true)`: Extracts files from a tar stream into a container. + +## Documentation (TODO: Agile) + +For detailed documentation on each method, including parameter descriptions and example usage, please refer to the official documentation (link to be provided). + +## Contribution + +Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes. If you encounter any issues or have feature requests, feel free to open an issue on GitHub. + +## License + +This project is licensed under the MIT License. See the full license text below. + +--- + +### MIT License + +``` +MIT License + +Copyright (c) 2024 Maksym Sadovnychyy (MAKS-IT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Contact + +For any questions or inquiries, please reach out via GitHub or [email](mailto:maksym.sadovnychyy@gmail.com). \ No newline at end of file diff --git a/src/README.md b/src/README.md deleted file mode 100644 index e762411..0000000 --- a/src/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# PodmanClientDotNet - -## Description - -`PodmanClientDotNet` is a .NET library designed to provide seamless interaction with the Podman API, allowing developers to manage and control containers directly from their .NET applications. This client library wraps the Podman API endpoints, offering a .NET-friendly interface to perform common container operations such as creating, starting, stopping, deleting containers, and more. - -## Purpose - -The primary goal of `PodmanClientDotNet` is to simplify the integration of Podman into .NET applications by providing a comprehensive, easy-to-use client library. Whether you're managing container lifecycles, executing commands inside containers, or manipulating container images, this library allows developers to interface with Podman using the familiar .NET development environment. - -## Key Features - -- **Container Management:** Create, start, stop, and delete containers with straightforward methods. -- **Image Operations:** Pull, tag, and manage images using the Podman API. -- **Exec Support:** Execute commands inside running containers, with support for attaching input/output streams. -- **Volume and Network Management:** Manage container volumes and networks as needed. -- **Streamlined Error Handling:** Provides detailed error handling, with informative responses based on HTTP status codes. - -## Usage Example - -```csharp -// Initialize the PodmanClient with base URL and timeout -var podmanClient = new PodmanClient("http://localhost:8080", 5); - -// Create a new container -var createResponse = await podmanClient.CreateContainerAsync( - name: "my-container", - image: "alpine:latest", - command: new List { "/bin/sh" }, - env: new Dictionary { { "ENV_VAR", "value" } }, - remove: true -); - -// Start the container -await podmanClient.StartContainerAsync(createResponse.Id); - -// Execute a command inside the container -var execResponse = await podmanClient.CreateExecAsync(createResponse.Id, new[] { "echo", "Hello, World!" }); -await podmanClient.StartExecAsync(execResponse.Id); -``` - -## Installation - -To include `PodmanClientDotNet` in your .NET project, you can add the package via NuGet: - -```shell -dotnet add package PodmanClientDotNet -``` - -## Documentation - -For detailed documentation on each method, including parameter descriptions and example usage, please refer to the official documentation (link to be provided). - -## Contribution - -Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes. If you encounter any issues or have feature requests, feel free to open an issue on GitHub. - -## License - -This project is licensed under the MIT License. See the full license text below. - ---- - -### MIT License - -``` -MIT License - -Copyright (c) 2024 Maksym Sadovnychyy (MAKS-IT) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` - -## Contact - -For any questions or inquiries, please reach out via GitHub or [email](mailto:maksym.sadovnychyy@gmail.com). \ No newline at end of file