Skip to content

Commit caa2dd7

Browse files
authored
XPack info and usage improvements. (#3764)
1 parent d73961e commit caa2dd7

File tree

4 files changed

+222
-2
lines changed

4 files changed

+222
-2
lines changed

src/Nest/XPack/Info/XPackInfo/XPackInfoResponse.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,33 @@ public class MinimalLicenseInformation
5555

5656
public class XPackFeatures
5757
{
58+
[JsonProperty("ccr")]
59+
public XPackFeature Ccr { get; internal set; }
60+
5861
[JsonProperty("graph")]
5962
public XPackFeature Graph { get; internal set; }
6063

64+
[JsonProperty("ilm")]
65+
public XPackFeature Ilm { get; internal set; }
66+
67+
[JsonProperty("logstash")]
68+
public XPackFeature Logstash { get; internal set; }
69+
6170
[JsonProperty("ml")]
6271
public XPackFeature MachineLearning { get; internal set; }
6372

6473
[JsonProperty("monitoring")]
6574
public XPackFeature Monitoring { get; internal set; }
6675

76+
[JsonProperty("rollup")]
77+
public XPackFeature Rollup { get; internal set; }
78+
6779
[JsonProperty("security")]
6880
public XPackFeature Security { get; internal set; }
6981

82+
[JsonProperty("sql")]
83+
public XPackFeature Sql { get; internal set; }
84+
7085
[JsonProperty("watcher")]
7186
public XPackFeature Watcher { get; internal set; }
7287
}

src/Nest/XPack/Info/XPackUsage/XPackUsageResponse.cs

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,87 @@ namespace Nest
55
{
66
public interface IXPackUsageResponse : IResponse
77
{
8-
[JsonProperty("watcher")]
9-
AlertingUsage Alerting { get; }
8+
[JsonProperty("ccr")]
9+
CcrUsage Ccr { get; }
1010

1111
[JsonProperty("graph")]
1212
XPackUsage Graph { get; }
1313

14+
[JsonProperty("logstash")]
15+
XPackUsage Logstash { get; }
16+
1417
[JsonProperty("ml")]
1518
MachineLearningUsage MachineLearning { get; }
1619

1720
[JsonProperty("monitoring")]
1821
MonitoringUsage Monitoring { get; }
1922

23+
[JsonProperty("rollup")]
24+
XPackUsage Rollup { get; }
25+
2026
[JsonProperty("security")]
2127
SecurityUsage Security { get; }
28+
29+
[JsonProperty("sql")]
30+
SqlUsage Sql { get; }
31+
32+
[JsonProperty("watcher")]
33+
AlertingUsage Alerting { get; }
34+
}
35+
36+
public class SqlUsage : XPackUsage
37+
{
38+
[JsonProperty("features")]
39+
public IReadOnlyDictionary<string, int> Features { get; set; } = EmptyReadOnly<string, int>.Dictionary;
40+
41+
[JsonProperty("queries")]
42+
public IReadOnlyDictionary<string, QueryUsage> Queries { get; set; } = EmptyReadOnly<string, QueryUsage>.Dictionary;
43+
}
44+
45+
public class QueryUsage
46+
{
47+
[JsonProperty("total")]
48+
public int Total { get; internal set; }
49+
50+
[JsonProperty("paging")]
51+
public int Paging { get; internal set; }
52+
53+
[JsonProperty("failed")]
54+
public int Failed { get; internal set; }
55+
56+
[JsonProperty("count")]
57+
public int? Count { get; internal set; }
58+
}
59+
60+
public class CcrUsage : XPackUsage
61+
{
62+
[JsonProperty("auto_follow_patterns_count")]
63+
public int AutoFollowPatternsCount { get; internal set; }
64+
65+
[JsonProperty("follower_indices_count")]
66+
public int FollowerIndicesCount { get; internal set; }
2267
}
2368

2469
public class XPackUsageResponse : ResponseBase, IXPackUsageResponse
2570
{
71+
[JsonProperty("sql")]
72+
public SqlUsage Sql { get; internal set; }
73+
74+
[JsonProperty("rollup")]
75+
public XPackUsage Rollup { get; internal set; }
76+
77+
[JsonProperty("ccr")]
78+
public CcrUsage Ccr { get; internal set; }
79+
2680
[JsonProperty("watcher")]
2781
public AlertingUsage Alerting { get; internal set; }
2882

2983
[JsonProperty("graph")]
3084
public XPackUsage Graph { get; internal set; }
3185

86+
[JsonProperty("logstash")]
87+
public XPackUsage Logstash { get; internal set; }
88+
3289
[JsonProperty("ml")]
3390
public MachineLearningUsage MachineLearning { get; internal set; }
3491

@@ -41,7 +98,10 @@ public class XPackUsageResponse : ResponseBase, IXPackUsageResponse
4198

4299
public class XPackUsage
43100
{
101+
[JsonProperty("available")]
44102
public bool Available { get; internal set; }
103+
104+
[JsonProperty("enabled")]
45105
public bool Enabled { get; internal set; }
46106
}
47107

@@ -59,6 +119,9 @@ public class SecurityUsage : XPackUsage
59119
[JsonProperty("realms")]
60120
public IReadOnlyDictionary<string, RealmUsage> Realms { get; internal set; } = EmptyReadOnly<string, RealmUsage>.Dictionary;
61121

122+
[JsonProperty("role_mapping")]
123+
public IReadOnlyDictionary<string, RoleMappingUsage> RoleMapping { get; internal set; } = EmptyReadOnly<string, RoleMappingUsage>.Dictionary;
124+
62125
[JsonProperty("roles")]
63126
public IReadOnlyDictionary<string, RoleUsage> Roles { get; internal set; } = EmptyReadOnly<string, RoleUsage>.Dictionary;
64127

@@ -68,6 +131,15 @@ public class SecurityUsage : XPackUsage
68131
[JsonProperty("system_key")]
69132
public SecurityFeatureToggle SystemKey { get; internal set; }
70133

134+
public class RoleMappingUsage
135+
{
136+
[JsonProperty("enabled")]
137+
public int Enabled { get; internal set; }
138+
139+
[JsonProperty("size")]
140+
public int Size { get; internal set; }
141+
}
142+
71143
public class AuditUsage : SecurityFeatureToggle
72144
{
73145
[JsonProperty("outputs")]
@@ -131,12 +203,24 @@ public class AlertingUsage : XPackUsage
131203
[JsonProperty("execution")]
132204
public AlertingExecution Execution { get; internal set; }
133205

206+
[JsonProperty("watch")]
207+
public AlertingInput Watch { get; internal set; }
208+
134209
public class AlertingExecution
135210
{
136211
[JsonProperty("actions")]
137212
public IReadOnlyDictionary<string, ExecutionAction> Actions { get; internal set; } = EmptyReadOnly<string, ExecutionAction>.Dictionary;
138213
}
139214

215+
public class AlertingInput
216+
{
217+
[JsonProperty("input")]
218+
public IReadOnlyDictionary<string, AlertingCount> Input { get; internal set; } = EmptyReadOnly<string, AlertingCount>.Dictionary;
219+
220+
[JsonProperty("trigger")]
221+
public IReadOnlyDictionary<string, AlertingCount> Trigger { get; internal set; } = EmptyReadOnly<string, AlertingCount>.Dictionary;
222+
}
223+
140224
public class ExecutionAction
141225
{
142226
[JsonProperty("total")]
@@ -158,6 +242,9 @@ public class AlertingCount
158242

159243
public class MonitoringUsage : XPackUsage
160244
{
245+
[JsonProperty("collection_enabled")]
246+
public bool CollectionEnabled { get; internal set; }
247+
161248
[JsonProperty("enabled_exporters")]
162249
public IReadOnlyDictionary<string, long> EnabledExporters { get; set; } = EmptyReadOnly<string, long>.Dictionary;
163250
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using FluentAssertions;
4+
using Nest;
5+
using Tests.Core.ManagedElasticsearch.Clusters;
6+
using Tests.Framework;
7+
using Tests.Framework.EndpointTests.TestState;
8+
using Tests.Framework.Integration;
9+
10+
namespace Tests.XPack.Info
11+
{
12+
[SkipVersion("<6.8.0", "All APIs exist in Elasticsearch 6.8.0")]
13+
public class XPackInfoApiTests : CoordinatedIntegrationTestBase<XPackCluster>
14+
{
15+
private const string XPackInfoStep = nameof(XPackInfoStep);
16+
private const string XPackUsageStep = nameof(XPackUsageStep);
17+
18+
public XPackInfoApiTests(XPackCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage)
19+
{
20+
{
21+
XPackInfoStep, u => u.Calls<XPackInfoDescriptor, XPackInfoRequest, IXPackInfoRequest, IXPackInfoResponse>(
22+
v => new XPackInfoRequest(),
23+
(v, d) => d,
24+
(v, c, f) => c.XPackInfo(f),
25+
(v, c, f) => c.XPackInfoAsync(f),
26+
(v, c, r) => c.XPackInfo(r),
27+
(v, c, r) => c.XPackInfoAsync(r)
28+
)
29+
},
30+
{
31+
XPackUsageStep, u => u.Calls<XPackUsageDescriptor, XPackUsageRequest, IXPackUsageRequest, IXPackUsageResponse>(
32+
v => new XPackUsageRequest(),
33+
(v, d) => d,
34+
(v, c, f) => c.XPackUsage(f),
35+
(v, c, f) => c.XPackUsageAsync(f),
36+
(v, c, r) => c.XPackUsage(r),
37+
(v, c, r) => c.XPackUsageAsync(r)
38+
)
39+
}
40+
}) { }
41+
42+
[I] public async Task XPackInfoResponse() => await Assert<XPackInfoResponse>(XPackInfoStep, (v, r) =>
43+
{
44+
r.IsValid.Should().BeTrue();
45+
r.ApiCall.HttpStatusCode.Should().Be(200);
46+
47+
r.Build.Should().NotBeNull();
48+
r.Features.Should().NotBeNull();
49+
r.Features.Ccr.Should().NotBeNull();
50+
r.Features.Graph.Should().NotBeNull();
51+
r.Features.Ilm.Should().NotBeNull();
52+
r.Features.Logstash.Should().NotBeNull();
53+
r.Features.MachineLearning.Should().NotBeNull();
54+
r.Features.MachineLearning.NativeCodeInformation.Should().NotBeNull();
55+
r.Features.Monitoring.Should().NotBeNull();
56+
r.Features.Rollup.Should().NotBeNull();
57+
r.Features.Security.Should().NotBeNull();
58+
r.Features.Sql.Should().NotBeNull();
59+
r.Features.Watcher.Should().NotBeNull();
60+
r.License.Should().NotBeNull();
61+
});
62+
63+
[I] public async Task XPackUsageResponse() => await Assert<XPackUsageResponse>(XPackUsageStep, (v, r) =>
64+
{
65+
r.IsValid.Should().BeTrue();
66+
r.ApiCall.HttpStatusCode.Should().Be(200);
67+
68+
r.Ccr.Should().NotBeNull();
69+
r.Graph.Should().NotBeNull();
70+
r.Logstash.Should().NotBeNull();
71+
r.MachineLearning.Should().NotBeNull();
72+
r.MachineLearning.Datafeeds.Should().NotBeNull();
73+
r.MachineLearning.Jobs.Should().NotBeNull();
74+
r.Monitoring.Should().NotBeNull();
75+
r.Monitoring.EnabledExporters.Should().NotBeNull();
76+
r.Rollup.Should().NotBeNull();
77+
r.Security.Should().NotBeNull();
78+
r.Security.Roles.Should().NotBeNull();
79+
r.Security.Realms.Should().NotBeNull();
80+
r.Security.RoleMapping.Should().NotBeNull();
81+
r.Sql.Should().NotBeNull();
82+
r.Sql.Features.Should().NotBeNull();
83+
r.Sql.Queries.Should().NotBeNull();
84+
r.Alerting.Should().NotBeNull();
85+
r.Alerting.Count.Should().NotBeNull();
86+
r.Alerting.Execution.Should().NotBeNull();
87+
r.Alerting.Watch.Should().NotBeNull();
88+
});
89+
}
90+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using Nest;
4+
using Tests.Framework;
5+
using static Tests.Framework.UrlTester;
6+
7+
namespace Tests.XPack.Info
8+
{
9+
public class XPackInfoUrlTests : UrlTestsBase
10+
{
11+
[U] public override async Task Urls()
12+
{
13+
await GET("/_xpack")
14+
.Fluent(c => c.XPackInfo())
15+
.Request(c => c.XPackInfo())
16+
.FluentAsync(c => c.XPackInfoAsync())
17+
.RequestAsync(c => c.XPackInfoAsync())
18+
;
19+
20+
await GET("/_xpack/usage")
21+
.Fluent(c => c.XPackUsage())
22+
.Request(c => c.XPackUsage())
23+
.FluentAsync(c => c.XPackUsageAsync())
24+
.RequestAsync(c => c.XPackUsageAsync())
25+
;
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)