Skip to content

Commit

Permalink
Implement cat.segment_replication
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Jan 24, 2024
1 parent ad271b8 commit c6c7c85
Show file tree
Hide file tree
Showing 12 changed files with 1,149 additions and 117 deletions.
25 changes: 1 addition & 24 deletions src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,7 @@ public static class CodeConfiguration
new("{create,delete}_pit"),
new("{delete,get}_all_pits"),

new("cat.aliases"),
new("cat.allocation"),
new("cat.all_pit_segments"),
new("cat.cluster_manager"),
new("cat.count"),
new("cat.fielddata"),
new("cat.health"),
new("cat.help"),
new("cat.indices"),
new("cat.master"),
new("cat.nodeattrs"),
new("cat.nodes"),
new("cat.pending_tasks"),
new("cat.pit_segments"),
new("cat.plugins"),
new("cat.recovery"),
new("cat.repositories"),
new("cat.segments"),
new("cat.shards"),
new("cat.snapshots"),
new("cat.tasks"),
new("cat.templates"),
new("cat.thread_pool"),

new("cat.*"),
new("cluster.*"),
new("dangling_indices.*"),

Expand Down
563 changes: 470 additions & 93 deletions src/ApiGenerator/OpenSearch.openapi.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* 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.
*/

using System.Runtime.Serialization;

namespace OpenSearch.Client;

