Skip to content

Commit 2f7717b

Browse files
committed
Added GetNetworkClientsAllAsync to get 1000 at a time
1 parent 4dc5b39 commit 2f7717b

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

Meraki.Api.NewTest/NetworkTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using FluentAssertions;
22
using Meraki.Api.Data;
3+
using Meraki.Api.Extensions;
34
using System.Net;
45
using Xunit.Abstractions;
56

@@ -101,4 +102,14 @@ public async Task BasicCrud_Succeeds()
101102
_ = exception.StatusCode.Should().Be(HttpStatusCode.NotFound);
102103

103104
}
105+
106+
[Fact]
107+
public async Task GetNetworkClientsAll_Succeeds()
108+
{
109+
TestMerakiClient.Statistics.Reset();
110+
var networks = await TestMerakiClient.Organizations.Networks.GetOrganizationNetworksAllAsync(TestOrganizationId);
111+
var network = networks[0];
112+
var clients = await TestMerakiClient.Networks.Clients.GetNetworkClientsAllAsync(network.Id, cancellationToken: default);
113+
_ = clients.Should().NotBeNull();
114+
}
104115
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace Meraki.Api.Extensions;
2+
3+
public static class INetworkClientsExtensions
4+
{
5+
public static Task<List<Client>> GetNetworkClientsAllAsync(
6+
this NetworksClientsSection networkClients,
7+
string networkId,
8+
string t0 = null!,
9+
double? timespan = null,
10+
string? statuses = null,
11+
string? ip = null,
12+
string? ip6 = null,
13+
string? ip6Local = null,
14+
string? mac = null,
15+
string? os = null,
16+
string? pskGroup = null,
17+
string? description = null,
18+
List<string>? recentDeviceConnections = null,
19+
CancellationToken cancellationToken = default)
20+
=> MerakiClient.GetAllAsync(
21+
(startingAfter, endingBefore, cancellationToken)
22+
=> networkClients.Clients.GetNetworkClientsApiResponseAsync(
23+
networkId,
24+
t0,
25+
timespan,
26+
1000,
27+
startingAfter,
28+
endingBefore,
29+
statuses,
30+
ip,
31+
ip6,
32+
ip6Local,
33+
mac,
34+
os,
35+
pskGroup,
36+
description,
37+
recentDeviceConnections,
38+
cancellationToken
39+
),
40+
cancellationToken
41+
);
42+
}

Meraki.Api/Interfaces/General/Networks/INetworksClients.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ Task<List<Client>> GetNetworkClientsAsync(
4242
[AliasAs("recentDeviceConnections[]")] List<string>? recentDeviceConnections = null,
4343
CancellationToken cancellationToken = default);
4444

45+
[ApiOperationId("getNetworkClients")]
46+
[Get("/networks/{networkId}/clients")]
47+
[QueryUriFormat(UriFormat.Unescaped)]
48+
internal Task<ApiResponse<List<Client>>> GetNetworkClientsApiResponseAsync(
49+
string networkId,
50+
string t0 = null!,
51+
double? timespan = null,
52+
int? perPage = null,
53+
string? startingAfter = null,
54+
string? endingBefore = null,
55+
string? statuses = null,
56+
string? ip = null,
57+
string? ip6 = null,
58+
string? ip6Local = null,
59+
string? mac = null,
60+
string? os = null,
61+
string? pskGroup = null,
62+
string? description = null,
63+
[AliasAs("recentDeviceConnections[]")] List<string>? recentDeviceConnections = null,
64+
CancellationToken cancellationToken = default);
65+
4566
/// <summary>
4667
/// Return the client associated with the given identifier. Clients can be identified by a client key or either the MAC or IP depending on whether the network uses Track-by-IP.
4768
/// </summary>

0 commit comments

Comments
 (0)