Skip to content

Commit de3d07a

Browse files
committed
update CatAllocationRecord (#4705)
This commit updates the fields available on CatAllocationRecord to match what is returned from Elasticsearch. Fixes #4699 (cherry picked from commit f3b329f)
1 parent 5e6a4e7 commit de3d07a

File tree

2 files changed

+71
-6
lines changed

2 files changed

+71
-6
lines changed

src/Nest/Cat/CatAllocation/CatAllocationRecord.cs

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,70 @@
11
using Newtonsoft.Json;
2+
// Licensed to Elasticsearch B.V under one or more agreements.
3+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
4+
// See the LICENSE file in the project root for more information
5+
6+
using System;
27

38
namespace Nest
49
{
510
[JsonObject]
611
public class CatAllocationRecord : ICatRecord
712
{
8-
[JsonProperty("diskAvail")]
13+
/// <summary>
14+
/// Amount of disk available
15+
/// </summary>
16+
[JsonProperty("disk.avail")]
917
public string DiskAvailable { get; set; }
1018

11-
[JsonProperty("diskRatio")]
19+
/// <summary>
20+
/// Amount of disk used by Elasticsearch indices
21+
/// </summary>
22+
[JsonProperty("disk.indices")]
23+
public string DiskIndices { get; set; }
24+
25+
/// <summary>
26+
/// The percentage of disk used
27+
/// </summary>
28+
[JsonProperty("disk.percent")]
29+
public string DiskPercent { get; set; }
30+
31+
[Obsolete("Use DiskPercent, DiskTotal, DiskAvailable, DiskTotal and DiskIndices")]
32+
[JsonIgnore]
1233
public string DiskRatio { get; set; }
1334

14-
[JsonProperty("diskUsed")]
35+
/// <summary>
36+
/// Total capacity of all volumes
37+
/// </summary>
38+
[JsonProperty("disk.total")]
39+
public string DiskTotal { get; set; }
40+
41+
/// <summary>
42+
/// Amount of disk used (total, not just Elasticsearch)
43+
/// </summary>
44+
[JsonProperty("disk.used")]
1545
public string DiskUsed { get; set; }
1646

47+
/// <summary>
48+
/// The host of the node
49+
/// </summary>
50+
[JsonProperty("host")]
51+
public string Host { get; set; }
52+
53+
/// <summary>
54+
/// The IP address of the node
55+
/// </summary>
1756
[JsonProperty("ip")]
1857
public string Ip { get; set; }
1958

59+
/// <summary>
60+
/// The name of the node
61+
/// </summary>
2062
[JsonProperty("node")]
2163
public string Node { get; set; }
2264

65+
/// <summary>
66+
/// Number of shards on the node
67+
/// </summary>
2368
[JsonProperty("shards")]
2469
public string Shards { get; set; }
2570
}

src/Tests/Tests/Cat/CatAllocation/CatAllocationApiTests.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using Elasticsearch.Net;
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.Linq;
6+
using Elasticsearch.Net;
27
using FluentAssertions;
38
using Nest;
49
using Tests.Core.ManagedElasticsearch.Clusters;
@@ -25,7 +30,22 @@ protected override LazyResponses ClientUsage() => Calls(
2530
(client, r) => client.CatAllocationAsync(r)
2631
);
2732

28-
protected override void ExpectResponse(ICatResponse<CatAllocationRecord> response) =>
29-
response.Records.Should().NotBeEmpty().And.Contain(a => !string.IsNullOrEmpty(a.Node));
33+
protected override void ExpectResponse(ICatResponse<CatAllocationRecord> response)
34+
{
35+
var records = response.Records;
36+
records.Should().NotBeEmpty().And.Contain(a => !string.IsNullOrEmpty(a.Node));
37+
38+
foreach (var record in records.Where(r => !string.IsNullOrEmpty(r.Ip)))
39+
{
40+
record.Shards.Should().NotBeNullOrEmpty();
41+
record.DiskIndices.Should().NotBeNullOrEmpty();
42+
record.DiskUsed.Should().NotBeNullOrEmpty();
43+
record.DiskAvailable.Should().NotBeNullOrEmpty();
44+
record.DiskTotal.Should().NotBeNullOrEmpty();
45+
record.DiskPercent.Should().NotBeNullOrEmpty();
46+
record.Host.Should().NotBeNullOrEmpty();
47+
record.Node.Should().NotBeNullOrEmpty();
48+
}
49+
}
3050
}
3151
}

0 commit comments

Comments
 (0)