Skip to content

Commit b42a304

Browse files
committed
Merge branch 'fix/master-5.0.0-alpha3'
2 parents 6d3b794 + 4e72571 commit b42a304

File tree

318 files changed

+17191
-13435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+17191
-13435
lines changed

build/scripts/Paths.fsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,19 @@ module Tooling =
285285

286286
type DnxTooling(exe) =
287287
member this.Exec runtime failedF workingDirectory arguments =
288+
this.ExecWithTimeout runtime failedF workingDirectory arguments (TimeSpan.FromMinutes 30.)
289+
290+
member this.ExecWithTimeout runtime failedF workingDirectory arguments timeout =
288291
match (runtime, hasClr, hasCoreClr) with
289292
| (Core, _, Some c) ->
290293
let proc = c.Process exe
291-
execProcessWithTimeout proc arguments (TimeSpan.FromMinutes 30.)
294+
execProcessWithTimeout proc arguments timeout
292295
| (Desktop, Some d, _) ->
293296
let proc = d.Process exe
294-
execProcessWithTimeout proc arguments (TimeSpan.FromMinutes 30.)
297+
execProcessWithTimeout proc arguments timeout
295298
| (Both, Some d, Some c) ->
296299
let proc = d.Process exe
297-
let result = execProcess proc arguments
300+
let result = execProcessWithTimeout proc arguments timeout
298301
if result <> 0 then failwith (sprintf "Failed to run dnx tooling for %s args: %A" proc arguments)
299302
let proc = c.Process exe
300303
execProcessWithTimeout proc arguments (TimeSpan.FromMinutes 30.)

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class ApiGenerator
1919
{
2020
static readonly RazorMachine RazorHelper = new RazorMachine();
2121

22-
public static void Generate(params string[] folders)
22+
public static void Generate(string downloadBranch, params string[] folders)
2323
{
24-
var spec = CreateRestApiSpecModel(folders);
24+
var spec = CreateRestApiSpecModel(downloadBranch, folders);
2525
var actions = new Dictionary<Action<RestApiSpec>, string>
2626
{
2727
{ GenerateClientInterface, "Client interface" },
@@ -45,7 +45,7 @@ public static void Generate(params string[] folders)
4545
}
4646
}
4747

48-
private static RestApiSpec CreateRestApiSpecModel(string[] folders)
48+
private static RestApiSpec CreateRestApiSpecModel(string downloadBranch, string[] folders)
4949
{
5050
var directories = Directory.GetDirectories(CodeConfiguration.RestSpecificationFolder, "*", SearchOption.AllDirectories)
5151
.Where(f=>folders == null || folders.Length == 0 || folders.Contains(new DirectoryInfo(f).Name))
@@ -68,7 +68,7 @@ private static RestApiSpec CreateRestApiSpecModel(string[] folders)
6868
}
6969
}
7070

71-
return new RestApiSpec { Endpoints = endpoints };
71+
return new RestApiSpec { Endpoints = endpoints, Commit = downloadBranch };
7272
}
7373

7474

src/CodeGeneration/CodeGeneration.LowLevelClient/CodeConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private static string Root
3333
public static string EsNetFolder { get; } = $@"{Root}..\..\..\src\Elasticsearch.Net\";
3434
public static string ViewFolder { get; } = $@"{Root}Views\";
3535
public static string RestSpecificationFolder { get; } = $@"{Root}RestSpecification\";
36+
public static string LastDownloadedVersionFile { get; } = Path.Combine(Root, "last_downloaded_version.txt");
3637

