Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSearch 2.0 essential support #29

Merged
merged 5 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/ApiGenerator/RestSpecification/Core/cat.cluster_manager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"cat.cluster_manager":{
"documentation":{
"url":"https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/",
"description":"Returns information about the cluster-manager node."
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_cat/cluster_manager",
"methods":[
"GET"
]
},
{
"path":"/_cat/master",
"methods":[
"GET"
],
"deprecated":{
"version":"2.0.0",
"description":"To promote inclusive language, please use '/_cat/cluster_manager' instead."
}
}
]
},
"params":{
"format":{
"type":"string",
"description":"a short version of the Accept header, e.g. json, yaml"
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from cluster-manager node (default: false)"
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To promote inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to cluster-manager node"
},
"h":{
"type":"list",
"description":"Comma-separated list of column names to display"
},
"help":{
"type":"boolean",
"description":"Return help information",
"default":false
},
"s":{
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"v":{
"type":"boolean",
"description":"Verbose mode. Display column headers",
"default":false
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

using System.Runtime.Serialization;

namespace OpenSearch.Client
{
[DataContract]
public class CatClusterManagerRecord : ICatRecord
{
[DataMember(Name ="id")]
public string Id { get; set; }

[DataMember(Name ="ip")]
public string Ip { get; set; }

[DataMember(Name ="node")]
public string Node { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

namespace OpenSearch.Client
{
[MapsApi("cat.cluster_manager.json")]
public partial interface ICatClusterManagerRequest { }

public partial class CatClusterManagerRequest { }

public partial class CatClusterManagerDescriptor { }
}
7 changes: 7 additions & 0 deletions src/OpenSearch.Client/Cat/CatNodes/CatNodesRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace OpenSearch.Client
public class CatNodesRecord : ICatRecord
{
public string Build => _b ?? _build;
public string ClusterManager => _cm ?? _cluster_manager;
public string CompletionSize => _completionSize ?? _cs ?? _completion_size;

[DataMember(Name ="cpu")]
Expand Down Expand Up @@ -125,6 +126,12 @@ public class CatNodesRecord : ICatRecord
[DataMember(Name ="build")]
internal string _build { get; set; }

[DataMember(Name ="cm")]
internal string _cm { get; set; }

[DataMember(Name ="cluster_manager")]
internal string _cluster_manager { get; set; }

[DataMember(Name ="completion.size")]
internal string _completion_size { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ public class ClusterOperatingSystemName
[DataContract]
public class ClusterNodeCount
{
[DataMember(Name = "cluster_manager")]
public int ClusterManager { get; internal set; }

[DataMember(Name = "coordinating_only")]
public int CoordinatingOnly { get; internal set; }

Expand Down
3 changes: 3 additions & 0 deletions src/OpenSearch.Client/Cluster/NodesInfo/NodeRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public enum NodeRole
[EnumMember(Value = "master")]
Master,

[EnumMember(Value = "cluster_manager")]
ClusterManager,

[EnumMember(Value = "data")]
Data,

Expand Down
4 changes: 4 additions & 0 deletions src/OpenSearch.Client/CommonOptions/Stats/SegmentsStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

namespace OpenSearch.Client
{
/// <summary>
/// OpenSearch 2.0 has Lucene upgraded up to version 9.0 which doesn't provide memory info for segments.
/// All fields except `count` might be zeroed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might or will?

/// </summary>
[DataContract]
public class SegmentsStats
{
Expand Down
31 changes: 30 additions & 1 deletion src/OpenSearch.Client/Descriptors.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ public CatIndicesDescriptor Index<TOther>()
public CatIndicesDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}

///<summary>Descriptor for Master <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</para></summary>
/// <summary>
/// Descriptor for Master
/// <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</para>
/// Replaced by <see cref="CatClusterManagerDescriptor"/> in OpenSearch 2.0
/// </summary>
public partial class CatMasterDescriptor : RequestDescriptorBase<CatMasterDescriptor, CatMasterRequestParameters, ICatMasterRequest>, ICatMasterRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatMaster;
Expand All @@ -308,6 +312,31 @@ public partial class CatMasterDescriptor : RequestDescriptorBase<CatMasterDescri
public CatMasterDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}

/// <summary>
/// Descriptor for cluster_manager
/// <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/</para>
/// </summary>
public partial class CatClusterManagerDescriptor : RequestDescriptorBase<CatClusterManagerDescriptor, CatClusterManagerRequestParameters, ICatClusterManagerRequest>, ICatClusterManagerRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatClusterManager;
// values part of the url path
// Request parameters
///<summary>a short version of the Accept header, e.g. json, yaml</summary>
public CatClusterManagerDescriptor Format(string format) => Qs("format", format);
///<summary>Comma-separated list of column names to display</summary>
public CatClusterManagerDescriptor Headers(params string[] headers) => Qs("h", headers);
///<summary>Return help information</summary>
public CatClusterManagerDescriptor Help(bool? help = true) => Qs("help", help);
///<summary>Return local information, do not retrieve the state from master node (default: false)</summary>
public CatClusterManagerDescriptor Local(bool? local = true) => Qs("local", local);
///<summary>Explicit operation timeout for connection to master node</summary>
public CatClusterManagerDescriptor ClusterManagerTimeout(Time mastertimeout) => Qs("cluster_manager_timeout", mastertimeout);
///<summary>Comma-separated list of column names or column aliases to sort by</summary>
public CatClusterManagerDescriptor SortByColumns(params string[] sortbycolumns) => Qs("s", sortbycolumns);
///<summary>Verbose mode. Display column headers</summary>
public CatClusterManagerDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}

///<summary>Descriptor for NodeAttributes <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-nodeattrs/</para></summary>
public partial class CatNodeAttributesDescriptor : RequestDescriptorBase<CatNodeAttributesDescriptor, CatNodeAttributesRequestParameters, ICatNodeAttributesRequest>, ICatNodeAttributesRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public bool IsValid
{
get
{
if (Error != null || Type.IsNullOrEmpty()) return false;
if (Error != null) return false;

switch (Operation.ToLowerInvariant())
{
Expand Down
28 changes: 28 additions & 0 deletions src/OpenSearch.Client/OpenSearchClient.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,55 @@ internal CatNamespace(OpenSearchClient client): base(client)
/// <c>GET</c> request to the <c>cat.master</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</a>
/// Replaced by <see cref="ClusterManager(Func&lt;CatClusterManagerDescriptor, ICatClusterManagerRequest&gt;)"/> in OpenSearch 2.0
/// </summary>
public CatResponse<CatMasterRecord> Master(Func<CatMasterDescriptor, ICatMasterRequest> selector = null) => Master(selector.InvokeOrDefault(new CatMasterDescriptor()));
/// <summary>
/// <c>GET</c> request to the <c>cat.master</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</a>
/// Replaced by <see cref="ClusterManagerAsync(Func&lt;CatClusterManagerDescriptor, ICatClusterManagerRequest&gt;, CancellationToken)"/> in OpenSearch 2.0
/// </summary>
public Task<CatResponse<CatMasterRecord>> MasterAsync(Func<CatMasterDescriptor, ICatMasterRequest> selector = null, CancellationToken ct = default) => MasterAsync(selector.InvokeOrDefault(new CatMasterDescriptor()), ct);
/// <summary>
/// <c>GET</c> request to the <c>cat.master</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</a>
/// Replaced by <see cref="ClusterManager(ICatClusterManagerRequest)"/> in OpenSearch 2.0
/// </summary>
public CatResponse<CatMasterRecord> Master(ICatMasterRequest request) => DoCat<ICatMasterRequest, CatMasterRequestParameters, CatMasterRecord>(request);
/// <summary>
/// <c>GET</c> request to the <c>cat.master</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</a>
/// Replaced by <see cref="ClusterManagerAsync(ICatClusterManagerRequest, CancellationToken)"/> in OpenSearch 2.0
/// </summary>
public Task<CatResponse<CatMasterRecord>> MasterAsync(ICatMasterRequest request, CancellationToken ct = default) => DoCatAsync<ICatMasterRequest, CatMasterRequestParameters, CatMasterRecord>(request, ct);
/// <summary>
/// <c>GET</c> request to the <c>cat.cluster_manager</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/</a>
/// </summary>
public CatResponse<CatClusterManagerRecord> ClusterManager(Func<CatClusterManagerDescriptor, ICatClusterManagerRequest> selector = null) => ClusterManager(selector.InvokeOrDefault(new CatClusterManagerDescriptor()));
/// <summary>
/// <c>GET</c> request to the <c>cat.cluster_manager</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/</a>
/// </summary>
public Task<CatResponse<CatClusterManagerRecord>> ClusterManagerAsync(Func<CatClusterManagerDescriptor, ICatClusterManagerRequest> selector = null, CancellationToken ct = default) => ClusterManagerAsync(selector.InvokeOrDefault(new CatClusterManagerDescriptor()), ct);
/// <summary>
/// <c>GET</c> request to the <c>cat.cluster_manager</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/</a>
/// </summary>
public CatResponse<CatClusterManagerRecord> ClusterManager(ICatClusterManagerRequest request) => DoCat<ICatClusterManagerRequest, CatClusterManagerRequestParameters, CatClusterManagerRecord>(request);
/// <summary>
/// <c>GET</c> request to the <c>cat.cluster_manager</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/</a>
/// </summary>
public Task<CatResponse<CatClusterManagerRecord>> ClusterManagerAsync(ICatClusterManagerRequest request, CancellationToken ct = default) => DoCatAsync<ICatClusterManagerRequest, CatClusterManagerRequestParameters, CatClusterManagerRecord>(request, ct);
/// <summary>
/// <c>GET</c> request to the <c>cat.nodeattrs</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-nodeattrs/">https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-nodeattrs/</a>
Expand Down
Loading