|
| 1 | +using System; |
| 2 | +using System.Collections; |
| 3 | +using System.IO; |
| 4 | +using System.Threading; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using Elasticsearch.Net; |
| 7 | + |
| 8 | +namespace Nest |
| 9 | +{ |
| 10 | + public partial interface IElasticClient |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// The certificates API enables you to retrieve information about the X.509 certificates |
| 14 | + /// that are used to encrypt communications in your Elasticsearch cluster. |
| 15 | + /// </summary> |
| 16 | + IGetCertificatesResponse GetCertificates(Func<GetCertificatesDescriptor, IGetCertificatesRequest> selector = null); |
| 17 | + |
| 18 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 19 | + IGetCertificatesResponse GetCertificates(IGetCertificatesRequest request); |
| 20 | + |
| 21 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 22 | + Task<IGetCertificatesResponse> GetCertificatesAsync(Func<GetCertificatesDescriptor, IGetCertificatesRequest> selector = null, |
| 23 | + CancellationToken cancellationToken = default |
| 24 | + ); |
| 25 | + |
| 26 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 27 | + Task<IGetCertificatesResponse> GetCertificatesAsync(IGetCertificatesRequest request, |
| 28 | + CancellationToken cancellationToken = default |
| 29 | + ); |
| 30 | + } |
| 31 | + |
| 32 | + public partial class ElasticClient |
| 33 | + { |
| 34 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 35 | + public IGetCertificatesResponse GetCertificates(Func<GetCertificatesDescriptor, IGetCertificatesRequest> selector = null) => |
| 36 | + GetCertificates(selector.InvokeOrDefault(new GetCertificatesDescriptor())); |
| 37 | + |
| 38 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 39 | + public IGetCertificatesResponse GetCertificates(IGetCertificatesRequest request) => |
| 40 | + Dispatcher.Dispatch<IGetCertificatesRequest, GetCertificatesRequestParameters, GetCertificatesResponse>( |
| 41 | + request, |
| 42 | + ToCertificatesResponse, |
| 43 | + (p, d) => LowLevelDispatch.XpackSslCertificatesDispatch<GetCertificatesResponse>(p) |
| 44 | + ); |
| 45 | + |
| 46 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 47 | + public Task<IGetCertificatesResponse> GetCertificatesAsync(Func<GetCertificatesDescriptor, IGetCertificatesRequest> selector = null, |
| 48 | + CancellationToken cancellationToken = default |
| 49 | + ) => |
| 50 | + GetCertificatesAsync(selector.InvokeOrDefault(new GetCertificatesDescriptor()), cancellationToken); |
| 51 | + |
| 52 | + /// <inheritdoc cref="GetCertificates(System.Func{Nest.GetCertificatesDescriptor,Nest.IGetCertificatesRequest})" /> |
| 53 | + public Task<IGetCertificatesResponse> GetCertificatesAsync(IGetCertificatesRequest request, |
| 54 | + CancellationToken cancellationToken = default |
| 55 | + ) => |
| 56 | + Dispatcher |
| 57 | + .DispatchAsync<IGetCertificatesRequest, GetCertificatesRequestParameters, GetCertificatesResponse, |
| 58 | + IGetCertificatesResponse>( |
| 59 | + request, |
| 60 | + cancellationToken, |
| 61 | + ToCertificatesResponse, |
| 62 | + (p, d, c) => LowLevelDispatch.XpackSslCertificatesDispatchAsync<GetCertificatesResponse>(p, c) |
| 63 | + ); |
| 64 | + |
| 65 | + private GetCertificatesResponse ToCertificatesResponse(IApiCallDetails apiCallDetails, Stream stream) |
| 66 | + { |
| 67 | + var result = RequestResponseSerializer.Deserialize<ClusterCertificateInformation[]>(stream); |
| 68 | + return new GetCertificatesResponse { Certificates = result }; |
| 69 | + } |
| 70 | + } |
| 71 | +} |
0 commit comments