3738
public static readonly Dictionary<string, string> MethodNameOverrides =
3839
(from f in new DirectoryInfo(NestFolder).GetFiles("*.cs", SearchOption.AllDirectories)

src/CodeGeneration/CodeGeneration.LowLevelClient/CodeGeneration.LowLevelClient.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@
6262
<Compile Include="Extensions.cs" />
6363
<Compile Include="Overrides\Allow404\ApiEndpointsThatAllow404.cs" />
6464
<Compile Include="Overrides\Descriptors\ClearCacheDescriptorOverrides.cs" />
65+
<Compile Include="Overrides\Descriptors\ClearCachedRealmsDescriptorOverrides.cs" />
66+
<Compile Include="Overrides\Descriptors\ClearCachedRolesDescriptorOverrides.cs" />
67+
<Compile Include="Overrides\Descriptors\DescriptorOverridesBase.cs" />
6568
<Compile Include="Overrides\Descriptors\FieldStatsDescriptorOverrides.cs" />
69+
<Compile Include="Overrides\Descriptors\GraphExploreDescriptorOverrides.cs" />
6670
<Compile Include="Overrides\Descriptors\IDescriptorOverrides.cs" />
6771
<Compile Include="Overrides\Descriptors\IndicesStatsDescriptorOverrides.cs" />
6872
<Compile Include="Overrides\Descriptors\MultiTermVectorsDescriptorOverrides.cs" />
6973
<Compile Include="Overrides\Descriptors\NodesHotThreadsDescriptorOverrides.cs" />
7074
<Compile Include="Overrides\Descriptors\PutIndexTemplateDescriptorOverrides.cs" />
75+
<Compile Include="Overrides\Descriptors\ReindexRethrottleDescriptorOverrides.cs" />
7176
<Compile Include="Overrides\Descriptors\ScrollDescriptorOverrides.cs" />
7277
<Compile Include="Overrides\Descriptors\SearchDescriptorOverrides.cs" />
7378
<Compile Include="Overrides\Descriptors\ReindexOnServerDescriptorOverrides.cs" />
@@ -96,6 +101,7 @@
96101
<None Include="RestSpecification\Core\cat.segments.json" />
97102
<None Include="RestSpecification\Core\cat.shards.json" />
98103
<None Include="RestSpecification\Core\cat.snapshots.json" />
104+
<None Include="RestSpecification\Core\cat.tasks.json" />
99105
<None Include="RestSpecification\Core\cat.thread_pool.json" />
100106
<None Include="RestSpecification\Core\clear_scroll.json" />
101107
<None Include="RestSpecification\Core\cluster.allocation_explain.json" />
@@ -109,6 +115,7 @@
109115
<None Include="RestSpecification\Core\count.json" />
110116
<None Include="RestSpecification\Core\count_percolate.json" />
111117
<None Include="RestSpecification\Core\delete.json" />
118+
<None Include="RestSpecification\Core\delete_by_query.json" />
112119
<None Include="RestSpecification\Core\delete_script.json" />
113120
<None Include="RestSpecification\Core\delete_template.json" />
114121
<None Include="RestSpecification\Core\exists.json" />
@@ -196,6 +203,16 @@
196203
<None Include="RestSpecification\XPack\License\license.delete.json" />
197204
<None Include="RestSpecification\XPack\License\license.get.json" />
198205
<None Include="RestSpecification\XPack\License\license.post.json" />
206+
<None Include="RestSpecification\XPack\Security\security.change_password.json" />
207+
<None Include="RestSpecification\XPack\Security\security.authenticate.json" />
208+
<None Include="RestSpecification\XPack\Security\security.clear_cached_realms.json" />
209+
<None Include="RestSpecification\XPack\Security\security.clear_cached_roles.json" />
210+
<None Include="RestSpecification\XPack\Security\security.delete_role.json" />
211+
<None Include="RestSpecification\XPack\Security\security.delete_user.json" />
212+
<None Include="RestSpecification\XPack\Security\security.get_role.json" />
213+
<None Include="RestSpecification\XPack\Security\security.get_user.json" />
214+
<None Include="RestSpecification\XPack\Security\security.put_role.json" />
215+
<None Include="RestSpecification\XPack\Security\security.put_user.json" />
199216
<None Include="RestSpecification\XPack\Shield\shield.authenticate.json" />
200217
<None Include="RestSpecification\XPack\Shield\shield.clear_cached_realms.json" />
201218
<None Include="RestSpecification\XPack\Shield\shield.clear_cached_roles.json" />

src/CodeGeneration/CodeGeneration.LowLevelClient/CodeGeneration.LowLevelClient.project.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"locked": false,
3-
"version": 1,
3+
"version": 2,
44
"targets": {
55
".NETFramework,Version=v4.5": {},
66
".NETFramework,Version=v4.5/win": {}

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiEndpoint.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ public static void PatchMethod(CsharpMethod method)
322322
{
323323
skipList = overrides.SkipQueryStringParams ?? skipList;
324324
renameList = overrides.RenameQueryStringParams ?? renameList;
325+
326+
overrides.PatchMethod(method);
325327
}
326328
}
327329

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiQueryParameters.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34

45
namespace CodeGeneration.LowLevelClient.Domain
@@ -11,6 +12,12 @@ public class ApiQueryParameters
1112
public string Description { get; set; }
1213
public IEnumerable<string> Options { get; set; }
1314

15+
public ApiQueryParameters()
16+
{
17+
FluentGenerator = (queryStringParamName, mm, original, setter) =>
18+
$"public {queryStringParamName} {mm.ToPascalCase()}({CsharpType(mm)} {mm}) => this.AddQueryString(\"{original}\", {setter});";
19+
}
20+
1421
public string CsharpType(string paramName)
1522
{
1623
switch (this.Type)
@@ -50,5 +57,11 @@ public string HighLevelType(string paramName)
5057
return csharpType;
5158
}
5259
}
60+
61+
public Func<string, string, string, string, string> Generator { get; set; } =
62+
(fieldType, mm, original, setter) =>
63+
$"public {fieldType} {mm} {{ get {{ return Q<{fieldType}>(\"{original}\"); }} set {{ Q(\"{original}\", {setter}); }} }}";
64+
65+
public Func<string, string, string, string, string> FluentGenerator { get; set; }
5366
}
5467
}

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiUrlPart.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

