Skip to content

[Backport 8.14] Implement common request query parameters for request descriptors #8259

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

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public bool? ErrorTrace
}

/// <summary>
/// A comma-separated list of filters used to reduce the response.
/// <para>
/// Use of response filtering can result in a response from Elasticsearch
/// that cannot be correctly deserialized to the respective response type for the request.
/// In such situations, use the low level client to issue the request and handle response deserialization.
/// </para>
/// A list of filters used to reduce the response.
/// <para>
/// Use of response filtering can result in a response from Elasticsearch
/// that cannot be correctly deserialized to the respective response type for the request.
/// In such situations, use the low level client to issue the request and handle response deserialization.
/// </para>
/// </summary>
[JsonIgnore]
public string[] FilterPath
Expand All @@ -44,7 +44,7 @@ public string[] FilterPath
set => Q("filter_path", value);
}

///<summary>Return human readable values for statistics.</summary>
///<summary>Return human-readable values for statistics.</summary>
[JsonIgnore]
public bool? Human
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ protected Request(Func<RouteValues, RouteValues> pathSelector)

[JsonIgnore] internal TParameters RequestParameters => _parameters;

protected TOut Q<TOut>(string name) => RequestParameters.GetQueryStringValue<TOut>(name);
protected TOut? Q<TOut>(string name) => RequestParameters.GetQueryStringValue<TOut>(name);

protected void Q(string name, object value) => RequestParameters.SetQueryString(name, value);
protected void Q(string name, object? value) => RequestParameters.SetQueryString(name, value);

protected void Q(string name, IStringable value) => RequestParameters.SetQueryString(name, value.GetString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.ComponentModel;
using System.Text.Json;

#if ELASTICSEARCH_SERVERLESS
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
#else
Expand Down Expand Up @@ -40,7 +41,7 @@ internal RequestDescriptor(Func<RouteValues, RouteValues> pathSelector) : base(p

protected TDescriptor Self => _descriptor;

protected TDescriptor Qs(string name, object value)
protected TDescriptor Qs(string name, object? value)
{
Q(name, value);
return _descriptor;
Expand All @@ -64,6 +65,22 @@ public TDescriptor RequestConfiguration(
return _descriptor;
}

/// <summary>
/// A list of filters used to reduce the response.
/// <para>
/// Use of response filtering can result in a response from Elasticsearch
/// that cannot be correctly deserialized to the respective response type for the request.
/// In such situations, use the low level client to issue the request and handle response deserialization.
/// </para>
/// </summary>
public TDescriptor FilterPath(params string[] value) => Qs("filter_path", value);

///<summary>Return human-readable values for statistics.</summary>
public TDescriptor Human(bool? value) => Qs("human", value);

///<summary>Pretty format the returned JSON response.</summary>
public TDescriptor Pretty(bool? value) => Qs("pretty", value);

/// <summary>
/// Hides the <see cref="ToString" /> method.
/// </summary>
Expand Down
Loading