Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 33 additions & 1 deletion src/Docker.DotNet/Endpoints/ISwarmOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Docker.DotNet.Models;
using System.Threading;
using System.IO;

namespace Docker.DotNet
{
Expand Down Expand Up @@ -154,6 +155,37 @@ public interface ISwarmOperations
/// <param name="id">ID or name of service.</param>
Task RemoveServiceAsync(string id, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Get service logs.
///
/// Get {stdout} and {stderr} logs from all service tasks.
/// Note: This endpoint works only for services with the {json-file} or {journald} logging driver.
/// </summary>
/// <remarks>
/// docker service logs
///
/// HTTP GET /services/(id)/logs
///
/// 101 - Logs returned as a stream.
/// 200 - Logs returned as a string in response body.
/// 404 - No such service.
/// 500 - Server error.
/// 503 - Node is not part of a swarm.
/// </remarks>
/// <param name="id">ID or name of the service.</param>
Task<Stream> GetServiceLogsAsync(string id, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Gets the <code>stdout</code> and <code>stderr</code> logs from all service tasks.
/// This endpoint works only for services with the <code>json-file</code> or <code>journald</code> logging driver.
/// </summary>
/// <param name="id">ID or name of the service.</param>
/// <param name="tty">If the service was created with a TTY or not. If <see langword="false" />, the returned stream is multiplexed.</param>
/// <param name="parameters">The parameters used to retrieve the logs.</param>
/// <param name="cancellationToken">A token used to cancel this operation.</param>
/// <returns>A stream with the retrieved logs. If the service wasn't created with a TTY, this stream is multiplexed.</returns>
Task<MultiplexedStream> GetServiceLogsAsync(string id, bool tty, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken));

#endregion Services

#region Nodes
Expand Down Expand Up @@ -207,4 +239,4 @@ public interface ISwarmOperations

#endregion
}
}
}
36 changes: 36 additions & 0 deletions src/Docker.DotNet/Endpoints/SwarmOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Docker.DotNet
using System.Threading.Tasks;
using System.Threading;
using Models;
using System.IO;

internal class SwarmOperations : ISwarmOperations
{
Expand Down Expand Up @@ -156,6 +157,41 @@ async Task<ServiceUpdateResponse> ISwarmOperations.UpdateServiceAsync(string id,
return this._client.JsonSerializer.DeserializeObject<ServiceUpdateResponse>(response.Body);
}

public Task<Stream> GetServiceLogsAsync(string id, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));
}

if (parameters == null)
{
throw new ArgumentNullException(nameof(parameters));
}

IQueryString queryParameters = new QueryString<ServiceLogsParameters>(parameters);
return this._client.MakeRequestForStreamAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, $"services/{id}/logs", queryParameters, cancellationToken);
}

public async Task<MultiplexedStream> GetServiceLogsAsync(string id, bool tty, ServiceLogsParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));
}

if (parameters == null)
{
throw new ArgumentNullException(nameof(parameters));
}

IQueryString queryParameters = new QueryString<ServiceLogsParameters>(parameters);

Stream result = await this._client.MakeRequestForStreamAsync(new[] { SwarmResponseHandler }, HttpMethod.Get, $"services/{id}/logs", queryParameters, cancellationToken).ConfigureAwait(false);

return new MultiplexedStream(result, !tty);
}

async Task ISwarmOperations.UpdateSwarmAsync(SwarmUpdateParameters parameters, CancellationToken cancellationToken)
{
var query = new QueryString<SwarmUpdateParameters>(parameters ?? throw new ArgumentNullException(nameof(parameters)));
Expand Down
4 changes: 2 additions & 2 deletions src/Docker.DotNet/JsonSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Docker.DotNet
Expand Down Expand Up @@ -35,4 +35,4 @@ public string SerializeObject<T>(T value)
return JsonConvert.SerializeObject(value, this._settings);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Docker.DotNet.Models
[DataContract]
public class ContainerExecInspectResponse // (types.ContainerExecInspect)
{
[DataMember(Name = "ExecID", EmitDefaultValue = false)]
[DataMember(Name = "ID", EmitDefaultValue = false)]
public string ExecID { get; set; }

[DataMember(Name = "ContainerID", EmitDefaultValue = false)]
Expand Down
3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/ContainerSpec.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,5 @@ public class ContainerSpec // (swarm.ContainerSpec)

[DataMember(Name = "Sysctls", EmitDefaultValue = false)]
public IDictionary<string, string> Sysctls { get; set; }

[DataMember(Name = "Capabilities", EmitDefaultValue = false)]
public IList<string> Capabilities { get; set; }
}
}
3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/HostConfig.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ public HostConfig(Resources Resources)
[DataMember(Name = "Capabilities", EmitDefaultValue = false)]
public IList<string> Capabilities { get; set; }

