Skip to content

Commit 395db85

Browse files
committed
Merge branch '2.x' of https://github.com/elastic/elasticsearch-net into 2.x
2 parents b6c6a33 + cf33721 commit 395db85

File tree

13 files changed

+548
-0
lines changed

13 files changed

+548
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Elasticsearch.Net;
4+
5+
namespace Nest
6+
{
7+
public partial interface IElasticClient
8+
{
9+
/// <summary>
10+
/// Indices level stats provide statistics on different operations happening on an index. The API provides statistics on
11+
/// the index level scope (though most stats can also be retrieved using node level scope).
12+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-stats.html
13+
/// </summary>
14+
/// <param name="selector">Optionaly further describe the indices stats operation</param>
15+
IIndicesShardStoresResponse IndicesShardStores(Func<IndicesShardStoresDescriptor, IIndicesShardStoresRequest> selector = null);
16+
17+
/// <inheritdoc/>
18+
IIndicesShardStoresResponse IndicesShardStores(IIndicesShardStoresRequest request);
19+
20+
/// <inheritdoc/>
21+
Task<IIndicesShardStoresResponse> IndicesShardStoresAsync(Func<IndicesShardStoresDescriptor, IIndicesShardStoresRequest> selector = null);
22+
23+
/// <inheritdoc/>
24+
Task<IIndicesShardStoresResponse> IndicesShardStoresAsync(IIndicesShardStoresRequest request);
25+
26+
}
27+
28+
public partial class ElasticClient
29+
{
30+
/// <inheritdoc/>
31+
public IIndicesShardStoresResponse IndicesShardStores(Func<IndicesShardStoresDescriptor, IIndicesShardStoresRequest> selector = null) =>
32+
this.IndicesShardStores(selector.InvokeOrDefault(new IndicesShardStoresDescriptor()));
33+
34+
/// <inheritdoc/>
35+
public IIndicesShardStoresResponse IndicesShardStores(IIndicesShardStoresRequest request) =>
36+
this.Dispatcher.Dispatch<IIndicesShardStoresRequest, IndicesShardStoresRequestParameters, IndicesShardStoresResponse>(
37+
request,
38+
(p, d) => this.LowLevelDispatch.IndicesShardStoresDispatch<IndicesShardStoresResponse>(p)
39+
);
40+
41+
/// <inheritdoc/>
42+
public Task<IIndicesShardStoresResponse> IndicesShardStoresAsync(Func<IndicesShardStoresDescriptor, IIndicesShardStoresRequest> selector = null) =>
43+
this.IndicesShardStoresAsync(selector.InvokeOrDefault(new IndicesShardStoresDescriptor()));
44+
45+
/// <inheritdoc/>
46+
public Task<IIndicesShardStoresResponse> IndicesShardStoresAsync(IIndicesShardStoresRequest request) =>
47+
this.Dispatcher.DispatchAsync<IIndicesShardStoresRequest, IndicesShardStoresRequestParameters, IndicesShardStoresResponse, IIndicesShardStoresResponse>(
48+
request,
49+
(p, d) => this.LowLevelDispatch.IndicesShardStoresDispatchAsync<IndicesShardStoresResponse>(p)
50+
);
51+
}
52+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Collections.Generic;
2+
3+
namespace Nest
4+
{
5+
public partial interface IIndicesShardStoresRequest
6+
{
7+
IEnumerable<TypeName> Types { get; set; }
8+
}
9+
10+
public partial class IndicesShardStoresRequest
11+
{
12+
private IEnumerable<TypeName> _types;
13+
public IEnumerable<TypeName> Types
14+
{
15+
get { return _types; }
16+
set
17+
{
18+
if (value.HasAny()) this.RequestState.RequestParameters.AddQueryString("types", value);
19+
else this.RequestState.RequestParameters.RemoveQueryString("types");
20+
this._types = value;
21+
}
22+
}
23+
}
24+
25+
[DescriptorFor("IndicesShardStores")]
26+
public partial class IndicesShardStoresDescriptor
27+
{
28+
private IEnumerable<TypeName> _types;
29+
IEnumerable<TypeName> IIndicesShardStoresRequest.Types
30+
{
31+
get { return _types; }
32+
set
33+
{
34+
if (value.HasAny()) this.RequestState.RequestParameters.AddQueryString("types", value);
35+
else this.RequestState.RequestParameters.RemoveQueryString("types");
36+
this._types = value;
37+
}
38+
}
39+
40+
//<summary>A comma-separated list of fields for `completion` metric (supports wildcards)</summary>
41+
public IndicesShardStoresDescriptor Types(params TypeName[] types) =>
42+
Assign(a => a.Types = types);
43+
44+
}
45+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
using Newtonsoft.Json;
4+
5+
namespace Nest
6+
{
7+
public interface IIndicesShardStoresResponse : IResponse
8+
{
9+
[JsonProperty(PropertyName = "indices")]
10+
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))]
11+
Dictionary<string, IndicesShardStores> Indices { get; set; }
12+
}
13+
14+
[JsonObject]
15+
public class IndicesShardStoresResponse : ResponseBase, IIndicesShardStoresResponse
16+
{
17+
public Dictionary<string, IndicesShardStores> Indices { get; set; }
18+
}
19+
20+
public class IndicesShardStores
21+
{
22+
[JsonProperty(PropertyName = "shards")]
23+
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))]
24+
public Dictionary<string, ShardStoreWrapper> Shards { get; set; }
25+
}
26+
27+
public class ShardStoreWrapper
28+
{
29+
public IEnumerable<ShardStore> Stores { get; set; }
30+
}
31+
32+
[JsonConverter(typeof(ShardStoreJsonConverter))]
33+
public class ShardStore
34+
{
35+
[JsonProperty("id")]
36+
public string Id { get; set; }
37+
38+
[JsonProperty("name")]
39+
public string Name { get; set; }
40+
41+
[JsonProperty("transport_address")]
42+
public string TransportAddress { get; set; }
43+
44+
[JsonProperty("version")]
45+
public long Version { get; set; }
46+
47+
[JsonProperty("store_exeption")]
48+
public ShardStoreException StoreException { get; set; }
49+
50+
[JsonProperty("allocation")]
51+
public ShardStoreAllocation Allocation { get; set; }
52+
53+
[JsonProperty("attributes")]
54+
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))]
55+
public Dictionary<string, object> Attributes { get; set; }
56+
}
57+
58+
public class ShardStoreException
59+
{
60+
[JsonProperty("type")]
61+
public string Type { get; set; }
62+
[JsonProperty("reason")]
63+
public string Reason { get; set; }
64+
}
65+
66+
public enum ShardStoreAllocation
67+
{
68+
[EnumMember(Value = "primary")]
69+
Primary,
70+
[EnumMember(Value = "replica")]
71+
Replica,
72+
[EnumMember(Value = "unused")]
73+
Unused
74+
}
75+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Linq;
6+
7+
namespace Nest
8+
{
9+
internal class ShardStoreJsonConverter : JsonConverter
10+
{
11+
private readonly VerbatimDictionaryKeysJsonConverter _dictionaryConverter =
12+
new VerbatimDictionaryKeysJsonConverter();
13+
14+
private readonly PropertyJsonConverter _elasticTypeConverter = new PropertyJsonConverter();
15+
16+
public override bool CanRead => true;
17+
public override bool CanWrite => false;
18+
public override bool CanConvert(Type objectType) => objectType == typeof(IDictionary<string, IFieldMapping>);
19+
20+
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
21+
{
22+
throw new NotImplementedException();
23+
}
24+
25+
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
26+
{
27+
var r = new ShardStore();
28+
JObject o = JObject.Load(reader);
29+
var properties = o.Properties().ToListOrNullIfEmpty();
30+
var id = properties.First();
31+
properties.AddRange(id.Value.Value<JObject>().Properties());
32+
33+
r.Id = id.Name;
34+
35+
foreach (var p in properties)
36+
{
37+
switch(p.Name)
38+
{
39+
case "name":
40+
r.Name = p.Value.Value<string>();
41+
break;
42+
case "transport_address":
43+
r.TransportAddress = p.Value.Value<string>();
44+
break;
45+
case "version":
46+
r.Version = p.Value.Value<long>();
47+
break;
48+
case "store_exception":
49+
r.StoreException = p.Value.ToObject<ShardStoreException>();
50+
break;
51+
case "allocation":
52+
r.Allocation = p.Value.ToObject<ShardStoreAllocation>();
53+
break;
54+
case "attributes":
55+
r.Attributes = p.Value.ToObject<Dictionary<string, object>>();
56+
break;
57+
}
58+
}
59+
return r;
60+
}
61+
}
62+
}

