Skip to content

Commit aa596a3

Browse files
committed
Add support for _license related API's
- License.LoadFromDisk(path) - Backported elasticsearch node improvements from master branch - Added bat file generations for the various clusters, allows you to manually start one of our test clusters with the right settings - Make sure tests that inherit ApiTestBase directly do not use a "real" client in `mixed` testing mode - Validate license information on startup, if this fails all tests fails. From the commandline we always start a fresh cluster so the trial license'll stay valid. If you manually start a node with no license but you have ES_LICENSE_FILE pointing to a license file we will try and register that. Conflicts: src/Nest/Nest.csproj src/Nest/_Generated/_Requests.generated.cs src/Tests/ClientConcepts/ConnectionPooling/Sniffing/RoleDetection.doc.cs src/Tests/Framework/Integration/Process/ElasticsearchNode.cs src/Tests/Framework/Integration/Process/ElasticsearchVersionInfo.cs src/Tests/Tests.csproj
1 parent 2f8670e commit aa596a3

40 files changed

+1252
-205
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
<None Include="RestSpecification\Core\update_by_query.json" />
188188
<None Include="RestSpecification\DeleteByQuery\delete_by_query.json" />
189189
<None Include="RestSpecification\XPack\Graph\graph.explore.json" />
190+
<None Include="RestSpecification\XPack\License\license.delete.json" />
190191
<None Include="RestSpecification\XPack\License\license.get.json" />
191192
<None Include="RestSpecification\XPack\License\license.post.json" />
192193
<None Include="RestSpecification\XPack\Shield\shield.authenticate.json" />

src/CodeGeneration/CodeGeneration.LowLevelClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void Main(string[] args)
2828
if (redownloadCoreSpecification)
2929
RestSpecDownloader.Download(downloadBranch);
3030

31-
ApiGenerator.Generate("Core", "DeleteByQuery", "Graph");
31+
ApiGenerator.Generate("Core", "DeleteByQuery", "Graph", "License");
3232
//ApiGenerator.Generate("Core", "Graph", "License");
3333
//ApiGenerator.Generate(); //generates everything under ApiSpecification
3434
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"license.delete": {
3+
"documentation": "https://www.elastic.co/guide/en/shield/current/license-management.html",
4+
"methods": ["DELETE"],
5+
"url": {
6+
"path": "/_license",
7+
"paths": ["/_license"],
8+
"parts" : { },
9+
"params": { }
10+
},
11+
"body": null
12+
}
13+
}

src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4545,4 +4545,66 @@ public class GraphExploreRequestParameters : FluentRequestParameters<GraphExplor
45454545
public GraphExploreRequestParameters FilterPath(string filter_path) => this.AddQueryString("filter_path", filter_path);
45464546