[DataContract]
public class CatSegmentReplicationRecord : ICatRecord
{
[DataMember(Name = "shardId")]
public string ShardId { get; set; }

[DataMember(Name = "target_node")]
public string TargetNode { get; set; }

[DataMember(Name = "target_host")]
public string TargetHost { get; set; }

[DataMember(Name = "checkpoints_behind")]
public string CheckpointsBehind { get; set; }

[DataMember(Name = "bytes_behind")]
public string BytesBehind { get; set; }

[DataMember(Name = "current_lag")]
public string CurrentLag { get; set; }

[DataMember(Name = "last_completed_lag")]
public string LastCompletedLag { get; set; }

[DataMember(Name = "rejected_requests")]
public string RejectedRequests { get; set; }

[DataMember(Name = "stage")]
public string Stage { get; set; }

[DataMember(Name = "time")]
public string Time { get; set; }

[DataMember(Name = "files_fetched")]
public string FilesFetched { get; set; }

[DataMember(Name = "files_percent")]
public string FilesPercent { get; set; }

[DataMember(Name = "bytes_fetched")]
public string BytesFetched { get; set; }

[DataMember(Name = "bytes_percent")]
public string BytesPercent { get; set; }

[DataMember(Name = "start_time")]
public string StartTime { get; set; }

[DataMember(Name = "stop_time")]
public string StopTime { get; set; }

[DataMember(Name = "files")]
public string Files { get; set; }

[DataMember(Name = "files_total")]
public string FilesTotal { get; set; }

[DataMember(Name = "bytes")]
public string Bytes { get; set; }

[DataMember(Name = "bytes_total")]
public string BytesTotal { get; set; }

[DataMember(Name = "replicating_stage_time_taken")]
public string ReplicatingStageTimeTaken { get; set; }

[DataMember(Name = "get_checkpoint_info_stage_time_taken")]
public string GetCheckpointInfoStageTimeTaken { get; set; }

[DataMember(Name = "file_diff_stage_time_taken")]
public string FileDiffStageTimeTaken { get; set; }

[DataMember(Name = "get_files_stage_time_taken")]
public string GetFilesStageTimeTaken { get; set; }

[DataMember(Name = "finalize_replication_stage_time_taken")]
public string FinalizeReplicationStageTimeTaken { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* 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.
*/

namespace OpenSearch.Client;

[MapsApi("cat.segment_replication")]
public partial interface ICatSegmentReplicationRequest { }

public partial class CatSegmentReplicationRequest { }

public partial class CatSegmentReplicationDescriptor { }
3 changes: 3 additions & 0 deletions src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ internal static partial class ApiUrlsLookups

internal static readonly ApiUrls CatRepositories = new(new[] { "_cat/repositories" });

internal static readonly ApiUrls CatSegmentReplication =
new(new[] { "_cat/segment_replication", "_cat/segment_replication/{index}" });

internal static readonly ApiUrls CatSegments =
new(new[] { "_cat/segments", "_cat/segments/{index}" });

Expand Down
91 changes: 91 additions & 0 deletions src/OpenSearch.Client/_Generated/Descriptors.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,97 @@ public CatRepositoriesDescriptor SortByColumns(params string[] sortbycolumns) =>
public CatRepositoriesDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}

/// <summary>Descriptor for SegmentReplication <para>https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/</para></summary>
public partial class CatSegmentReplicationDescriptor
: RequestDescriptorBase<
CatSegmentReplicationDescriptor,
CatSegmentReplicationRequestParameters,
ICatSegmentReplicationRequest
>,
ICatSegmentReplicationRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatSegmentReplication;

/// <summary>/_cat/segment_replication</summary>
public CatSegmentReplicationDescriptor()
: base() { }

/// <summary>/_cat/segment_replication/{index}</summary>
/// <param name="index">Optional, accepts null</param>
public CatSegmentReplicationDescriptor(Indices index)
: base(r => r.Optional("index", index)) { }

// values part of the url path
Indices ICatSegmentReplicationRequest.Index => Self.RouteValues.Get<Indices>("index");

/// <summary>Comma-separated list or wildcard expression of index names to limit the returned information.</summary>
public CatSegmentReplicationDescriptor Index(Indices index) =>
Assign(index, (a, v) => a.RouteValues.Optional("index", v));

/// <summary>a shortcut into calling Index(typeof(TOther))</summary>
public CatSegmentReplicationDescriptor Index<TOther>()
where TOther : class =>
Assign(typeof(TOther), (a, v) => a.RouteValues.Optional("index", (Indices)v));

/// <summary>A shortcut into calling Index(Indices.All)</summary>
public CatSegmentReplicationDescriptor AllIndices() => Index(Indices.All);

// Request parameters
/// <summary>If `true`, the response only includes ongoing segment replication events.</summary>
public CatSegmentReplicationDescriptor ActiveOnly(bool? activeonly = true) =>
Qs("active_only", activeonly);

/// <summary>Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified).</summary>
public CatSegmentReplicationDescriptor AllowNoIndices(bool? allownoindices = true) =>
Qs("allow_no_indices", allownoindices);

/// <summary>The unit in which to display byte values.</summary>
public CatSegmentReplicationDescriptor Bytes(Bytes? bytes) => Qs("bytes", bytes);

/// <summary>If `true`, the response only includes latest completed segment replication events.</summary>
public CatSegmentReplicationDescriptor CompletedOnly(bool? completedonly = true) =>
Qs("completed_only", completedonly);

/// <summary>If `true`, the response includes detailed information about segment replications.</summary>
public CatSegmentReplicationDescriptor Detailed(bool? detailed = true) =>
Qs("detailed", detailed);

/// <summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
public CatSegmentReplicationDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) =>
Qs("expand_wildcards", expandwildcards);

/// <summary>A short version of the Accept header, e.g. json, yaml.</summary>
public CatSegmentReplicationDescriptor Format(string format) => Qs("format", format);

/// <summary>Comma-separated list of column names to display.</summary>
public CatSegmentReplicationDescriptor Headers(params string[] headers) => Qs("h", headers);

/// <summary>Return help information.</summary>
public CatSegmentReplicationDescriptor Help(bool? help = true) => Qs("help", help);

/// <summary>Whether specified concrete, expanded or aliased indices should be ignored when throttled.</summary>
public CatSegmentReplicationDescriptor IgnoreThrottled(bool? ignorethrottled = true) =>
Qs("ignore_throttled", ignorethrottled);