src/Nest/Nest.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@
697697
<Compile Include="Indices\Monitoring\IndicesSegments\SegmentsResponse.cs" />
698698
<Compile Include="Indices\Monitoring\IndicesSegments\ShardSegmentRouting.cs" />
699699
<Compile Include="Indices\Monitoring\IndicesSegments\ShardsSegment.cs" />
700+
<Compile Include="Indices\Monitoring\IndicesShardStores\ElasticClient-IndicesShardStores.cs" />
701+
<Compile Include="Indices\Monitoring\IndicesShardStores\ShardStoreJsonConverter.cs" />
702+
<Compile Include="Indices\Monitoring\IndicesShardStores\IndicesShardStoresRequest.cs" />
703+
<Compile Include="Indices\Monitoring\IndicesShardStores\IndicesShardStoresResponse.cs" />
700704
<Compile Include="Indices\Monitoring\IndicesStats\ElasticClient-IndicesStats.cs" />
701705
<Compile Include="Indices\Monitoring\IndicesStats\IndexStats.cs" />
702706
<Compile Include="Indices\Monitoring\IndicesStats\IndicesStats.cs" />
@@ -1084,6 +1088,9 @@
10841088
<Compile Include="Search\SearchTemplate\DeleteSearchTemplate\DeleteSearchTemplateResponse.cs" />
10851089
<Compile Include="Search\SearchTemplate\DeleteSearchTemplate\ElasticClient-DeleteSearchTemplate.cs" />
10861090
<Compile Include="Search\SearchTemplate\ElasticClient-SearchTemplate.cs" />
1091+
<Compile Include="Search\SearchTemplate\RenderSearchTemplate\ElasticClient-RenderSearchTemplate.cs" />
1092+
<Compile Include="Search\SearchTemplate\RenderSearchTemplate\RenderSearchTemplateRequest.cs" />
1093+
<Compile Include="Search\SearchTemplate\RenderSearchTemplate\RenderSearchTemplateResponse.cs" />
10871094
<Compile Include="Search\SearchTemplate\GetSearchTemplate\ElasticClient-GetSearchTemplate.cs" />
10881095
<Compile Include="Search\SearchTemplate\GetSearchTemplate\GetSearchTemplateRequest.cs" />
10891096
<Compile Include="Search\SearchTemplate\GetSearchTemplate\GetSearchTemplateResponse.cs" />
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Elasticsearch.Net;
4+
5+
namespace Nest
6+
{
7+
public partial interface IElasticClient
8+
{
9+
/// <inheritdoc/>
10+
IRenderSearchTemplateResponse RenderSearchTemplate(Func<RenderSearchTemplateDescriptor, IRenderSearchTemplateRequest> selector);
11+
12+
/// <inheritdoc/>
13+
IRenderSearchTemplateResponse RenderSearchTemplate(IRenderSearchTemplateRequest request);
14+
15+
/// <inheritdoc/>
16+
Task<IRenderSearchTemplateResponse> RenderSearchTemplateAsync(Func<RenderSearchTemplateDescriptor, IRenderSearchTemplateRequest> selector);
17+
18+
/// <inheritdoc/>
19+
Task<IRenderSearchTemplateResponse> RenderSearchTemplateAsync(IRenderSearchTemplateRequest request);
20+
}
21+
public partial class ElasticClient
22+
{
23+
public IRenderSearchTemplateResponse RenderSearchTemplate(Func<RenderSearchTemplateDescriptor, IRenderSearchTemplateRequest> selector) =>
24+
this.RenderSearchTemplate(selector.InvokeOrDefault(new RenderSearchTemplateDescriptor()));
25+
26+
public IRenderSearchTemplateResponse RenderSearchTemplate(IRenderSearchTemplateRequest request) =>
27+
this.Dispatcher.Dispatch<IRenderSearchTemplateRequest, RenderSearchTemplateRequestParameters, RenderSearchTemplateResponse>(
28+
request,
29+
(p, d) => this.LowLevelDispatch.RenderSearchTemplateDispatch<RenderSearchTemplateResponse>(p, d)
30+
);
31+
32+
public Task<IRenderSearchTemplateResponse> RenderSearchTemplateAsync(Func<RenderSearchTemplateDescriptor, IRenderSearchTemplateRequest> selector) =>
33+
this.RenderSearchTemplateAsync(selector.InvokeOrDefault(new RenderSearchTemplateDescriptor()));
34+
35+
public Task<IRenderSearchTemplateResponse> RenderSearchTemplateAsync(IRenderSearchTemplateRequest request) =>
36+
this.Dispatcher.DispatchAsync<IRenderSearchTemplateRequest, RenderSearchTemplateRequestParameters, RenderSearchTemplateResponse, IRenderSearchTemplateResponse>(
37+
request,
38+
(p, d) => this.LowLevelDispatch.RenderSearchTemplateDispatchAsync<RenderSearchTemplateResponse>(p, d)
39+
);
40+
}
41+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
5+
namespace Nest
6+
{
7+
public partial interface IRenderSearchTemplateRequest
8+
{
9+
[JsonProperty("inline")]
10+
string Inline { get; set; }
11+
12+
[JsonProperty("file")]
13+
string File { get; set; }
14+
15+
[JsonProperty("params")]
16+
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))]
17+
Dictionary<string, object> Params { get; set; }
18+
19+
}
20+
21+
public partial class RenderSearchTemplateRequest
22+
{
23+
public string Inline { get; set; }
24+
public string File { get; set; }
25+
public Dictionary<string, object> Params { get; set; }
26+
}
27+
28+
29+
public partial class RenderSearchTemplateDescriptor
30+
{
31+
string IRenderSearchTemplateRequest.Inline { get; set; }
32+
string IRenderSearchTemplateRequest.File { get; set; }
33+
Dictionary<string, object> IRenderSearchTemplateRequest.Params { get; set; }
34+
35+
public RenderSearchTemplateDescriptor Inline(string inline) => Assign(a => a.Inline = inline);
36+
37+
public RenderSearchTemplateDescriptor File(string file) => Assign(a => a.File = file);
38+
39+
public RenderSearchTemplateDescriptor Params(Dictionary<string, object> scriptParams) => Assign(a => a.Params = scriptParams);
40+
41+
public RenderSearchTemplateDescriptor Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramsSelector) =>
42+
Assign(a => a.Params = paramsSelector?.Invoke(new FluentDictionary<string, object>()));
43+
44+
}
45+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Nest
4+
{
5+
public interface IRenderSearchTemplateResponse : IResponse
6+
{
7+
ILazyDocument TemplateOutput { get; set; }
8+
}
9+
10+
[JsonObject]
11+
public class RenderSearchTemplateResponse : ResponseBase, IRenderSearchTemplateResponse
12+
{
13+
[JsonProperty("template_output")]
14+
public ILazyDocument TemplateOutput { get; set; }
15+
}
16+
}

0 commit comments

Comments
 (0)