|
| 1 | +// Licensed to Elasticsearch B.V under one or more agreements. |
| 2 | +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
| 3 | +// See the LICENSE file in the project root for more information |
| 4 | + |
| 5 | +using System; |
| 6 | + |
| 7 | +namespace Elastic.Transport.Products.Elasticsearch; |
| 8 | + |
| 9 | +/// <summary> |
| 10 | +/// Allows you to control how <see cref="ITransport{TConfiguration}"/> behaves and where/how it connects to Elasticsearch |
| 11 | +/// </summary> |
| 12 | +public record ElasticsearchConfiguration : TransportConfiguration |
| 13 | +{ |
| 14 | + /// <summary> |
| 15 | + /// Creates a new instance of <see cref="ElasticsearchConfiguration"/> |
| 16 | + /// </summary> |
| 17 | + /// <param name="uri">The root of the Elastic stack product node we want to connect to. Defaults to http://localhost:9200</param> |
| 18 | + public ElasticsearchConfiguration(Uri? uri = null) |
| 19 | + : base(new SingleNodePool(uri ?? new Uri("http://localhost:9200")), productRegistration: ElasticsearchProductRegistration.Default ) { } |
| 20 | + |
| 21 | + /// <summary> |
| 22 | + /// Sets up the client to communicate to Elastic Cloud using <paramref name="cloudId"/>, |
| 23 | + /// <para><see cref="CloudNodePool"/> documentation for more information on how to get your Cloud ID</para> |
| 24 | + /// </summary> |
| 25 | + public ElasticsearchConfiguration(string cloudId, BasicAuthentication credentials) |
| 26 | + : base(new CloudNodePool(cloudId, credentials), productRegistration: ElasticsearchProductRegistration.Default) { } |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Sets up the client to communicate to Elastic Cloud using <paramref name="cloudId"/>, |
| 30 | + /// <para><see cref="CloudNodePool"/> documentation for more information on how to get your Cloud ID</para> |
| 31 | + /// </summary> |
| 32 | + public ElasticsearchConfiguration(string cloudId, ApiKey credentials) |
| 33 | + : base(new CloudNodePool(cloudId, credentials), productRegistration: ElasticsearchProductRegistration.Default) { } |
| 34 | + |
| 35 | + /// <summary> Sets up the client to communicate to Elastic Cloud.</summary> |
| 36 | + public ElasticsearchConfiguration(Uri cloudEndpoint, BasicAuthentication credentials) |
| 37 | + : base(new CloudNodePool(cloudEndpoint, credentials), productRegistration: ElasticsearchProductRegistration.Default) { } |
| 38 | + |
| 39 | + /// <summary> Sets up the client to communicate to Elastic Cloud. </summary> |
| 40 | + public ElasticsearchConfiguration(Uri cloudEndpoint, ApiKey credentials) |
| 41 | + : base(new CloudNodePool(cloudEndpoint, credentials), productRegistration: ElasticsearchProductRegistration.Default) { } |
| 42 | + |
| 43 | +} |
0 commit comments