/// <summary>Whether specified concrete indices should be ignored when unavailable (missing or closed).</summary>
public CatSegmentReplicationDescriptor IgnoreUnavailable(bool? ignoreunavailable = true) =>
Qs("ignore_unavailable", ignoreunavailable);

/// <summary>Comma-separated list of shards to display.</summary>
public CatSegmentReplicationDescriptor Shards(params string[] shards) =>
Qs("shards", shards);

/// <summary>Comma-separated list of column names or column aliases to sort by.</summary>
public CatSegmentReplicationDescriptor SortByColumns(params string[] sortbycolumns) =>
Qs("s", sortbycolumns);

/// <summary>Operation timeout.</summary>
public CatSegmentReplicationDescriptor Timeout(Time timeout) => Qs("timeout", timeout);

/// <summary>Verbose mode. Display column headers.</summary>
public CatSegmentReplicationDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}

/// <summary>Descriptor for Segments <para>https://opensearch.org/docs/latest/api-reference/cat/cat-segments/</para></summary>
public partial class CatSegmentsDescriptor
: RequestDescriptorBase<
Expand Down
56 changes: 56 additions & 0 deletions src/OpenSearch.Client/_Generated/OpenSearchClient.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,62 @@ public Task<CatResponse<CatRepositoriesRecord>> RepositoriesAsync(
CatRepositoriesRecord
>(request, ct);

/// <summary>
/// <c>GET</c> request to the <c>cat.segment_replication</c> API, read more about this API online:
/// <para></para>
/// <a href="https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/">https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/</a>
/// </summary>
/// <remarks>Supported by OpenSearch servers of version 2.6.0 or greater.</remarks>
public CatResponse<CatSegmentReplicationRecord> SegmentReplication(
Func<CatSegmentReplicationDescriptor, ICatSegmentReplicationRequest> selector = null
) => SegmentReplication(selector.InvokeOrDefault(new CatSegmentReplicationDescriptor()));

/// <summary>
/// <c>GET</c> request to the <c>cat.segment_replication</c> API, read more about this API online:
/// <para></para>
/// <a href="https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/">https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/</a>
/// </summary>
/// <remarks>Supported by OpenSearch servers of version 2.6.0 or greater.</remarks>
public Task<CatResponse<CatSegmentReplicationRecord>> SegmentReplicationAsync(
Func<CatSegmentReplicationDescriptor, ICatSegmentReplicationRequest> selector = null,
CancellationToken ct = default
) =>
SegmentReplicationAsync(
selector.InvokeOrDefault(new CatSegmentReplicationDescriptor()),
ct
);

/// <summary>
/// <c>GET</c> request to the <c>cat.segment_replication</c> API, read more about this API online:
/// <para></para>
/// <a href="https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/">https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/</a>
/// </summary>
/// <remarks>Supported by OpenSearch servers of version 2.6.0 or greater.</remarks>
public CatResponse<CatSegmentReplicationRecord> SegmentReplication(
ICatSegmentReplicationRequest request
) =>
DoCat<
ICatSegmentReplicationRequest,
CatSegmentReplicationRequestParameters,
CatSegmentReplicationRecord
>(request);

/// <summary>
/// <c>GET</c> request to the <c>cat.segment_replication</c> API, read more about this API online:
/// <para></para>
/// <a href="https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/">https://opensearch.org/docs/latest/api-reference/cat/cat-segment-replication/</a>
/// </summary>
/// <remarks>Supported by OpenSearch servers of version 2.6.0 or greater.</remarks>
public Task<CatResponse<CatSegmentReplicationRecord>> SegmentReplicationAsync(
ICatSegmentReplicationRequest request,
CancellationToken ct = default
) =>
DoCatAsync<
ICatSegmentReplicationRequest,
CatSegmentReplicationRequestParameters,
CatSegmentReplicationRecord
>(request, ct);

/// <summary>
/// <c>GET</c> request to the <c>cat.segments</c> API, read more about this API online:
/// <para></para>
Expand Down
Loading

0 comments on commit c6c7c85

Please sign in to comment.