Skip to content

Commit 9205c78

Browse files
author
timt
committed
Updated docker go types dependency version; Added service logs type; Added service logs endpoint
1 parent a5ee061 commit 9205c78

15 files changed

+139
-95
lines changed

src/Docker.DotNet/Endpoints/ISwarmOperations.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading.Tasks;
33
using Docker.DotNet.Models;
44
using System.Threading;
5+
using System.IO;
56

67
namespace Docker.DotNet
78
{
@@ -154,6 +155,26 @@ public interface ISwarmOperations
154155
/// <param name="id">ID or name of service.</param>
155156
Task RemoveServiceAsync(string id, CancellationToken cancellationToken = default(CancellationToken));
156157

158+
/// <summary>
159+
/// Get service logs.
160+
///
161+
/// Get {stdout} and {stderr} logs from a container.
162+
/// Note: This endpoint works only for services with the {json-file} or {journald} logging driver.
163+
/// </summary>
164+
/// <remarks>
165+
/// docker service logs
166+
///
167+
/// HTTP GET /services/(id)/logs
168+
///
169+
/// 101 - Logs returned as a stream.
170+
/// 200 - Logs returned as a string in response body.
171+
/// 404 - No such service.
172+
/// 500 - Server error.
173+
/// 503 - Node is not part of a swarm.
174+
/// </remarks>
175+
/// <param name="id">ID or name of the service.</param>
176+
Task<Stream> GetServiceLogsAsync(string id, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken));
177+
157178
#endregion Services
158179

159180
#region Nodes
@@ -207,4 +228,4 @@ public interface ISwarmOperations
207228

208229
#endregion
209230
}
210-
}
231+
}

src/Docker.DotNet/Endpoints/SwarmOperations.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Docker.DotNet
88
using System.Threading.Tasks;
99
using System.Threading;
1010
using Models;
11+
using System.IO;
1112

1213
internal class SwarmOperations : ISwarmOperations
1314
{
@@ -156,6 +157,22 @@ async Task<ServiceUpdateResponse> ISwarmOperations.UpdateServiceAsync(string id,
156157
return this._client.JsonSerializer.DeserializeObject<ServiceUpdateResponse>(response.Body);
157158
}
158159

160+
public Task<Stream> GetServiceLogsAsync(string id, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
161+
{
162+
if (string.IsNullOrEmpty(id))
163+
{
164+
throw new ArgumentNullException(nameof(id));
165+
}
166+
167+
if (parameters == null)
168+
{
169+
throw new ArgumentNullException(nameof(parameters));
170+
}
171+
172+
IQueryString queryParameters = new QueryString<ServiceLogsParameters>(parameters);
173+
return this._client.MakeRequestForStreamAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, $"services/{id}/logs", queryParameters, cancellationToken);
174+
}
175+
159176
async Task ISwarmOperations.UpdateSwarmAsync(SwarmUpdateParameters parameters, CancellationToken cancellationToken)
160177
{
161178
var query = new QueryString<SwarmUpdateParameters>(parameters ?? throw new ArgumentNullException(nameof(parameters)));

src/Docker.DotNet/JsonSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using Newtonsoft.Json.Converters;
33

44
namespace Docker.DotNet
@@ -35,4 +35,4 @@ public string SerializeObject<T>(T value)
3535
return JsonConvert.SerializeObject(value, this._settings);
3636
}
3737
}
38-
}
38+
}

src/Docker.DotNet/Models/ContainerExecInspectResponse.Generated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Docker.DotNet.Models
55
[DataContract]
66
public class ContainerExecInspectResponse // (types.ContainerExecInspect)
77
{
8-
[DataMember(Name = "ExecID", EmitDefaultValue = false)]
8+
[DataMember(Name = "ID", EmitDefaultValue = false)]
99
public string ExecID { get; set; }
1010

1111
[DataMember(Name = "ContainerID", EmitDefaultValue = false)]

src/Docker.DotNet/Models/ContainerSpec.Generated.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,5 @@ public class ContainerSpec // (swarm.ContainerSpec)
7777

7878
[DataMember(Name = "Sysctls", EmitDefaultValue = false)]
7979
public IDictionary<string, string> Sysctls { get; set; }
80-
81-
[DataMember(Name = "Capabilities", EmitDefaultValue = false)]
82-
public IList<string> Capabilities { get; set; }
8380
}
8481
}

src/Docker.DotNet/Models/HostConfig.Generated.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ public HostConfig(Resources Resources)
8484
[DataMember(Name = "Capabilities", EmitDefaultValue = false)]
8585
public IList<string> Capabilities { get; set; }
8686

87-
[DataMember(Name = "CgroupnsMode", EmitDefaultValue = false)]
88-
public string CgroupnsMode { get; set; }
89-
9087
[DataMember(Name = "Dns", EmitDefaultValue = false)]
9188
public IList<string> DNS { get; set; }
9289

src/Docker.DotNet/Models/ImageInspectResponse.Generated.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ public class ImageInspectResponse // (types.ImageInspect)
4343
[DataMember(Name = "Architecture", EmitDefaultValue = false)]
4444
public string Architecture { get; set; }
4545

46-
[DataMember(Name = "Variant", EmitDefaultValue = false)]
47-
public string Variant { get; set; }
48-
4946
[DataMember(Name = "Os", EmitDefaultValue = false)]
5047
public string Os { get; set; }
5148

src/Docker.DotNet/Models/PluginSpec.Generated.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@ public class PluginSpec // (runtime.PluginSpec)
1717

1818
[DataMember(Name = "disabled", EmitDefaultValue = false)]
1919
public bool Disabled { get; set; }
20-
21-
[DataMember(Name = "env", EmitDefaultValue = false)]
22-
public IList<string> Env { get; set; }
2320
}
2421
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Docker.DotNet.Models
4+
{
5+
[DataContract]
6+
public class ServiceLogsParameters // (main.ServiceLogsParameters)
7+
{
8+
[QueryStringParameter("stdout", false, typeof(BoolQueryStringConverter))]
9+
public bool? ShowStdout { get; set; }
10+
11+
[QueryStringParameter("stderr", false, typeof(BoolQueryStringConverter))]
12+
public bool? ShowStderr { get; set; }
13+
14+
[QueryStringParameter("since", false)]
15+
public string Since { get; set; }
16+
17+
[QueryStringParameter("timestamps", false, typeof(BoolQueryStringConverter))]
18+
public bool? Timestamps { get; set; }
19+
20+
[QueryStringParameter("follow", false, typeof(BoolQueryStringConverter))]
21+
public bool? Follow { get; set; }
22+
23+
[QueryStringParameter("tail", false)]
24+
public string Tail { get; set; }
25+
26+
[QueryStringParameter("details", false, typeof(BoolQueryStringConverter))]
27+
public bool? Details { get; set; }
28+
}
29+
}

src/Docker.DotNet/Models/ServiceStatus.Generated.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)