From af0580e2a0bea3164513398cbb1e5c563308776a Mon Sep 17 00:00:00 2001
From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
Date: Thu, 7 Nov 2024 19:02:07 +0100
Subject: [PATCH] feat: Replace JSON.NET with System.Text.Json (#6)
---
src/Docker.DotNet/Docker.DotNet.csproj | 5 +-
src/Docker.DotNet/DockerClient.cs | 93 ++++++++---
.../Endpoints/ConfigsOperations.cs | 13 +-
.../Endpoints/ContainerOperations.cs | 52 +++----
src/Docker.DotNet/Endpoints/ExecOperations.cs | 14 +-
.../Endpoints/ImageOperations.cs | 38 ++---
.../Endpoints/NetworkOperations.cs | 20 +--
.../Endpoints/PluginOperations.cs | 21 ++-
.../Endpoints/SecretsOperations.cs | 11 +-
src/Docker.DotNet/Endpoints/StreamUtil.cs | 9 +-
.../Endpoints/SwarmOperations.cs | 49 +++---
.../Endpoints/SystemOperations.cs | 8 +-
.../Endpoints/TasksOperations.cs | 6 +-
.../Endpoints/VolumeOperations.cs | 19 +--
.../EnumerableQueryStringConverter.cs | 3 +-
src/Docker.DotNet/JsonBase64Converter.cs | 38 +++--
src/Docker.DotNet/JsonDateTimeConverter.cs | 28 ++++
src/Docker.DotNet/JsonEnumMemberConverter.cs | 34 ++++
.../JsonIso8601AndUnixEpochDateConverter.cs | 56 -------
.../JsonNullableDateTimeConverter.cs | 30 ++++
src/Docker.DotNet/JsonQueryStringConverter.cs | 3 +-
src/Docker.DotNet/JsonRequestContent.cs | 6 +-
src/Docker.DotNet/JsonSerializer.cs | 121 +++++++++------
src/Docker.DotNet/JsonVersionConverter.cs | 30 ----
src/Docker.DotNet/MapQueryStringConverter.cs | 3 +-
.../UnixDomainSocketEndPoint.cs | 2 +-
src/Docker.DotNet/Models/Actor.Generated.cs | 7 +-
src/Docker.DotNet/Models/Address.Generated.cs | 7 +-
.../Models/Annotations.Generated.cs | 7 +-
.../Models/AppArmorOpts.Generated.cs | 5 +-
.../Models/AttestationProperties.Generated.cs | 5 +-
.../Models/AuthConfig.Generated.cs | 17 +-
.../Models/AuthResponse.Generated.cs | 7 +-
.../Models/BindOptions.Generated.cs | 13 +-
.../Models/BlkioStatEntry.Generated.cs | 11 +-
.../Models/BlkioStats.Generated.cs | 19 ++-
.../Models/CAConfig.Generated.cs | 13 +-
.../Models/CPUStats.Generated.cs | 11 +-
.../Models/CPUUsage.Generated.cs | 11 +-
.../Models/CapacityRange.Generated.cs | 7 +-
.../Models/ClusterInfo.Generated.cs | 23 ++-
.../Models/ClusterOptions.Generated.cs | 2 -
.../Models/ClusterVolume.Generated.cs | 17 +-
.../Models/ClusterVolumeSpec.Generated.cs | 15 +-
src/Docker.DotNet/Models/Commit.Generated.cs | 7 +-
...mitContainerChangesParameters.Generated.cs | 54 ++++---
...ommitContainerChangesResponse.Generated.cs | 5 +-
.../Models/ComponentVersion.Generated.cs | 9 +-
src/Docker.DotNet/Models/Config.Generated.cs | 54 ++++---
.../Models/ConfigReference.Generated.cs | 5 +-
.../ConfigReferenceFileTarget.Generated.cs | 11 +-
.../ConfigReferenceRuntimeTarget.Generated.cs | 2 -
.../ContainerAttachParameters.Generated.cs | 2 -
.../ContainerEventsParameters.Generated.cs | 2 -
...ContainerExecCreateParameters.Generated.cs | 27 ++--
.../ContainerExecCreateResponse.Generated.cs | 5 +-
.../ContainerExecInspectResponse.Generated.cs | 13 +-
.../ContainerExecStartParameters.Generated.cs | 27 ++--
...ainerFileSystemChangeResponse.Generated.cs | 7 +-
.../ContainerInspectParameters.Generated.cs | 2 -
.../ContainerInspectResponse.Generated.cs | 55 ++++---
.../Models/ContainerJSONBase.Generated.cs | 49 +++---
.../ContainerKillParameters.Generated.cs | 2 -
...tainerListProcessesParameters.Generated.cs | 2 -
.../Models/ContainerListResponse.Generated.cs | 31 ++--
.../ContainerLogsParameters.Generated.cs | 2 -
.../Models/ContainerNode.Generated.cs | 17 +-
.../ContainerPathStatParameters.Generated.cs | 2 -
.../ContainerPathStatResponse.Generated.cs | 13 +-
.../ContainerProcessesResponse.Generated.cs | 7 +-
.../ContainerRemoveParameters.Generated.cs | 2 -
.../ContainerRenameParameters.Generated.cs | 2 -
.../ContainerResizeParameters.Generated.cs | 2 -
.../ContainerRestartParameters.Generated.cs | 2 -
.../Models/ContainerSpec.Generated.cs | 59 ++++---
.../ContainerStartParameters.Generated.cs | 2 -
.../Models/ContainerState.Generated.cs | 27 ++--
.../ContainerStatsParameters.Generated.cs | 2 -
.../ContainerStatsResponse.Generated.cs | 27 ++--
.../Models/ContainerStatus.Generated.cs | 9 +-
.../ContainerStopParameters.Generated.cs | 2 -
.../ContainerUpdateParameters.Generated.cs | 67 ++++----
.../ContainerUpdateResponse.Generated.cs | 5 +-
.../Models/ContainerWaitResponse.Generated.cs | 7 +-
.../Models/ContainerdInfo.Generated.cs | 7 +-
.../Models/ContainerdNamespaces.Generated.cs | 7 +-
.../ContainersListParameters.Generated.cs | 2 -
.../ContainersPruneParameters.Generated.cs | 2 -
.../ContainersPruneResponse.Generated.cs | 7 +-
.../CreateContainerParameters.Generated.cs | 58 ++++---
.../CreateContainerResponse.Generated.cs | 7 +-
.../Models/CreateOptions.Generated.cs | 25 ++-
.../Models/CredentialSpec.Generated.cs | 9 +-
.../Models/DNSConfig.Generated.cs | 9 +-
.../DefaultNetworkSettings.Generated.cs | 19 ++-
.../Models/Descriptor.Generated.cs | 15 +-
.../Models/DeviceMapping.Generated.cs | 9 +-
.../Models/DeviceRequest.Generated.cs | 13 +-
.../DiscreteGenericResource.Generated.cs | 7 +-
.../Models/DispatcherConfig.Generated.cs | 5 +-
src/Docker.DotNet/Models/Driver.Generated.cs | 7 +-
.../Models/EncryptionConfig.Generated.cs | 5 +-
.../Models/Endpoint.Generated.cs | 9 +-
.../Models/EndpointIPAMConfig.Generated.cs | 9 +-
.../Models/EndpointResource.Generated.cs | 13 +-
.../Models/EndpointSettings.Generated.cs | 31 ++--
.../Models/EndpointSpec.Generated.cs | 7 +-
.../Models/EndpointVirtualIP.Generated.cs | 7 +-
.../Models/EngineDescription.Generated.cs | 9 +-
.../Models/ExternalCA.Generated.cs | 11 +-
.../Models/GenericResource.Generated.cs | 7 +-
.../Models/GlobalJob.Generated.cs | 2 -
.../Models/GlobalService.Generated.cs | 2 -
.../Models/GraphDriverData.Generated.cs | 7 +-
src/Docker.DotNet/Models/Health.Generated.cs | 9 +-
.../Models/HealthcheckConfig.Generated.cs | 16 +-
.../Models/HealthcheckResult.Generated.cs | 11 +-
.../Models/HostConfig.Generated.cs | 145 +++++++++---------
src/Docker.DotNet/Models/IPAM.Generated.cs | 9 +-
.../Models/IPAMConfig.Generated.cs | 11 +-
.../Models/IPAMOptions.Generated.cs | 7 +-
.../Models/ImageBuildParameters.Generated.cs | 5 +-
.../Models/ImageBuildResponse.Generated.cs | 7 +-
.../Models/ImageDeleteParameters.Generated.cs | 2 -
.../Models/ImageDeleteResponse.Generated.cs | 7 +-
.../Models/ImageHistoryResponse.Generated.cs | 15 +-
.../Models/ImageInspectResponse.Generated.cs | 43 +++---
.../Models/ImageLoadParameters.Generated.cs | 2 -
.../Models/ImageProperties.Generated.cs | 7 +-
.../Models/ImagePushParameters.Generated.cs | 5 +-
.../Models/ImageSearchResponse.Generated.cs | 13 +-
.../Models/ImageTagParameters.Generated.cs | 2 -
.../ImagesCreateParameters.Generated.cs | 5 +-
.../Models/ImagesListParameters.Generated.cs | 2 -
.../Models/ImagesListResponse.Generated.cs | 25 ++-
.../Models/ImagesLoadResponse.Generated.cs | 7 +-
.../Models/ImagesPruneParameters.Generated.cs | 2 -
.../Models/ImagesPruneResponse.Generated.cs | 7 +-
.../ImagesSearchParameters.Generated.cs | 2 -
.../Models/IndexInfo.Generated.cs | 11 +-
src/Docker.DotNet/Models/Info.Generated.cs | 23 ++-
.../Models/JSONError.Generated.cs | 7 +-
.../Models/JSONMessage.Generated.cs | 25 ++-
.../Models/JSONProgress.Generated.cs | 15 +-
.../Models/JobStatus.Generated.cs | 7 +-
.../Models/JoinTokens.Generated.cs | 7 +-
.../Models/LogConfig.Generated.cs | 7 +-
.../Models/ManagerStatus.Generated.cs | 9 +-
.../Models/ManifestSummary.Generated.cs | 15 +-
.../Models/MemoryStats.Generated.cs | 19 ++-
src/Docker.DotNet/Models/Message.Generated.cs | 21 ++-
src/Docker.DotNet/Models/Meta.Generated.cs | 9 +-
.../Models/Metadata.Generated.cs | 5 +-
src/Docker.DotNet/Models/Mount.Generated.cs | 21 ++-
.../Models/MountPoint.Generated.cs | 19 ++-
.../Models/NamedGenericResource.Generated.cs | 7 +-
src/Docker.DotNet/Models/Network.Generated.cs | 17 +-
.../Models/NetworkAddressPool.Generated.cs | 7 +-
.../Models/NetworkAttachment.Generated.cs | 7 +-
.../NetworkAttachmentConfig.Generated.cs | 9 +-
.../Models/NetworkAttachmentSpec.Generated.cs | 5 +-
.../NetworkConnectParameters.Generated.cs | 7 +-
.../NetworkDisconnectParameters.Generated.cs | 7 +-
.../Models/NetworkResponse.Generated.cs | 37 +++--
.../Models/NetworkSettings.Generated.cs | 39 +++--
.../Models/NetworkSettingsBase.Generated.cs | 21 ++-
.../Models/NetworkSpec.Generated.cs | 23 ++-
.../Models/NetworkStats.Generated.cs | 23 ++-
.../Models/NetworkTask.Generated.cs | 11 +-
.../Models/NetworkingConfig.Generated.cs | 5 +-
.../NetworksCreateParameters.Generated.cs | 29 ++--
.../NetworksCreateResponse.Generated.cs | 7 +-
...etworksDeleteUnusedParameters.Generated.cs | 2 -
.../NetworksListParameters.Generated.cs | 2 -
.../Models/NetworksPruneResponse.Generated.cs | 5 +-
.../Models/NodeCSIInfo.Generated.cs | 11 +-
.../Models/NodeDescription.Generated.cs | 15 +-
.../Models/NodeListResponse.Generated.cs | 19 ++-
.../Models/NodeRemoveParameters.Generated.cs | 2 -
.../Models/NodeStatus.Generated.cs | 9 +-
.../Models/NodeUpdateParameters.Generated.cs | 11 +-
.../Models/ObjectExtensionData.cs | 2 +-
.../Models/OrchestrationConfig.Generated.cs | 5 +-
src/Docker.DotNet/Models/Peer.Generated.cs | 7 +-
.../Models/PeerInfo.Generated.cs | 7 +-
.../Models/PidsStats.Generated.cs | 7 +-
.../Models/Placement.Generated.cs | 11 +-
.../Models/PlacementPreference.Generated.cs | 5 +-
.../Models/Platform.Generated.cs | 13 +-
src/Docker.DotNet/Models/Plugin.Generated.cs | 15 +-
.../Models/PluginConfig.Generated.cs | 35 ++---
.../Models/PluginConfigArgs.Generated.cs | 11 +-
.../Models/PluginConfigInterface.Generated.cs | 9 +-
.../Models/PluginConfigLinux.Generated.cs | 9 +-
.../Models/PluginConfigNetwork.Generated.cs | 5 +-
.../Models/PluginConfigRootfs.Generated.cs | 7 +-
.../Models/PluginConfigUser.Generated.cs | 7 +-
.../PluginConfigureParameters.Generated.cs | 5 +-
.../PluginCreateParameters.Generated.cs | 2 -
.../Models/PluginDescription.Generated.cs | 7 +-
.../Models/PluginDevice.Generated.cs | 11 +-
.../PluginDisableParameters.Generated.cs | 2 -
.../PluginEnableParameters.Generated.cs | 2 -
.../Models/PluginEnv.Generated.cs | 11 +-
.../PluginGetPrivilegeParameters.Generated.cs | 2 -
.../PluginInstallParameters.Generated.cs | 7 +-
.../Models/PluginInterfaceType.Generated.cs | 9 +-
.../Models/PluginListParameters.Generated.cs | 2 -
.../Models/PluginMount.Generated.cs | 17 +-
.../Models/PluginPrivilege.Generated.cs | 9 +-
.../PluginRemoveParameters.Generated.cs | 2 -
.../Models/PluginSettings.Generated.cs | 11 +-
.../Models/PluginSpec.Generated.cs | 13 +-
.../PluginUpgradeParameters.Generated.cs | 7 +-
.../Models/PluginsInfo.Generated.cs | 11 +-
src/Docker.DotNet/Models/Port.Generated.cs | 11 +-
.../Models/PortBinding.Generated.cs | 7 +-
.../Models/PortConfig.Generated.cs | 13 +-
.../Models/PortStatus.Generated.cs | 5 +-
.../Models/Privileges.Generated.cs | 13 +-
.../Models/PublishStatus.Generated.cs | 9 +-
.../Models/RaftConfig.Generated.cs | 13 +-
.../Models/ReplicatedJob.Generated.cs | 7 +-
.../Models/ReplicatedService.Generated.cs | 5 +-
.../Models/ResourceRequirements.Generated.cs | 7 +-
.../Models/Resources.Generated.cs | 65 ++++----
.../Models/RestartPolicy.Generated.cs | 7 +-
src/Docker.DotNet/Models/RootFS.Generated.cs | 7 +-
src/Docker.DotNet/Models/Runtime.Generated.cs | 11 +-
.../RuntimePluginPrivilege.Generated.cs | 9 +-
.../Models/RuntimeWithStatus.Generated.cs | 13 +-
.../Models/SELinuxContext.Generated.cs | 13 +-
.../Models/SeccompOpts.Generated.cs | 7 +-
src/Docker.DotNet/Models/Secret.Generated.cs | 13 +-
.../Models/SecretCreateResponse.Generated.cs | 5 +-
.../Models/SecretReference.Generated.cs | 9 +-
.../SecretReferenceFileTarget.Generated.cs | 11 +-
.../Models/SecretSpec.Generated.cs | 13 +-
.../Models/ServiceConfig.Generated.cs | 13 +-
.../ServiceCreateParameters.Generated.cs | 7 +-
.../Models/ServiceCreateResponse.Generated.cs | 7 +-
.../Models/ServiceInfo.Generated.cs | 11 +-
.../Models/ServiceListParameters.Generated.cs | 2 -
.../Models/ServiceLogsParameters.Generated.cs | 2 -
.../Models/ServiceMode.Generated.cs | 11 +-
.../Models/ServiceSpec.Generated.cs | 19 ++-
.../Models/ServiceStatus.Generated.cs | 9 +-
.../ServiceUpdateParameters.Generated.cs | 7 +-
.../Models/ServiceUpdateResponse.Generated.cs | 5 +-
src/Docker.DotNet/Models/Spec.Generated.cs | 19 ++-
.../Models/SpreadOver.Generated.cs | 5 +-
src/Docker.DotNet/Models/Stats.Generated.cs | 21 ++-
.../Models/StorageStats.Generated.cs | 11 +-
.../SummaryNetworkSettings.Generated.cs | 5 +-
.../Models/SwarmConfig.Generated.cs | 13 +-
.../Models/SwarmConfigReference.Generated.cs | 11 +-
.../Models/SwarmConfigSpec.Generated.cs | 11 +-
.../SwarmCreateConfigParameters.Generated.cs | 5 +-
.../SwarmCreateConfigResponse.Generated.cs | 5 +-
.../Models/SwarmDriver.Generated.cs | 7 +-
.../Models/SwarmIPAMConfig.Generated.cs | 9 +-
.../Models/SwarmInitParameters.Generated.cs | 23 ++-
.../Models/SwarmInspectResponse.Generated.cs | 25 ++-
.../Models/SwarmJoinParameters.Generated.cs | 15 +-
.../Models/SwarmLeaveParameters.Generated.cs | 2 -
.../Models/SwarmLimit.Generated.cs | 9 +-
.../Models/SwarmPlatform.Generated.cs | 7 +-
.../Models/SwarmResources.Generated.cs | 9 +-
.../Models/SwarmRestartPolicy.Generated.cs | 11 +-
.../Models/SwarmService.Generated.cs | 23 ++-
.../Models/SwarmUnlockParameters.Generated.cs | 5 +-
.../Models/SwarmUnlockResponse.Generated.cs | 5 +-
.../Models/SwarmUpdateConfig.Generated.cs | 15 +-
.../SwarmUpdateConfigParameters.Generated.cs | 5 +-
.../Models/SwarmUpdateParameters.Generated.cs | 5 +-
.../Models/SystemInfoResponse.Generated.cs | 131 ++++++++--------
src/Docker.DotNet/Models/TLSInfo.Generated.cs | 9 +-
.../Models/TaskDefaults.Generated.cs | 5 +-
.../Models/TaskResponse.Generated.cs | 35 ++---
.../Models/TaskSpec.Generated.cs | 23 ++-
.../Models/TaskStatus.Generated.cs | 15 +-
.../Models/TasksListParameters.Generated.cs | 2 -
.../Models/ThrottleDevice.Generated.cs | 7 +-
.../Models/ThrottlingData.Generated.cs | 9 +-
.../Models/TmpfsOptions.Generated.cs | 9 +-
.../Models/Topology.Generated.cs | 5 +-
.../Models/TopologyRequirement.Generated.cs | 7 +-
.../Models/TypeBlock.Generated.cs | 2 -
.../Models/TypeMount.Generated.cs | 7 +-
src/Docker.DotNet/Models/Ulimit.Generated.cs | 9 +-
.../Models/UpdateConfig.Generated.cs | 67 ++++----
.../Models/UpdateStatus.Generated.cs | 11 +-
.../Models/UsageData.Generated.cs | 7 +-
src/Docker.DotNet/Models/Version.Generated.cs | 5 +-
.../Models/VersionResponse.Generated.cs | 25 ++-
.../Models/VolumeAccessMode.Generated.cs | 11 +-
.../Models/VolumeAttachment.Generated.cs | 9 +-
.../Models/VolumeInfo.Generated.cs | 11 +-
.../Models/VolumeOptions.Generated.cs | 11 +-
.../Models/VolumeResponse.Generated.cs | 23 ++-
.../Models/VolumeSecret.Generated.cs | 7 +-
.../Models/VolumeTopology.Generated.cs | 5 +-
.../VolumesCreateParameters.Generated.cs | 11 +-
.../Models/VolumesListParameters.Generated.cs | 2 -
.../Models/VolumesListResponse.Generated.cs | 7 +-
.../VolumesPruneParameters.Generated.cs | 2 -
.../Models/VolumesPruneResponse.Generated.cs | 7 +-
.../Models/WaitExitError.Generated.cs | 5 +-
.../Models/WeightDevice.Generated.cs | 7 +-
.../TimeSpanNanoSecondsConverter.cs | 35 ++---
src/Docker.DotNet/TimeSpanSecondsConverter.cs | 28 ++--
.../IContainerOperationsTests.cs | 5 +-
.../ISystemOperations.Tests.cs | 8 +-
tools/specgen/csharptype.go | 2 -
tools/specgen/specgen.exe | Bin 0 -> 4756480 bytes
tools/specgen/specgen.go | 13 +-
316 files changed, 1998 insertions(+), 2319 deletions(-)
create mode 100644 src/Docker.DotNet/JsonDateTimeConverter.cs
create mode 100644 src/Docker.DotNet/JsonEnumMemberConverter.cs
delete mode 100644 src/Docker.DotNet/JsonIso8601AndUnixEpochDateConverter.cs
create mode 100644 src/Docker.DotNet/JsonNullableDateTimeConverter.cs
delete mode 100644 src/Docker.DotNet/JsonVersionConverter.cs
create mode 100644 tools/specgen/specgen.exe
diff --git a/src/Docker.DotNet/Docker.DotNet.csproj b/src/Docker.DotNet/Docker.DotNet.csproj
index ac77c8111..07a06a976 100644
--- a/src/Docker.DotNet/Docker.DotNet.csproj
+++ b/src/Docker.DotNet/Docker.DotNet.csproj
@@ -3,9 +3,12 @@
Docker.DotNet.Enhanced
Docker.DotNet is a library that allows you to interact with the Docker Remote API programmatically with fully asynchronous, non-blocking and object-oriented code in your .NET applications.
Docker.DotNet
+ latest
-
+
+
+
\ No newline at end of file
diff --git a/src/Docker.DotNet/DockerClient.cs b/src/Docker.DotNet/DockerClient.cs
index 64a428f84..1960e8a84 100644
--- a/src/Docker.DotNet/DockerClient.cs
+++ b/src/Docker.DotNet/DockerClient.cs
@@ -33,7 +33,6 @@ internal DockerClient(DockerClientConfiguration configuration, Version requested
Configuration = configuration;
DefaultTimeout = configuration.DefaultTimeout;
- JsonSerializer = new JsonSerializer();
Images = new ImageOperations(this);
Containers = new ContainerOperations(this);
System = new SystemOperations(this);
@@ -149,7 +148,7 @@ await sock.ConnectAsync(new Microsoft.Net.Http.Client.UnixDomainSocketEndPoint(p
public IExecOperations Exec { get; }
- internal JsonSerializer JsonSerializer { get; }
+ internal static JsonSerializer JsonSerializer => JsonSerializer.Instance;
public void Dispose()
{
@@ -157,49 +156,92 @@ public void Dispose()
_client.Dispose();
}
- internal Task MakeRequestAsync(
+ internal Task MakeRequestAsync(
IEnumerable errorHandlers,
HttpMethod method,
string path,
CancellationToken token)
{
- return MakeRequestAsync(errorHandlers, method, path, null, null, token);
+ return MakeRequestAsync(errorHandlers, method, path, null, null, token);
}
- internal Task MakeRequestAsync(
+ internal Task MakeRequestAsync(
+ IEnumerable errorHandlers,
+ HttpMethod method,
+ string path,
+ CancellationToken token)
+ {
+ return MakeRequestAsync(errorHandlers, method, path, null, null, token);
+ }
+
+ internal Task MakeRequestAsync(
+ IEnumerable errorHandlers,
+ HttpMethod method,
+ string path,
+ IQueryString queryString,
+ CancellationToken token)
+ {
+ return MakeRequestAsync(errorHandlers, method, path, queryString, null, token);
+ }
+
+ internal Task MakeRequestAsync(
+ IEnumerable errorHandlers,
+ HttpMethod method,
+ string path,
+ IQueryString queryString,
+ CancellationToken token)
+ {
+ return MakeRequestAsync(errorHandlers, method, path, queryString, null, token);
+ }
+
+ internal Task MakeRequestAsync(
+ IEnumerable errorHandlers,
+ HttpMethod method,
+ string path,
+ IQueryString queryString,
+ IRequestContent body,
+ CancellationToken token)
+ {
+ return MakeRequestAsync(errorHandlers, method, path, queryString, body, null, token);
+ }
+
+ internal Task MakeRequestAsync(
IEnumerable errorHandlers,
HttpMethod method,
string path,
IQueryString queryString,
+ IRequestContent body,
CancellationToken token)
{
- return MakeRequestAsync(errorHandlers, method, path, queryString, null, token);
+ return MakeRequestAsync(errorHandlers, method, path, queryString, body, null, token);
}
- internal Task MakeRequestAsync(
+ internal Task MakeRequestAsync(
IEnumerable errorHandlers,
HttpMethod method,
string path,
IQueryString queryString,
IRequestContent body,
+ IDictionary headers,
CancellationToken token)
{
- return MakeRequestAsync(errorHandlers, method, path, queryString, body, null, token);
+ return MakeRequestAsync(errorHandlers, method, path, queryString, body, headers, DefaultTimeout, token);
}
- internal Task MakeRequestAsync(
+ internal Task MakeRequestAsync(
IEnumerable errorHandlers,
HttpMethod method,
string path,
IQueryString queryString,
IRequestContent body,
IDictionary headers,
+ TimeSpan timeout,
CancellationToken token)
{
- return MakeRequestAsync(errorHandlers, method, path, queryString, body, headers, DefaultTimeout, token);
+ return MakeRequestAsync(errorHandlers, method, path, queryString, body, headers, timeout, token);
}
- internal async Task MakeRequestAsync(
+ internal async Task MakeRequestAsync(
IEnumerable errorHandlers,
HttpMethod method,
string path,
@@ -209,19 +251,19 @@ internal async Task MakeRequestAsync(
TimeSpan timeout,
CancellationToken token)
{
- var response = await PrivateMakeRequestAsync(timeout, HttpCompletionOption.ResponseContentRead, method, path, queryString, headers, body, token)
+ using var response = await PrivateMakeRequestAsync(timeout, HttpCompletionOption.ResponseContentRead, method, path, queryString, headers, body, token)
.ConfigureAwait(false);
- using (response)
- {
- await HandleIfErrorResponseAsync(response.StatusCode, response, errorHandlers)
- .ConfigureAwait(false);
-
- var responseBody = await response.Content.ReadAsStringAsync()
- .ConfigureAwait(false);
+ await HandleIfErrorResponseAsync(response.StatusCode, response, errorHandlers)
+ .ConfigureAwait(false);
- return new DockerApiResponse(response.StatusCode, responseBody);
+ if (typeof(T) == typeof(NoContent))
+ {
+ return default;
}
+
+ return await JsonSerializer.DeserializeAsync(response.Content, token)
+ .ConfigureAwait(false);
}
internal Task MakeRequestForStreamAsync(
@@ -294,9 +336,12 @@ internal async Task MakeRequestForRawResponseAsync(
IDictionary headers,
CancellationToken token)
{
- var response = await PrivateMakeRequestAsync(SInfiniteTimeout, HttpCompletionOption.ResponseHeadersRead, method, path, queryString, headers, body, token).ConfigureAwait(false);
+ var response = await PrivateMakeRequestAsync(SInfiniteTimeout, HttpCompletionOption.ResponseHeadersRead, method, path, queryString, headers, body, token)
+ .ConfigureAwait(false);
+
await HandleIfErrorResponseAsync(response.StatusCode, response)
.ConfigureAwait(false);
+
return response;
}
@@ -347,7 +392,7 @@ internal async Task MakeRequestForHijackedStreamAsync(
await HandleIfErrorResponseAsync(response.StatusCode, response, errorHandlers)
.ConfigureAwait(false);
- if (!(response.Content is HttpConnectionResponseContent content))
+ if (response.Content is not HttpConnectionResponseContent content)
{
throw new NotSupportedException("message handler does not support hijacked streams");
}
@@ -388,7 +433,7 @@ private async Task PrivateMakeRequestAsync(
}
}
- internal HttpRequestMessage PrepareRequest(HttpMethod method, string path, IQueryString queryString, IDictionary headers, IRequestContent data)
+ private HttpRequestMessage PrepareRequest(HttpMethod method, string path, IQueryString queryString, IDictionary headers, IRequestContent data)
{
if (string.IsNullOrEmpty(path))
{
@@ -469,6 +514,8 @@ private async Task HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpRes
throw new DockerApiException(statusCode, responseBody);
}
}
+
+ private struct NoContent;
}
internal delegate void ApiResponseErrorHandlingDelegate(HttpStatusCode statusCode, string responseBody);
diff --git a/src/Docker.DotNet/Endpoints/ConfigsOperations.cs b/src/Docker.DotNet/Endpoints/ConfigsOperations.cs
index e7e04e8c8..04492f000 100644
--- a/src/Docker.DotNet/Endpoints/ConfigsOperations.cs
+++ b/src/Docker.DotNet/Endpoints/ConfigsOperations.cs
@@ -18,8 +18,7 @@ internal ConfigOperations(DockerClient client)
async Task> IConfigOperations.ListConfigsAsync(CancellationToken cancellationToken)
{
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject>(response.Body);
+ return await _client.MakeRequestAsync>(_client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken).ConfigureAwait(false);
}
async Task IConfigOperations.CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken)
@@ -29,9 +28,8 @@ async Task IConfigOperations.CreateConfigAsync(SwarmC
throw new ArgumentNullException(nameof(body));
}
- var data = new JsonRequestContent(body.Config, _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(body.Config, DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken).ConfigureAwait(false);
}
async Task IConfigOperations.InspectConfigAsync(string id, CancellationToken cancellationToken)
@@ -41,8 +39,7 @@ async Task IConfigOperations.InspectConfigAsync(string id, Cancella
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken).ConfigureAwait(false);
}
Task IConfigOperations.RemoveConfigAsync(string id, CancellationToken cancellationToken)
@@ -55,4 +52,4 @@ Task IConfigOperations.RemoveConfigAsync(string id, CancellationToken cancellati
return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Delete, $"configs/{id}", cancellationToken);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Docker.DotNet/Endpoints/ContainerOperations.cs b/src/Docker.DotNet/Endpoints/ContainerOperations.cs
index 03960ab7c..9d2ffe0a5 100644
--- a/src/Docker.DotNet/Endpoints/ContainerOperations.cs
+++ b/src/Docker.DotNet/Endpoints/ContainerOperations.cs
@@ -5,7 +5,6 @@
using System.Linq;
using System.Net;
using System.Net.Http;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -13,14 +12,15 @@ namespace Docker.DotNet
{
internal class ContainerOperations : IContainerOperations
{
- internal static readonly ApiResponseErrorHandlingDelegate NoSuchContainerHandler = (statusCode, responseBody) =>
+ private static readonly ApiResponseErrorHandlingDelegate NoSuchContainerHandler = (statusCode, responseBody) =>
{
if (statusCode == HttpStatusCode.NotFound)
{
throw new DockerContainerNotFoundException(statusCode, responseBody);
}
};
- internal static readonly ApiResponseErrorHandlingDelegate NoSuchImageHandler = (statusCode, responseBody) =>
+
+ private static readonly ApiResponseErrorHandlingDelegate NoSuchImageHandler = (statusCode, responseBody) =>
{
if (statusCode == HttpStatusCode.NotFound)
{
@@ -43,8 +43,7 @@ internal ContainerOperations(DockerClient client)
}
IQueryString queryParameters = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "containers/json", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "containers/json", queryParameters, cancellationToken).ConfigureAwait(false);
}
public async Task CreateContainerAsync(CreateContainerParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -61,9 +60,8 @@ internal ContainerOperations(DockerClient client)
qs = new QueryString(parameters);
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Post, "containers/create", qs, data, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Post, "containers/create", qs, data, cancellationToken).ConfigureAwait(false);
}
public async Task InspectContainerAsync(string id, CancellationToken cancellationToken = default(CancellationToken))
@@ -73,8 +71,7 @@ internal ContainerOperations(DockerClient client)
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/json", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/json", cancellationToken).ConfigureAwait(false);
}
public async Task ListProcessesAsync(string id, ContainerListProcessesParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -90,8 +87,7 @@ internal ContainerOperations(DockerClient client)
}
IQueryString queryParameters = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/top", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/top", queryParameters, cancellationToken).ConfigureAwait(false);
}
public Task GetContainerLogsAsync(string id, ContainerLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -145,8 +141,7 @@ public Task GetContainerLogsAsync(string id, ContainerLogsParameters parameters,
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/changes", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/changes", cancellationToken).ConfigureAwait(false);
}
public Task ExportContainerAsync(string id, CancellationToken cancellationToken)
@@ -207,9 +202,10 @@ public Task GetContainerStatsAsync(string id, ContainerStatsParameters p
throw new ArgumentNullException(nameof(id));
}
- var queryParams = parameters == null ? null : new QueryString(parameters);
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/start", queryParams, cancellationToken).ConfigureAwait(false);
- return response.StatusCode != HttpStatusCode.NotModified;
+ var queryParameters = parameters == null ? null : new QueryString(parameters);
+ bool? result = null;
+ await _client.MakeRequestAsync(new[] { NoSuchContainerHandler, (statusCode, _) => result = statusCode != HttpStatusCode.NotModified }, HttpMethod.Post, $"containers/{id}/start", queryParameters, cancellationToken).ConfigureAwait(false);
+ return result ?? throw new InvalidOperationException();
}
public async Task StopContainerAsync(string id, ContainerStopParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -224,11 +220,12 @@ public Task GetContainerStatsAsync(string id, ContainerStatsParameters p
throw new ArgumentNullException(nameof(parameters));
}
- IQueryString queryParameters = new QueryString(parameters);
+ var queryParameters = new QueryString(parameters);
// since specified wait timespan can be greater than HttpClient's default, we set the
// client timeout to infinite and provide a cancellation token.
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/stop", queryParameters, null, null, TimeSpan.FromMilliseconds(Timeout.Infinite), cancellationToken).ConfigureAwait(false);
- return response.StatusCode != HttpStatusCode.NotModified;
+ bool? result = null;
+ await _client.MakeRequestAsync(new[] { NoSuchContainerHandler, (statusCode, _) => result = statusCode != HttpStatusCode.NotModified }, HttpMethod.Post, $"containers/{id}/stop", queryParameters, null, null, TimeSpan.FromMilliseconds(Timeout.Infinite), cancellationToken).ConfigureAwait(false);
+ return result ?? throw new InvalidOperationException();
}
public Task RestartContainerAsync(string id, ContainerRestartParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -327,8 +324,7 @@ public Task RenameContainerAsync(string id, ContainerRenameParameters parameters
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/wait", null, null, null, TimeSpan.FromMilliseconds(Timeout.Infinite), cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/wait", null, null, null, TimeSpan.FromMilliseconds(Timeout.Infinite), cancellationToken).ConfigureAwait(false);
}
public Task RemoveContainerAsync(string id, ContainerRemoveParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -367,9 +363,7 @@ public Task RenameContainerAsync(string id, ContainerRenameParameters parameters
var bytes = Convert.FromBase64String(statHeader);
- var stat = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
-
- var pathStat = _client.JsonSerializer.DeserializeObject(stat);
+ var pathStat = DockerClient.JsonSerializer.Deserialize(bytes);
return new GetArchiveFromContainerResponse
{
@@ -399,8 +393,7 @@ public Task RenameContainerAsync(string id, ContainerRenameParameters parameters
public async Task PruneContainersAsync(ContainersPruneParameters parameters, CancellationToken cancellationToken)
{
var queryParameters = parameters == null ? null : new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "containers/prune", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "containers/prune", queryParameters, cancellationToken).ConfigureAwait(false);
}
public async Task UpdateContainerAsync(string id, ContainerUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -415,9 +408,8 @@ public async Task PruneContainersAsync(ContainersPruneP
throw new ArgumentNullException(nameof(parameters));
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/update", null, data, cancellationToken);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/update", null, data, cancellationToken);
}
}
}
\ No newline at end of file
diff --git a/src/Docker.DotNet/Endpoints/ExecOperations.cs b/src/Docker.DotNet/Endpoints/ExecOperations.cs
index 27c695989..1708c6057 100644
--- a/src/Docker.DotNet/Endpoints/ExecOperations.cs
+++ b/src/Docker.DotNet/Endpoints/ExecOperations.cs
@@ -36,9 +36,8 @@ internal ExecOperations(DockerClient client)
throw new ArgumentNullException(nameof(parameters));
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/exec", null, data, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/exec", null, data, cancellationToken).ConfigureAwait(false);
}
public async Task InspectContainerExecAsync(string id, CancellationToken cancellationToken)
@@ -48,8 +47,7 @@ public async Task InspectContainerExecAsync(string
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"exec/{id}/json", null, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"exec/{id}/json", null, cancellationToken).ConfigureAwait(false);
}
public Task ResizeContainerExecTtyAsync(string id, ContainerResizeParameters parameters, CancellationToken cancellationToken)
@@ -81,7 +79,7 @@ public Task StartContainerExecAsync(string id, CancellationToken cancellationTok
{
Detach = true,
};
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
return _client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"exec/{id}/start", null, data, cancellationToken);
}
@@ -99,7 +97,7 @@ public async Task StartWithConfigContainerExecAsync(string id
throw new ArgumentNullException(nameof(id));
}
- var data = new JsonRequestContent(eConfig, _client.JsonSerializer);
+ var data = new JsonRequestContent(eConfig, DockerClient.JsonSerializer);
var stream = await _client.MakeRequestForHijackedStreamAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"exec/{id}/start", null, data, null, cancellationToken).ConfigureAwait(false);
if (!stream.CanCloseWrite)
{
@@ -110,4 +108,4 @@ public async Task StartWithConfigContainerExecAsync(string id
return new MultiplexedStream(stream, !eConfig.Tty);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Docker.DotNet/Endpoints/ImageOperations.cs b/src/Docker.DotNet/Endpoints/ImageOperations.cs
index a33df2def..1a965c48d 100644
--- a/src/Docker.DotNet/Endpoints/ImageOperations.cs
+++ b/src/Docker.DotNet/Endpoints/ImageOperations.cs
@@ -5,7 +5,6 @@
using System.Linq;
using System.Net;
using System.Net.Http;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -41,8 +40,7 @@ internal ImageOperations(DockerClient client)
}
IQueryString queryParameters = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "images/json", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "images/json", queryParameters, cancellationToken).ConfigureAwait(false);
}
public Task BuildImageFromDockerfileAsync(Stream contents, ImageBuildParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -140,7 +138,7 @@ public Task BuildImageFromDockerfileAsync(ImageBuildParameters parameters, Strea
if(headers != null)
{
- foreach(string key in headers.Keys)
+ foreach(var key in headers.Keys)
{
customHeaders[key] = headers[key];
}
@@ -161,8 +159,7 @@ public Task BuildImageFromDockerfileAsync(ImageBuildParameters parameters, Strea
throw new ArgumentNullException(nameof(name));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Get, $"images/{name}/json", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Get, $"images/{name}/json", cancellationToken).ConfigureAwait(false);
}
public async Task> GetImageHistoryAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
@@ -172,8 +169,7 @@ public Task BuildImageFromDockerfileAsync(ImageBuildParameters parameters, Strea
throw new ArgumentNullException(nameof(name));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Get, $"images/{name}/history", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Get, $"images/{name}/history", cancellationToken).ConfigureAwait(false);
}
public Task PushImageAsync(string name, ImagePushParameters parameters, AuthConfig authConfig, IProgress progress, CancellationToken cancellationToken = default(CancellationToken))
@@ -225,8 +221,7 @@ public Task BuildImageFromDockerfileAsync(ImageBuildParameters parameters, Strea
}
IQueryString queryParameters = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(new[] { NoSuchImageHandler }, HttpMethod.Delete, $"images/{name}", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject[]>(response.Body);
+ return await _client.MakeRequestAsync[]>(new[] { NoSuchImageHandler }, HttpMethod.Delete, $"images/{name}", queryParameters, cancellationToken).ConfigureAwait(false);
}
public async Task> SearchImagesAsync(ImagesSearchParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -237,15 +232,13 @@ public Task BuildImageFromDockerfileAsync(ImageBuildParameters parameters, Strea
}
IQueryString queryParameters = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "images/search", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "images/search", queryParameters, cancellationToken).ConfigureAwait(false);
}
public async Task PruneImagesAsync(ImagesPruneParameters parameters, CancellationToken cancellationToken)
{
var queryParameters = parameters == null ? null : new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "images/prune", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "images/prune", queryParameters, cancellationToken).ConfigureAwait(false);
}
public async Task CommitContainerChangesAsync(CommitContainerChangesParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -255,11 +248,10 @@ public async Task PruneImagesAsync(ImagesPruneParameters pa
throw new ArgumentNullException(nameof(parameters));
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
IQueryString queryParameters = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "commit", queryParameters, data, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "commit", queryParameters, data, cancellationToken).ConfigureAwait(false);
}
public Task SaveImageAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
@@ -307,12 +299,10 @@ private Dictionary RegistryAuthHeaders(AuthConfig authConfig)
{
{
RegistryAuthHeaderKey,
- Convert.ToBase64String(
- Encoding.UTF8.GetBytes(
- _client.JsonSerializer.SerializeObject(authConfig ?? new AuthConfig())))
- .Replace("/", "_").Replace("+", "-")
+ Convert.ToBase64String(DockerClient.JsonSerializer.SerializeToUtf8Bytes(authConfig ?? new AuthConfig()))
+ .Replace("/", "_").Replace("+", "-")
// This is not documented in Docker API but from source code (https://github.com/docker/docker-ce/blob/10e40bd1548f69354a803a15fde1b672cc024b91/components/cli/cli/command/registry.go#L47)
- // and from multiple internet sources it has to be base64-url-safe.
+ // and from multiple internet sources it has to be base64-url-safe.
// See RFC 4648 Section 5. Padding (=) needs to be kept.
}
};
@@ -320,12 +310,12 @@ private Dictionary RegistryAuthHeaders(AuthConfig authConfig)
private Dictionary RegistryConfigHeaders(IEnumerable authConfig)
{
- var configDictionary = (authConfig ?? new AuthConfig[0]).ToDictionary(e => e.ServerAddress, e => e);
+ var configDictionary = (authConfig ?? Array.Empty()).ToDictionary(e => e.ServerAddress, e => e);
return new Dictionary
{
{
RegistryConfigHeaderKey,
- Convert.ToBase64String(Encoding.UTF8.GetBytes(_client.JsonSerializer.SerializeObject(configDictionary)))
+ Convert.ToBase64String(DockerClient.JsonSerializer.SerializeToUtf8Bytes(configDictionary))
}
};
}
diff --git a/src/Docker.DotNet/Endpoints/NetworkOperations.cs b/src/Docker.DotNet/Endpoints/NetworkOperations.cs
index 3271c636c..aee91d2f0 100644
--- a/src/Docker.DotNet/Endpoints/NetworkOperations.cs
+++ b/src/Docker.DotNet/Endpoints/NetworkOperations.cs
@@ -29,8 +29,7 @@ internal NetworkOperations(DockerClient client)
async Task> INetworkOperations.ListNetworksAsync(NetworksListParameters parameters, CancellationToken cancellationToken)
{
var queryParameters = parameters == null ? null : new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "networks", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "networks", queryParameters, cancellationToken).ConfigureAwait(false);
}
async Task INetworkOperations.InspectNetworkAsync(string id, CancellationToken cancellationToken)
@@ -40,8 +39,7 @@ async Task INetworkOperations.InspectNetworkAsync(string id, Ca
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchNetworkHandler }, HttpMethod.Get, $"networks/{id}", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchNetworkHandler }, HttpMethod.Get, $"networks/{id}", cancellationToken).ConfigureAwait(false);
}
Task INetworkOperations.DeleteNetworkAsync(string id, CancellationToken cancellationToken)
@@ -61,9 +59,8 @@ async Task INetworkOperations.CreateNetworkAsync(Network
throw new ArgumentNullException(nameof(parameters));
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "networks/create", null, data, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "networks/create", null, data, cancellationToken).ConfigureAwait(false);
}
Task INetworkOperations.ConnectNetworkAsync(string id, NetworkConnectParameters parameters, CancellationToken cancellationToken)
@@ -78,7 +75,7 @@ Task INetworkOperations.ConnectNetworkAsync(string id, NetworkConnectParameters
throw new ArgumentNullException(nameof(parameters));
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
return _client.MakeRequestAsync(new[] { NoSuchNetworkHandler }, HttpMethod.Post, $"networks/{id}/connect", null, data, cancellationToken);
}
@@ -94,7 +91,7 @@ Task INetworkOperations.DisconnectNetworkAsync(string id, NetworkDisconnectParam
throw new ArgumentNullException(nameof(parameters));
}
- var data = new JsonRequestContent(parameters, _client.JsonSerializer);
+ var data = new JsonRequestContent(parameters, DockerClient.JsonSerializer);
return _client.MakeRequestAsync(new[] { NoSuchNetworkHandler }, HttpMethod.Post, $"networks/{id}/disconnect", null, data, cancellationToken);
}
@@ -106,8 +103,7 @@ Task INetworkOperations.DeleteUnusedNetworksAsync(NetworksDeleteUnusedParameters
async Task INetworkOperations.PruneNetworksAsync(NetworksDeleteUnusedParameters parameters, CancellationToken cancellationToken)
{
var queryParameters = parameters == null ? null : new QueryString(parameters);
- var response = await _client.MakeRequestAsync(null, HttpMethod.Post, "networks/prune", queryParameters, cancellationToken);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(null, HttpMethod.Post, "networks/prune", queryParameters, cancellationToken);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Docker.DotNet/Endpoints/PluginOperations.cs b/src/Docker.DotNet/Endpoints/PluginOperations.cs
index 472c302a9..38ae57c0c 100644
--- a/src/Docker.DotNet/Endpoints/PluginOperations.cs
+++ b/src/Docker.DotNet/Endpoints/PluginOperations.cs
@@ -30,8 +30,7 @@ internal PluginOperations(DockerClient client)
public async Task> ListPluginsAsync(PluginListParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
{
IQueryString queryParameters = parameters == null ? null : new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "plugins", queryParameters, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "plugins", queryParameters, cancellationToken).ConfigureAwait(false);
}
public async Task> GetPluginPrivilegesAsync(PluginGetPrivilegeParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -42,8 +41,7 @@ internal PluginOperations(DockerClient client)
}
var query = new QueryString(parameters);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "plugins/privileges", query, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "plugins/privileges", query, cancellationToken).ConfigureAwait(false);
}
public Task InstallPluginAsync(PluginInstallParameters parameters, IProgress progress, CancellationToken cancellationToken = default(CancellationToken))
@@ -58,11 +56,11 @@ internal PluginOperations(DockerClient client)
throw new ArgumentNullException(nameof(parameters.Privileges));
}
- var data = new JsonRequestContent>(parameters.Privileges, _client.JsonSerializer);
+ var data = new JsonRequestContent>(parameters.Privileges, DockerClient.JsonSerializer);
IQueryString queryParameters = new QueryString(parameters);
return StreamUtil.MonitorStreamForMessagesAsync(
- _client.MakeRequestForStreamAsync(_client.NoErrorHandlers, HttpMethod.Post, "plugins/pull", queryParameters, data, null, CancellationToken.None),
+ _client.MakeRequestForStreamAsync(_client.NoErrorHandlers, HttpMethod.Post, $"plugins/pull", queryParameters, data, null, CancellationToken.None),
_client,
cancellationToken,
progress);
@@ -75,8 +73,7 @@ public async Task InspectPluginAsync(string name, CancellationToken canc
throw new ArgumentNullException(nameof(name));
}
- var response = await _client.MakeRequestAsync(new[] { NoSuchPluginHandler }, HttpMethod.Get, $"plugins/{name}/json", cancellationToken);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { NoSuchPluginHandler }, HttpMethod.Get, $"plugins/{name}/json", cancellationToken);
}
public Task RemovePluginAsync(string name, PluginRemoveParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -130,7 +127,7 @@ public async Task InspectPluginAsync(string name, CancellationToken canc
}
var query = new QueryString(parameters);
- var data = new JsonRequestContent>(parameters.Privileges, _client.JsonSerializer);
+ var data = new JsonRequestContent>(parameters.Privileges, DockerClient.JsonSerializer);
return _client.MakeRequestAsync(new[] { NoSuchPluginHandler }, HttpMethod.Post, $"plugins/{name}/upgrade", query, data, cancellationToken);
}
@@ -148,7 +145,7 @@ public async Task InspectPluginAsync(string name, CancellationToken canc
var query = new QueryString(parameters);
var data = new BinaryRequestContent(plugin, TarContentType);
- return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "plugins/create", query, data, cancellationToken);
+ return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, $"plugins/create", query, data, cancellationToken);
}
public Task PushPluginAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
@@ -178,8 +175,8 @@ public async Task InspectPluginAsync(string name, CancellationToken canc
throw new ArgumentNullException(nameof(parameters.Args));
}
- var body = new JsonRequestContent>(parameters.Args, _client.JsonSerializer);
+ var body = new JsonRequestContent>(parameters.Args, DockerClient.JsonSerializer);
return _client.MakeRequestAsync(new[] { NoSuchPluginHandler }, HttpMethod.Post, $"plugins/{name}/set", null, body, cancellationToken);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Docker.DotNet/Endpoints/SecretsOperations.cs b/src/Docker.DotNet/Endpoints/SecretsOperations.cs
index 3c61a00cc..3145b52e0 100644
--- a/src/Docker.DotNet/Endpoints/SecretsOperations.cs
+++ b/src/Docker.DotNet/Endpoints/SecretsOperations.cs
@@ -18,8 +18,7 @@ internal SecretsOperations(DockerClient client)
async Task> ISecretsOperations.ListAsync(CancellationToken cancellationToken)
{
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "secrets", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject>(response.Body);
+ return await _client.MakeRequestAsync>(_client.NoErrorHandlers, HttpMethod.Get, "secrets", cancellationToken).ConfigureAwait(false);
}
async Task ISecretsOperations.CreateAsync(SecretSpec body, CancellationToken cancellationToken)
@@ -29,9 +28,8 @@ async Task ISecretsOperations.CreateAsync(SecretSpec body,
throw new ArgumentNullException(nameof(body));
}
- var data = new JsonRequestContent(body, _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "secrets/create", null, data, cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(body, DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "secrets/create", null, data, cancellationToken).ConfigureAwait(false);
}
async Task ISecretsOperations.InspectAsync(string id, CancellationToken cancellationToken)
@@ -41,8 +39,7 @@ async Task ISecretsOperations.InspectAsync(string id, CancellationToken
throw new ArgumentNullException(nameof(id));
}
- var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, $"secrets/{id}", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, $"secrets/{id}", cancellationToken).ConfigureAwait(false);
}
Task ISecretsOperations.DeleteAsync(string id, CancellationToken cancellationToken)
diff --git a/src/Docker.DotNet/Endpoints/StreamUtil.cs b/src/Docker.DotNet/Endpoints/StreamUtil.cs
index 92ea822e8..dbe9f2af9 100644
--- a/src/Docker.DotNet/Endpoints/StreamUtil.cs
+++ b/src/Docker.DotNet/Endpoints/StreamUtil.cs
@@ -4,7 +4,6 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Newtonsoft.Json;
namespace Docker.DotNet.Models
{
@@ -28,16 +27,10 @@ internal static async Task MonitorStreamAsync(Task streamTask, DockerCli
internal static async Task MonitorStreamForMessagesAsync(Task streamTask, DockerClient client, CancellationToken cancellationToken, IProgress progress)
{
- var tcs = new TaskCompletionSource();
-
using (var stream = await streamTask)
- using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
- using (var jsonReader = new JsonTextReader(reader) { SupportMultipleContent = true })
- using (cancellationToken.Register(() => tcs.TrySetCanceled(cancellationToken)))
{
- while (await await Task.WhenAny(jsonReader.ReadAsync(cancellationToken), tcs.Task))
+ await foreach (var ev in DockerClient.JsonSerializer.DeserializeAsync(stream, cancellationToken))
{
- var ev = await client.JsonSerializer.Deserialize(jsonReader, cancellationToken);
progress.Report(ev);
}
}
diff --git a/src/Docker.DotNet/Endpoints/SwarmOperations.cs b/src/Docker.DotNet/Endpoints/SwarmOperations.cs
index e6215df37..a511708db 100644
--- a/src/Docker.DotNet/Endpoints/SwarmOperations.cs
+++ b/src/Docker.DotNet/Endpoints/SwarmOperations.cs
@@ -4,7 +4,6 @@ namespace Docker.DotNet
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
- using System.Text;
using System.Threading.Tasks;
using System.Threading;
using Models;
@@ -32,21 +31,19 @@ async Task ISwarmOperations.CreateServiceAsync(ServiceCre
{
if (parameters == null) throw new ArgumentNullException(nameof(parameters));
- var data = new JsonRequestContent(parameters.Service ?? throw new ArgumentNullException(nameof(parameters.Service)), _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, "services/create", null, data, RegistryAuthHeaders(parameters.RegistryAuth), cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var data = new JsonRequestContent(parameters.Service ?? throw new ArgumentNullException(nameof(parameters.Service)), DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, "services/create", null, data, RegistryAuthHeaders(parameters.RegistryAuth), cancellationToken).ConfigureAwait(false);
}
async Task ISwarmOperations.GetSwarmUnlockKeyAsync(CancellationToken cancellationToken)
{
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "swarm/unlockkey", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "swarm/unlockkey", cancellationToken).ConfigureAwait(false);
}
async Task ISwarmOperations.InitSwarmAsync(SwarmInitParameters parameters, CancellationToken cancellationToken)
{
- var data = new JsonRequestContent(parameters ?? throw new ArgumentNullException(nameof(parameters)), _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(
+ var data = new JsonRequestContent(parameters ?? throw new ArgumentNullException(nameof(parameters)), DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(
new ApiResponseErrorHandlingDelegate[]
{
(statusCode, responseBody) =>
@@ -63,27 +60,23 @@ async Task ISwarmOperations.InitSwarmAsync(SwarmInitParameters parameter
null,
data,
cancellationToken).ConfigureAwait(false);
-
- return response.Body;
}
async Task ISwarmOperations.InspectServiceAsync(string id, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(id)) throw new ArgumentNullException(nameof(id));
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, $"services/{id}", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, $"services/{id}", cancellationToken).ConfigureAwait(false);
}
async Task ISwarmOperations.InspectSwarmAsync(CancellationToken cancellationToken)
{
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "swarm", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "swarm", cancellationToken).ConfigureAwait(false);
}
async Task ISwarmOperations.JoinSwarmAsync(SwarmJoinParameters parameters, CancellationToken cancellationToken)
{
- var data = new JsonRequestContent(parameters ?? throw new ArgumentNullException(nameof(parameters)), _client.JsonSerializer);
+ var data = new JsonRequestContent(parameters ?? throw new ArgumentNullException(nameof(parameters)), DockerClient.JsonSerializer);
await _client.MakeRequestAsync(
new ApiResponseErrorHandlingDelegate[]
{
@@ -127,10 +120,9 @@ await _client.MakeRequestAsync(
async Task> ISwarmOperations.ListServicesAsync(ServiceListParameters parameters, CancellationToken cancellationToken)
{
var queryParameters = parameters != null ? new QueryString(parameters) : null;
- var response = await _client
- .MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "services", queryParameters, cancellationToken)
+ return await _client
+ .MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "services", queryParameters, cancellationToken)
.ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
}
async Task ISwarmOperations.RemoveServiceAsync(string id, CancellationToken cancellationToken)
@@ -142,7 +134,7 @@ async Task ISwarmOperations.RemoveServiceAsync(string id, CancellationToken canc
async Task ISwarmOperations.UnlockSwarmAsync(SwarmUnlockParameters parameters, CancellationToken cancellationToken)
{
- var body = new JsonRequestContent(parameters ?? throw new ArgumentNullException(nameof(parameters)), _client.JsonSerializer);
+ var body = new JsonRequestContent(parameters ?? throw new ArgumentNullException(nameof(parameters)), DockerClient.JsonSerializer);
await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, "swarm/unlock", null, body, cancellationToken).ConfigureAwait(false);
}
@@ -152,9 +144,8 @@ async Task ISwarmOperations.UpdateServiceAsync(string id,
if (parameters == null) throw new ArgumentNullException(nameof(parameters));
var query = new QueryString(parameters);
- var body = new JsonRequestContent(parameters.Service ?? throw new ArgumentNullException(nameof(parameters.Service)), _client.JsonSerializer);
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, $"services/{id}/update", query, body, RegistryAuthHeaders(parameters.RegistryAuth), cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ var body = new JsonRequestContent(parameters.Service ?? throw new ArgumentNullException(nameof(parameters.Service)), DockerClient.JsonSerializer);
+ return await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, $"services/{id}/update", query, body, RegistryAuthHeaders(parameters.RegistryAuth), cancellationToken).ConfigureAwait(false);
}
public Task GetServiceLogsAsync(string id, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
@@ -195,7 +186,7 @@ async Task ISwarmOperations.UpdateServiceAsync(string id,
async Task ISwarmOperations.UpdateSwarmAsync(SwarmUpdateParameters parameters, CancellationToken cancellationToken)
{
var query = new QueryString(parameters ?? throw new ArgumentNullException(nameof(parameters)));
- var body = new JsonRequestContent(parameters.Spec ?? throw new ArgumentNullException(nameof(parameters.Spec)), _client.JsonSerializer);
+ var body = new JsonRequestContent(parameters.Spec ?? throw new ArgumentNullException(nameof(parameters.Spec)), DockerClient.JsonSerializer);
await _client.MakeRequestAsync(
new ApiResponseErrorHandlingDelegate[]
{
@@ -226,22 +217,20 @@ private IDictionary RegistryAuthHeaders(AuthConfig authConfig)
{
{
"X-Registry-Auth",
- Convert.ToBase64String(Encoding.UTF8.GetBytes(_client.JsonSerializer.SerializeObject(authConfig)))
+ Convert.ToBase64String(DockerClient.JsonSerializer.SerializeToUtf8Bytes(authConfig))
}
};
}
async Task> ISwarmOperations.ListNodesAsync(CancellationToken cancellationToken)
{
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "nodes", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject(response.Body);
+ return await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, "nodes", cancellationToken).ConfigureAwait(false);
}
async Task ISwarmOperations.InspectNodeAsync(string id, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(id)) throw new ArgumentNullException(nameof(id));
- var response = await _client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, $"nodes/{id}", cancellationToken).ConfigureAwait(false);
- return _client.JsonSerializer.DeserializeObject