Skip to content
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
130 changes: 64 additions & 66 deletions src/Elastic.Clients.Elasticsearch/Common/Infer/Id/Ids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,70 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Elastic.Transport;

namespace Elastic.Clients.Elasticsearch
{
//public partial class Ids
//{
// // This is temporary
// public Ids(IEnumerable<Id> ids) => _idList.AddRange(ids);

// public string GetString(ITransportConfiguration settings) => throw new NotImplementedException();
//}

//[DebuggerDisplay("{DebugDisplay,nq}")]
//public partial class Ids : IUrlParameter, IEquatable<Ids>
//{
// private readonly List<string> _ids;

// public Ids(IEnumerable<string> value) => _ids = value?.ToList();

// public Ids(string value)
// {
// if (!value.IsNullOrEmptyCommaSeparatedList(out var arr))
// _ids = arr.ToList();
// }

// private string DebugDisplay => ((IUrlParameter)this).GetString(null);

// public bool Equals(Ids other)
// {
// if (other == null)
// return false;
// if (_ids == null && other._ids == null)
// return true;
// if (_ids == null || other._ids == null)
// return false;

// return _ids.Count == other._ids.Count &&
// _ids.OrderBy(id => id).SequenceEqual(other._ids.OrderBy(id => id));
// }

// string IUrlParameter.GetString(ITransportConfiguration settings) =>
// string.Join(",", _ids ?? Enumerable.Empty<string>());

// public override string ToString() => DebugDisplay;

// public static implicit operator Ids(string value) =>
// value.IsNullOrEmptyCommaSeparatedList(out var arr) ? null : new Ids(arr);

// public static implicit operator Ids(string[] value) =>
// value.IsEmpty() ? null : new Ids(value);

// public override bool Equals(object obj) => obj is Ids other && Equals(other);

// public override int GetHashCode()
// {
// if (_ids == null)
// return 0;
// unchecked
// {
// var hc = 0;
// foreach (var id in _ids.OrderBy(id => id))
// hc = hc * 17 + id.GetHashCode();
// return hc;
// }
// }

// public static bool operator ==(Ids left, Ids right) => Equals(left, right);

// public static bool operator !=(Ids left, Ids right) => !Equals(left, right);
//}
[DebuggerDisplay("{DebugDisplay,nq}")]
public partial class Ids : IUrlParameter, IEquatable<Ids>
{
private readonly List<string> _ids;

public Ids(IEnumerable<string> value) => _ids = value?.ToList();

public Ids(string value)
{
if (!value.IsNullOrEmptyCommaSeparatedList(out var arr))
_ids = arr.ToList();
}

private string DebugDisplay => ((IUrlParameter)this).GetString(null);

public bool Equals(Ids other)
{
if (other == null)
return false;
if (_ids == null && other._ids == null)
return true;
if (_ids == null || other._ids == null)
return false;

return _ids.Count == other._ids.Count &&
_ids.OrderBy(id => id).SequenceEqual(other._ids.OrderBy(id => id));
}

string IUrlParameter.GetString(ITransportConfiguration settings) =>
string.Join(",", _ids ?? Enumerable.Empty<string>());

public override string ToString() => DebugDisplay;

public static implicit operator Ids(string value) =>
value.IsNullOrEmptyCommaSeparatedList(out var arr) ? null : new Ids(arr);

public static implicit operator Ids(string[] value) =>
value.IsEmpty() ? null : new Ids(value);

public override bool Equals(object obj) => obj is Ids other && Equals(other);

public override int GetHashCode()
{
if (_ids == null)
return 0;
unchecked
{
var hc = 0;
foreach (var id in _ids.OrderBy(id => id))
hc = hc * 17 + id.GetHashCode();
return hc;
}
}

public static bool operator ==(Ids left, Ids right) => Equals(left, right);

public static bool operator !=(Ids left, Ids right) => !Equals(left, right);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ internal static class ApiUrlsLookups
internal static ApiUrls SearchableSnapshotsStats = new ApiUrls(new[] { "/_searchable_snapshots/stats", "/{index}/_searchable_snapshots/stats" });
internal static ApiUrls NoNamespaceSearch = new ApiUrls(new[] { "/_search", "/{index}/_search" });
internal static ApiUrls NoNamespaceSearchShards = new ApiUrls(new[] { "/_search_shards", "/{index}/_search_shards" });
internal static ApiUrls SecurityClearApiKeyCache = new ApiUrls(new[] { "/_security/api_key/{ids}/_clear_cache" });
internal static ApiUrls SecurityCreateApiKey = new ApiUrls(new[] { "/_security/api_key" });
internal static ApiUrls SecurityGetApiKey = new ApiUrls(new[] { "/_security/api_key" });
internal static ApiUrls SecurityGrantApiKey = new ApiUrls(new[] { "/_security/api_key/grant" });
internal static ApiUrls SecurityInvalidateApiKey = new ApiUrls(new[] { "/_security/api_key" });
internal static ApiUrls SecurityQueryApiKeys = new ApiUrls(new[] { "/_security/_query/api_key" });
internal static ApiUrls SnapshotLifecycleManagementDeleteLifecycle = new ApiUrls(new[] { "/_slm/policy/{policy_id}" });
internal static ApiUrls SnapshotLifecycleManagementExecuteLifecycle = new ApiUrls(new[] { "/_slm/policy/{policy_id}/_execute" });
internal static ApiUrls SnapshotLifecycleManagementExecuteRetention = new ApiUrls(new[] { "/_slm/_execute_retention" });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Security
{
public class SecurityClearApiKeyCacheRequestParameters : RequestParameters<SecurityClearApiKeyCacheRequestParameters>
{
}

public partial class SecurityClearApiKeyCacheRequest : PlainRequestBase<SecurityClearApiKeyCacheRequestParameters>
{
public SecurityClearApiKeyCacheRequest(Elastic.Clients.Elasticsearch.Ids ids) : base(r => r.Required("ids", ids))
{
}

internal override ApiUrls ApiUrls => ApiUrlsLookups.SecurityClearApiKeyCache;
protected override HttpMethod HttpMethod => HttpMethod.POST;
protected override bool SupportsBody => false;
}

public sealed partial class SecurityClearApiKeyCacheRequestDescriptor : RequestDescriptorBase<SecurityClearApiKeyCacheRequestDescriptor, SecurityClearApiKeyCacheRequestParameters>
{
internal SecurityClearApiKeyCacheRequestDescriptor(Action<SecurityClearApiKeyCacheRequestDescriptor> configure) => configure.Invoke(this);
public SecurityClearApiKeyCacheRequestDescriptor(Elastic.Clients.Elasticsearch.Ids ids) : base(r => r.Required("ids", ids))
{
}

internal SecurityClearApiKeyCacheRequestDescriptor()
{
}

internal override ApiUrls ApiUrls => ApiUrlsLookups.SecurityClearApiKeyCache;
protected override HttpMethod HttpMethod => HttpMethod.POST;
protected override bool SupportsBody => false;
public SecurityClearApiKeyCacheRequestDescriptor Ids(Elastic.Clients.Elasticsearch.Ids ids)
{
RouteValues.Required("ids", ids);
return Self;
}

protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport.Products.Elasticsearch;
using System.Collections.Generic;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Security
{
public partial class SecurityClearApiKeyCacheResponse : ElasticsearchResponseBase
{
[JsonInclude]
[JsonPropertyName("cluster_name")]
public string ClusterName { get; init; }

[JsonInclude]
[JsonPropertyName("nodes")]
public Dictionary<string, Elastic.Clients.Elasticsearch.Security.ClusterNode> Nodes { get; init; }

[JsonInclude]
[JsonPropertyName("_nodes")]
public Elastic.Clients.Elasticsearch.NodeStatistics NodeStats { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Security
{
public class SecurityCreateApiKeyRequestParameters : RequestParameters<SecurityCreateApiKeyRequestParameters>
{
[JsonIgnore]
public Elastic.Clients.Elasticsearch.Refresh? Refresh { get => Q<Elastic.Clients.Elasticsearch.Refresh?>("refresh"); set => Q("refresh", value); }
}

public partial class SecurityCreateApiKeyRequest : PlainRequestBase<SecurityCreateApiKeyRequestParameters>
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.SecurityCreateApiKey;
protected override HttpMethod HttpMethod => HttpMethod.PUT;
protected override bool SupportsBody => true;
[JsonIgnore]
public Elastic.Clients.Elasticsearch.Refresh? Refresh { get => Q<Elastic.Clients.Elasticsearch.Refresh?>("refresh"); set => Q("refresh", value); }

[JsonInclude]
[JsonPropertyName("expiration")]
public Elastic.Clients.Elasticsearch.Time? Expiration { get; set; }

[JsonInclude]
[JsonPropertyName("name")]
public Elastic.Clients.Elasticsearch.Name? Name { get; set; }

[JsonInclude]
[JsonPropertyName("role_descriptors")]
public Dictionary<string, Elastic.Clients.Elasticsearch.Security.RoleDescriptor>? RoleDescriptors { get; set; }

[JsonInclude]
[JsonPropertyName("metadata")]
public Dictionary<string, object>? Metadata { get; set; }
}

public sealed partial class SecurityCreateApiKeyRequestDescriptor : RequestDescriptorBase<SecurityCreateApiKeyRequestDescriptor, SecurityCreateApiKeyRequestParameters>
{
internal SecurityCreateApiKeyRequestDescriptor(Action<SecurityCreateApiKeyRequestDescriptor> configure) => configure.Invoke(this);
public SecurityCreateApiKeyRequestDescriptor()
{
}

internal override ApiUrls ApiUrls => ApiUrlsLookups.SecurityCreateApiKey;
protected override HttpMethod HttpMethod => HttpMethod.PUT;
protected override bool SupportsBody => true;
public SecurityCreateApiKeyRequestDescriptor Refresh(Elastic.Clients.Elasticsearch.Refresh? refresh) => Qs("refresh", refresh);
private Elastic.Clients.Elasticsearch.Time? ExpirationValue { get; set; }

private Dictionary<string, object>? MetadataValue { get; set; }

private Elastic.Clients.Elasticsearch.Name? NameValue { get; set; }

private Dictionary<string, Elastic.Clients.Elasticsearch.Security.RoleDescriptor>? RoleDescriptorsValue { get; set; }

public SecurityCreateApiKeyRequestDescriptor Expiration(Elastic.Clients.Elasticsearch.Time? expiration)
{
ExpirationValue = expiration;
return Self;
}

public SecurityCreateApiKeyRequestDescriptor Metadata(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
{
MetadataValue = selector?.Invoke(new FluentDictionary<string, object>());
return Self;
}

public SecurityCreateApiKeyRequestDescriptor Name(Elastic.Clients.Elasticsearch.Name? name)
{
NameValue = name;
return Self;
}

public SecurityCreateApiKeyRequestDescriptor RoleDescriptors(Func<FluentDictionary<string, Elastic.Clients.Elasticsearch.Security.RoleDescriptor>, FluentDictionary<string, Elastic.Clients.Elasticsearch.Security.RoleDescriptor>> selector)
{
RoleDescriptorsValue = selector?.Invoke(new FluentDictionary<string, Elastic.Clients.Elasticsearch.Security.RoleDescriptor>());
return Self;
}

protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
{
writer.WriteStartObject();
if (ExpirationValue is not null)
{
writer.WritePropertyName("expiration");
JsonSerializer.Serialize(writer, ExpirationValue, options);
}

if (MetadataValue is not null)
{
writer.WritePropertyName("metadata");
JsonSerializer.Serialize(writer, MetadataValue, options);
}

if (NameValue is not null)
{
writer.WritePropertyName("name");
JsonSerializer.Serialize(writer, NameValue, options);
}

if (RoleDescriptorsValue is not null)
{
writer.WritePropertyName("role_descriptors");
JsonSerializer.Serialize(writer, RoleDescriptorsValue, options);
}

writer.WriteEndObject();
}
}
}
Loading