forked from opensearch-project/opensearch-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for component template APIs (opensearch-project#411)
* Generate `cluster.put_component_template` Signed-off-by: Thomas Farr <[email protected]> * Implement high-level DeleteComponentTemplate Signed-off-by: Thomas Farr <[email protected]> * Implement high-level ComponentTemplateExists Signed-off-by: Thomas Farr <[email protected]> * Fix license Signed-off-by: Thomas Farr <[email protected]> * Remove old put_component_template Signed-off-by: Thomas Farr <[email protected]> * Implement high-level GetComponentTemplate Signed-off-by: Thomas Farr <[email protected]> * Add tests for ComponentTemplateExists Signed-off-by: Thomas Farr <[email protected]> * Add tests for DeleteComponentTemplate Signed-off-by: Thomas Farr <[email protected]> * Add tests for GetComponentTemplate Signed-off-by: Thomas Farr <[email protected]> * Implement high-level PutComponentTemplate Signed-off-by: Thomas Farr <[email protected]> * Add component template CRUD tests Signed-off-by: Thomas Farr <[email protected]> * Add naming convention exception for ComponentTemplateExists Signed-off-by: Thomas Farr <[email protected]> * Update guide Signed-off-by: Thomas Farr <[email protected]> * Formatting Signed-off-by: Thomas Farr <[email protected]> * Add changelog entry Signed-off-by: Thomas Farr <[email protected]> * Fix license header Signed-off-by: Thomas Farr <[email protected]> * Fix namespaces Signed-off-by: Thomas Farr <[email protected]> * Fix license header Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Thomas Farr <[email protected]>
- Loading branch information
Showing
31 changed files
with
1,481 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* 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; | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
using OpenSearch.Net.Utf8Json; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
[ReadAs(typeof(ComponentTemplate))] | ||
public interface IComponentTemplate | ||
{ | ||
[DataMember(Name = "template")] | ||
ITemplate Template { get; set; } | ||
|
||
[DataMember(Name = "version")] | ||
long? Version { get; set; } | ||
|
||
[DataMember(Name = "_meta")] | ||
[JsonFormatter(typeof(VerbatimDictionaryInterfaceKeysFormatter<string, object>))] | ||
IDictionary<string, object> Meta { get; set; } | ||
} | ||
|
||
public class ComponentTemplate : IComponentTemplate | ||
{ | ||
public ITemplate Template { get; set; } | ||
public long? Version { get; set; } | ||
public IDictionary<string, object> Meta { get; set; } | ||
} | ||
|
||
[ReadAs(typeof(Template))] | ||
public interface ITemplate | ||
{ | ||
[DataMember(Name = "aliases")] | ||
IAliases Aliases { get; set; } | ||
|
||
[DataMember(Name = "mappings")] | ||
ITypeMapping Mappings { get; set; } | ||
|
||
[DataMember(Name = "settings")] | ||
IIndexSettings Settings { get; set; } | ||
} | ||
|
||
public class Template : ITemplate | ||
{ | ||
public IAliases Aliases { get; set; } | ||
public ITypeMapping Mappings { get; set; } | ||
public IIndexSettings Settings { get; set; } | ||
} | ||
|
||
public class TemplateDescriptor : DescriptorBase<TemplateDescriptor, ITemplate>, ITemplate | ||
{ | ||
IAliases ITemplate.Aliases { get; set; } | ||
ITypeMapping ITemplate.Mappings { get; set; } | ||
IIndexSettings ITemplate.Settings { get; set; } | ||
|
||
public TemplateDescriptor Aliases(Func<AliasesDescriptor, IPromise<IAliases>> aliasDescriptor) => | ||
Assign(aliasDescriptor, (a, v) => a.Aliases = v?.Invoke(new AliasesDescriptor())?.Value); | ||
|
||
public TemplateDescriptor Map<T>(Func<TypeMappingDescriptor<T>, ITypeMapping> selector) where T : class => | ||
Assign(selector, (a, v) => a.Mappings = v?.Invoke(new TypeMappingDescriptor<T>())); | ||
|
||
public TemplateDescriptor Map(Func<TypeMappingDescriptor<object>, ITypeMapping> selector) => | ||
Assign(selector, (a, v) => a.Mappings = v?.Invoke(new TypeMappingDescriptor<object>())); | ||
|
||
public TemplateDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> settingsSelector) => | ||
Assign(settingsSelector, (a, v) => a.Settings = v?.Invoke(new IndexSettingsDescriptor())?.Value); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplateExistsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("cluster.exists_component_template")] | ||
public partial interface IComponentTemplateExistsRequest { } | ||
|
||
public partial class ComponentTemplateExistsRequest { } | ||
|
||
public partial class ComponentTemplateExistsDescriptor { } |
15 changes: 15 additions & 0 deletions
15
src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("cluster.delete_component_template")] | ||
public partial interface IDeleteComponentTemplateRequest { } | ||
|
||
public partial class DeleteComponentTemplateRequest { } | ||
|
||
public partial class DeleteComponentTemplateDescriptor { } |
13 changes: 13 additions & 0 deletions
13
src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* 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 DeleteComponentTemplateResponse : AcknowledgedResponseBase { } |
15 changes: 15 additions & 0 deletions
15
src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("cluster.get_component_template")] | ||
public partial interface IGetComponentTemplateRequest { } | ||
|
||
public partial class GetComponentTemplateRequest { } | ||
|
||
public partial class GetComponentTemplateDescriptor { } |
28 changes: 28 additions & 0 deletions
28
src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* 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.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
[DataContract] | ||
public class GetComponentTemplateResponse : ResponseBase | ||
{ | ||
[DataMember(Name = "component_templates")] | ||
public IReadOnlyCollection<NamedComponentTemplate> ComponentTemplates { get; internal set; } | ||
} | ||
|
||
[DataContract] | ||
public class NamedComponentTemplate | ||
{ | ||
[DataMember(Name = "name")] | ||
public string Name { get; internal set; } | ||
|
||
[DataMember(Name = "component_template")] | ||
public ComponentTemplate ComponentTemplate { get; internal set; } | ||
} |
38 changes: 38 additions & 0 deletions
38
src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* 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; | ||
using System.Collections.Generic; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
[MapsApi("cluster.put_component_template")] | ||
public partial interface IPutComponentTemplateRequest : IComponentTemplate { } | ||
|
||
public partial class PutComponentTemplateRequest | ||
{ | ||
public ITemplate Template { get; set; } | ||
public long? Version { get; set; } | ||
public IDictionary<string, object> Meta { get; set; } | ||
} | ||
|
||
public partial class PutComponentTemplateDescriptor | ||
{ | ||
ITemplate IComponentTemplate.Template { get; set; } | ||
long? IComponentTemplate.Version { get; set; } | ||
IDictionary<string, object> IComponentTemplate.Meta { get; set; } | ||
|
||
public PutComponentTemplateDescriptor Version(long? version) => Assign(version, (a, v) => a.Version = v); | ||
|
||
public PutComponentTemplateDescriptor Meta(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> metaSelector) => | ||
Assign(metaSelector(new FluentDictionary<string, object>()), (a, v) => a.Meta = v); | ||
|
||
public PutComponentTemplateDescriptor Meta(Dictionary<string, object> metaDictionary) => Assign(metaDictionary, (a, v) => a.Meta = v); | ||
|
||
public PutComponentTemplateDescriptor Template(Func<TemplateDescriptor, ITemplate> selector) => | ||
Assign(selector, (a, v) => a.Template = v?.Invoke(new TemplateDescriptor())); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* 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 PutComponentTemplateResponse : AcknowledgedResponseBase { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.