Skip to content

Commit 48291cc

Browse files
committed
many small fixes following the breaking changes list
1 parent 5e23197 commit 48291cc

28 files changed

+333
-211
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/RestApiSpec.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using System.Runtime.InteropServices;
34
using System.Text;
45

56
namespace CodeGeneration.LowLevelClient.Domain
@@ -31,12 +32,16 @@ where m.Value.CsharpType(m.Key).EndsWith("Options")
3132

3233
};
3334

34-
var urlParamEnums = from p in this.Endpoints.Values.SelectMany(v => v.CsharpMethods)
35-
.SelectMany(m => m.Parts)
35+
var urlParamEnums = from data in this.Endpoints.Values
36+
.SelectMany(v => v.CsharpMethods.Select(m=>new { m, n = v.CsharpMethodName}))
37+
.SelectMany(m => m.m.Parts.Select(part=> new { m = m.n, p = part}))
38+
let p = data.p
39+
let m = data.m
3640
where p.Options != null && p.Options.Any()
41+
let name = p.Name.Contains("metric") ? m + p.Name.ToPascalCase() : p.Name.ToPascalCase()
3742
select new EnumDescription
3843
{
39-
Name = p.Name.ToPascalCase() + "Options",
44+
Name = name,
4045
Options = p.Options
4146
};
4247

src/Nest/DSL/ClusterStateDescriptor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ public partial class ClusterStateDescriptor :
1515
IndicesOptionalPathDescriptor<ClusterStateDescriptor, ClusterStateQueryString>
1616
, IPathInfo<ClusterStateQueryString>
1717
{
18+
19+
private IEnumerable<ClusterStateMetric> _Metrics { get; set; }
20+
public ClusterStateDescriptor Metrics(params ClusterStateMetric[] metrics)
21+
{
22+
this._Metrics = metrics;
23+
return this;
24+
}
1825
ElasticsearchPathInfo<ClusterStateQueryString> IPathInfo<ClusterStateQueryString>.ToPathInfo(IConnectionSettings settings)
1926
{
2027
var pathInfo = base.ToPathInfo<ClusterStateQueryString>(settings, this._QueryString);
2128
pathInfo.HttpMethod = PathInfoHttpMethod.GET;
22-
29+
if (this._Metrics != null)
30+
pathInfo.Metric = this._Metrics.Cast<Enum>().GetStringValue();
2331
return pathInfo;
2432
}
2533
}

src/Nest/DSL/DeleteByQueryDescriptor.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,23 @@
1010

1111
namespace Nest
1212
{
13-
[JsonConverter(typeof(CustomJsonConverter))]
1413
public partial class DeleteByQueryDescriptor<T>
1514
: QueryPathDescriptorBase<DeleteByQueryDescriptor<T>, T, DeleteByQueryQueryString>
16-
, IActAsQuery
1715
, IPathInfo<DeleteByQueryQueryString>
18-
, ICustomJson
1916
where T : class
2017
{
21-
BaseQuery IActAsQuery._Query { get; set; }
18+
[JsonProperty("query")]
19+
internal BaseQuery _Query { get; set; }
2220

2321
public DeleteByQueryDescriptor<T> MatchAll()
2422
{
25-
((IActAsQuery)this)._Query = new QueryDescriptor<T>().MatchAll();
23+
this._Query = new QueryDescriptor<T>().MatchAll();
2624
return this;
2725
}
2826

2927
public DeleteByQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery> querySelector)
3028
{
31-
((IActAsQuery)this)._Query = querySelector(new QueryDescriptor<T>());
29+
this._Query = querySelector(new QueryDescriptor<T>());
3230
return this;
3331
}
3432

@@ -38,9 +36,5 @@ ElasticsearchPathInfo<DeleteByQueryQueryString> IPathInfo<DeleteByQueryQueryStri
3836
pathInfo.HttpMethod = PathInfoHttpMethod.DELETE;
3937
return pathInfo;
4038
}
41-
object ICustomJson.GetCustomJson()
42-
{
43-
return ((IActAsQuery) this)._Query;
44-
}
4539
}
4640
}