45474547
}
4548+
4549+
///<summary>Request parameters descriptor for LicenseDelete
4550+
///<pre>
4551+
///https://www.elastic.co/guide/en/shield/current/license-management.html
4552+
///</pre>
4553+
///</summary>
4554+
public class DeleteLicenseRequestParameters : FluentRequestParameters<DeleteLicenseRequestParameters>
4555+
{
4556+
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
4557+
4558+
///<summary>The URL-encoded request definition</summary>
4559+
public DeleteLicenseRequestParameters Source(string source) => this.AddQueryString("source", source);
4560+
4561+
4562+
///<summary>Comma separated list of filters used to reduce the response returned by Elasticsearch</summary>
4563+
public DeleteLicenseRequestParameters FilterPath(string filter_path) => this.AddQueryString("filter_path", filter_path);
4564+
4565+
}
4566+
4567+
///<summary>Request parameters descriptor for LicenseGet
4568+
///<pre>
4569+
///https://www.elastic.co/guide/en/shield/current/license-management.html
4570+
///</pre>
4571+
///</summary>
4572+
public class GetLicenseRequestParameters : FluentRequestParameters<GetLicenseRequestParameters>
4573+
{
4574+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
4575+
4576+
///<summary>Return local information, do not retrieve the state from master node (default: false)</summary>
4577+
public GetLicenseRequestParameters Local(bool local) => this.AddQueryString("local", local);
4578+
4579+
4580+
///<summary>The URL-encoded request definition</summary>
4581+
public GetLicenseRequestParameters Source(string source) => this.AddQueryString("source", source);
4582+
4583+
4584+
///<summary>Comma separated list of filters used to reduce the response returned by Elasticsearch</summary>
4585+
public GetLicenseRequestParameters FilterPath(string filter_path) => this.AddQueryString("filter_path", filter_path);
4586+
4587+
}
4588+
4589+
///<summary>Request parameters descriptor for LicensePost
4590+
///<pre>
4591+
///https://www.elastic.co/guide/en/shield/current/license-management.html
4592+
///</pre>
4593+
///</summary>
4594+
public class PostLicenseRequestParameters : FluentRequestParameters<PostLicenseRequestParameters>
4595+
{
4596+
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
4597+
4598+
///<summary>whether the user has acknowledged acknowledge messages (default: false)</summary>
4599+
public PostLicenseRequestParameters Acknowledge(bool acknowledge) => this.AddQueryString("acknowledge", acknowledge);
4600+
4601+
4602+
///<summary>The URL-encoded request definition</summary>
4603+
public PostLicenseRequestParameters Source(string source) => this.AddQueryString("source", source);
4604+
4605+
4606+
///<summary>Comma separated list of filters used to reduce the response returned by Elasticsearch</summary>
4607+
public PostLicenseRequestParameters FilterPath(string filter_path) => this.AddQueryString("filter_path", filter_path);
4608+
4609+
}
45484610
}

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7871,6 +7871,86 @@ public ElasticsearchResponse<T> GraphExplore<T>(string index, string type, PostD
78717871
public Task<ElasticsearchResponse<T>> GraphExploreAsync<T>(string index, string type, PostData<object> body, Func<GraphExploreRequestParameters, GraphExploreRequestParameters> requestParameters = null)
78727872
where T : class => this.DoRequestAsync<T>(POST, Url($"{index.NotNull("index")}/{type.NotNull("type")}/_graph/explore"), body, _params(requestParameters));
78737873

7874+
///<summary>Represents a DELETE on /_license
7875+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7876+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7877+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7878+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7879+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7880+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7881+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7882+
///</summary>
7883+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7884+
public ElasticsearchResponse<T> LicenseDelete<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null)
7885+
where T : class => this.DoRequest<T>(DELETE, Url($"_license"), null, _params(requestParameters));
7886+
7887+
///<summary>Represents a DELETE on /_license
7888+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7889+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7890+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7891+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7892+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7893+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7894+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7895+
///</summary>
7896+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7897+
public Task<ElasticsearchResponse<T>> LicenseDeleteAsync<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null)
7898+
where T : class => this.DoRequestAsync<T>(DELETE, Url($"_license"), null, _params(requestParameters));
7899+
7900+
///<summary>Represents a GET on /_license
7901+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7902+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7903+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7904+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7905+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7906+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7907+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7908+
///</summary>
7909+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7910+
public ElasticsearchResponse<T> LicenseGet<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null)
7911+
where T : class => this.DoRequest<T>(GET, Url($"_license"), null, _params(requestParameters));
7912+
7913+
///<summary>Represents a GET on /_license
7914+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7915+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7916+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7917+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7918+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7919+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7920+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7921+
///</summary>
7922+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7923+
public Task<ElasticsearchResponse<T>> LicenseGetAsync<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null)
7924+
where T : class => this.DoRequestAsync<T>(GET, Url($"_license"), null, _params(requestParameters));
7925+
7926+
///<summary>Represents a PUT on /_license
7927+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7928+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7929+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7930+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7931+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7932+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7933+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7934+
///</summary>
7935+
///<param name="body">licenses to be installed</param>
7936+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7937+
public ElasticsearchResponse<T> LicensePost<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null)
7938+
where T : class => this.DoRequest<T>(PUT, Url($"_license"), body, _params(requestParameters));
7939+
7940+
///<summary>Represents a PUT on /_license
7941+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7942+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7943+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7944+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7945+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7946+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7947+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7948+
///</summary>
7949+
///<param name="body">licenses to be installed</param>
7950+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7951+
public Task<ElasticsearchResponse<T>> LicensePostAsync<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null)
7952+
where T : class => this.DoRequestAsync<T>(PUT, Url($"_license"), body, _params(requestParameters));
7953+
78747954

