Skip to content

Commit a9ebc1f

Browse files
authored
feat: Add query argument for container inspect API: containers/{id}/json (#16)
1 parent 32b2d95 commit a9ebc1f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Docker.DotNet/Endpoints/ContainerOperations.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ internal ContainerOperations(DockerClient client)
6464
return await _client.MakeRequestAsync<ContainerInspectResponse>(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/json", cancellationToken).ConfigureAwait(false);
6565
}
6666

67+
public async Task<ContainerInspectResponse> InspectContainerAsync(string id, ContainerInspectParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
68+
{
69+
if (string.IsNullOrEmpty(id))
70+
{
71+
throw new ArgumentNullException(nameof(id));
72+
}
73+
74+
if (parameters == null)
75+
{
76+
throw new ArgumentNullException(nameof(parameters));
77+
}
78+
79+
IQueryString queryString = new QueryString<ContainerInspectParameters>(parameters);
80+
return await _client.MakeRequestAsync<ContainerInspectResponse>(new[] { NoSuchContainerHandler }, HttpMethod.Get, $"containers/{id}/json", queryString, cancellationToken).ConfigureAwait(false);
81+
}
82+
6783
public async Task<ContainerProcessesResponse> ListProcessesAsync(string id, ContainerListProcessesParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
6884
{
6985
if (string.IsNullOrEmpty(id))

src/Docker.DotNet/Endpoints/IContainerOperations.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ public interface IContainerOperations
4343
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
4444
Task<ContainerInspectResponse> InspectContainerAsync(string id, CancellationToken cancellationToken = default(CancellationToken));
4545

46+
/// <summary>
47+
/// Retrieves low-level information about a container with additional options.
48+
/// </summary>
49+
/// <param name="id">The ID or name of the container.</param>
50+
/// <param name="parameters">Specifics of how to perform the operation, such as whether to include size information.</param>
51+
/// <param name="cancellationToken">When triggered, the operation will stop at the next available time, if possible.</param>
52+
/// <returns>A <see cref="Task{TResult}"/> that resolves to a <see cref="ContainerInspectResponse"/>, which holds details about the container.</returns>
53+
/// <remarks>The corresponding commands in the Docker CLI are <c>docker inspect --size</c> and <c>docker container inspect --size</c>.</remarks>
54+
/// <exception cref="DockerContainerNotFoundException">No such container was found.</exception>
55+
/// <exception cref="ArgumentNullException">One or more of the inputs was <see langword="null"/>.</exception>
56+
/// <exception cref="DockerApiException">the daemon experienced an error.</exception>
57+
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
58+
Task<ContainerInspectResponse> InspectContainerAsync(string id, ContainerInspectParameters parameters, CancellationToken cancellationToken = default(CancellationToken));
59+
4660
/// <summary>
4761
/// Retrieves a list of processes running within the container.
4862
/// </summary>

0 commit comments

Comments
 (0)