src/Nest/DSL/IndicesStatsDescriptor.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ public partial class IndicesStatsDescriptor :
1616
, IPathInfo<IndicesStatsQueryString>
1717
{
1818
private IEnumerable<TypeNameMarker> _Types { get; set; }
19+
private IEnumerable<IndicesStatsMetric> _Metrics { get; set; }
1920

2021
//<summary>A comma-separated list of fields for `completion` metric (supports wildcards)</summary>
2122
public IndicesStatsDescriptor Types(params Type[] completion_fields)
2223
{
2324
this._Types = completion_fields.Select(t=>(TypeNameMarker)t);
2425
return this;
2526
}
27+
28+
public IndicesStatsDescriptor Metrics(params IndicesStatsMetric[] metrics)
29+
{
30+
this._Metrics = metrics;
31+
return this;
32+
}
33+
2634
ElasticsearchPathInfo<IndicesStatsQueryString> IPathInfo<IndicesStatsQueryString>.ToPathInfo(IConnectionSettings settings)
2735
{
2836
var pathInfo = base.ToPathInfo<IndicesStatsQueryString>(settings, this._QueryString);
@@ -32,6 +40,8 @@ ElasticsearchPathInfo<IndicesStatsQueryString> IPathInfo<IndicesStatsQueryString
3240
var types = inferrer.TypeNames(this._Types);
3341
this._QueryString.Add("types", string.Join(",", types));
3442
}
43+
if (this._Metrics != null)
44+
pathInfo.Metric = this._Metrics.Cast<Enum>().GetStringValue();
3545
pathInfo.HttpMethod = PathInfoHttpMethod.GET;
3646

3747
return pathInfo;

src/Nest/DSL/NodesInfoDescriptor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ namespace Nest
1313
public partial class NodesInfoDescriptor : NodeIdOptionalDescriptor<NodesInfoDescriptor, NodesInfoQueryString>
1414
, IPathInfo<NodesInfoQueryString>
1515
{
16+
private IEnumerable<NodesInfoMetric> _Metrics { get; set; }
17+
public NodesInfoDescriptor Metrics(params NodesInfoMetric[] metrics)
18+
{
19+
this._Metrics = metrics;
20+
return this;
21+
}
1622
ElasticsearchPathInfo<NodesInfoQueryString> IPathInfo<NodesInfoQueryString>.ToPathInfo(IConnectionSettings settings)
1723
{
1824
var pathInfo = base.ToPathInfo<NodesInfoQueryString>(settings, this._QueryString);
25+
if (this._Metrics != null)
26+
pathInfo.Metric = this._Metrics.Cast<Enum>().GetStringValue();
1927
pathInfo.HttpMethod = PathInfoHttpMethod.GET;
2028
return pathInfo;
2129
}

src/Nest/DSL/NodesStatsDescriptor.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,28 @@ namespace Nest
1313
public partial class NodesStatsDescriptor : NodeIdOptionalDescriptor<NodesStatsDescriptor, NodesStatsQueryString>
1414
, IPathInfo<NodesStatsQueryString>
1515
{
16+
private IEnumerable<NodesStatsMetric> _Metrics { get; set; }
17+
private IEnumerable<NodesStatsIndexMetric> _IndexMetrics { get; set; }
18+
19+
public NodesStatsDescriptor Metrics(params NodesStatsMetric[] metrics)
20+
{
21+
this._Metrics = metrics;
22+
return this;
23+
}
24+
public NodesStatsDescriptor IndexMetrics(params NodesStatsIndexMetric[] metrics)
25+
{
26+
this._IndexMetrics = metrics;
27+
return this;
28+
}
29+
1630
ElasticsearchPathInfo<NodesStatsQueryString> IPathInfo<NodesStatsQueryString>.ToPathInfo(IConnectionSettings settings)
1731
{
1832
var pathInfo = base.ToPathInfo<NodesStatsQueryString>(settings, this._QueryString);
1933
pathInfo.HttpMethod = PathInfoHttpMethod.GET;
34+
if (this._Metrics != null)
35+
pathInfo.Metric = this._Metrics.Cast<Enum>().GetStringValue();
36+
if (this._IndexMetrics != null)
37+
pathInfo.IndexMetric = this._IndexMetrics.Cast<Enum>().GetStringValue();
2038
return pathInfo;
2139
}
2240

src/Nest/DSL/ValidateQueryDescriptor.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55
namespace Nest
66
{
77
[DescriptorFor("IndicesValidateQuery")]
8-
[JsonConverter(typeof(CustomJsonConverter))]
98
public partial class ValidateQueryDescriptor<T>
109
: QueryPathDescriptorBase<ValidateQueryDescriptor<T>, T, ValidateQueryQueryString>
11-
, IActAsQuery
1210
, IPathInfo<ValidateQueryQueryString>
13-
, ICustomJson
1411
where T : class
1512
{
16-
BaseQuery IActAsQuery._Query { get; set; }
13+
[JsonProperty("query")]
14+
public BaseQuery _Query { get; set; }
1715

1816
public ValidateQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery> querySelector)
1917
{
20-
((IActAsQuery)this)._Query = querySelector(new QueryDescriptor<T>());
18+
this._Query = querySelector(new QueryDescriptor<T>());
2119
return this;
2220
}
2321

@@ -32,9 +30,5 @@ ElasticsearchPathInfo<ValidateQueryQueryString> IPathInfo<ValidateQueryQueryStri
3230

3331
return pathInfo;
3432
}
35-
object ICustomJson.GetCustomJson()
36-
{
37-
return ((IActAsQuery) this)._Query;
38-
}
3933
}
4034
}

src/Nest/Domain/Mapping/Types/MultiFieldMapping.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Runtime.InteropServices;
23
using Nest.Resolvers.Converters;
34
using Newtonsoft.Json;
45
using System;
@@ -11,8 +12,14 @@ public class MultiFieldMapping : IElasticType
1112
{
1213
public PropertyNameMarker Name { get; set; }
1314

15+
private TypeNameMarker _typeOverride;
16+
1417
[JsonProperty("type")]
15-
public virtual TypeNameMarker Type { get { return new TypeNameMarker { Name = "multi_field" }; } }
18+
public virtual TypeNameMarker Type
19+
{
20+
get { return _typeOverride ?? new TypeNameMarker { Name = "multi_field" }; }
21+
set { _typeOverride = value; }
22+
}
1623

1724
[JsonProperty("similarity")]
1825
public string Similarity { get; set; }

src/Nest/Domain/Responses/ClusterStateResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public interface IClusterStateResponse : IResponse
1111
MetadataState Metadata { get; }
1212
RoutingTableState RoutingTable { get; }
1313
RoutingNodesState RoutingNodes { get; }
14+
BlockState Blocks { get; }
1415
}
1516

1617
[JsonObject]
@@ -37,5 +38,8 @@ public ClusterStateResponse()
3738

3839
[JsonProperty("routing_nodes")]
3940
public RoutingNodesState RoutingNodes { get; internal set; }
41+
42+
[JsonProperty("blocks")]
43+
public BlockState Blocks { get; internal set; }
4044
}
4145
}
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
using Newtonsoft.Json;
22
using System.Collections.Generic;
33