78757955
}
78767956
}

src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7330,5 +7330,79 @@ public partial interface IElasticLowLevelClient
73307330
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
73317331
Task<ElasticsearchResponse<T>> GraphExploreAsync<T>(string index, string type, PostData<object> body, Func<GraphExploreRequestParameters, GraphExploreRequestParameters> requestParameters = null) where T : class;
73327332

7333+
///<summary>Represents a DELETE on /_license
7334+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7335+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7336+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7337+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7338+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7339+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7340+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7341+
///</summary>
7342+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7343+
ElasticsearchResponse<T> LicenseDelete<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null) where T : class;
7344+
7345+
///<summary>Represents a DELETE on /_license
7346+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7347+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7348+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7349+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7350+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7351+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7352+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7353+
///</summary>
7354+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7355+
Task<ElasticsearchResponse<T>> LicenseDeleteAsync<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null) where T : class;
7356+
7357+
///<summary>Represents a GET on /_license
7358+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7359+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7360+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7361+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7362+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7363+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7364+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7365+
///</summary>
7366+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7367+
ElasticsearchResponse<T> LicenseGet<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null) where T : class;
7368+
7369+
///<summary>Represents a GET on /_license
7370+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7371+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7372+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7373+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7374+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7375+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7376+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7377+
///</summary>
7378+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7379+
Task<ElasticsearchResponse<T>> LicenseGetAsync<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null) where T : class;
7380+
7381+
///<summary>Represents a PUT on /_license
7382+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7383+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7384+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7385+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7386+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7387+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7388+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7389+
///</summary>
7390+
///<param name="body">licenses to be installed</param>
7391+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7392+
ElasticsearchResponse<T> LicensePost<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null) where T : class;
7393+
7394+
///<summary>Represents a PUT on /_license
7395+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7396+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7397+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7398+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7399+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7400+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7401+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7402+
///</summary>
7403+
///<param name="body">licenses to be installed</param>
7404+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7405+
Task<ElasticsearchResponse<T>> LicensePostAsync<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null) where T : class;
7406+
73337407
}
73347408
}

src/Nest/Nest.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,18 @@
11671167
<Compile Include="XPack\Graph\Explore\Request\GraphVertexInclude.cs" />
11681168
<Compile Include="XPack\Graph\Explore\Request\Hop.cs" />
11691169
<Compile Include="XPack\Graph\Explore\Request\SampleDiversity.cs" />
1170+
<Compile Include="XPack\License\DeleteLicense\ElasticClient-DeleteLicense.cs" />
1171+
<Compile Include="XPack\License\GetLicense\ElasticClient-GetLicense.cs" />
1172+
<Compile Include="XPack\License\GetLicense\GetLicenseRequest.cs" />
1173+
<Compile Include="XPack\License\GetLicense\GetLicenseResponse.cs" />
1174+
<Compile Include="XPack\License\GetLicense\LicenseStatus.cs" />
1175+
<Compile Include="XPack\License\GetLicense\LicenseType.cs" />
1176+
<Compile Include="XPack\License\DeleteLicense\DeleteLicenseRequest.cs" />
1177+
<Compile Include="XPack\License\DeleteLicense\DeleteLicenseResponse.cs" />
1178+
<Compile Include="XPack\License\PostLicense\ElasticClient-PostLicense.cs" />
1179+
<Compile Include="XPack\License\PostLicense\LicenseAcknowledgement.cs" />
1180+
<Compile Include="XPack\License\PostLicense\PostLicenseRequest.cs" />
1181+
<Compile Include="XPack\License\PostLicense\PostLicenseResponse.cs" />
11701182
<Compile Include="_Generated\_Descriptors.generated.cs" />
11711183
<Compile Include="_Generated\_LowLevelDispatch.generated.cs" />
11721184
<Compile Include="_Generated\_RequestParametersExtensions.Generated.cs" />

0 commit comments

Comments
 (0)