Skip to content

Commit

Permalink
Rename master node role to cluster_manager as it was done in Open…
Browse files Browse the repository at this point in the history
…Search.

Ref: opensearch-project/OpenSearch#2480

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
  • Loading branch information
Yury-Fridlyand committed Jun 9, 2022
1 parent cac4d86 commit fbd850d
Show file tree
Hide file tree
Showing 16 changed files with 475 additions and 3 deletions.
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
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
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
73 changes: 72 additions & 1 deletion src/OpenSearch.Client/Requests.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,10 @@ public partial interface ICatMasterRequest : IRequest<CatMasterRequestParameters
{
}

///<summary>Request for Master <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</para></summary>
/// <summary>Request for Master
/// <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/</para>
/// Replaced by <see cref="CatClusterManagerRequest"/> in OpenSearch 2.0
/// </summary>
public partial class CatMasterRequest : PlainRequestBase<CatMasterRequestParameters>, ICatMasterRequest
{
protected ICatMasterRequest Self => this;
Expand Down Expand Up @@ -650,6 +653,74 @@ public bool? Verbose
}
}

[InterfaceDataContract]
public partial interface ICatClusterManagerRequest : IRequest<CatClusterManagerRequestParameters>
{
}

/// <summary>Request for ClusterManager
/// <para>https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/</para>
/// </summary>
public partial class CatClusterManagerRequest : PlainRequestBase<CatClusterManagerRequestParameters>, ICatClusterManagerRequest
{
protected ICatClusterManagerRequest Self => this;
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 string Format
{
get => Q<string>("format");
set
{
Q("format", value);
SetAcceptHeader(value);
}
}

///<summary>Comma-separated list of column names to display</summary>
public string[] Headers
{
get => Q<string[]>("h");
set => Q("h", value);
}

///<summary>Return help information</summary>
public bool? Help
{
get => Q<bool? >("help");
set => Q("help", value);
}

///<summary>Return local information, do not retrieve the state from cluster_manager node (default: false)</summary>
public bool? Local
{
get => Q<bool? >("local");
set => Q("local", value);
}

///<summary>Explicit operation timeout for connection to cluster_manager node</summary>
public Time ClusterManagerTimeout
{
get => Q<Time>("cluster_manager_timeout");
set => Q("cluster_manager_timeout", value);
}

///<summary>Comma-separated list of column names or column aliases to sort by</summary>
public string[] SortByColumns
{
get => Q<string[]>("s");
set => Q("s", value);
}

///<summary>Verbose mode. Display column headers</summary>
public bool? Verbose
{
get => Q<bool? >("v");
set => Q("v", value);
}
}

[InterfaceDataContract]
public partial interface ICatNodeAttributesRequest : IRequest<CatNodeAttributesRequestParameters>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal static class ApiUrlsLookups
internal static ApiUrls NoNamespaceBulk = new ApiUrls(new[]{"_bulk", "{index}/_bulk"});
internal static ApiUrls CatAliases = new ApiUrls(new[]{"_cat/aliases", "_cat/aliases/{name}"});
internal static ApiUrls CatAllocation = new ApiUrls(new[]{"_cat/allocation", "_cat/allocation/{node_id}"});
internal static ApiUrls CatClusterManager = new ApiUrls(new[]{"_cat/cluster_manager"});
internal static ApiUrls CatCount = new ApiUrls(new[]{"_cat/count", "_cat/count/{index}"});
internal static ApiUrls CatFielddata = new ApiUrls(new[]{"_cat/fielddata", "_cat/fielddata/{fields}"});
internal static ApiUrls CatHealth = new ApiUrls(new[]{"_cat/health"});
Expand Down
Loading

0 comments on commit fbd850d

Please sign in to comment.