[DataMember(Name = "CgroupnsMode", EmitDefaultValue = false)]
public string CgroupnsMode { get; set; }

[DataMember(Name = "Dns", EmitDefaultValue = false)]
public IList<string> DNS { get; set; }

Expand Down
3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/ImageInspectResponse.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ public class ImageInspectResponse // (types.ImageInspect)
[DataMember(Name = "Architecture", EmitDefaultValue = false)]
public string Architecture { get; set; }

[DataMember(Name = "Variant", EmitDefaultValue = false)]
public string Variant { get; set; }

[DataMember(Name = "Os", EmitDefaultValue = false)]
public string Os { get; set; }

Expand Down
3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/PluginSpec.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ public class PluginSpec // (runtime.PluginSpec)

[DataMember(Name = "disabled", EmitDefaultValue = false)]
public bool Disabled { get; set; }

[DataMember(Name = "env", EmitDefaultValue = false)]
public IList<string> Env { get; set; }
}
}
29 changes: 29 additions & 0 deletions src/Docker.DotNet/Models/ServiceLogsParameters.Generated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Runtime.Serialization;

namespace Docker.DotNet.Models
{
[DataContract]
public class ServiceLogsParameters // (main.ServiceLogsParameters)
{
[QueryStringParameter("stdout", false, typeof(BoolQueryStringConverter))]
public bool? ShowStdout { get; set; }

[QueryStringParameter("stderr", false, typeof(BoolQueryStringConverter))]
public bool? ShowStderr { get; set; }

[QueryStringParameter("since", false)]
public string Since { get; set; }

[QueryStringParameter("timestamps", false, typeof(BoolQueryStringConverter))]
public bool? Timestamps { get; set; }

[QueryStringParameter("follow", false, typeof(BoolQueryStringConverter))]
public bool? Follow { get; set; }

[QueryStringParameter("tail", false)]
public string Tail { get; set; }

[QueryStringParameter("details", false, typeof(BoolQueryStringConverter))]
public bool? Details { get; set; }
}
}
14 changes: 0 additions & 14 deletions src/Docker.DotNet/Models/ServiceStatus.Generated.cs

This file was deleted.

3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/SwarmService.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,5 @@ public SwarmService(Meta Meta)

[DataMember(Name = "UpdateStatus", EmitDefaultValue = false)]
public UpdateStatus UpdateStatus { get; set; }

[DataMember(Name = "ServiceStatus", EmitDefaultValue = false)]
public ServiceStatus ServiceStatus { get; set; }
}
}
3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/SystemInfoResponse.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public class SystemInfoResponse // (types.Info)
[DataMember(Name = "OperatingSystem", EmitDefaultValue = false)]
public string OperatingSystem { get; set; }

[DataMember(Name = "OSVersion", EmitDefaultValue = false)]
public string OSVersion { get; set; }

[DataMember(Name = "OSType", EmitDefaultValue = false)]
public string OSType { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions tools/specgen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
specgen.exe
specgen
139 changes: 0 additions & 139 deletions tools/specgen/Godeps/Godeps.json

This file was deleted.

5 changes: 0 additions & 5 deletions tools/specgen/Godeps/Readme

This file was deleted.

7 changes: 3 additions & 4 deletions tools/specgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ A tool that reflects the Docker client [engine-api](https://github.com/docker/en

##How to use:

This tool relies on [GoDep](https://github.com/tools/godep), a tool used to manage which git hash's were used at which time to generate the corresponding models.

To update the source repositories please use the following from your `$GOPATH`:

```
> go get -u foo/bar
> godep update foo/bar
> go get -u github.com/docker/docker@<release-tag>
```

Note: Since the docker library is not a go module the version go generates will look something like this v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible even though this is for v19.03.13. The commit hash bd33bbf0497b matches the commit hash of docker v 19.03.13

Once you have the latest engine-api. Calling:

```
Expand Down
Loading