34
namespace CodeGeneration.LowLevelClient.Domain
45
{
@@ -14,6 +15,8 @@ public string ClrTypeName
1415
{
1516
get
1617
{
18+
if (ClrTypeNameOverride != null) return ClrTypeNameOverride;
19+
1720
switch(this.Name)
1821
{
1922
case "index": return this.Type == "string" ? "IndexName" : "Indices";
@@ -41,6 +44,8 @@ public string ClrTypeName
4144
}
4245
}
4346

47+
public string ClrTypeNameOverride { get; set; }
48+
4449
public string InterfaceName
4550
{
4651
get

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public IEnumerable<Constructor> RequestConstructors()
116116
var generated = $"public {m}({par}) : base({routing}){{}}";
117117

118118
// special case SearchRequest<T> to pass the type of T as the type, when only the index is specified.
119-
if (m == "SearchRequest" && cp.Count() == 1 && !string.IsNullOrEmpty(this.RequestTypeGeneric))
119+
if ((m == "SearchRequest") && cp.Count() == 1 && !string.IsNullOrEmpty(this.RequestTypeGeneric))
120120
{
121121
var generic = this.RequestTypeGeneric.Replace("<", "").Replace(">", "");
122122
generated = $"public {m}({par}) : this({cp.First().Key}, typeof({generic})){{}}";
@@ -191,7 +191,17 @@ public IEnumerable<Constructor> DescriptorConstructors()
191191
{
192192
doc += "\r\n" + string.Join("\t\t\r\n", cp.Select(p => $"///<param name=\"{p.Key}\"> this parameter is required</param>"));
193193
}
194-
var c = new Constructor { Generated = $"public {m}({par}) : base({routing}){{}}", Description = doc };
194+
195+
var generated = $"public {m}({par}) : base({routing}){{}}";
196+
197+
// Add typeof(T) as the default type when only index specified
198+
if ((m == "DeleteByQueryDescriptor" || m == "UpdateByQueryDescriptor") && cp.Count() == 1 && !string.IsNullOrEmpty(this.RequestTypeGeneric))
199+
{
200+
var generic = this.RequestTypeGeneric.Replace("<", "").Replace(">", "");
201+
generated = $"public {m}({par}) : base({routing}.Required(\"type\", (Types)typeof({generic}))){{}}";
202+
}
203+
204+
var c = new Constructor { Generated = generated, Description = doc };
195205
ctors.Add(c);
196206
}
197207
if (IsDocumentPath && !string.IsNullOrEmpty(this.DescriptorTypeGeneric))

src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/ClearCacheDescriptorOverrides.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
namespace CodeGeneration.LowLevelClient.Overrides.Descriptors
66
{
77
// ReSharper disable once UnusedMember.Global
8-
public class ClearCacheDescriptorOverrides : IDescriptorOverrides
8+
public class ClearCacheDescriptorOverrides : DescriptorOverridesBase
99
{
10-
public IEnumerable<string> SkipQueryStringParams => new []
10+
public override IEnumerable<string> SkipQueryStringParams => new []
1111
{
1212
"fielddata"
1313
};
14-
15-
public IDictionary<string, string> RenameQueryStringParams => null;
1614
}
1715
}

0 commit comments

Comments
 (0)