Skip to content

Commit f7fd847

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.
1 parent 2652a13 commit f7fd847

40 files changed

+1378
-286
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
<None Include="RestSpecification\Core\update_by_query.json" />
195195
<None Include="RestSpecification\DeleteByQuery\delete_by_query.json" />
196196
<None Include="RestSpecification\XPack\Graph\graph.explore.json" />
197+
<None Include="RestSpecification\XPack\License\license.delete.json" />
197198
<None Include="RestSpecification\XPack\License\license.get.json" />
198199
<None Include="RestSpecification\XPack\License\license.post.json" />
199200
<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
@@ -4541,4 +4541,66 @@ public class GraphExploreRequestParameters : FluentRequestParameters<GraphExplor
45414541
public GraphExploreRequestParameters FilterPath(string filter_path) => this.AddQueryString("filter_path", filter_path);
45424542

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

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

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

8408+
///<summary>Represents a DELETE on /_license
8409+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
8410+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
8411+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
8412+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
8413+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
8414+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
8415+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
8416+
///</summary>
8417+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
8418+
public ElasticsearchResponse<T> LicenseDelete<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null)
8419+
where T : class => this.DoRequest<T>(DELETE, Url($"_license"), null, _params(requestParameters));
8420+
8421+
///<summary>Represents a DELETE on /_license
8422+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
8423+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
8424+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
8425+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
8426+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
8427+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
8428+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
8429+
///</summary>
8430+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
8431+
public Task<ElasticsearchResponse<T>> LicenseDeleteAsync<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null)
8432+
where T : class => this.DoRequestAsync<T>(DELETE, Url($"_license"), null, _params(requestParameters));
8433+
8434+
///<summary>Represents a GET on /_license
8435+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
8436+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
8437+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
8438+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
8439+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
8440+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
8441+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
8442+
///</summary>
8443+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
8444+
public ElasticsearchResponse<T> LicenseGet<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null)
8445+
where T : class => this.DoRequest<T>(GET, Url($"_license"), null, _params(requestParameters));
8446+
8447+
///<summary>Represents a GET on /_license
8448+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
8449+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
8450+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
8451+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
8452+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
8453+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
8454+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
8455+
///</summary>
8456+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
8457+
public Task<ElasticsearchResponse<T>> LicenseGetAsync<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null)
8458+
where T : class => this.DoRequestAsync<T>(GET, Url($"_license"), null, _params(requestParameters));
8459+
8460+
///<summary>Represents a PUT on /_license
8461+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
8462+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
8463+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
8464+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
8465+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
8466+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
8467+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
8468+
///</summary>
8469+
///<param name="body">licenses to be installed</param>
8470+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
8471+
public ElasticsearchResponse<T> LicensePost<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null)
8472+
where T : class => this.DoRequest<T>(PUT, Url($"_license"), body, _params(requestParameters));
8473+
8474+
///<summary>Represents a PUT on /_license
8475+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
8476+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
8477+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
8478+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
8479+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
8480+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
8481+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
8482+
///</summary>
8483+
///<param name="body">licenses to be installed</param>
8484+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
8485+
public Task<ElasticsearchResponse<T>> LicensePostAsync<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null)
8486+
where T : class => this.DoRequestAsync<T>(PUT, Url($"_license"), body, _params(requestParameters));
8487+
84088488

84098489
}
84108490
}

src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs

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

7831+
///<summary>Represents a DELETE on /_license
7832+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7833+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7834+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7835+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7836+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7837+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7838+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7839+
///</summary>
7840+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7841+
ElasticsearchResponse<T> LicenseDelete<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null) where T : class;
7842+
7843+
///<summary>Represents a DELETE on /_license
7844+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7845+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7846+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7847+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7848+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7849+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7850+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7851+
///</summary>
7852+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7853+
Task<ElasticsearchResponse<T>> LicenseDeleteAsync<T>(Func<DeleteLicenseRequestParameters, DeleteLicenseRequestParameters> requestParameters = null) where T : class;
7854+
7855+
///<summary>Represents a GET on /_license
7856+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7857+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7858+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7859+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7860+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7861+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7862+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7863+
///</summary>
7864+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7865+
ElasticsearchResponse<T> LicenseGet<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null) where T : class;
7866+
7867+
///<summary>Represents a GET on /_license
7868+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7869+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7870+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7871+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7872+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7873+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7874+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7875+
///</summary>
7876+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7877+
Task<ElasticsearchResponse<T>> LicenseGetAsync<T>(Func<GetLicenseRequestParameters, GetLicenseRequestParameters> requestParameters = null) where T : class;
7878+
7879+
///<summary>Represents a PUT on /_license
7880+
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
7881+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7882+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7883+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7884+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7885+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7886+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7887+
///</summary>
7888+
///<param name="body">licenses to be installed</param>
7889+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7890+
ElasticsearchResponse<T> LicensePost<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null) where T : class;
7891+
7892+
///<summary>Represents a PUT on /_license
7893+
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
7894+
///<para> - T, an object you own that the elasticsearch response will be deserialized to </para>
7895+
///<para> - byte[], no deserialization, but the response stream will be closed </para>
7896+
///<para> - Stream, no deserialization, response stream is your responsibility </para>
7897+
///<para> - VoidResponse, no deserialization, response stream never read and closed </para>
7898+
///<para> - DynamicDictionary, a dynamic aware dictionary that can be safely traversed to any depth </para>
7899+
///<para>See also: https://www.elastic.co/guide/en/shield/current/license-management.html </para>
7900+
///</summary>
7901+
///<param name="body">licenses to be installed</param>
7902+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
7903+
Task<ElasticsearchResponse<T>> LicensePostAsync<T>(PostData<object> body, Func<PostLicenseRequestParameters, PostLicenseRequestParameters> requestParameters = null) where T : class;
7904+
78317905
}
78327906
}

src/Nest/Nest.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,18 @@
11951195
<Compile Include="XPack\Graph\Explore\Request\GraphVertexInclude.cs" />
11961196
<Compile Include="XPack\Graph\Explore\Request\Hop.cs" />
11971197
<Compile Include="XPack\Graph\Explore\Request\SampleDiversity.cs" />
1198+
<Compile Include="XPack\License\DeleteLicense\ElasticClient-DeleteLicense.cs" />
1199+
<Compile Include="XPack\License\GetLicense\ElasticClient-GetLicense.cs" />
1200+
<Compile Include="XPack\License\GetLicense\GetLicenseRequest.cs" />
1201+
<Compile Include="XPack\License\GetLicense\GetLicenseResponse.cs" />
1202+
<Compile Include="XPack\License\GetLicense\LicenseStatus.cs" />
1203+
<Compile Include="XPack\License\GetLicense\LicenseType.cs" />
1204+
<Compile Include="XPack\License\DeleteLicense\DeleteLicenseRequest.cs" />
1205+
<Compile Include="XPack\License\DeleteLicense\DeleteLicenseResponse.cs" />
1206+
<Compile Include="XPack\License\PostLicense\ElasticClient-PostLicense.cs" />
1207+
<Compile Include="XPack\License\PostLicense\LicenseAcknowledgement.cs" />
1208+
<Compile Include="XPack\License\PostLicense\PostLicenseRequest.cs" />
1209+
<Compile Include="XPack\License\PostLicense\PostLicenseResponse.cs" />
11981210
<Compile Include="_Generated\_Descriptors.generated.cs" />
11991211
<Compile Include="_Generated\_LowLevelDispatch.generated.cs" />
12001212
<Compile Include="_Generated\_RequestParametersExtensions.Generated.cs" />

0 commit comments

Comments
 (0)