4-
namespace Nest
4+
namespace Nest
55
{
6-
public interface IGlobalStatsResponse : IResponse
7-
{
8-
bool OK { get; }
9-
ShardsMetaData Shards { get; }
10-
Stats Stats { get; set; }
6+
public interface IGlobalStatsResponse : IResponse
7+
{
8+
ShardsMetaData Shards { get; }
9+
Stats Stats { get; set; }
1110
Dictionary<string, Stats> Indices { get; set; }
12-
}
11+
}
1312

14-
[JsonObject]
13+
[JsonObject]
1514
public class GlobalStatsResponse : BaseResponse, IGlobalStatsResponse
16-
{
17-
public GlobalStatsResponse()
18-
{
19-
this.IsValid = true;
20-
}
21-
22-
[JsonProperty(PropertyName = "ok")]
23-
public bool OK { get; internal set; }
24-
25-
[JsonProperty(PropertyName = "_shards")]
26-
public ShardsMetaData Shards { get; internal set; }
27-
28-
[JsonProperty(PropertyName = "_all")]
15+
{
16+
17+
[JsonProperty(PropertyName = "_shards")]
18+
public ShardsMetaData Shards { get; internal set; }
19+
20+
[JsonProperty(PropertyName = "_all")]
2921
public Stats Stats { get; set; }
3022

3123
[JsonProperty(PropertyName = "indices")]
3224
[JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))]
33-
public Dictionary<string, Stats> Indices { get; set; }
34-
35-
}
25+
public Dictionary<string, Stats> Indices { get; set; }
26+
27+
}
3628
}

0 commit comments

Comments
 (0)