Skip to content
Merged
21 changes: 13 additions & 8 deletions src/Docker.DotNet/Endpoints/ConfigsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,44 @@ internal ConfigOperations(DockerClient client)
_client = client;
}

async Task<IList<SwarmConfig>> IConfigOperations.ListConfigsAsync(CancellationToken cancellationToken)
public async Task<IList<SwarmConfig>> ListConfigsAsync(CancellationToken cancellationToken = default)
{
return await _client.MakeRequestAsync<IList<SwarmConfig>>(_client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken).ConfigureAwait(false);
return await _client.MakeRequestAsync<IList<SwarmConfig>>(_client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken)
.ConfigureAwait(false);
}

async Task<SwarmCreateConfigResponse> IConfigOperations.CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken)
public async Task<SwarmCreateConfigResponse> CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken = default)
{
if (body == null)
{
throw new ArgumentNullException(nameof(body));
}

var data = new JsonRequestContent<SwarmConfigSpec>(body.Config, DockerClient.JsonSerializer);
return await _client.MakeRequestAsync<SwarmCreateConfigResponse>(_client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken).ConfigureAwait(false);

return await _client.MakeRequestAsync<SwarmCreateConfigResponse>(_client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken)
.ConfigureAwait(false);
}

async Task<SwarmConfig> IConfigOperations.InspectConfigAsync(string id, CancellationToken cancellationToken)
public async Task<SwarmConfig> InspectConfigAsync(string id, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));
}

return await _client.MakeRequestAsync<SwarmConfig>(_client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken).ConfigureAwait(false);
return await _client.MakeRequestAsync<SwarmConfig>(_client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken)
.ConfigureAwait(false);
}

Task IConfigOperations.RemoveConfigAsync(string id, CancellationToken cancellationToken)
public async Task RemoveConfigAsync(string id, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));
}

return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Delete, $"configs/{id}", cancellationToken);
await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Delete, $"configs/{id}", cancellationToken)
.ConfigureAwait(false);
}
}
137 changes: 86 additions & 51 deletions src/Docker.DotNet/Endpoints/ContainerOperations.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Docker.DotNet/Endpoints/ExecOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<ContainerExecInspectResponse> InspectContainerExecAsync(string
throw new ArgumentNullException(nameof(id));
}

return await _client.MakeRequestAsync<ContainerExecInspectResponse>([NoSuchContainerHandler], HttpMethod.Get, $"exec/{id}/json", null, cancellationToken)
return await _client.MakeRequestAsync<ContainerExecInspectResponse>([NoSuchContainerHandler], HttpMethod.Get, $"exec/{id}/json", cancellationToken)
.ConfigureAwait(false);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Docker.DotNet/Endpoints/IConfigsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IConfigOperations
/// 200 - No error.
/// 500 - Server error.
/// </remarks>
Task<IList<SwarmConfig>> ListConfigsAsync(CancellationToken cancellationToken = default(CancellationToken));
Task<IList<SwarmConfig>> ListConfigsAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Create a configs
Expand All @@ -20,7 +20,7 @@ public interface IConfigOperations
/// 409 - Name conflicts with an existing object.
/// 500 - Server error.
/// </remarks>
Task<SwarmCreateConfigResponse> CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken = default(CancellationToken));
Task<SwarmCreateConfigResponse> CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken = default);

/// <summary>
/// Inspect a configs
Expand All @@ -32,7 +32,7 @@ public interface IConfigOperations
/// 500 - Server error.
/// </remarks>
/// <param name="id">ID of the config.</param>
Task<SwarmConfig> InspectConfigAsync(string id, CancellationToken cancellationToken = default(CancellationToken));
Task<SwarmConfig> InspectConfigAsync(string id, CancellationToken cancellationToken = default);

/// <summary>
/// Remove a configs
Expand All @@ -43,5 +43,5 @@ public interface IConfigOperations
/// 500 - Server error.
/// </remarks>
/// <param name="id">ID of the config.</param>
Task RemoveConfigAsync(string id, CancellationToken cancellationToken = default(CancellationToken));
Task RemoveConfigAsync(string id, CancellationToken cancellationToken = default);
}
10 changes: 5 additions & 5 deletions src/Docker.DotNet/Endpoints/IContainerOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public interface IContainerOperations
/// <exception cref="ArgumentNullException">One or more of the inputs was <see langword="null"/>.</exception>
/// <exception cref="DockerApiException">The input is invalid or the daemon experienced an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
[Obsolete("Use 'Task GetContainerStatsAsync(string id, ContainerStatsParameters parameters, CancellationToken cancellationToken, IProgress<JSONMessage> progress)'")]
Task<Stream> GetContainerStatsAsync(string id, ContainerStatsParameters parameters, CancellationToken cancellationToken);
[Obsolete("Use 'Task GetContainerStatsAsync(string id, ContainerStatsParameters parameters, IProgress<ContainerStatsResponse> progress, CancellationToken cancellationToken)'")]
Task<Stream> GetContainerStatsAsync(string id, ContainerStatsParameters parameters, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieves a live, raw stream of the container's resource usage statistics.
Expand Down Expand Up @@ -196,7 +196,7 @@ public interface IContainerOperations
/// <exception cref="ArgumentNullException">One or more of the inputs was <see langword="null"/>.</exception>
/// <exception cref="DockerApiException">The input is invalid or the daemon experienced an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
Task<bool> StartContainerAsync(string id, ContainerStartParameters parameters, CancellationToken cancellationToken = default);
Task<bool> StartContainerAsync(string id, ContainerStartParameters? parameters = null, CancellationToken cancellationToken = default);

/// <summary>
/// Stops a container.
Expand Down Expand Up @@ -257,7 +257,7 @@ public interface IContainerOperations
/// <exception cref="ArgumentNullException">One or more of the inputs was <see langword="null"/>.</exception>
/// <exception cref="DockerApiException">The name is already in use, the input is invalid, or the daemon experienced an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
Task RenameContainerAsync(string id, ContainerRenameParameters parameters, CancellationToken cancellationToken);
Task RenameContainerAsync(string id, ContainerRenameParameters parameters, CancellationToken cancellationToken = default);

/// <summary>
/// Suspends a container.
Expand Down Expand Up @@ -381,7 +381,7 @@ public interface IContainerOperations
/// <exception cref="ArgumentNullException">One or more of the inputs was <see langword="null"/>.</exception>
/// <exception cref="DockerApiException">The input is invalid or the daemon experienced an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
Task<ContainersPruneResponse> PruneContainersAsync(ContainersPruneParameters parameters = null, CancellationToken cancellationToken = default);
Task<ContainersPruneResponse> PruneContainersAsync(ContainersPruneParameters? parameters = null, CancellationToken cancellationToken = default);

/// <summary>
/// Changes configuration options of a container without recreating it.
Expand Down
Loading
Loading