From 9c54684786d26c15feec9f6ea636414bd4aede38 Mon Sep 17 00:00:00 2001
From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
Date: Sat, 16 Sep 2023 19:08:36 +0200
Subject: [PATCH] chore: Generate Docker client from OpenAPI specifications
---
Testcontainers.sln | 14 +
src/DockerEngine/.editorconfig | 1 +
src/DockerEngine/DockerClient.cs | 25168 ++++++++++++++++
src/DockerEngine/DockerEngine.csproj | 15 +
src/DockerEngine/NSwag.json | 18 +
tests/DockerEngine.Tests/.editorconfig | 1 +
tests/DockerEngine.Tests/DockerClientTest.cs | 53 +
.../DockerEngine.Tests.csproj | 18 +
tests/DockerEngine.Tests/Usings.cs | 6 +
9 files changed, 25294 insertions(+)
create mode 100644 src/DockerEngine/.editorconfig
create mode 100644 src/DockerEngine/DockerClient.cs
create mode 100644 src/DockerEngine/DockerEngine.csproj
create mode 100644 src/DockerEngine/NSwag.json
create mode 100644 tests/DockerEngine.Tests/.editorconfig
create mode 100644 tests/DockerEngine.Tests/DockerClientTest.cs
create mode 100644 tests/DockerEngine.Tests/DockerEngine.Tests.csproj
create mode 100644 tests/DockerEngine.Tests/Usings.cs
diff --git a/Testcontainers.sln b/Testcontainers.sln
index 4a415068d..f3167bd47 100644
--- a/Testcontainers.sln
+++ b/Testcontainers.sln
@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{673F23AE-769
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DockerEngine", "src\DockerEngine\DockerEngine.csproj", "{64B58ABB-A849-4FC1-9D3B-2620140427A9}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Azurite", "src\Testcontainers.Azurite\Testcontainers.Azurite.csproj", "{3F2E254F-C203-43FD-A078-DC3E2CBC0F9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ClickHouse", "src\Testcontainers.ClickHouse\Testcontainers.ClickHouse.csproj", "{B061A78E-536E-4CA1-8401-234D5FBFBAB7}"
@@ -71,6 +73,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers", "src\Testcontainers\Testcontainers.csproj", "{EC76857B-A3B8-4B7A-A1B0-8D867A4D1733}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DockerEngine.Tests", "tests\DockerEngine.Tests\DockerEngine.Tests.csproj", "{F54DE0D3-D1C4-4A30-9B78-9F72338B5E6A}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Azurite.Tests", "tests\Testcontainers.Azurite.Tests\Testcontainers.Azurite.Tests.csproj", "{B272FDDE-5E01-425D-B9E1-10FF883DDAAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ClickHouse.Tests", "tests\Testcontainers.ClickHouse.Tests\Testcontainers.ClickHouse.Tests.csproj", "{9D0A0B32-4921-400C-99CB-8650677E3E44}"
@@ -146,6 +150,10 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {64B58ABB-A849-4FC1-9D3B-2620140427A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {64B58ABB-A849-4FC1-9D3B-2620140427A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {64B58ABB-A849-4FC1-9D3B-2620140427A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {64B58ABB-A849-4FC1-9D3B-2620140427A9}.Release|Any CPU.Build.0 = Release|Any CPU
{3F2E254F-C203-43FD-A078-DC3E2CBC0F9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F2E254F-C203-43FD-A078-DC3E2CBC0F9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F2E254F-C203-43FD-A078-DC3E2CBC0F9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -262,6 +270,10 @@ Global
{EC76857B-A3B8-4B7A-A1B0-8D867A4D1733}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC76857B-A3B8-4B7A-A1B0-8D867A4D1733}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC76857B-A3B8-4B7A-A1B0-8D867A4D1733}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F54DE0D3-D1C4-4A30-9B78-9F72338B5E6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F54DE0D3-D1C4-4A30-9B78-9F72338B5E6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F54DE0D3-D1C4-4A30-9B78-9F72338B5E6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F54DE0D3-D1C4-4A30-9B78-9F72338B5E6A}.Release|Any CPU.Build.0 = Release|Any CPU
{B272FDDE-5E01-425D-B9E1-10FF883DDAAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B272FDDE-5E01-425D-B9E1-10FF883DDAAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B272FDDE-5E01-425D-B9E1-10FF883DDAAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -396,6 +408,7 @@ Global
{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
+ {64B58ABB-A849-4FC1-9D3B-2620140427A9} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{3F2E254F-C203-43FD-A078-DC3E2CBC0F9F} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{B061A78E-536E-4CA1-8401-234D5FBFBAB7} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{A724806F-8C94-4438-8011-04A9A1575318} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
@@ -425,6 +438,7 @@ Global
{C95A3B2F-2B28-49A7-8806-731C158BBC21} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{64A87DE5-29B0-4A54-9E74-560484D8C7C0} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{EC76857B-A3B8-4B7A-A1B0-8D867A4D1733} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
+ {F54DE0D3-D1C4-4A30-9B78-9F72338B5E6A} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{B272FDDE-5E01-425D-B9E1-10FF883DDAAA} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{9D0A0B32-4921-400C-99CB-8650677E3E44} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{2478673C-B063-469D-ABD1-0C3E0A25541B} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
diff --git a/src/DockerEngine/.editorconfig b/src/DockerEngine/.editorconfig
new file mode 100644
index 000000000..6f066619d
--- /dev/null
+++ b/src/DockerEngine/.editorconfig
@@ -0,0 +1 @@
+root = true
\ No newline at end of file
diff --git a/src/DockerEngine/DockerClient.cs b/src/DockerEngine/DockerClient.cs
new file mode 100644
index 000000000..fc42c8090
--- /dev/null
+++ b/src/DockerEngine/DockerClient.cs
@@ -0,0 +1,25168 @@
+//----------------------
+//
+// Generated using the NSwag toolchain v13.20.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
+//
+//----------------------
+
+#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
+#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
+#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?'
+#pragma warning disable 612 // Disable "CS0612 '...' is obsolete"
+#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ...
+#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..."
+#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'"
+#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant"
+#pragma warning disable 8603 // Disable "CS8603 Possible null reference return"
+#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter"
+
+namespace DockerEngine
+{
+ using System = global::System;
+
+ [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.20.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0))")]
+ public partial class DockerClient
+ {
+ private string _baseUrl = "";
+ private System.Net.Http.HttpClient _httpClient;
+ private System.Lazy _settings;
+
+ public DockerClient(string baseUrl, System.Net.Http.HttpClient httpClient)
+ {
+ BaseUrl = baseUrl;
+ _httpClient = httpClient;
+ _settings = new System.Lazy(CreateSerializerSettings, true);
+ }
+
+ private System.Text.Json.JsonSerializerOptions CreateSerializerSettings()
+ {
+ var settings = new System.Text.Json.JsonSerializerOptions();
+ UpdateJsonSerializerSettings(settings);
+ return settings;
+ }
+
+ public string BaseUrl
+ {
+ get { return _baseUrl; }
+ set { _baseUrl = value; }
+ }
+
+ protected System.Text.Json.JsonSerializerOptions JsonSerializerSettings { get { return _settings.Value; } }
+
+ partial void UpdateJsonSerializerSettings(System.Text.Json.JsonSerializerOptions settings);
+
+ partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url);
+ partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
+ partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
+
+ ///
+ /// List containers
+ ///
+ ///
+ /// Returns a list of containers. For details on the format, see the
+ /// [inspect endpoint](#operation/ContainerInspect).
+ ///
+ /// Note that it uses a different, smaller representation of a container
+ /// than inspecting a single container. For example, the list of linked
+ /// containers is not propagated .
+ ///
+ /// Return all containers. By default, only running containers are shown.
+ /// Return this number of most recently created containers, including
+ /// non-running ones.
+ /// Return the size of container as fields `SizeRw` and `SizeRootFs`.
+ /// Filters to process on the container list, encoded as JSON (a
+ /// `map[string][]string`). For example, `{"status": ["paused"]}` will
+ /// only return paused containers.
+ ///
+ /// Available filters:
+ ///
+ /// - `ancestor`=(`<image-name>[:<tag>]`, `<image id>`, or `<image@digest>`)
+ /// - `before`=(`<container id>` or `<container name>`)
+ /// - `expose`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`)
+ /// - `exited=<int>` containers with exit code of `<int>`
+ /// - `health`=(`starting`|`healthy`|`unhealthy`|`none`)
+ /// - `id=<ID>` a container's ID
+ /// - `isolation=`(`default`|`process`|`hyperv`) (Windows daemon only)
+ /// - `is-task=`(`true`|`false`)
+ /// - `label=key` or `label="key=value"` of a container label
+ /// - `name=<name>` a container's name
+ /// - `network`=(`<network id>` or `<network name>`)
+ /// - `publish`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`)
+ /// - `since`=(`<container id>` or `<container name>`)
+ /// - `status=`(`created`|`restarting`|`running`|`removing`|`paused`|`exited`|`dead`)
+ /// - `volume`=(`<volume name>` or `<mount point destination>`)
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task> ContainerListAsync(bool? all, int? limit, bool? size, string filters)
+ {
+ return ContainerListAsync(all, limit, size, filters, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// List containers
+ ///
+ ///
+ /// Returns a list of containers. For details on the format, see the
+ /// [inspect endpoint](#operation/ContainerInspect).
+ ///
+ /// Note that it uses a different, smaller representation of a container
+ /// than inspecting a single container. For example, the list of linked
+ /// containers is not propagated .
+ ///
+ /// Return all containers. By default, only running containers are shown.
+ /// Return this number of most recently created containers, including
+ /// non-running ones.
+ /// Return the size of container as fields `SizeRw` and `SizeRootFs`.
+ /// Filters to process on the container list, encoded as JSON (a
+ /// `map[string][]string`). For example, `{"status": ["paused"]}` will
+ /// only return paused containers.
+ ///
+ /// Available filters:
+ ///
+ /// - `ancestor`=(`<image-name>[:<tag>]`, `<image id>`, or `<image@digest>`)
+ /// - `before`=(`<container id>` or `<container name>`)
+ /// - `expose`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`)
+ /// - `exited=<int>` containers with exit code of `<int>`
+ /// - `health`=(`starting`|`healthy`|`unhealthy`|`none`)
+ /// - `id=<ID>` a container's ID
+ /// - `isolation=`(`default`|`process`|`hyperv`) (Windows daemon only)
+ /// - `is-task=`(`true`|`false`)
+ /// - `label=key` or `label="key=value"` of a container label
+ /// - `name=<name>` a container's name
+ /// - `network`=(`<network id>` or `<network name>`)
+ /// - `publish`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`)
+ /// - `since`=(`<container id>` or `<container name>`)
+ /// - `status=`(`created`|`restarting`|`running`|`removing`|`paused`|`exited`|`dead`)
+ /// - `volume`=(`<volume name>` or `<mount point destination>`)
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task> ContainerListAsync(bool? all, int? limit, bool? size, string filters, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/json?");
+ if (all != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("all") + "=").Append(System.Uri.EscapeDataString(ConvertToString(all, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (limit != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("limit") + "=").Append(System.Uri.EscapeDataString(ConvertToString(limit, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (size != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("size") + "=").Append(System.Uri.EscapeDataString(ConvertToString(size, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (filters != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("filters") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filters, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Create a container
+ ///
+ /// Assign the specified name to the container. Must match
+ /// `/?[a-zA-Z0-9][a-zA-Z0-9_.-]+`.
+ /// Platform in the format `os[/arch[/variant]]` used for image lookup.
+ ///
+ /// When specified, the daemon checks if the requested image is present
+ /// in the local image cache with the given OS and Architecture, and
+ /// otherwise returns a `404` status.
+ ///
+ /// If the option is not set, the host's native OS and Architecture are
+ /// used to look up the image in the image cache. However, if no platform
+ /// is passed and the given image does exist in the local image cache,
+ /// but its OS or architecture does not match, the container is created
+ /// with the available image, and a warning is added to the `Warnings`
+ /// field in the response, for example;
+ ///
+ /// WARNING: The requested image's platform (linux/arm64/v8) does not
+ /// match the detected host platform (linux/amd64) and no
+ /// specific platform was requested
+ /// Container to create
+ /// Container created successfully
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerCreateAsync(string name, string platform, Body body)
+ {
+ return ContainerCreateAsync(name, platform, body, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Create a container
+ ///
+ /// Assign the specified name to the container. Must match
+ /// `/?[a-zA-Z0-9][a-zA-Z0-9_.-]+`.
+ /// Platform in the format `os[/arch[/variant]]` used for image lookup.
+ ///
+ /// When specified, the daemon checks if the requested image is present
+ /// in the local image cache with the given OS and Architecture, and
+ /// otherwise returns a `404` status.
+ ///
+ /// If the option is not set, the host's native OS and Architecture are
+ /// used to look up the image in the image cache. However, if no platform
+ /// is passed and the given image does exist in the local image cache,
+ /// but its OS or architecture does not match, the container is created
+ /// with the available image, and a warning is added to the `Warnings`
+ /// field in the response, for example;
+ ///
+ /// WARNING: The requested image's platform (linux/arm64/v8) does not
+ /// match the detected host platform (linux/amd64) and no
+ /// specific platform was requested
+ /// Container to create
+ /// Container created successfully
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerCreateAsync(string name, string platform, Body body, System.Threading.CancellationToken cancellationToken)
+ {
+ if (body == null)
+ throw new System.ArgumentNullException("body");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/create?");
+ if (name != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("name") + "=").Append(System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (platform != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("platform") + "=").Append(System.Uri.EscapeDataString(ConvertToString(platform, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ var json_ = System.Text.Json.JsonSerializer.Serialize(body, _settings.Value);
+ var content_ = new System.Net.Http.StringContent(json_);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 201)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such image", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 409)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("conflict", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Inspect a container
+ ///
+ ///
+ /// Return low-level information about a container.
+ ///
+ /// ID or name of the container
+ /// Return the size of container as fields `SizeRw` and `SizeRootFs`
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerInspectAsync(string id, bool? size)
+ {
+ return ContainerInspectAsync(id, size, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Inspect a container
+ ///
+ ///
+ /// Return low-level information about a container.
+ ///
+ /// ID or name of the container
+ /// Return the size of container as fields `SizeRw` and `SizeRootFs`
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerInspectAsync(string id, bool? size, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/json?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (size != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("size") + "=").Append(System.Uri.EscapeDataString(ConvertToString(size, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// List processes running inside a container
+ ///
+ ///
+ /// On Unix systems, this is done by running the `ps` command. This endpoint
+ /// is not supported on Windows.
+ ///
+ /// ID or name of the container
+ /// The arguments to pass to `ps`. For example, `aux`
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerTopAsync(string id, string ps_args)
+ {
+ return ContainerTopAsync(id, ps_args, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// List processes running inside a container
+ ///
+ ///
+ /// On Unix systems, this is done by running the `ps` command. This endpoint
+ /// is not supported on Windows.
+ ///
+ /// ID or name of the container
+ /// The arguments to pass to `ps`. For example, `aux`
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerTopAsync(string id, string ps_args, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/top?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (ps_args != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("ps_args") + "=").Append(System.Uri.EscapeDataString(ConvertToString(ps_args, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get container logs
+ ///
+ ///
+ /// Get `stdout` and `stderr` logs from a container.
+ ///
+ /// Note: This endpoint works only for containers with the `json-file` or
+ /// `journald` logging driver.
+ ///
+ /// ID or name of the container
+ /// Keep connection after returning logs.
+ /// Return logs from `stdout`
+ /// Return logs from `stderr`
+ /// Only return logs since this time, as a UNIX timestamp
+ /// Only return logs before this time, as a UNIX timestamp
+ /// Add timestamps to every log line
+ /// Only return this number of log lines from the end of the logs.
+ /// Specify as an integer or `all` to output all log lines.
+ /// logs returned as a stream in response body.
+ /// For the stream format, [see the documentation for the attach endpoint](#operation/ContainerAttach).
+ /// Note that unlike the attach endpoint, the logs endpoint does not
+ /// upgrade the connection and does not set Content-Type.
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerLogsAsync(string id, bool? follow, bool? stdout, bool? stderr, int? since, int? until, bool? timestamps, string tail)
+ {
+ return ContainerLogsAsync(id, follow, stdout, stderr, since, until, timestamps, tail, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get container logs
+ ///
+ ///
+ /// Get `stdout` and `stderr` logs from a container.
+ ///
+ /// Note: This endpoint works only for containers with the `json-file` or
+ /// `journald` logging driver.
+ ///
+ /// ID or name of the container
+ /// Keep connection after returning logs.
+ /// Return logs from `stdout`
+ /// Return logs from `stderr`
+ /// Only return logs since this time, as a UNIX timestamp
+ /// Only return logs before this time, as a UNIX timestamp
+ /// Add timestamps to every log line
+ /// Only return this number of log lines from the end of the logs.
+ /// Specify as an integer or `all` to output all log lines.
+ /// logs returned as a stream in response body.
+ /// For the stream format, [see the documentation for the attach endpoint](#operation/ContainerAttach).
+ /// Note that unlike the attach endpoint, the logs endpoint does not
+ /// upgrade the connection and does not set Content-Type.
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerLogsAsync(string id, bool? follow, bool? stdout, bool? stderr, int? since, int? until, bool? timestamps, string tail, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/logs?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (follow != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("follow") + "=").Append(System.Uri.EscapeDataString(ConvertToString(follow, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stdout != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stdout") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stdout, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stderr != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stderr") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stderr, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (since != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("since") + "=").Append(System.Uri.EscapeDataString(ConvertToString(since, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (until != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("until") + "=").Append(System.Uri.EscapeDataString(ConvertToString(until, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (timestamps != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("timestamps") + "=").Append(System.Uri.EscapeDataString(ConvertToString(timestamps, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (tail != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("tail") + "=").Append(System.Uri.EscapeDataString(ConvertToString(tail, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/vnd.docker.raw-stream"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200 || status_ == 206)
+ {
+ var responseStream_ = response_.Content == null ? System.IO.Stream.Null : await response_.Content.ReadAsStreamAsync().ConfigureAwait(false);
+ var fileResponse_ = new FileResponse(status_, headers_, responseStream_, null, response_);
+ disposeClient_ = false; disposeResponse_ = false; // response and client are disposed by FileResponse
+ return fileResponse_;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get changes on a container’s filesystem
+ ///
+ ///
+ /// Returns which files in a container's filesystem have been added, deleted,
+ /// or modified. The `Kind` of modification can be one of:
+ ///
+ /// - `0`: Modified ("C")
+ /// - `1`: Added ("A")
+ /// - `2`: Deleted ("D")
+ ///
+ /// ID or name of the container
+ /// The list of changes
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task> ContainerChangesAsync(string id)
+ {
+ return ContainerChangesAsync(id, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get changes on a container’s filesystem
+ ///
+ ///
+ /// Returns which files in a container's filesystem have been added, deleted,
+ /// or modified. The `Kind` of modification can be one of:
+ ///
+ /// - `0`: Modified ("C")
+ /// - `1`: Added ("A")
+ /// - `2`: Deleted ("D")
+ ///
+ /// ID or name of the container
+ /// The list of changes
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task> ContainerChangesAsync(string id, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/changes");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Export a container
+ ///
+ ///
+ /// Export the contents of a container as a tarball.
+ ///
+ /// ID or name of the container
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerExportAsync(string id)
+ {
+ return ContainerExportAsync(id, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Export a container
+ ///
+ ///
+ /// Export the contents of a container as a tarball.
+ ///
+ /// ID or name of the container
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerExportAsync(string id, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/export");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/octet-stream"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200 || status_ == 206)
+ {
+ return default(FileResponse);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get container stats based on resource usage
+ ///
+ ///
+ /// This endpoint returns a live stream of a container’s resource usage
+ /// statistics.
+ ///
+ /// The `precpu_stats` is the CPU statistic of the *previous* read, and is
+ /// used to calculate the CPU usage percentage. It is not an exact copy
+ /// of the `cpu_stats` field.
+ ///
+ /// If either `precpu_stats.online_cpus` or `cpu_stats.online_cpus` is
+ /// nil then for compatibility with older daemons the length of the
+ /// corresponding `cpu_usage.percpu_usage` array should be used.
+ ///
+ /// On a cgroup v2 host, the following fields are not set
+ /// * `blkio_stats`: all fields other than `io_service_bytes_recursive`
+ /// * `cpu_stats`: `cpu_usage.percpu_usage`
+ /// * `memory_stats`: `max_usage` and `failcnt`
+ /// Also, `memory_stats.stats` fields are incompatible with cgroup v1.
+ ///
+ /// To calculate the values shown by the `stats` command of the docker cli tool
+ /// the following formulas can be used:
+ /// * used_memory = `memory_stats.usage - memory_stats.stats.cache`
+ /// * available_memory = `memory_stats.limit`
+ /// * Memory usage % = `(used_memory / available_memory) * 100.0`
+ /// * cpu_delta = `cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage`
+ /// * system_cpu_delta = `cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage`
+ /// * number_cpus = `lenght(cpu_stats.cpu_usage.percpu_usage)` or `cpu_stats.online_cpus`
+ /// * CPU usage % = `(cpu_delta / system_cpu_delta) * number_cpus * 100.0`
+ ///
+ /// ID or name of the container
+ /// Stream the output. If false, the stats will be output once and then
+ /// it will disconnect.
+ /// Only get a single stat instead of waiting for 2 cycles. Must be used
+ /// with `stream=false`.
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerStatsAsync(string id, bool? stream, bool? one_shot)
+ {
+ return ContainerStatsAsync(id, stream, one_shot, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get container stats based on resource usage
+ ///
+ ///
+ /// This endpoint returns a live stream of a container’s resource usage
+ /// statistics.
+ ///
+ /// The `precpu_stats` is the CPU statistic of the *previous* read, and is
+ /// used to calculate the CPU usage percentage. It is not an exact copy
+ /// of the `cpu_stats` field.
+ ///
+ /// If either `precpu_stats.online_cpus` or `cpu_stats.online_cpus` is
+ /// nil then for compatibility with older daemons the length of the
+ /// corresponding `cpu_usage.percpu_usage` array should be used.
+ ///
+ /// On a cgroup v2 host, the following fields are not set
+ /// * `blkio_stats`: all fields other than `io_service_bytes_recursive`
+ /// * `cpu_stats`: `cpu_usage.percpu_usage`
+ /// * `memory_stats`: `max_usage` and `failcnt`
+ /// Also, `memory_stats.stats` fields are incompatible with cgroup v1.
+ ///
+ /// To calculate the values shown by the `stats` command of the docker cli tool
+ /// the following formulas can be used:
+ /// * used_memory = `memory_stats.usage - memory_stats.stats.cache`
+ /// * available_memory = `memory_stats.limit`
+ /// * Memory usage % = `(used_memory / available_memory) * 100.0`
+ /// * cpu_delta = `cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage`
+ /// * system_cpu_delta = `cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage`
+ /// * number_cpus = `lenght(cpu_stats.cpu_usage.percpu_usage)` or `cpu_stats.online_cpus`
+ /// * CPU usage % = `(cpu_delta / system_cpu_delta) * number_cpus * 100.0`
+ ///
+ /// ID or name of the container
+ /// Stream the output. If false, the stats will be output once and then
+ /// it will disconnect.
+ /// Only get a single stat instead of waiting for 2 cycles. Must be used
+ /// with `stream=false`.
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerStatsAsync(string id, bool? stream, bool? one_shot, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/stats?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (stream != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stream") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stream, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (one_shot != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("one-shot") + "=").Append(System.Uri.EscapeDataString(ConvertToString(one_shot, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Resize a container TTY
+ ///
+ ///
+ /// Resize the TTY for a container.
+ ///
+ /// ID or name of the container
+ /// Height of the TTY session in characters
+ /// Width of the TTY session in characters
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerResizeAsync(string id, int? h, int? w)
+ {
+ return ContainerResizeAsync(id, h, w, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Resize a container TTY
+ ///
+ ///
+ /// Resize the TTY for a container.
+ ///
+ /// ID or name of the container
+ /// Height of the TTY session in characters
+ /// Width of the TTY session in characters
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerResizeAsync(string id, int? h, int? w, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/resize?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (h != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("h") + "=").Append(System.Uri.EscapeDataString(ConvertToString(h, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (w != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("w") + "=").Append(System.Uri.EscapeDataString(ConvertToString(w, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "text/plain");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("cannot resize container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Start a container
+ ///
+ /// ID or name of the container
+ /// Override the key sequence for detaching a container. Format is a
+ /// single character `[a-Z]` or `ctrl-<value>` where `<value>` is one
+ /// of: `a-z`, `@`, `^`, `[`, `,` or `_`.
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerStartAsync(string id, string detachKeys)
+ {
+ return ContainerStartAsync(id, detachKeys, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Start a container
+ ///
+ /// ID or name of the container
+ /// Override the key sequence for detaching a container. Format is a
+ /// single character `[a-Z]` or `ctrl-<value>` where `<value>` is one
+ /// of: `a-z`, `@`, `^`, `[`, `,` or `_`.
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerStartAsync(string id, string detachKeys, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/start?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (detachKeys != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("detachKeys") + "=").Append(System.Uri.EscapeDataString(ConvertToString(detachKeys, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 304)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("container already started", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Stop a container
+ ///
+ /// ID or name of the container
+ /// Signal to send to the container as an integer or string (e.g. `SIGINT`).
+ /// Number of seconds to wait before killing the container
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerStopAsync(string id, string signal, int? t)
+ {
+ return ContainerStopAsync(id, signal, t, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Stop a container
+ ///
+ /// ID or name of the container
+ /// Signal to send to the container as an integer or string (e.g. `SIGINT`).
+ /// Number of seconds to wait before killing the container
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerStopAsync(string id, string signal, int? t, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/stop?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (signal != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("signal") + "=").Append(System.Uri.EscapeDataString(ConvertToString(signal, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (t != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("t") + "=").Append(System.Uri.EscapeDataString(ConvertToString(t, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 304)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("container already stopped", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Restart a container
+ ///
+ /// ID or name of the container
+ /// Signal to send to the container as an integer or string (e.g. `SIGINT`).
+ /// Number of seconds to wait before killing the container
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerRestartAsync(string id, string signal, int? t)
+ {
+ return ContainerRestartAsync(id, signal, t, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Restart a container
+ ///
+ /// ID or name of the container
+ /// Signal to send to the container as an integer or string (e.g. `SIGINT`).
+ /// Number of seconds to wait before killing the container
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerRestartAsync(string id, string signal, int? t, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/restart?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (signal != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("signal") + "=").Append(System.Uri.EscapeDataString(ConvertToString(signal, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (t != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("t") + "=").Append(System.Uri.EscapeDataString(ConvertToString(t, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Kill a container
+ ///
+ ///
+ /// Send a POSIX signal to a container, defaulting to killing to the
+ /// container.
+ ///
+ /// ID or name of the container
+ /// Signal to send to the container as an integer or string (e.g. `SIGINT`).
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerKillAsync(string id, string signal)
+ {
+ return ContainerKillAsync(id, signal, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Kill a container
+ ///
+ ///
+ /// Send a POSIX signal to a container, defaulting to killing to the
+ /// container.
+ ///
+ /// ID or name of the container
+ /// Signal to send to the container as an integer or string (e.g. `SIGINT`).
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerKillAsync(string id, string signal, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/kill?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (signal != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("signal") + "=").Append(System.Uri.EscapeDataString(ConvertToString(signal, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 409)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("container is not running", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Update a container
+ ///
+ ///
+ /// Change various configuration options of a container without having to
+ /// recreate it.
+ ///
+ /// ID or name of the container
+ /// The container has been updated.
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerUpdateAsync(string id, Update update)
+ {
+ return ContainerUpdateAsync(id, update, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Update a container
+ ///
+ ///
+ /// Change various configuration options of a container without having to
+ /// recreate it.
+ ///
+ /// ID or name of the container
+ /// The container has been updated.
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerUpdateAsync(string id, Update update, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ if (update == null)
+ throw new System.ArgumentNullException("update");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/update");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ var json_ = System.Text.Json.JsonSerializer.Serialize(update, _settings.Value);
+ var content_ = new System.Net.Http.StringContent(json_);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Rename a container
+ ///
+ /// ID or name of the container
+ /// New name for the container
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerRenameAsync(string id, string name)
+ {
+ return ContainerRenameAsync(id, name, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Rename a container
+ ///
+ /// ID or name of the container
+ /// New name for the container
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerRenameAsync(string id, string name, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ if (name == null)
+ throw new System.ArgumentNullException("name");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/rename?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ urlBuilder_.Append(System.Uri.EscapeDataString("name") + "=").Append(System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 409)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("name already in use", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Pause a container
+ ///
+ ///
+ /// Use the freezer cgroup to suspend all processes in a container.
+ ///
+ /// Traditionally, when suspending a process the `SIGSTOP` signal is used,
+ /// which is observable by the process being suspended. With the freezer
+ /// cgroup the process is unaware, and unable to capture, that it is being
+ /// suspended, and subsequently resumed.
+ ///
+ /// ID or name of the container
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerPauseAsync(string id)
+ {
+ return ContainerPauseAsync(id, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Pause a container
+ ///
+ ///
+ /// Use the freezer cgroup to suspend all processes in a container.
+ ///
+ /// Traditionally, when suspending a process the `SIGSTOP` signal is used,
+ /// which is observable by the process being suspended. With the freezer
+ /// cgroup the process is unaware, and unable to capture, that it is being
+ /// suspended, and subsequently resumed.
+ ///
+ /// ID or name of the container
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerPauseAsync(string id, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/pause");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Unpause a container
+ ///
+ ///
+ /// Resume a container which has been paused.
+ ///
+ /// ID or name of the container
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerUnpauseAsync(string id)
+ {
+ return ContainerUnpauseAsync(id, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Unpause a container
+ ///
+ ///
+ /// Resume a container which has been paused.
+ ///
+ /// ID or name of the container
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerUnpauseAsync(string id, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/unpause");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Attach to a container
+ ///
+ ///
+ /// Attach to a container to read its output or send it input. You can attach
+ /// to the same container multiple times and you can reattach to containers
+ /// that have been detached.
+ ///
+ /// Either the `stream` or `logs` parameter must be `true` for this endpoint
+ /// to do anything.
+ ///
+ /// See the [documentation for the `docker attach` command](https://docs.docker.com/engine/reference/commandline/attach/)
+ /// for more details.
+ ///
+ /// ### Hijacking
+ ///
+ /// This endpoint hijacks the HTTP connection to transport `stdin`, `stdout`,
+ /// and `stderr` on the same socket.
+ ///
+ /// This is the response from the daemon for an attach request:
+ ///
+ /// ```
+ /// HTTP/1.1 200 OK
+ /// Content-Type: application/vnd.docker.raw-stream
+ ///
+ /// [STREAM]
+ /// ```
+ ///
+ /// After the headers and two new lines, the TCP connection can now be used
+ /// for raw, bidirectional communication between the client and server.
+ ///
+ /// To hint potential proxies about connection hijacking, the Docker client
+ /// can also optionally send connection upgrade headers.
+ ///
+ /// For example, the client sends this request to upgrade the connection:
+ ///
+ /// ```
+ /// POST /containers/16253994b7c4/attach?stream=1&stdout=1 HTTP/1.1
+ /// Upgrade: tcp
+ /// Connection: Upgrade
+ /// ```
+ ///
+ /// The Docker daemon will respond with a `101 UPGRADED` response, and will
+ /// similarly follow with the raw stream:
+ ///
+ /// ```
+ /// HTTP/1.1 101 UPGRADED
+ /// Content-Type: application/vnd.docker.raw-stream
+ /// Connection: Upgrade
+ /// Upgrade: tcp
+ ///
+ /// [STREAM]
+ /// ```
+ ///
+ /// ### Stream format
+ ///
+ /// When the TTY setting is disabled in [`POST /containers/create`](#operation/ContainerCreate),
+ /// the HTTP Content-Type header is set to application/vnd.docker.multiplexed-stream
+ /// and the stream over the hijacked connected is multiplexed to separate out
+ /// `stdout` and `stderr`. The stream consists of a series of frames, each
+ /// containing a header and a payload.
+ ///
+ /// The header contains the information which the stream writes (`stdout` or
+ /// `stderr`). It also contains the size of the associated frame encoded in
+ /// the last four bytes (`uint32`).
+ ///
+ /// It is encoded on the first eight bytes like this:
+ ///
+ /// ```go
+ /// header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
+ /// ```
+ ///
+ /// `STREAM_TYPE` can be:
+ ///
+ /// - 0: `stdin` (is written on `stdout`)
+ /// - 1: `stdout`
+ /// - 2: `stderr`
+ ///
+ /// `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of the `uint32` size
+ /// encoded as big endian.
+ ///
+ /// Following the header is the payload, which is the specified number of
+ /// bytes of `STREAM_TYPE`.
+ ///
+ /// The simplest way to implement this protocol is the following:
+ ///
+ /// 1. Read 8 bytes.
+ /// 2. Choose `stdout` or `stderr` depending on the first byte.
+ /// 3. Extract the frame size from the last four bytes.
+ /// 4. Read the extracted size and output it on the correct output.
+ /// 5. Goto 1.
+ ///
+ /// ### Stream format when using a TTY
+ ///
+ /// When the TTY setting is enabled in [`POST /containers/create`](#operation/ContainerCreate),
+ /// the stream is not multiplexed. The data exchanged over the hijacked
+ /// connection is simply the raw data from the process PTY and client's
+ /// `stdin`.
+ ///
+ /// ID or name of the container
+ /// Override the key sequence for detaching a container.Format is a single
+ /// character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`,
+ /// `@`, `^`, `[`, `,` or `_`.
+ /// Replay previous logs from the container.
+ ///
+ /// This is useful for attaching to a container that has started and you
+ /// want to output everything since the container started.
+ ///
+ /// If `stream` is also enabled, once all the previous output has been
+ /// returned, it will seamlessly transition into streaming current
+ /// output.
+ /// Stream attached streams from the time the request was made onwards.
+ /// Attach to `stdin`
+ /// Attach to `stdout`
+ /// Attach to `stderr`
+ /// no error, no upgrade header found
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerAttachAsync(string id, string detachKeys, bool? logs, bool? stream, bool? stdin, bool? stdout, bool? stderr)
+ {
+ return ContainerAttachAsync(id, detachKeys, logs, stream, stdin, stdout, stderr, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Attach to a container
+ ///
+ ///
+ /// Attach to a container to read its output or send it input. You can attach
+ /// to the same container multiple times and you can reattach to containers
+ /// that have been detached.
+ ///
+ /// Either the `stream` or `logs` parameter must be `true` for this endpoint
+ /// to do anything.
+ ///
+ /// See the [documentation for the `docker attach` command](https://docs.docker.com/engine/reference/commandline/attach/)
+ /// for more details.
+ ///
+ /// ### Hijacking
+ ///
+ /// This endpoint hijacks the HTTP connection to transport `stdin`, `stdout`,
+ /// and `stderr` on the same socket.
+ ///
+ /// This is the response from the daemon for an attach request:
+ ///
+ /// ```
+ /// HTTP/1.1 200 OK
+ /// Content-Type: application/vnd.docker.raw-stream
+ ///
+ /// [STREAM]
+ /// ```
+ ///
+ /// After the headers and two new lines, the TCP connection can now be used
+ /// for raw, bidirectional communication between the client and server.
+ ///
+ /// To hint potential proxies about connection hijacking, the Docker client
+ /// can also optionally send connection upgrade headers.
+ ///
+ /// For example, the client sends this request to upgrade the connection:
+ ///
+ /// ```
+ /// POST /containers/16253994b7c4/attach?stream=1&stdout=1 HTTP/1.1
+ /// Upgrade: tcp
+ /// Connection: Upgrade
+ /// ```
+ ///
+ /// The Docker daemon will respond with a `101 UPGRADED` response, and will
+ /// similarly follow with the raw stream:
+ ///
+ /// ```
+ /// HTTP/1.1 101 UPGRADED
+ /// Content-Type: application/vnd.docker.raw-stream
+ /// Connection: Upgrade
+ /// Upgrade: tcp
+ ///
+ /// [STREAM]
+ /// ```
+ ///
+ /// ### Stream format
+ ///
+ /// When the TTY setting is disabled in [`POST /containers/create`](#operation/ContainerCreate),
+ /// the HTTP Content-Type header is set to application/vnd.docker.multiplexed-stream
+ /// and the stream over the hijacked connected is multiplexed to separate out
+ /// `stdout` and `stderr`. The stream consists of a series of frames, each
+ /// containing a header and a payload.
+ ///
+ /// The header contains the information which the stream writes (`stdout` or
+ /// `stderr`). It also contains the size of the associated frame encoded in
+ /// the last four bytes (`uint32`).
+ ///
+ /// It is encoded on the first eight bytes like this:
+ ///
+ /// ```go
+ /// header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
+ /// ```
+ ///
+ /// `STREAM_TYPE` can be:
+ ///
+ /// - 0: `stdin` (is written on `stdout`)
+ /// - 1: `stdout`
+ /// - 2: `stderr`
+ ///
+ /// `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of the `uint32` size
+ /// encoded as big endian.
+ ///
+ /// Following the header is the payload, which is the specified number of
+ /// bytes of `STREAM_TYPE`.
+ ///
+ /// The simplest way to implement this protocol is the following:
+ ///
+ /// 1. Read 8 bytes.
+ /// 2. Choose `stdout` or `stderr` depending on the first byte.
+ /// 3. Extract the frame size from the last four bytes.
+ /// 4. Read the extracted size and output it on the correct output.
+ /// 5. Goto 1.
+ ///
+ /// ### Stream format when using a TTY
+ ///
+ /// When the TTY setting is enabled in [`POST /containers/create`](#operation/ContainerCreate),
+ /// the stream is not multiplexed. The data exchanged over the hijacked
+ /// connection is simply the raw data from the process PTY and client's
+ /// `stdin`.
+ ///
+ /// ID or name of the container
+ /// Override the key sequence for detaching a container.Format is a single
+ /// character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`,
+ /// `@`, `^`, `[`, `,` or `_`.
+ /// Replay previous logs from the container.
+ ///
+ /// This is useful for attaching to a container that has started and you
+ /// want to output everything since the container started.
+ ///
+ /// If `stream` is also enabled, once all the previous output has been
+ /// returned, it will seamlessly transition into streaming current
+ /// output.
+ /// Stream attached streams from the time the request was made onwards.
+ /// Attach to `stdin`
+ /// Attach to `stdout`
+ /// Attach to `stderr`
+ /// no error, no upgrade header found
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerAttachAsync(string id, string detachKeys, bool? logs, bool? stream, bool? stdin, bool? stdout, bool? stderr, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/attach?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (detachKeys != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("detachKeys") + "=").Append(System.Uri.EscapeDataString(ConvertToString(detachKeys, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (logs != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("logs") + "=").Append(System.Uri.EscapeDataString(ConvertToString(logs, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stream != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stream") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stream, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stdin != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stdin") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stdin, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stdout != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stdout") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stdout, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stderr != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stderr") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stderr, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/vnd.docker.raw-stream");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/vnd.docker.raw-stream"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 101)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("no error, hints proxy about hijacking", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 200 || status_ == 206)
+ {
+ return default(FileResponse);
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Attach to a container via a websocket
+ ///
+ /// ID or name of the container
+ /// Override the key sequence for detaching a container.Format is a single
+ /// character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`,
+ /// `@`, `^`, `[`, `,`, or `_`.
+ /// Return logs
+ /// Return stream
+ /// Attach to `stdin`
+ /// Attach to `stdout`
+ /// Attach to `stderr`
+ /// no error, no upgrade header found
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerAttachWebsocketAsync(string id, string detachKeys, bool? logs, bool? stream, bool? stdin, bool? stdout, bool? stderr)
+ {
+ return ContainerAttachWebsocketAsync(id, detachKeys, logs, stream, stdin, stdout, stderr, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Attach to a container via a websocket
+ ///
+ /// ID or name of the container
+ /// Override the key sequence for detaching a container.Format is a single
+ /// character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`,
+ /// `@`, `^`, `[`, `,`, or `_`.
+ /// Return logs
+ /// Return stream
+ /// Attach to `stdin`
+ /// Attach to `stdout`
+ /// Attach to `stderr`
+ /// no error, no upgrade header found
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerAttachWebsocketAsync(string id, string detachKeys, bool? logs, bool? stream, bool? stdin, bool? stdout, bool? stderr, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/attach/ws?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (detachKeys != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("detachKeys") + "=").Append(System.Uri.EscapeDataString(ConvertToString(detachKeys, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (logs != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("logs") + "=").Append(System.Uri.EscapeDataString(ConvertToString(logs, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stream != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stream") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stream, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stdin != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stdin") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stdin, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stdout != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stdout") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stdout, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (stderr != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("stderr") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stderr, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 101)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("no error, hints proxy about hijacking", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Wait for a container
+ ///
+ ///
+ /// Block until a container stops, then returns the exit code.
+ ///
+ /// ID or name of the container
+ /// Wait until a container state reaches the given condition.
+ ///
+ /// Defaults to `not-running` if omitted or empty.
+ /// The container has exit.
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerWaitAsync(string id, Condition? condition)
+ {
+ return ContainerWaitAsync(id, condition, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Wait for a container
+ ///
+ ///
+ /// Block until a container stops, then returns the exit code.
+ ///
+ /// ID or name of the container
+ /// Wait until a container state reaches the given condition.
+ ///
+ /// Defaults to `not-running` if omitted or empty.
+ /// The container has exit.
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerWaitAsync(string id, Condition? condition, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/wait?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (condition != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("condition") + "=").Append(System.Uri.EscapeDataString(ConvertToString(condition, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Remove a container
+ ///
+ /// ID or name of the container
+ /// Remove anonymous volumes associated with the container.
+ /// If the container is running, kill it before removing it.
+ /// Remove the specified link associated with the container.
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerDeleteAsync(string id, bool? v, bool? force, bool? link)
+ {
+ return ContainerDeleteAsync(id, v, force, link, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Remove a container
+ ///
+ /// ID or name of the container
+ /// Remove anonymous volumes associated with the container.
+ /// If the container is running, kill it before removing it.
+ /// Remove the specified link associated with the container.
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerDeleteAsync(string id, bool? v, bool? force, bool? link, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ if (v != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("v") + "=").Append(System.Uri.EscapeDataString(ConvertToString(v, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (force != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("force") + "=").Append(System.Uri.EscapeDataString(ConvertToString(force, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (link != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("link") + "=").Append(System.Uri.EscapeDataString(ConvertToString(link, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("DELETE");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 204)
+ {
+ return;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("no such container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 409)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("conflict", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get information about files in a container
+ ///
+ ///
+ /// A response header `X-Docker-Container-Path-Stat` is returned, containing
+ /// a base64 - encoded JSON object with some filesystem header information
+ /// about the path.
+ ///
+ /// ID or name of the container
+ /// Resource in the container’s filesystem to archive.
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerArchiveInfoAsync(string id, string path)
+ {
+ return ContainerArchiveInfoAsync(id, path, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get information about files in a container
+ ///
+ ///
+ /// A response header `X-Docker-Container-Path-Stat` is returned, containing
+ /// a base64 - encoded JSON object with some filesystem header information
+ /// about the path.
+ ///
+ /// ID or name of the container
+ /// Resource in the container’s filesystem to archive.
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerArchiveInfoAsync(string id, string path, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ if (path == null)
+ throw new System.ArgumentNullException("path");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/archive?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ urlBuilder_.Append(System.Uri.EscapeDataString("path") + "=").Append(System.Uri.EscapeDataString(ConvertToString(path, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("HEAD");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Container or path does not exist", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get an archive of a filesystem resource in a container
+ ///
+ ///
+ /// Get a tar archive of a resource in the filesystem of container id.
+ ///
+ /// ID or name of the container
+ /// Resource in the container’s filesystem to archive.
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerArchiveAsync(string id, string path)
+ {
+ return ContainerArchiveAsync(id, path, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get an archive of a filesystem resource in a container
+ ///
+ ///
+ /// Get a tar archive of a resource in the filesystem of container id.
+ ///
+ /// ID or name of the container
+ /// Resource in the container’s filesystem to archive.
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerArchiveAsync(string id, string path, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ if (path == null)
+ throw new System.ArgumentNullException("path");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/archive?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ urlBuilder_.Append(System.Uri.EscapeDataString("path") + "=").Append(System.Uri.EscapeDataString(ConvertToString(path, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/x-tar"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200 || status_ == 206)
+ {
+ return default(FileResponse);
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Container or path does not exist", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Extract an archive of files or folders to a directory in a container
+ ///
+ ///
+ /// Upload a tar archive to be extracted to a path in the filesystem of container id.
+ /// `path` parameter is asserted to be a directory. If it exists as a file, 400 error
+ /// will be returned with message "not a directory".
+ ///
+ /// ID or name of the container
+ /// Path to a directory in the container to extract the archive’s contents into.
+ /// If `1`, `true`, or `True` then it will be an error if unpacking the
+ /// given content would cause an existing directory to be replaced with
+ /// a non-directory and vice versa.
+ /// If `1`, `true`, then it will copy UID/GID maps to the dest file or
+ /// dir
+ /// The input stream must be a tar archive compressed with one of the
+ /// following algorithms: `identity` (no compression), `gzip`, `bzip2`,
+ /// or `xz`.
+ /// The content was extracted successfully
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task PutContainerArchiveAsync(string id, string path, string noOverwriteDirNonDir, string copyUIDGID, FileParameter inputStream)
+ {
+ return PutContainerArchiveAsync(id, path, noOverwriteDirNonDir, copyUIDGID, inputStream, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Extract an archive of files or folders to a directory in a container
+ ///
+ ///
+ /// Upload a tar archive to be extracted to a path in the filesystem of container id.
+ /// `path` parameter is asserted to be a directory. If it exists as a file, 400 error
+ /// will be returned with message "not a directory".
+ ///
+ /// ID or name of the container
+ /// Path to a directory in the container to extract the archive’s contents into.
+ /// If `1`, `true`, or `True` then it will be an error if unpacking the
+ /// given content would cause an existing directory to be replaced with
+ /// a non-directory and vice versa.
+ /// If `1`, `true`, then it will copy UID/GID maps to the dest file or
+ /// dir
+ /// The input stream must be a tar archive compressed with one of the
+ /// following algorithms: `identity` (no compression), `gzip`, `bzip2`,
+ /// or `xz`.
+ /// The content was extracted successfully
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task PutContainerArchiveAsync(string id, string path, string noOverwriteDirNonDir, string copyUIDGID, FileParameter inputStream, System.Threading.CancellationToken cancellationToken)
+ {
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
+ if (path == null)
+ throw new System.ArgumentNullException("path");
+
+ if (inputStream == null)
+ throw new System.ArgumentNullException("inputStream");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/{id}/archive?");
+ urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
+ urlBuilder_.Append(System.Uri.EscapeDataString("path") + "=").Append(System.Uri.EscapeDataString(ConvertToString(path, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ if (noOverwriteDirNonDir != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("noOverwriteDirNonDir") + "=").Append(System.Uri.EscapeDataString(ConvertToString(noOverwriteDirNonDir, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (copyUIDGID != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("copyUIDGID") + "=").Append(System.Uri.EscapeDataString(ConvertToString(copyUIDGID, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ var content_ = new System.Net.Http.StreamContent(inputStream.Data);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(inputStream.ContentType);
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("PUT");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 403)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Permission denied, the volume or container rootfs is marked as read-only.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("No such container or path does not exist inside the container", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Delete stopped containers
+ ///
+ /// Filters to process on the prune list, encoded as JSON (a `map[string][]string`).
+ ///
+ /// Available filters:
+ /// - `until=<timestamp>` Prune containers created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time.
+ /// - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune containers with (or without, in case `label!=...` is used) the specified labels.
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ContainerPruneAsync(string filters)
+ {
+ return ContainerPruneAsync(filters, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Delete stopped containers
+ ///
+ /// Filters to process on the prune list, encoded as JSON (a `map[string][]string`).
+ ///
+ /// Available filters:
+ /// - `until=<timestamp>` Prune containers created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time.
+ /// - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune containers with (or without, in case `label!=...` is used) the specified labels.
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ContainerPruneAsync(string filters, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/containers/prune?");
+ if (filters != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("filters") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filters, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// List Images
+ ///
+ ///
+ /// Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
+ ///
+ /// Show all images. Only images from a final layer (no children) are shown by default.
+ /// A JSON encoded value of the filters (a `map[string][]string`) to
+ /// process on the images list.
+ ///
+ /// Available filters:
+ ///
+ /// - `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
+ /// - `dangling=true`
+ /// - `label=key` or `label="key=value"` of an image label
+ /// - `reference`=(`<image-name>[:<tag>]`)
+ /// - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
+ /// Compute and show shared size as a `SharedSize` field on each image.
+ /// Show digest information as a `RepoDigests` field on each image.
+ /// Summary image data for the images matching the query
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task> ImageListAsync(bool? all, string filters, bool? shared_size, bool? digests)
+ {
+ return ImageListAsync(all, filters, shared_size, digests, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// List Images
+ ///
+ ///
+ /// Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
+ ///
+ /// Show all images. Only images from a final layer (no children) are shown by default.
+ /// A JSON encoded value of the filters (a `map[string][]string`) to
+ /// process on the images list.
+ ///
+ /// Available filters:
+ ///
+ /// - `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
+ /// - `dangling=true`
+ /// - `label=key` or `label="key=value"` of an image label
+ /// - `reference`=(`<image-name>[:<tag>]`)
+ /// - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
+ /// Compute and show shared size as a `SharedSize` field on each image.
+ /// Show digest information as a `RepoDigests` field on each image.
+ /// Summary image data for the images matching the query
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task> ImageListAsync(bool? all, string filters, bool? shared_size, bool? digests, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/json?");
+ if (all != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("all") + "=").Append(System.Uri.EscapeDataString(ConvertToString(all, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (filters != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("filters") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filters, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (shared_size != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("shared-size") + "=").Append(System.Uri.EscapeDataString(ConvertToString(shared_size, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (digests != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("digests") + "=").Append(System.Uri.EscapeDataString(ConvertToString(digests, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Build an image
+ ///
+ ///
+ /// Build an image from a tar archive with a `Dockerfile` in it.
+ ///
+ /// The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. [See the `Dockerfile` reference for more information](https://docs.docker.com/engine/reference/builder/).
+ ///
+ /// The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output.
+ ///
+ /// The build is canceled if the client drops the connection by quitting or being killed.
+ ///
+ /// A tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
+ /// Path within the build context to the `Dockerfile`. This is ignored if `remote` is specified and points to an external `Dockerfile`.
+ /// A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default `latest` value is assumed. You can provide several `t` parameters.
+ /// Extra hosts to add to /etc/hosts
+ /// A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called `Dockerfile` and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the `dockerfile` parameter is also specified, there must be a file with the corresponding path inside the tarball.
+ /// Suppress verbose build output.
+ /// Do not use the cache when building the image.
+ /// JSON array of images used for build cache resolution.
+ /// Attempt to pull the image even if an older image exists locally.
+ /// Remove intermediate containers after a successful build.
+ /// Always remove intermediate containers, even upon failure.
+ /// Set memory limit for build.
+ /// Total memory (memory + swap). Set as `-1` to disable swap.
+ /// CPU shares (relative weight).
+ /// CPUs in which to allow execution (e.g., `0-3`, `0,1`).
+ /// The length of a CPU period in microseconds.
+ /// Microseconds of CPU time that the container can get in a CPU period.
+ /// JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values.
+ ///
+ /// For example, the build arg `FOO=bar` would become `{"FOO":"bar"}` in JSON. This would result in the query parameter `buildargs={"FOO":"bar"}`. Note that `{"FOO":"bar"}` should be URI component encoded.
+ ///
+ /// [Read more about the buildargs instruction.](https://docs.docker.com/engine/reference/builder/#arg)
+ /// Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB.
+ /// Squash the resulting images layers into a single layer. *(Experimental release only.)*
+ /// Arbitrary key/value labels to set on the image, as a JSON map of string pairs.
+ /// Sets the networking mode for the run commands during build. Supported
+ /// standard values are: `bridge`, `host`, `none`, and `container:<name|id>`.
+ /// Any other value is taken as a custom network's name or ID to which this
+ /// container should connect to.
+ /// This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to.
+ ///
+ /// The key is a registry URL, and the value is an auth configuration object, [as described in the authentication section](#section/Authentication). For example:
+ ///
+ /// ```
+ /// {
+ /// "docker.example.com": {
+ /// "username": "janedoe",
+ /// "password": "hunter2"
+ /// },
+ /// "https://index.docker.io/v1/": {
+ /// "username": "mobydock",
+ /// "password": "conta1n3rize14"
+ /// }
+ /// }
+ /// ```
+ ///
+ /// Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a `https://` prefix and a `/v1/` suffix even though Docker will prefer to use the v2 registry API.
+ /// Platform in the format os[/arch[/variant]]
+ /// Target build stage
+ /// BuildKit output configuration
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImageBuildAsync(System.IO.Stream inputStream, string dockerfile, string t, string extrahosts, string remote, bool? q, bool? nocache, string cachefrom, string pull, bool? rm, bool? forcerm, int? memory, int? memswap, int? cpushares, string cpusetcpus, int? cpuperiod, int? cpuquota, string buildargs, int? shmsize, bool? squash, string labels, string networkmode, ContentType? content_type, string x_Registry_Config, string platform, string target, string outputs)
+ {
+ return ImageBuildAsync(inputStream, dockerfile, t, extrahosts, remote, q, nocache, cachefrom, pull, rm, forcerm, memory, memswap, cpushares, cpusetcpus, cpuperiod, cpuquota, buildargs, shmsize, squash, labels, networkmode, content_type, x_Registry_Config, platform, target, outputs, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Build an image
+ ///
+ ///
+ /// Build an image from a tar archive with a `Dockerfile` in it.
+ ///
+ /// The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. [See the `Dockerfile` reference for more information](https://docs.docker.com/engine/reference/builder/).
+ ///
+ /// The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output.
+ ///
+ /// The build is canceled if the client drops the connection by quitting or being killed.
+ ///
+ /// A tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
+ /// Path within the build context to the `Dockerfile`. This is ignored if `remote` is specified and points to an external `Dockerfile`.
+ /// A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default `latest` value is assumed. You can provide several `t` parameters.
+ /// Extra hosts to add to /etc/hosts
+ /// A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called `Dockerfile` and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the `dockerfile` parameter is also specified, there must be a file with the corresponding path inside the tarball.
+ /// Suppress verbose build output.
+ /// Do not use the cache when building the image.
+ /// JSON array of images used for build cache resolution.
+ /// Attempt to pull the image even if an older image exists locally.
+ /// Remove intermediate containers after a successful build.
+ /// Always remove intermediate containers, even upon failure.
+ /// Set memory limit for build.
+ /// Total memory (memory + swap). Set as `-1` to disable swap.
+ /// CPU shares (relative weight).
+ /// CPUs in which to allow execution (e.g., `0-3`, `0,1`).
+ /// The length of a CPU period in microseconds.
+ /// Microseconds of CPU time that the container can get in a CPU period.
+ /// JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values.
+ ///
+ /// For example, the build arg `FOO=bar` would become `{"FOO":"bar"}` in JSON. This would result in the query parameter `buildargs={"FOO":"bar"}`. Note that `{"FOO":"bar"}` should be URI component encoded.
+ ///
+ /// [Read more about the buildargs instruction.](https://docs.docker.com/engine/reference/builder/#arg)
+ /// Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB.
+ /// Squash the resulting images layers into a single layer. *(Experimental release only.)*
+ /// Arbitrary key/value labels to set on the image, as a JSON map of string pairs.
+ /// Sets the networking mode for the run commands during build. Supported
+ /// standard values are: `bridge`, `host`, `none`, and `container:<name|id>`.
+ /// Any other value is taken as a custom network's name or ID to which this
+ /// container should connect to.
+ /// This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to.
+ ///
+ /// The key is a registry URL, and the value is an auth configuration object, [as described in the authentication section](#section/Authentication). For example:
+ ///
+ /// ```
+ /// {
+ /// "docker.example.com": {
+ /// "username": "janedoe",
+ /// "password": "hunter2"
+ /// },
+ /// "https://index.docker.io/v1/": {
+ /// "username": "mobydock",
+ /// "password": "conta1n3rize14"
+ /// }
+ /// }
+ /// ```
+ ///
+ /// Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a `https://` prefix and a `/v1/` suffix even though Docker will prefer to use the v2 registry API.
+ /// Platform in the format os[/arch[/variant]]
+ /// Target build stage
+ /// BuildKit output configuration
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ImageBuildAsync(System.IO.Stream inputStream, string dockerfile, string t, string extrahosts, string remote, bool? q, bool? nocache, string cachefrom, string pull, bool? rm, bool? forcerm, int? memory, int? memswap, int? cpushares, string cpusetcpus, int? cpuperiod, int? cpuquota, string buildargs, int? shmsize, bool? squash, string labels, string networkmode, ContentType? content_type, string x_Registry_Config, string platform, string target, string outputs, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/build?");
+ if (dockerfile != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("dockerfile") + "=").Append(System.Uri.EscapeDataString(ConvertToString(dockerfile, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (t != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("t") + "=").Append(System.Uri.EscapeDataString(ConvertToString(t, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (extrahosts != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("extrahosts") + "=").Append(System.Uri.EscapeDataString(ConvertToString(extrahosts, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (remote != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("remote") + "=").Append(System.Uri.EscapeDataString(ConvertToString(remote, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (q != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("q") + "=").Append(System.Uri.EscapeDataString(ConvertToString(q, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (nocache != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("nocache") + "=").Append(System.Uri.EscapeDataString(ConvertToString(nocache, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (cachefrom != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("cachefrom") + "=").Append(System.Uri.EscapeDataString(ConvertToString(cachefrom, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (pull != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("pull") + "=").Append(System.Uri.EscapeDataString(ConvertToString(pull, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (rm != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("rm") + "=").Append(System.Uri.EscapeDataString(ConvertToString(rm, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (forcerm != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("forcerm") + "=").Append(System.Uri.EscapeDataString(ConvertToString(forcerm, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (memory != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("memory") + "=").Append(System.Uri.EscapeDataString(ConvertToString(memory, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (memswap != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("memswap") + "=").Append(System.Uri.EscapeDataString(ConvertToString(memswap, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (cpushares != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("cpushares") + "=").Append(System.Uri.EscapeDataString(ConvertToString(cpushares, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (cpusetcpus != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("cpusetcpus") + "=").Append(System.Uri.EscapeDataString(ConvertToString(cpusetcpus, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (cpuperiod != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("cpuperiod") + "=").Append(System.Uri.EscapeDataString(ConvertToString(cpuperiod, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (cpuquota != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("cpuquota") + "=").Append(System.Uri.EscapeDataString(ConvertToString(cpuquota, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (buildargs != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("buildargs") + "=").Append(System.Uri.EscapeDataString(ConvertToString(buildargs, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (shmsize != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("shmsize") + "=").Append(System.Uri.EscapeDataString(ConvertToString(shmsize, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (squash != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("squash") + "=").Append(System.Uri.EscapeDataString(ConvertToString(squash, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (labels != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("labels") + "=").Append(System.Uri.EscapeDataString(ConvertToString(labels, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (networkmode != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("networkmode") + "=").Append(System.Uri.EscapeDataString(ConvertToString(networkmode, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (platform != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("platform") + "=").Append(System.Uri.EscapeDataString(ConvertToString(platform, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (target != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("target") + "=").Append(System.Uri.EscapeDataString(ConvertToString(target, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (outputs != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("outputs") + "=").Append(System.Uri.EscapeDataString(ConvertToString(outputs, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+
+ if (content_type != null)
+ request_.Headers.TryAddWithoutValidation("Content-type", ConvertToString(content_type, System.Globalization.CultureInfo.InvariantCulture));
+
+ if (x_Registry_Config != null)
+ request_.Headers.TryAddWithoutValidation("X-Registry-Config", ConvertToString(x_Registry_Config, System.Globalization.CultureInfo.InvariantCulture));
+ var content_ = new System.Net.Http.StreamContent(inputStream);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Delete builder cache
+ ///
+ /// Amount of disk space in bytes to keep for cache
+ /// Remove all types of build cache
+ /// A JSON encoded value of the filters (a `map[string][]string`) to
+ /// process on the list of build cache objects.
+ ///
+ /// Available filters:
+ ///
+ /// - `until=<timestamp>` remove cache older than `<timestamp>`. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time.
+ /// - `id=<id>`
+ /// - `parent=<id>`
+ /// - `type=<string>`
+ /// - `description=<string>`
+ /// - `inuse`
+ /// - `shared`
+ /// - `private`
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task BuildPruneAsync(long? keep_storage, bool? all, string filters)
+ {
+ return BuildPruneAsync(keep_storage, all, filters, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Delete builder cache
+ ///
+ /// Amount of disk space in bytes to keep for cache
+ /// Remove all types of build cache
+ /// A JSON encoded value of the filters (a `map[string][]string`) to
+ /// process on the list of build cache objects.
+ ///
+ /// Available filters:
+ ///
+ /// - `until=<timestamp>` remove cache older than `<timestamp>`. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time.
+ /// - `id=<id>`
+ /// - `parent=<id>`
+ /// - `type=<string>`
+ /// - `description=<string>`
+ /// - `inuse`
+ /// - `shared`
+ /// - `private`
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task BuildPruneAsync(long? keep_storage, bool? all, string filters, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/build/prune?");
+ if (keep_storage != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("keep-storage") + "=").Append(System.Uri.EscapeDataString(ConvertToString(keep_storage, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (all != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("all") + "=").Append(System.Uri.EscapeDataString(ConvertToString(all, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (filters != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("filters") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filters, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Create an image
+ ///
+ ///
+ /// Create an image by either pulling it from a registry or importing it.
+ ///
+ /// Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed.
+ /// Source to import. The value may be a URL from which the image can be retrieved or `-` to read the image from the request body. This parameter may only be used when importing an image.
+ /// Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image.
+ /// Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled.
+ /// Set commit message for imported image.
+ /// Image content if the value `-` has been specified in fromSrc query parameter
+ /// A base64url-encoded auth configuration.
+ ///
+ /// Refer to the [authentication section](#section/Authentication) for
+ /// details.
+ /// Apply `Dockerfile` instructions to the image that is created,
+ /// for example: `changes=ENV DEBUG=true`.
+ /// Note that `ENV DEBUG=true` should be URI component encoded.
+ ///
+ /// Supported `Dockerfile` instructions:
+ /// `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
+ /// Platform in the format os[/arch[/variant]].
+ ///
+ /// When used in combination with the `fromImage` option, the daemon checks
+ /// if the given image is present in the local image cache with the given
+ /// OS and Architecture, and otherwise attempts to pull the image. If the
+ /// option is not set, the host's native OS and Architecture are used.
+ /// If the given image does not exist in the local image cache, the daemon
+ /// attempts to pull the image with the host's native OS and Architecture.
+ /// If the given image does exists in the local image cache, but its OS or
+ /// architecture does not match, a warning is produced.
+ ///
+ /// When used with the `fromSrc` option to import an image from an archive,
+ /// this option sets the platform information for the imported image. If
+ /// the option is not set, the host's native OS and Architecture are used
+ /// for the imported image.
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImageCreateAsync(string fromImage, string fromSrc, string repo, string tag, string message, string inputImage, string x_Registry_Auth, System.Collections.Generic.IEnumerable changes, string platform)
+ {
+ return ImageCreateAsync(fromImage, fromSrc, repo, tag, message, inputImage, x_Registry_Auth, changes, platform, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Create an image
+ ///
+ ///
+ /// Create an image by either pulling it from a registry or importing it.
+ ///
+ /// Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed.
+ /// Source to import. The value may be a URL from which the image can be retrieved or `-` to read the image from the request body. This parameter may only be used when importing an image.
+ /// Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image.
+ /// Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled.
+ /// Set commit message for imported image.
+ /// Image content if the value `-` has been specified in fromSrc query parameter
+ /// A base64url-encoded auth configuration.
+ ///
+ /// Refer to the [authentication section](#section/Authentication) for
+ /// details.
+ /// Apply `Dockerfile` instructions to the image that is created,
+ /// for example: `changes=ENV DEBUG=true`.
+ /// Note that `ENV DEBUG=true` should be URI component encoded.
+ ///
+ /// Supported `Dockerfile` instructions:
+ /// `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
+ /// Platform in the format os[/arch[/variant]].
+ ///
+ /// When used in combination with the `fromImage` option, the daemon checks
+ /// if the given image is present in the local image cache with the given
+ /// OS and Architecture, and otherwise attempts to pull the image. If the
+ /// option is not set, the host's native OS and Architecture are used.
+ /// If the given image does not exist in the local image cache, the daemon
+ /// attempts to pull the image with the host's native OS and Architecture.
+ /// If the given image does exists in the local image cache, but its OS or
+ /// architecture does not match, a warning is produced.
+ ///
+ /// When used with the `fromSrc` option to import an image from an archive,
+ /// this option sets the platform information for the imported image. If
+ /// the option is not set, the host's native OS and Architecture are used
+ /// for the imported image.
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ImageCreateAsync(string fromImage, string fromSrc, string repo, string tag, string message, string inputImage, string x_Registry_Auth, System.Collections.Generic.IEnumerable changes, string platform, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/create?");
+ if (fromImage != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("fromImage") + "=").Append(System.Uri.EscapeDataString(ConvertToString(fromImage, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (fromSrc != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("fromSrc") + "=").Append(System.Uri.EscapeDataString(ConvertToString(fromSrc, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (repo != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("repo") + "=").Append(System.Uri.EscapeDataString(ConvertToString(repo, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (tag != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("tag") + "=").Append(System.Uri.EscapeDataString(ConvertToString(tag, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (message != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("message") + "=").Append(System.Uri.EscapeDataString(ConvertToString(message, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (changes != null)
+ {
+ foreach (var item_ in changes) { urlBuilder_.Append(System.Uri.EscapeDataString("changes") + "=").Append(System.Uri.EscapeDataString(ConvertToString(item_, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); }
+ }
+ if (platform != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("platform") + "=").Append(System.Uri.EscapeDataString(ConvertToString(platform, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+
+ if (x_Registry_Auth != null)
+ request_.Headers.TryAddWithoutValidation("X-Registry-Auth", ConvertToString(x_Registry_Auth, System.Globalization.CultureInfo.InvariantCulture));
+ var content_ = new System.Net.Http.StringContent(inputImage);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("text/plain");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("repository does not exist or no read access", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Inspect an image
+ ///
+ ///
+ /// Return low-level information about an image.
+ ///
+ /// Image name or id
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImageInspectAsync(string name)
+ {
+ return ImageInspectAsync(name, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Inspect an image
+ ///
+ ///
+ /// Return low-level information about an image.
+ ///
+ /// Image name or id
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ImageInspectAsync(string name, System.Threading.CancellationToken cancellationToken)
+ {
+ if (name == null)
+ throw new System.ArgumentNullException("name");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/{name}/json");
+ urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("No such image", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get the history of an image
+ ///
+ ///
+ /// Return parent layers of an image.
+ ///
+ /// Image name or ID
+ /// List of image layers
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task> ImageHistoryAsync(string name)
+ {
+ return ImageHistoryAsync(name, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get the history of an image
+ ///
+ ///
+ /// Return parent layers of an image.
+ ///
+ /// Image name or ID
+ /// List of image layers
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task> ImageHistoryAsync(string name, System.Threading.CancellationToken cancellationToken)
+ {
+ if (name == null)
+ throw new System.ArgumentNullException("name");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/{name}/history");
+ urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture)));
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("No such image", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Push an image
+ ///
+ ///
+ /// Push an image to a registry.
+ ///
+ /// If you wish to push an image on to a private registry, that image must
+ /// already have a tag which references the registry. For example,
+ /// `registry.example.com/myimage:latest`.
+ ///
+ /// The push is cancelled if the HTTP connection is closed.
+ ///
+ /// Image name or ID.
+ /// The tag to associate with the image on the registry.
+ /// A base64url-encoded auth configuration.
+ ///
+ /// Refer to the [authentication section](#section/Authentication) for
+ /// details.
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImagePushAsync(string name, string tag, string x_Registry_Auth)
+ {
+ return ImagePushAsync(name, tag, x_Registry_Auth, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Push an image
+ ///
+ ///
+ /// Push an image to a registry.
+ ///
+ /// If you wish to push an image on to a private registry, that image must
+ /// already have a tag which references the registry. For example,
+ /// `registry.example.com/myimage:latest`.
+ ///
+ /// The push is cancelled if the HTTP connection is closed.
+ ///
+ /// Image name or ID.
+ /// The tag to associate with the image on the registry.
+ /// A base64url-encoded auth configuration.
+ ///
+ /// Refer to the [authentication section](#section/Authentication) for
+ /// details.
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ImagePushAsync(string name, string tag, string x_Registry_Auth, System.Threading.CancellationToken cancellationToken)
+ {
+ if (name == null)
+ throw new System.ArgumentNullException("name");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/{name}/push?");
+ urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture)));
+ if (tag != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("tag") + "=").Append(System.Uri.EscapeDataString(ConvertToString(tag, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+
+ if (x_Registry_Auth == null)
+ throw new System.ArgumentNullException("x_Registry_Auth");
+ request_.Headers.TryAddWithoutValidation("X-Registry-Auth", ConvertToString(x_Registry_Auth, System.Globalization.CultureInfo.InvariantCulture));
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ return;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("No such image", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Tag an image
+ ///
+ ///
+ /// Tag an image so that it becomes part of a repository.
+ ///
+ /// Image name or ID to tag.
+ /// The repository to tag in. For example, `someuser/someimage`.
+ /// The name of the new tag.
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImageTagAsync(string name, string repo, string tag)
+ {
+ return ImageTagAsync(name, repo, tag, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Tag an image
+ ///
+ ///
+ /// Tag an image so that it becomes part of a repository.
+ ///
+ /// Image name or ID to tag.
+ /// The repository to tag in. For example, `someuser/someimage`.
+ /// The name of the new tag.
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ImageTagAsync(string name, string repo, string tag, System.Threading.CancellationToken cancellationToken)
+ {
+ if (name == null)
+ throw new System.ArgumentNullException("name");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/{name}/tag?");
+ urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture)));
+ if (repo != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("repo") + "=").Append(System.Uri.EscapeDataString(ConvertToString(repo, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (tag != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("tag") + "=").Append(System.Uri.EscapeDataString(ConvertToString(tag, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 201)
+ {
+ return;
+ }
+ else
+ if (status_ == 400)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Bad parameter", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("No such image", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 409)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Conflict", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Remove an image
+ ///
+ ///
+ /// Remove an image, along with any untagged parent images that were
+ /// referenced by that image.
+ ///
+ /// Images can't be removed if they have descendant images, are being
+ /// used by a running container or are being used by a build.
+ ///
+ /// Image name or ID
+ /// Remove the image even if it is being used by stopped containers or has other tags
+ /// Do not delete untagged parent images
+ /// The image was deleted successfully
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task> ImageDeleteAsync(string name, bool? force, bool? noprune)
+ {
+ return ImageDeleteAsync(name, force, noprune, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Remove an image
+ ///
+ ///
+ /// Remove an image, along with any untagged parent images that were
+ /// referenced by that image.
+ ///
+ /// Images can't be removed if they have descendant images, are being
+ /// used by a running container or are being used by a build.
+ ///
+ /// Image name or ID
+ /// Remove the image even if it is being used by stopped containers or has other tags
+ /// Do not delete untagged parent images
+ /// The image was deleted successfully
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task> ImageDeleteAsync(string name, bool? force, bool? noprune, System.Threading.CancellationToken cancellationToken)
+ {
+ if (name == null)
+ throw new System.ArgumentNullException("name");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/{name}?");
+ urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture)));
+ if (force != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("force") + "=").Append(System.Uri.EscapeDataString(ConvertToString(force, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (noprune != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("noprune") + "=").Append(System.Uri.EscapeDataString(ConvertToString(noprune, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("DELETE");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 404)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("No such image", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 409)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Conflict", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Search images
+ ///
+ ///
+ /// Search for an image on Docker Hub.
+ ///
+ /// Term to search
+ /// Maximum number of results to return
+ /// A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters:
+ ///
+ /// - `is-automated=(true|false)`
+ /// - `is-official=(true|false)`
+ /// - `stars=<number>` Matches images that has at least 'number' stars.
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task> ImageSearchAsync(string term, int? limit, string filters)
+ {
+ return ImageSearchAsync(term, limit, filters, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Search images
+ ///
+ ///
+ /// Search for an image on Docker Hub.
+ ///
+ /// Term to search
+ /// Maximum number of results to return
+ /// A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters:
+ ///
+ /// - `is-automated=(true|false)`
+ /// - `is-official=(true|false)`
+ /// - `stars=<number>` Matches images that has at least 'number' stars.
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task> ImageSearchAsync(string term, int? limit, string filters, System.Threading.CancellationToken cancellationToken)
+ {
+ if (term == null)
+ throw new System.ArgumentNullException("term");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/search?");
+ urlBuilder_.Append(System.Uri.EscapeDataString("term") + "=").Append(System.Uri.EscapeDataString(ConvertToString(term, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ if (limit != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("limit") + "=").Append(System.Uri.EscapeDataString(ConvertToString(limit, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ if (filters != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("filters") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filters, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Delete unused images
+ ///
+ /// Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters:
+ ///
+ /// - `dangling=<boolean>` When set to `true` (or `1`), prune only
+ /// unused *and* untagged images. When set to `false`
+ /// (or `0`), all unused images are pruned.
+ /// - `until=<string>` Prune images created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time.
+ /// - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune images with (or without, in case `label!=...` is used) the specified labels.
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImagePruneAsync(string filters)
+ {
+ return ImagePruneAsync(filters, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Delete unused images
+ ///
+ /// Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters:
+ ///
+ /// - `dangling=<boolean>` When set to `true` (or `1`), prune only
+ /// unused *and* untagged images. When set to `false`
+ /// (or `0`), all unused images are pruned.
+ /// - `until=<string>` Prune images created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time.
+ /// - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune images with (or without, in case `label!=...` is used) the specified labels.
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ImagePruneAsync(string filters, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/images/prune?");
+ if (filters != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("filters") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filters, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
+ }
+ urlBuilder_.Length--;
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Check auth configuration
+ ///
+ ///
+ /// Validate credentials for a registry and, if available, get an identity
+ /// token for accessing the registry without password.
+ ///
+ /// Authentication to check
+ /// An identity token was generated successfully.
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task SystemAuthAsync(AuthConfig authConfig)
+ {
+ return SystemAuthAsync(authConfig, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Check auth configuration
+ ///
+ ///
+ /// Validate credentials for a registry and, if available, get an identity
+ /// token for accessing the registry without password.
+ ///
+ /// Authentication to check
+ /// An identity token was generated successfully.
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task SystemAuthAsync(AuthConfig authConfig, System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/auth");
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ var json_ = System.Text.Json.JsonSerializer.Serialize(authConfig, _settings.Value);
+ var content_ = new System.Net.Http.StringContent(json_);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 204)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("No error", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 401)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Auth error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get system information
+ ///
+ /// No error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task SystemInfoAsync()
+ {
+ return SystemInfoAsync(System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get system information
+ ///
+ /// No error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task SystemInfoAsync(System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/info");
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("Server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Get version
+ ///
+ ///
+ /// Returns the version of Docker that is running and various information about the system that Docker is running on.
+ ///
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task SystemVersionAsync()
+ {
+ return SystemVersionAsync(System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get version
+ ///
+ ///
+ /// Returns the version of Docker that is running and various information about the system that Docker is running on.
+ ///
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task SystemVersionAsync(System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/version");
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Ping
+ ///
+ ///
+ /// This is a dummy endpoint you can use to test if the server is accessible.
+ ///
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task SystemPingAsync()
+ {
+ return SystemPingAsync(System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Ping
+ ///
+ ///
+ /// This is a dummy endpoint you can use to test if the server is accessible.
+ ///
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task SystemPingAsync(System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/_ping");
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Ping
+ ///
+ ///
+ /// This is a dummy endpoint you can use to test if the server is accessible.
+ ///
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task SystemPingHeadAsync()
+ {
+ return SystemPingHeadAsync(System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Ping
+ ///
+ ///
+ /// This is a dummy endpoint you can use to test if the server is accessible.
+ ///
+ /// no error
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task SystemPingHeadAsync(System.Threading.CancellationToken cancellationToken)
+ {
+ var urlBuilder_ = new System.Text.StringBuilder();
+ urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/_ping");
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("HEAD");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 500)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ApiException("server error", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Create a new image from a container
+ ///
+ /// The container configuration
+ /// The ID or name of the container to commit
+ /// Repository name for the created image
+ /// Tag name for the create image
+ /// Commit message
+ /// Author of the image (e.g., `John Hannibal Smith <hannibal@a-team.com>`)
+ /// Whether to pause the container before committing
+ /// `Dockerfile` instructions to apply while committing
+ /// no error
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ImageCommitAsync(ContainerConfig containerConfig, string container, string repo, string tag, string comment, string author, bool? pause, string changes)
+ {
+ return ImageCommitAsync(containerConfig, container, repo, tag, comment, author, pause, changes, System.Threading.CancellationToken.None);
+ }
+
+ ///