-
Notifications
You must be signed in to change notification settings - Fork 404
Add client support for Swarm Logs and Swarm Config #589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
90d94a1
6fc666c
bcf12b1
7a40f49
bb3212d
12aec2f
6dd30fc
b04f266
7c0e19e
91af57f
532f4e6
e6b3993
4f75b71
4a7cdf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| # Autodetect text files | ||
| * text=auto | ||
|
|
||
| # Definitively text files | ||
| *.cs text |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Net.Http; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Docker.DotNet.Models; | ||
|
|
||
| namespace Docker.DotNet | ||
| { | ||
| internal class ConfigsOperations : IConfigsOperations | ||
|
||
| { | ||
| private readonly DockerClient _client; | ||
|
|
||
| internal ConfigsOperations(DockerClient client) | ||
| { | ||
| this._client = client; | ||
| } | ||
|
|
||
| async Task<IList<SwarmConfig>> IConfigsOperations.ListConfigAsync(CancellationToken cancellationToken) | ||
| { | ||
| var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken).ConfigureAwait(false); | ||
| return this._client.JsonSerializer.DeserializeObject<IList<SwarmConfig>>(response.Body); | ||
| } | ||
|
|
||
| async Task<SwarmCreateConfigResponse> IConfigsOperations.CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken) | ||
| { | ||
| if (body == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(body)); | ||
| } | ||
|
|
||
| var data = new JsonRequestContent<SwarmConfigSpec>(body.Config, this._client.JsonSerializer); | ||
| var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken).ConfigureAwait(false); | ||
| return this._client.JsonSerializer.DeserializeObject<SwarmCreateConfigResponse>(response.Body); | ||
| } | ||
|
|
||
| async Task<SwarmConfig> IConfigsOperations.InspectConfigAsync(string id, CancellationToken cancellationToken) | ||
| { | ||
| if (string.IsNullOrEmpty(id)) | ||
| { | ||
| throw new ArgumentNullException(nameof(id)); | ||
| } | ||
|
|
||
| var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken).ConfigureAwait(false); | ||
| return this._client.JsonSerializer.DeserializeObject<SwarmConfig>(response.Body); | ||
| } | ||
|
|
||
| Task IConfigsOperations.RemoveConfigAsync(string id, CancellationToken cancellationToken) | ||
| { | ||
| if (string.IsNullOrEmpty(id)) | ||
| { | ||
| throw new ArgumentNullException(nameof(id)); | ||
| } | ||
|
|
||
| return this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Delete, $"configs/{id}", cancellationToken); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using System.Collections.Generic; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Docker.DotNet.Models; | ||
|
|
||
| namespace Docker.DotNet | ||
| { | ||
| public interface IConfigsOperations | ||
ACoderLife marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ACoderLife marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| /// <summary> | ||
| /// List configs | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// 200 - No error. | ||
| /// 500 - Server error. | ||
| /// </remarks> | ||
| Task<IList<SwarmConfig>> ListConfigAsync(CancellationToken cancellationToken = default(CancellationToken)); | ||
ACoderLife marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Create a configs | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// 201 - No error. | ||
| /// 406 - Server error or node is not part of a swarm. | ||
| /// 409 - Name conflicts with an existing object. | ||
| /// 500 - Server error. | ||
| /// </remarks> | ||
| Task<SwarmCreateConfigResponse> CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken = default(CancellationToken)); | ||
|
|
||
| /// <summary> | ||
| /// Inspect a configs | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// 200 - No error. | ||
| /// 404 - Secret not found. | ||
| /// 406 - Node is not part of a swarm. | ||
| /// 500 - Server error. | ||
| /// </remarks> | ||
| /// <param name="id">ID of the config.</param> | ||
| Task<SwarmConfig> InspectConfigAsync(string id, CancellationToken cancellationToken = default(CancellationToken)); | ||
|
|
||
| /// <summary> | ||
| /// Remove a configs | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// 204 - No error. | ||
| /// 404 - Secret not found. | ||
| /// 500 - Server error. | ||
| /// </remarks> | ||
| /// <param name="id">ID of the config.</param> | ||
| Task RemoveConfigAsync(string id, CancellationToken cancellationToken = default(CancellationToken)); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.