From 89beff446786f749633790483d5cbc0eeccdfc49 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Thu, 10 Oct 2019 12:03:54 +1000 Subject: [PATCH 1/2] Implement Snapshot Lifecycle Management APIs This commit implements the Snapshot Lifecycle APIs in both the high level and low level clients. Unit tests for URLs, integration tests for the SLM API flow. The slm.get_lifecycle JSON spec is patched so that policy_id is a list and the Ids type is used to model multiple ids. --- .../Configuration/CodeConfiguration.cs | 5 - .../ApiGenerator/Domain/Code/CsharpNames.cs | 1 + .../Domain/Specification/UrlPart.cs | 32 ++-- .../_Patches/slm.get_lifecycle.patch.json | 12 ++ .../RequestParameters.Slm.cs | 50 +++++ ...tParameters.SnapshotLifecycleManagement.cs | 50 +++++ .../ElasticLowLevelClient.NoNamespace.cs | 8 + ...LevelClient.SnapshotLifecycleManagement.cs | 97 ++++++++++ .../IElasticLowLevelClient.Generated.cs | 7 + ...Descriptors.SnapshotLifecycleManagement.cs | 117 ++++++++++++ src/Nest/ElasticClient.NoNamespace.cs | 9 + ...asticClient.SnapshotLifecycleManagement.cs | 136 ++++++++++++++ src/Nest/IElasticClient.Generated.cs | 7 + .../Requests.SnapshotLifecycleManagement.cs | 164 +++++++++++++++++ src/Nest/Requests.cs | 1 + .../DeleteSnapshotLifecycleRequest.cs | 9 + .../DeleteSnapshotLifecycleResponse.cs | 4 + .../ExecuteSnapshotLifecycleRequest.cs | 9 + .../ExecuteSnapshotLifecycleResponse.cs | 13 ++ .../GetSnapshotLifecycleRequest.cs | 9 + .../GetSnapshotLifecycleResponse.cs | 13 ++ .../PutSnapshotLifecycleRequest.cs | 75 ++++++++ .../PutSnapshotLifecycleResponse.cs | 4 + src/Nest/XPack/Slm/SnapshotLifecycleConfig.cs | 56 ++++++ src/Nest/XPack/Slm/SnapshotLifecyclePolicy.cs | 58 ++++++ .../Slm/SnapshotLifecyclePolicyMetadata.cs | 49 +++++ .../_Generated/ApiUrlsLookup.generated.cs | 4 + src/Tests/Tests/XPack/Slm/SlmApiTests.cs | 171 ++++++++++++++++++ src/Tests/Tests/XPack/Slm/SlmUrlTests.cs | 56 ++++++ 29 files changed, 1206 insertions(+), 20 deletions(-) create mode 100644 src/CodeGeneration/ApiGenerator/RestSpecification/_Patches/slm.get_lifecycle.patch.json create mode 100644 src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Slm.cs create mode 100644 src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.SnapshotLifecycleManagement.cs create mode 100644 src/Elasticsearch.Net/ElasticLowLevelClient.SnapshotLifecycleManagement.cs create mode 100644 src/Nest/Descriptors.SnapshotLifecycleManagement.cs create mode 100644 src/Nest/ElasticClient.SnapshotLifecycleManagement.cs create mode 100644 src/Nest/Requests.SnapshotLifecycleManagement.cs create mode 100644 src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleRequest.cs create mode 100644 src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleResponse.cs create mode 100644 src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleRequest.cs create mode 100644 src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleResponse.cs create mode 100644 src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleRequest.cs create mode 100644 src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleResponse.cs create mode 100644 src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleRequest.cs create mode 100644 src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleResponse.cs create mode 100644 src/Nest/XPack/Slm/SnapshotLifecycleConfig.cs create mode 100644 src/Nest/XPack/Slm/SnapshotLifecyclePolicy.cs create mode 100644 src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs create mode 100644 src/Tests/Tests/XPack/Slm/SlmApiTests.cs create mode 100644 src/Tests/Tests/XPack/Slm/SlmUrlTests.cs diff --git a/src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs b/src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs index f9470311d7d..6223d164075 100644 --- a/src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs +++ b/src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs @@ -46,11 +46,6 @@ public static class CodeConfiguration "snapshot.cleanup_repository.json", "ml.estimate_memory_usage.json", "indices.clone.json", - - "slm.delete_lifecycle.json", - "slm.execute_lifecycle.json", - "slm.get_lifecycle.json", - "slm.put_lifecycle.json", }; diff --git a/src/CodeGeneration/ApiGenerator/Domain/Code/CsharpNames.cs b/src/CodeGeneration/ApiGenerator/Domain/Code/CsharpNames.cs index 0f32153ea3a..20f2b8735a5 100644 --- a/src/CodeGeneration/ApiGenerator/Domain/Code/CsharpNames.cs +++ b/src/CodeGeneration/ApiGenerator/Domain/Code/CsharpNames.cs @@ -88,6 +88,7 @@ private static string CreateCSharpNamespace(string endpointNamespace) case "ccr": return "CrossClusterReplication"; case "ml": return "MachineLearning"; case "xpack": return "XPack"; + case "slm": return "SnapshotLifecycleManagement"; default: return endpointNamespace.ToPascalCase(); } } diff --git a/src/CodeGeneration/ApiGenerator/Domain/Specification/UrlPart.cs b/src/CodeGeneration/ApiGenerator/Domain/Specification/UrlPart.cs index 6e2c3e7be40..678bb101321 100644 --- a/src/CodeGeneration/ApiGenerator/Domain/Specification/UrlPart.cs +++ b/src/CodeGeneration/ApiGenerator/Domain/Specification/UrlPart.cs @@ -53,26 +53,26 @@ public string HighLevelTypeName case "timestamp": return "Timestamp"; case "index_metric": return "IndexMetrics"; case "metric": return "Metrics"; - - case "node_id" when Type == "list": + + case "node_id" when Type == "list": return "NodeIds"; - - case "fields" when Type == "list": + + case "fields" when Type == "list": return "Fields"; - + case "parent_task_id": - case "task_id": + case "task_id": return "TaskId"; - + case "forecast_id": case "action_id": return "Ids"; - + case "index": case "new_index": - case "target": + case "target": return Type == "string" ? "IndexName" : "Indices"; - + case "watch_id": case "job_id": case "calendar_id": @@ -80,10 +80,12 @@ public string HighLevelTypeName case "datafeed_id": case "snapshot_id": case "filter_id": - case "policy_id": - case "id": + case "id": return "Id"; - + + case "policy_id": + return Type == "string" ? "Id" : "Ids"; + case "application": case "repository": case "snapshot": @@ -96,8 +98,8 @@ public string HighLevelTypeName case "thread_pool_patterns": case "type": return Type == "string" ? "Name" : "Names"; - - + + //This forces a compilation error post code generation as intended default: return Type + "_"; } diff --git a/src/CodeGeneration/ApiGenerator/RestSpecification/_Patches/slm.get_lifecycle.patch.json b/src/CodeGeneration/ApiGenerator/RestSpecification/_Patches/slm.get_lifecycle.patch.json new file mode 100644 index 00000000000..37066d1ec43 --- /dev/null +++ b/src/CodeGeneration/ApiGenerator/RestSpecification/_Patches/slm.get_lifecycle.patch.json @@ -0,0 +1,12 @@ +{ + "slm.get_lifecycle":{ + "url":{ + "parts":{ + "policy_id":{ + "type":"list", + "description":"Comma-separated list of snapshot lifecycle policies to retrieve" + } + } + } + } +} diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Slm.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Slm.cs new file mode 100644 index 00000000000..3f6dfda5e2c --- /dev/null +++ b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Slm.cs @@ -0,0 +1,50 @@ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; + +// ReSharper disable once CheckNamespace +namespace Elasticsearch.Net.Specification.SlmApi +{ + ///Request options for DeleteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + public class DeleteSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE; + } + + ///Request options for ExecuteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + public class ExecuteSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.PUT; + } + + ///Request options for GetSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + public class GetSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.GET; + } + + ///Request options for PutSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + public class PutSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.PUT; + } +} \ No newline at end of file diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.SnapshotLifecycleManagement.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.SnapshotLifecycleManagement.cs new file mode 100644 index 00000000000..da2e233adf5 --- /dev/null +++ b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.SnapshotLifecycleManagement.cs @@ -0,0 +1,50 @@ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; + +// ReSharper disable once CheckNamespace +namespace Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi +{ + ///Request options for DeleteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + public class DeleteSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE; + } + + ///Request options for ExecuteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + public class ExecuteSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.PUT; + } + + ///Request options for GetSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + public class GetSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.GET; + } + + ///Request options for PutSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + public class PutSnapshotLifecycleRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.PUT; + } +} \ No newline at end of file diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.NoNamespace.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.NoNamespace.cs index 25a888e2d75..54faa9bf97e 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.NoNamespace.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.NoNamespace.cs @@ -37,6 +37,7 @@ using Elasticsearch.Net.Specification.RollupApi; using Elasticsearch.Net.Specification.SecurityApi; using Elasticsearch.Net.Specification.SnapshotApi; +using Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi; using Elasticsearch.Net.Specification.SqlApi; using Elasticsearch.Net.Specification.TasksApi; using Elasticsearch.Net.Specification.WatcherApi; @@ -136,6 +137,12 @@ public LowLevelSnapshotNamespace Snapshot private set; } + public LowLevelSnapshotLifecycleManagementNamespace SnapshotLifecycleManagement + { + get; + private set; + } + public LowLevelSqlNamespace Sql { get; @@ -176,6 +183,7 @@ partial void SetupNamespaces() Rollup = new LowLevelRollupNamespace(this); Security = new LowLevelSecurityNamespace(this); Snapshot = new LowLevelSnapshotNamespace(this); + SnapshotLifecycleManagement = new LowLevelSnapshotLifecycleManagementNamespace(this); Sql = new LowLevelSqlNamespace(this); Tasks = new LowLevelTasksNamespace(this); Watcher = new LowLevelWatcherNamespace(this); diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.SnapshotLifecycleManagement.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.SnapshotLifecycleManagement.cs new file mode 100644 index 00000000000..d7c2ae1da8b --- /dev/null +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.SnapshotLifecycleManagement.cs @@ -0,0 +1,97 @@ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net; +using static Elasticsearch.Net.HttpMethod; + +// ReSharper disable InterpolatedStringExpressionIsNotIFormattable +// ReSharper disable once CheckNamespace +// ReSharper disable InterpolatedStringExpressionIsNotIFormattable +// ReSharper disable RedundantExtendsListEntry +namespace Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi +{ + /// + /// Snapshot Lifecycle Management APIs. + /// Not intended to be instantiated directly. Use the property + /// on . + /// + /// + public class LowLevelSnapshotLifecycleManagementNamespace : NamespacedClientProxy + { + internal LowLevelSnapshotLifecycleManagementNamespace(ElasticLowLevelClient client): base(client) + { + } + + ///DELETE on /_slm/policy/{policy_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + ///The id of the snapshot lifecycle policy to remove + ///Request specific configuration such as querystring parameters & request specific connection settings. + public TResponse DeleteSnapshotLifecycle(string policyId, DeleteSnapshotLifecycleRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => DoRequest(DELETE, Url($"_slm/policy/{policyId:policyId}"), null, RequestParams(requestParameters)); + ///DELETE on /_slm/policy/{policy_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + ///The id of the snapshot lifecycle policy to remove + ///Request specific configuration such as querystring parameters & request specific connection settings. + public Task DeleteSnapshotLifecycleAsync(string policyId, DeleteSnapshotLifecycleRequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(DELETE, Url($"_slm/policy/{policyId:policyId}"), ctx, null, RequestParams(requestParameters)); + ///PUT on /_slm/policy/{policy_id}/_execute https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + ///The id of the snapshot lifecycle policy to be executed + ///Request specific configuration such as querystring parameters & request specific connection settings. + public TResponse ExecuteSnapshotLifecycle(string policyId, ExecuteSnapshotLifecycleRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => DoRequest(PUT, Url($"_slm/policy/{policyId:policyId}/_execute"), null, RequestParams(requestParameters)); + ///PUT on /_slm/policy/{policy_id}/_execute https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + ///The id of the snapshot lifecycle policy to be executed + ///Request specific configuration such as querystring parameters & request specific connection settings. + public Task ExecuteSnapshotLifecycleAsync(string policyId, ExecuteSnapshotLifecycleRequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(PUT, Url($"_slm/policy/{policyId:policyId}/_execute"), ctx, null, RequestParams(requestParameters)); + ///GET on /_slm/policy/{policy_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + ///Comma-separated list of snapshot lifecycle policies to retrieve + ///Request specific configuration such as querystring parameters & request specific connection settings. + public TResponse GetSnapshotLifecycle(string policyId, GetSnapshotLifecycleRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => DoRequest(GET, Url($"_slm/policy/{policyId:policyId}"), null, RequestParams(requestParameters)); + ///GET on /_slm/policy/{policy_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + ///Comma-separated list of snapshot lifecycle policies to retrieve + ///Request specific configuration such as querystring parameters & request specific connection settings. + public Task GetSnapshotLifecycleAsync(string policyId, GetSnapshotLifecycleRequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, Url($"_slm/policy/{policyId:policyId}"), ctx, null, RequestParams(requestParameters)); + ///GET on /_slm/policy https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + ///Request specific configuration such as querystring parameters & request specific connection settings. + public TResponse GetSnapshotLifecycle(GetSnapshotLifecycleRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => DoRequest(GET, "_slm/policy", null, RequestParams(requestParameters)); + ///GET on /_slm/policy https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + ///Request specific configuration such as querystring parameters & request specific connection settings. + public Task GetSnapshotLifecycleAsync(GetSnapshotLifecycleRequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, "_slm/policy", ctx, null, RequestParams(requestParameters)); + ///PUT on /_slm/policy/{policy_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + ///The id of the snapshot lifecycle policy + ///The snapshot lifecycle policy definition to register + ///Request specific configuration such as querystring parameters & request specific connection settings. + public TResponse PutSnapshotLifecycle(string policyId, PostData body, PutSnapshotLifecycleRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => DoRequest(PUT, Url($"_slm/policy/{policyId:policyId}"), body, RequestParams(requestParameters)); + ///PUT on /_slm/policy/{policy_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + ///The id of the snapshot lifecycle policy + ///The snapshot lifecycle policy definition to register + ///Request specific configuration such as querystring parameters & request specific connection settings. + public Task PutSnapshotLifecycleAsync(string policyId, PostData body, PutSnapshotLifecycleRequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(PUT, Url($"_slm/policy/{policyId:policyId}"), ctx, body, RequestParams(requestParameters)); + } +} \ No newline at end of file diff --git a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs index e871e538e67..36cfa8a85b8 100644 --- a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs @@ -37,6 +37,7 @@ using Elasticsearch.Net.Specification.RollupApi; using Elasticsearch.Net.Specification.SecurityApi; using Elasticsearch.Net.Specification.SnapshotApi; +using Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi; using Elasticsearch.Net.Specification.SqlApi; using Elasticsearch.Net.Specification.TasksApi; using Elasticsearch.Net.Specification.WatcherApi; @@ -1069,6 +1070,12 @@ LowLevelSnapshotNamespace Snapshot get; } + ///Snapshot Lifecycle Management APIs + LowLevelSnapshotLifecycleManagementNamespace SnapshotLifecycleManagement + { + get; + } + ///Sql APIs LowLevelSqlNamespace Sql { diff --git a/src/Nest/Descriptors.SnapshotLifecycleManagement.cs b/src/Nest/Descriptors.SnapshotLifecycleManagement.cs new file mode 100644 index 00000000000..caca936b5f4 --- /dev/null +++ b/src/Nest/Descriptors.SnapshotLifecycleManagement.cs @@ -0,0 +1,117 @@ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; +using Elasticsearch.Net; +using Elasticsearch.Net.Utf8Json; +using Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi; + +// ReSharper disable RedundantBaseConstructorCall +// ReSharper disable UnusedTypeParameter +// ReSharper disable PartialMethodWithSinglePart +// ReSharper disable RedundantNameQualifier +namespace Nest +{ + ///Descriptor for DeleteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + public partial class DeleteSnapshotLifecycleDescriptor : RequestDescriptorBase, IDeleteSnapshotLifecycleRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementDeleteSnapshotLifecycle; + ////_slm/policy/{policy_id} + ///this parameter is required + public DeleteSnapshotLifecycleDescriptor(Id policyId): base(r => r.Required("policy_id", policyId)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected DeleteSnapshotLifecycleDescriptor(): base() + { + } + + // values part of the url path + Id IDeleteSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } + + ///Descriptor for ExecuteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + public partial class ExecuteSnapshotLifecycleDescriptor : RequestDescriptorBase, IExecuteSnapshotLifecycleRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementExecuteSnapshotLifecycle; + ////_slm/policy/{policy_id}/_execute + ///this parameter is required + public ExecuteSnapshotLifecycleDescriptor(Id policyId): base(r => r.Required("policy_id", policyId)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected ExecuteSnapshotLifecycleDescriptor(): base() + { + } + + // values part of the url path + Id IExecuteSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } + + ///Descriptor for GetSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + public partial class GetSnapshotLifecycleDescriptor : RequestDescriptorBase, IGetSnapshotLifecycleRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementGetSnapshotLifecycle; + ////_slm/policy/{policy_id} + ///Optional, accepts null + public GetSnapshotLifecycleDescriptor(Ids policyId): base(r => r.Optional("policy_id", policyId)) + { + } + + ////_slm/policy + public GetSnapshotLifecycleDescriptor(): base() + { + } + + // values part of the url path + Ids IGetSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + ///Comma-separated list of snapshot lifecycle policies to retrieve + public GetSnapshotLifecycleDescriptor PolicyId(Ids policyId) => Assign(policyId, (a, v) => a.RouteValues.Optional("policy_id", v)); + // Request parameters + } + + ///Descriptor for PutSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + public partial class PutSnapshotLifecycleDescriptor : RequestDescriptorBase, IPutSnapshotLifecycleRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementPutSnapshotLifecycle; + ////_slm/policy/{policy_id} + ///this parameter is required + public PutSnapshotLifecycleDescriptor(Id policyId): base(r => r.Required("policy_id", policyId)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected PutSnapshotLifecycleDescriptor(): base() + { + } + + // values part of the url path + Id IPutSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } +} \ No newline at end of file diff --git a/src/Nest/ElasticClient.NoNamespace.cs b/src/Nest/ElasticClient.NoNamespace.cs index 45ce511b9ff..55568fea16b 100644 --- a/src/Nest/ElasticClient.NoNamespace.cs +++ b/src/Nest/ElasticClient.NoNamespace.cs @@ -33,6 +33,7 @@ using Nest.Specification.RollupApi; using Nest.Specification.SecurityApi; using Nest.Specification.SnapshotApi; +using Nest.Specification.SnapshotLifecycleManagementApi; using Nest.Specification.SqlApi; using Nest.Specification.TasksApi; using Nest.Specification.WatcherApi; @@ -144,6 +145,13 @@ public SnapshotNamespace Snapshot private set; } + ///Snapshot Lifecycle Management APIs + public SnapshotLifecycleManagementNamespace SnapshotLifecycleManagement + { + get; + private set; + } + ///Sql APIs public SqlNamespace Sql { @@ -188,6 +196,7 @@ partial void SetupNamespaces() Rollup = new RollupNamespace(this); Security = new SecurityNamespace(this); Snapshot = new SnapshotNamespace(this); + SnapshotLifecycleManagement = new SnapshotLifecycleManagementNamespace(this); Sql = new SqlNamespace(this); Tasks = new TasksNamespace(this); Watcher = new WatcherNamespace(this); diff --git a/src/Nest/ElasticClient.SnapshotLifecycleManagement.cs b/src/Nest/ElasticClient.SnapshotLifecycleManagement.cs new file mode 100644 index 00000000000..e391a06c790 --- /dev/null +++ b/src/Nest/ElasticClient.SnapshotLifecycleManagement.cs @@ -0,0 +1,136 @@ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi; + +// ReSharper disable once CheckNamespace +// ReSharper disable RedundantTypeArgumentsOfMethod +namespace Nest.Specification.SnapshotLifecycleManagementApi +{ + /// + /// Snapshot Lifecycle Management APIs. + /// Not intended to be instantiated directly. Use the property + /// on . + /// + /// + public class SnapshotLifecycleManagementNamespace : NamespacedClientProxy + { + internal SnapshotLifecycleManagementNamespace(ElasticClient client): base(client) + { + } + + /// + /// DELETE request to the slm.delete_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + /// + public DeleteSnapshotLifecycleResponse DeleteSnapshotLifecycle(Id policyId, Func selector = null) => DeleteSnapshotLifecycle(selector.InvokeOrDefault(new DeleteSnapshotLifecycleDescriptor(policyId: policyId))); + /// + /// DELETE request to the slm.delete_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + /// + public Task DeleteSnapshotLifecycleAsync(Id policyId, Func selector = null, CancellationToken ct = default) => DeleteSnapshotLifecycleAsync(selector.InvokeOrDefault(new DeleteSnapshotLifecycleDescriptor(policyId: policyId)), ct); + /// + /// DELETE request to the slm.delete_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + /// + public DeleteSnapshotLifecycleResponse DeleteSnapshotLifecycle(IDeleteSnapshotLifecycleRequest request) => DoRequest(request, request.RequestParameters); + /// + /// DELETE request to the slm.delete_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + /// + public Task DeleteSnapshotLifecycleAsync(IDeleteSnapshotLifecycleRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); + /// + /// PUT request to the slm.execute_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + /// + public ExecuteSnapshotLifecycleResponse ExecuteSnapshotLifecycle(Id policyId, Func selector = null) => ExecuteSnapshotLifecycle(selector.InvokeOrDefault(new ExecuteSnapshotLifecycleDescriptor(policyId: policyId))); + /// + /// PUT request to the slm.execute_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + /// + public Task ExecuteSnapshotLifecycleAsync(Id policyId, Func selector = null, CancellationToken ct = default) => ExecuteSnapshotLifecycleAsync(selector.InvokeOrDefault(new ExecuteSnapshotLifecycleDescriptor(policyId: policyId)), ct); + /// + /// PUT request to the slm.execute_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + /// + public ExecuteSnapshotLifecycleResponse ExecuteSnapshotLifecycle(IExecuteSnapshotLifecycleRequest request) => DoRequest(request, request.RequestParameters); + /// + /// PUT request to the slm.execute_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + /// + public Task ExecuteSnapshotLifecycleAsync(IExecuteSnapshotLifecycleRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); + /// + /// GET request to the slm.get_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + /// + public GetSnapshotLifecycleResponse GetSnapshotLifecycle(Func selector = null) => GetSnapshotLifecycle(selector.InvokeOrDefault(new GetSnapshotLifecycleDescriptor())); + /// + /// GET request to the slm.get_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + /// + public Task GetSnapshotLifecycleAsync(Func selector = null, CancellationToken ct = default) => GetSnapshotLifecycleAsync(selector.InvokeOrDefault(new GetSnapshotLifecycleDescriptor()), ct); + /// + /// GET request to the slm.get_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + /// + public GetSnapshotLifecycleResponse GetSnapshotLifecycle(IGetSnapshotLifecycleRequest request) => DoRequest(request, request.RequestParameters); + /// + /// GET request to the slm.get_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + /// + public Task GetSnapshotLifecycleAsync(IGetSnapshotLifecycleRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); + /// + /// PUT request to the slm.put_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + /// + public PutSnapshotLifecycleResponse PutSnapshotLifecycle(Id policyId, Func selector = null) => PutSnapshotLifecycle(selector.InvokeOrDefault(new PutSnapshotLifecycleDescriptor(policyId: policyId))); + /// + /// PUT request to the slm.put_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + /// + public Task PutSnapshotLifecycleAsync(Id policyId, Func selector = null, CancellationToken ct = default) => PutSnapshotLifecycleAsync(selector.InvokeOrDefault(new PutSnapshotLifecycleDescriptor(policyId: policyId)), ct); + /// + /// PUT request to the slm.put_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + /// + public PutSnapshotLifecycleResponse PutSnapshotLifecycle(IPutSnapshotLifecycleRequest request) => DoRequest(request, request.RequestParameters); + /// + /// PUT request to the slm.put_lifecycle API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + /// + public Task PutSnapshotLifecycleAsync(IPutSnapshotLifecycleRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); + } +} \ No newline at end of file diff --git a/src/Nest/IElasticClient.Generated.cs b/src/Nest/IElasticClient.Generated.cs index b62e637a3d7..fbd0a7ba140 100644 --- a/src/Nest/IElasticClient.Generated.cs +++ b/src/Nest/IElasticClient.Generated.cs @@ -35,6 +35,7 @@ using Nest.Specification.RollupApi; using Nest.Specification.SecurityApi; using Nest.Specification.SnapshotApi; +using Nest.Specification.SnapshotLifecycleManagementApi; using Nest.Specification.SqlApi; using Nest.Specification.TasksApi; using Nest.Specification.WatcherApi; @@ -1067,6 +1068,12 @@ SnapshotNamespace Snapshot get; } + ///Snapshot Lifecycle Management APIs + SnapshotLifecycleManagementNamespace SnapshotLifecycleManagement + { + get; + } + ///Sql APIs SqlNamespace Sql { diff --git a/src/Nest/Requests.SnapshotLifecycleManagement.cs b/src/Nest/Requests.SnapshotLifecycleManagement.cs new file mode 100644 index 00000000000..852d287b34a --- /dev/null +++ b/src/Nest/Requests.SnapshotLifecycleManagement.cs @@ -0,0 +1,164 @@ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; +using System.Runtime.Serialization; +using Elasticsearch.Net; +using Elasticsearch.Net.Utf8Json; +using Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi; + +// ReSharper disable RedundantBaseConstructorCall +// ReSharper disable UnusedTypeParameter +// ReSharper disable PartialMethodWithSinglePart +// ReSharper disable RedundantNameQualifier +namespace Nest +{ + [InterfaceDataContract] + public partial interface IDeleteSnapshotLifecycleRequest : IRequest + { + [IgnoreDataMember] + Id PolicyId + { + get; + } + } + + ///Request for DeleteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + public partial class DeleteSnapshotLifecycleRequest : PlainRequestBase, IDeleteSnapshotLifecycleRequest + { + protected IDeleteSnapshotLifecycleRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementDeleteSnapshotLifecycle; + ////_slm/policy/{policy_id} + ///this parameter is required + public DeleteSnapshotLifecycleRequest(Id policyId): base(r => r.Required("policy_id", policyId)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected DeleteSnapshotLifecycleRequest(): base() + { + } + + // values part of the url path + [IgnoreDataMember] + Id IDeleteSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } + + [InterfaceDataContract] + public partial interface IExecuteSnapshotLifecycleRequest : IRequest + { + [IgnoreDataMember] + Id PolicyId + { + get; + } + } + + ///Request for ExecuteSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + public partial class ExecuteSnapshotLifecycleRequest : PlainRequestBase, IExecuteSnapshotLifecycleRequest + { + protected IExecuteSnapshotLifecycleRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementExecuteSnapshotLifecycle; + ////_slm/policy/{policy_id}/_execute + ///this parameter is required + public ExecuteSnapshotLifecycleRequest(Id policyId): base(r => r.Required("policy_id", policyId)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected ExecuteSnapshotLifecycleRequest(): base() + { + } + + // values part of the url path + [IgnoreDataMember] + Id IExecuteSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } + + [InterfaceDataContract] + public partial interface IGetSnapshotLifecycleRequest : IRequest + { + [IgnoreDataMember] + Ids PolicyId + { + get; + } + } + + ///Request for GetSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + public partial class GetSnapshotLifecycleRequest : PlainRequestBase, IGetSnapshotLifecycleRequest + { + protected IGetSnapshotLifecycleRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementGetSnapshotLifecycle; + ////_slm/policy/{policy_id} + ///Optional, accepts null + public GetSnapshotLifecycleRequest(Ids policyId): base(r => r.Optional("policy_id", policyId)) + { + } + + ////_slm/policy + public GetSnapshotLifecycleRequest(): base() + { + } + + // values part of the url path + [IgnoreDataMember] + Ids IGetSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } + + [InterfaceDataContract] + public partial interface IPutSnapshotLifecycleRequest : IRequest + { + [IgnoreDataMember] + Id PolicyId + { + get; + } + } + + ///Request for PutSnapshotLifecycle https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + public partial class PutSnapshotLifecycleRequest : PlainRequestBase, IPutSnapshotLifecycleRequest + { + protected IPutSnapshotLifecycleRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotLifecycleManagementPutSnapshotLifecycle; + ////_slm/policy/{policy_id} + ///this parameter is required + public PutSnapshotLifecycleRequest(Id policyId): base(r => r.Required("policy_id", policyId)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected PutSnapshotLifecycleRequest(): base() + { + } + + // values part of the url path + [IgnoreDataMember] + Id IPutSnapshotLifecycleRequest.PolicyId => Self.RouteValues.Get("policy_id"); + // Request parameters + } +} \ No newline at end of file diff --git a/src/Nest/Requests.cs b/src/Nest/Requests.cs index 4a5412663e0..cf917a3cf66 100644 --- a/src/Nest/Requests.cs +++ b/src/Nest/Requests.cs @@ -37,6 +37,7 @@ using Elasticsearch.Net.Specification.RollupApi; using Elasticsearch.Net.Specification.SecurityApi; using Elasticsearch.Net.Specification.SnapshotApi; +using Elasticsearch.Net.Specification.SnapshotLifecycleManagementApi; using Elasticsearch.Net.Specification.SqlApi; using Elasticsearch.Net.Specification.TasksApi; using Elasticsearch.Net.Specification.WatcherApi; diff --git a/src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleRequest.cs b/src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleRequest.cs new file mode 100644 index 00000000000..5ca85bc36f8 --- /dev/null +++ b/src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("slm.delete_lifecycle")] + public partial interface IDeleteSnapshotLifecycleRequest { } + + public partial class DeleteSnapshotLifecycleRequest { } + + public partial class DeleteSnapshotLifecycleDescriptor { } +} diff --git a/src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleResponse.cs b/src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleResponse.cs new file mode 100644 index 00000000000..d374898ea7e --- /dev/null +++ b/src/Nest/XPack/Slm/DeleteLifecycle/DeleteSnapshotLifecycleResponse.cs @@ -0,0 +1,4 @@ +namespace Nest +{ + public class DeleteSnapshotLifecycleResponse : AcknowledgedResponseBase { } +} diff --git a/src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleRequest.cs b/src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleRequest.cs new file mode 100644 index 00000000000..aec31506b70 --- /dev/null +++ b/src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("slm.execute_lifecycle")] + public partial interface IExecuteSnapshotLifecycleRequest { } + + public partial class ExecuteSnapshotLifecycleRequest { } + + public partial class ExecuteSnapshotLifecycleDescriptor { } +} diff --git a/src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleResponse.cs b/src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleResponse.cs new file mode 100644 index 00000000000..448d2de0828 --- /dev/null +++ b/src/Nest/XPack/Slm/ExecuteLifecycle/ExecuteSnapshotLifecycleResponse.cs @@ -0,0 +1,13 @@ +using System.Runtime.Serialization; + +namespace Nest +{ + public class ExecuteSnapshotLifecycleResponse : ResponseBase + { + /// + /// The generated snapshot name + /// + [DataMember(Name = "snapshot_name")] + public string SnapshotName { get; internal set; } + } +} diff --git a/src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleRequest.cs b/src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleRequest.cs new file mode 100644 index 00000000000..0c584523ce0 --- /dev/null +++ b/src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("slm.get_lifecycle")] + public partial interface IGetSnapshotLifecycleRequest { } + + public partial class GetSnapshotLifecycleRequest { } + + public partial class GetSnapshotLifecycleDescriptor { } +} diff --git a/src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleResponse.cs b/src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleResponse.cs new file mode 100644 index 00000000000..69f7177ae07 --- /dev/null +++ b/src/Nest/XPack/Slm/GetLifecycle/GetSnapshotLifecycleResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Elasticsearch.Net.Utf8Json; + +namespace Nest +{ + [JsonFormatter(typeof(DictionaryResponseFormatter))] + public class GetSnapshotLifecycleResponse : DictionaryResponseBase + { + public IReadOnlyDictionary Policies => Self.BackingDictionary; + } +} diff --git a/src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleRequest.cs b/src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleRequest.cs new file mode 100644 index 00000000000..607fc6c911c --- /dev/null +++ b/src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleRequest.cs @@ -0,0 +1,75 @@ +using System; +using System.Runtime.Serialization; +using Nest.Specification.SnapshotApi; + +namespace Nest +{ + [MapsApi("slm.put_lifecycle")] + [ReadAs(typeof(PutSnapshotLifecycleRequest))] + public partial interface IPutSnapshotLifecycleRequest + { + /// + /// Configuration for each snapshot that will be created by this policy. + /// + [DataMember(Name = "config")] + ISnapshotLifecycleConfig Config { get; set; } + + /// + /// A name automatically given to each snapshot performed by this policy. + /// Supports the same date math supported in index names. A UUID is automatically appended to the + /// end of the name to prevent conflicting snapshot names. + /// + [DataMember(Name = "name")] + string Name { get; set; } + + /// + /// The snapshot repository that will contain snapshots created by this policy. + /// The repository must exist prior to the policy’s creation and can be created + /// with the Snapshot CreateRespository API. + /// + [DataMember(Name = "repository")] + string Repository { get; set; } + + /// + /// A periodic or absolute time schedule specified as a cron expression. + /// + [DataMember(Name = "schedule")] + CronExpression Schedule { get; set; } + } + + public partial class PutSnapshotLifecycleRequest + { + /// + public ISnapshotLifecycleConfig Config { get; set; } + + /// + public string Name { get; set; } + + /// + public string Repository { get; set; } + + /// + public CronExpression Schedule { get; set; } + } + + public partial class PutSnapshotLifecycleDescriptor + { + ISnapshotLifecycleConfig IPutSnapshotLifecycleRequest.Config { get; set; } + string IPutSnapshotLifecycleRequest.Name { get; set; } + string IPutSnapshotLifecycleRequest.Repository { get; set; } + CronExpression IPutSnapshotLifecycleRequest.Schedule { get; set; } + + /// + public PutSnapshotLifecycleDescriptor Name(string name) => Assign(name, (a, v) => a.Name = v); + + /// + public PutSnapshotLifecycleDescriptor Repository(string repository) => Assign(repository, (a, v) => a.Repository = v); + + /// + public PutSnapshotLifecycleDescriptor Schedule(CronExpression schedule) => Assign(schedule, (a, v) => a.Schedule = v); + + /// + public PutSnapshotLifecycleDescriptor Config(Func selector) => + Assign(selector, (a, v) => a.Config = v.InvokeOrDefault(new SnapshotLifecycleConfigDescriptor())); + } +} diff --git a/src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleResponse.cs b/src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleResponse.cs new file mode 100644 index 00000000000..f5ce6cf7200 --- /dev/null +++ b/src/Nest/XPack/Slm/PutLifecycle/PutSnapshotLifecycleResponse.cs @@ -0,0 +1,4 @@ +namespace Nest +{ + public class PutSnapshotLifecycleResponse : AcknowledgedResponseBase { } +} diff --git a/src/Nest/XPack/Slm/SnapshotLifecycleConfig.cs b/src/Nest/XPack/Slm/SnapshotLifecycleConfig.cs new file mode 100644 index 00000000000..153604b73e4 --- /dev/null +++ b/src/Nest/XPack/Slm/SnapshotLifecycleConfig.cs @@ -0,0 +1,56 @@ +using System.Runtime.Serialization; +using Elasticsearch.Net.Utf8Json; + +namespace Nest +{ + /// + /// A snapshot lifecycle configuration + /// + [ReadAs(typeof(SnapshotLifecycleConfig))] + [InterfaceDataContract] + public interface ISnapshotLifecycleConfig + { + [DataMember(Name = "ignore_unavailable")] + bool? IgnoreUnavailable { get; set; } + + [DataMember(Name = "include_global_state")] + bool? IncludeGlobalState { get; set; } + + /// + /// The indices to snapshot + /// + [DataMember(Name = "indices")] + [JsonFormatter(typeof(IndicesMultiSyntaxFormatter))] + Indices Indices { get; set; } + } + + + public class SnapshotLifecycleConfig : ISnapshotLifecycleConfig + { + /// + public bool? IgnoreUnavailable { get; set; } + + /// + public bool? IncludeGlobalState { get; set; } + + /// + public Indices Indices { get; set; } + } + + public class SnapshotLifecycleConfigDescriptor : DescriptorBase, ISnapshotLifecycleConfig + { + bool? ISnapshotLifecycleConfig.IgnoreUnavailable { get; set; } + bool? ISnapshotLifecycleConfig.IncludeGlobalState { get; set; } + Indices ISnapshotLifecycleConfig.Indices { get; set; } + + public SnapshotLifecycleConfigDescriptor Indices(IndexName index) => Indices((Indices)index); + + public SnapshotLifecycleConfigDescriptor Indices() where T : class => Indices(typeof(T)); + + public SnapshotLifecycleConfigDescriptor Indices(Indices indices) => Assign(indices, (a, v) => a.Indices = v); + + public SnapshotLifecycleConfigDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Assign(ignoreUnavailable, (a, v) => a.IgnoreUnavailable = v); + + public SnapshotLifecycleConfigDescriptor IncludeGlobalState(bool? includeGlobalState = true) => Assign(includeGlobalState, (a, v) => a.IncludeGlobalState = v); + } +} diff --git a/src/Nest/XPack/Slm/SnapshotLifecyclePolicy.cs b/src/Nest/XPack/Slm/SnapshotLifecyclePolicy.cs new file mode 100644 index 00000000000..12009ddb3fb --- /dev/null +++ b/src/Nest/XPack/Slm/SnapshotLifecyclePolicy.cs @@ -0,0 +1,58 @@ +using System.Runtime.Serialization; +using Elasticsearch.Net.Utf8Json; + +namespace Nest +{ + /// + /// A snapshot lifecycle policy + /// + public class SnapshotLifecyclePolicy + : ISnapshotLifecyclePolicy + { + /// + public ISnapshotLifecycleConfig Config { get; set; } + + /// + public string Name { get; set; } + + /// + public string Repository { get; set; } + + /// + public CronExpression Schedule { get; set; } + } + + /// + [InterfaceDataContract] + [ReadAs(typeof(SnapshotLifecyclePolicy))] + public interface ISnapshotLifecyclePolicy + { + /// + /// Configuration for each snapshot that will be created by this policy. + /// + [DataMember(Name = "config")] + ISnapshotLifecycleConfig Config { get; set; } + + /// + /// A name automatically given to each snapshot performed by this policy. + /// Supports the same date math supported in index names. A UUID is automatically appended to the + /// end of the name to prevent conflicting snapshot names. + /// + [DataMember(Name = "name")] + string Name { get; set; } + + /// + /// The snapshot repository that will contain snapshots created by this policy. + /// The repository must exist prior to the policy’s creation and can be created + /// with the Snapshot CreateRespository API. + /// + [DataMember(Name = "repository")] + string Repository { get; set; } + + /// + /// A periodic or absolute time schedule specified as a cron expression. + /// + [DataMember(Name = "schedule")] + CronExpression Schedule { get; set; } + } +} diff --git a/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs b/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs new file mode 100644 index 00000000000..1895eb516c0 --- /dev/null +++ b/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs @@ -0,0 +1,49 @@ +using System; +using System.Runtime.Serialization; + +namespace Nest +{ + /// + /// Metadata about a Snapshot lifecycle policy + /// + public class SnapshotLifecyclePolicyMetadata + { + /// + /// The modified date. + /// Returned only when Human is set to true on the request + /// + [DataMember(Name = "modified_date")] + public DateTimeOffset? ModifiedDate { get; internal set; } + + /// + /// The modified date in milliseconds + /// + [DataMember(Name = "modified_date_millis")] + public long ModifiedDateInMilliseconds { get; internal set; } + + /// + /// The next execution date. + /// Returned only when Human is set to true on the request + /// + [DataMember(Name = "next_execution")] + public DateTimeOffset? NextExecution { get; internal set; } + + /// + /// The next execution date in milliseconds + /// + [DataMember(Name = "next_execution_millis")] + public long NextExecutionInMilliseconds { get; internal set; } + + /// + /// The snapshot lifecycle policy + /// + [DataMember(Name = "policy")] + public SnapshotLifecyclePolicy Policy { get; internal set; } + + /// + /// The version + /// + [DataMember(Name = "version")] + public int Version { get; internal set; } + } +} diff --git a/src/Nest/_Generated/ApiUrlsLookup.generated.cs b/src/Nest/_Generated/ApiUrlsLookup.generated.cs index 6a5f159be75..cfebde29516 100644 --- a/src/Nest/_Generated/ApiUrlsLookup.generated.cs +++ b/src/Nest/_Generated/ApiUrlsLookup.generated.cs @@ -232,6 +232,10 @@ internal static class ApiUrlsLookups internal static ApiUrls SecurityPutRole = new ApiUrls(new[]{"_security/role/{name}"}); internal static ApiUrls SecurityPutRoleMapping = new ApiUrls(new[]{"_security/role_mapping/{name}"}); internal static ApiUrls SecurityPutUser = new ApiUrls(new[]{"_security/user/{username}"}); + internal static ApiUrls SnapshotLifecycleManagementDeleteSnapshotLifecycle = new ApiUrls(new[]{"_slm/policy/{policy_id}"}); + internal static ApiUrls SnapshotLifecycleManagementExecuteSnapshotLifecycle = new ApiUrls(new[]{"_slm/policy/{policy_id}/_execute"}); + internal static ApiUrls SnapshotLifecycleManagementGetSnapshotLifecycle = new ApiUrls(new[]{"_slm/policy/{policy_id}", "_slm/policy"}); + internal static ApiUrls SnapshotLifecycleManagementPutSnapshotLifecycle = new ApiUrls(new[]{"_slm/policy/{policy_id}"}); internal static ApiUrls SnapshotSnapshot = new ApiUrls(new[]{"_snapshot/{repository}/{snapshot}"}); internal static ApiUrls SnapshotCreateRepository = new ApiUrls(new[]{"_snapshot/{repository}"}); internal static ApiUrls SnapshotDelete = new ApiUrls(new[]{"_snapshot/{repository}/{snapshot}"}); diff --git a/src/Tests/Tests/XPack/Slm/SlmApiTests.cs b/src/Tests/Tests/XPack/Slm/SlmApiTests.cs new file mode 100644 index 00000000000..6ddc8424144 --- /dev/null +++ b/src/Tests/Tests/XPack/Slm/SlmApiTests.cs @@ -0,0 +1,171 @@ +using System; +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using FluentAssertions; +using Nest; +using Tests.Core.Extensions; +using Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Domain; +using Tests.Framework.EndpointTests; +using Tests.Framework.EndpointTests.TestState; + +namespace Tests.XPack.Slm +{ + [SkipVersion("<7.4.0", "All APIs exist in Elasticsearch 7.4.0")] + public class SlmApiTests : CoordinatedIntegrationTestBase + { + private const string CreateRepositoryStep = nameof(CreateRepositoryStep); + private const string DeleteSnapshotLifecycleStep = nameof(DeleteSnapshotLifecycleStep); + private const string ExecuteSnapshotLifecycleStep = nameof(ExecuteSnapshotLifecycleStep); + private const string GetAllSnapshotLifecycleStep = nameof(GetAllSnapshotLifecycleStep); + private const string GetSnapshotLifecycleStep = nameof(GetSnapshotLifecycleStep); + private const string PutSnapshotLifecycleStep = nameof(PutSnapshotLifecycleStep); + + + public SlmApiTests(XPackCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage) + { + { + CreateRepositoryStep, u => + u.Calls( + v => new CreateRepositoryRequest(v) + { + Repository = new FileSystemRepository(new FileSystemRepositorySettings(cluster.FileSystem.RepositoryPath)) + }, + (v, d) => d.FileSystem(f => f.Settings(cluster.FileSystem.RepositoryPath)), + (v, c, f) => c.Snapshot.CreateRepository(v, f), + (v, c, f) => c.Snapshot.CreateRepositoryAsync(v, f), + (v, c, r) => c.Snapshot.CreateRepository(r), + (v, c, r) => c.Snapshot.CreateRepositoryAsync(r) + ) + }, + { + PutSnapshotLifecycleStep, u => + u.Calls( + v => new PutSnapshotLifecycleRequest(v) + { + Name = v, + Repository = v, + Schedule = "0 0 0 1 1 ? *", + Config = new SnapshotLifecycleConfig + { + Indices = typeof(Project) + } + }, + (v, d) => d + .Name(v) + .Repository(v) + .Schedule("0 0 0 1 1 ? *") + .Config(c => c + .Indices() + ), + (v, c, f) => c.SnapshotLifecycleManagement.PutSnapshotLifecycle(v, f), + (v, c, f) => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync(v, f), + (v, c, r) => c.SnapshotLifecycleManagement.PutSnapshotLifecycle(r), + (v, c, r) => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync(r) + ) + }, + { + GetSnapshotLifecycleStep, u => + u.Calls( + v => new GetSnapshotLifecycleRequest(v) + { + Human = true + }, + (v, d) => d.PolicyId(v).Human(), + (v, c, f) => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(f), + (v, c, f) => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(f), + (v, c, r) => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(r), + (v, c, r) => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(r) + ) + }, + { + GetAllSnapshotLifecycleStep, u => + u.Calls( + v => new GetSnapshotLifecycleRequest(), + (v, d) => d, + (v, c, f) => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(f), + (v, c, f) => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(f), + (v, c, r) => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(r), + (v, c, r) => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(r) + ) + }, + { + ExecuteSnapshotLifecycleStep, u => + u.Calls( + v => new ExecuteSnapshotLifecycleRequest(v), + (v, d) => d, + (v, c, f) => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle(v, f), + (v, c, f) => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync(v, f), + (v, c, r) => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle(r), + (v, c, r) => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync(r) + ) + }, + { + DeleteSnapshotLifecycleStep, u => + u.Calls( + v => new DeleteSnapshotLifecycleRequest(v), + (v, d) => d, + (v, c, f) => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle(v, f), + (v, c, f) => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync(v, f), + (v, c, r) => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle(r), + (v, c, r) => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync(r) + ) + }, + }) { } + + [I] public async Task CreateRepositoryResponse() => await Assert(CreateRepositoryStep, (v, r) => + { + r.IsValid.Should().BeTrue(); + r.Acknowledged.Should().BeTrue(); + r.ApiCall.HttpStatusCode.Should().Be(200); + }); + + [I] public async Task PutSnapshotLifecycleResponse() => await Assert(PutSnapshotLifecycleStep, (v, r) => + { + r.IsValid.Should().BeTrue(); + r.Acknowledged.Should().BeTrue(); + r.ApiCall.HttpStatusCode.Should().Be(200); + }); + + [I] public async Task GetSnapshotLifecycleResponse() => await Assert(GetSnapshotLifecycleStep, (v, r) => + { + r.IsValid.Should().BeTrue(); + r.Policies.Should().NotBeNull().And.HaveCount(1).And.ContainKey(v); + + var metadata = r.Policies[v]; + + metadata.Version.Should().Be(1); + metadata.ModifiedDate.Should().BeAfter(DateTimeOffset.MinValue); + metadata.ModifiedDateInMilliseconds.Should().BeGreaterThan(0); + metadata.NextExecution.Should().BeAfter(DateTimeOffset.MinValue); + metadata.NextExecutionInMilliseconds.Should().BeGreaterThan(0); + metadata.Policy.Name.Should().Be(v); + metadata.Policy.Repository.Should().Be(v); + metadata.Policy.Schedule.Should().BeEquivalentTo(new CronExpression("0 0 0 1 1 ? *")); + metadata.Policy.Config.Should().NotBeNull(); + metadata.Policy.Config.Indices.Should().NotBeNull().And.Be(Nest.Indices.Parse("project")); + }); + + [I] public async Task GetAllSnapshotLifecycleResponse() => await Assert(GetAllSnapshotLifecycleStep, (v, r) => + { + r.IsValid.Should().BeTrue(); + r.Policies.Should().NotBeNull().And.HaveCount(4).And.ContainKey(v); + }); + + [I] public async Task ExecuteSnapshotLifecycleResponse() => await Assert(ExecuteSnapshotLifecycleStep, + (v, r) => + { + r.IsValid.Should().BeTrue(); + r.SnapshotName.Should().NotBeNull(); + }); + + [I] public async Task DeleteSnapshotLifecycleResponse() => await Assert(DeleteSnapshotLifecycleStep, + (v, r) => + { + r.IsValid.Should().BeTrue(); + r.Acknowledged.Should().BeTrue(); + }); + } +} diff --git a/src/Tests/Tests/XPack/Slm/SlmUrlTests.cs b/src/Tests/Tests/XPack/Slm/SlmUrlTests.cs new file mode 100644 index 00000000000..951564aa777 --- /dev/null +++ b/src/Tests/Tests/XPack/Slm/SlmUrlTests.cs @@ -0,0 +1,56 @@ +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using Nest; +using Tests.Framework.EndpointTests; +using static Tests.Framework.EndpointTests.UrlTester; + +namespace Tests.XPack.Slm +{ + public class SlmUrlTests : UrlTestsBase + { + [U] public override async Task Urls() + { + await PUT("/_slm/policy/policy_id") + .Fluent(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycle("policy_id")) + .Request(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycle(new PutSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync("policy_id")) + .RequestAsync(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync(new PutSnapshotLifecycleRequest("policy_id"))) + ; + + await GET("/_slm/policy/policy_id") + .Fluent(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(g => g.PolicyId("policy_id"))) + .Request(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(new GetSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(g => g.PolicyId("policy_id"))) + .RequestAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(new GetSnapshotLifecycleRequest("policy_id"))) + ; + + await GET("/_slm/policy/policy_id1%2Cpolicy_id2") + .Fluent(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(g => g.PolicyId("policy_id1,policy_id2"))) + .Request(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(new GetSnapshotLifecycleRequest(new [] { "policy_id1","policy_id2" }))) + .FluentAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(g => g.PolicyId("policy_id1,policy_id2"))) + .RequestAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(new GetSnapshotLifecycleRequest("policy_id1,policy_id2"))) + ; + + await GET("/_slm/policy") + .Fluent(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle()) + .Request(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(new GetSnapshotLifecycleRequest())) + .FluentAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync()) + .RequestAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(new GetSnapshotLifecycleRequest())) + ; + + await PUT("/_slm/policy/policy_id/_execute") + .Fluent(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle("policy_id")) + .Request(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle(new ExecuteSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync("policy_id")) + .RequestAsync(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync(new ExecuteSnapshotLifecycleRequest("policy_id"))) + ; + + await DELETE("/_slm/policy/policy_id") + .Fluent(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle("policy_id")) + .Request(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle(new DeleteSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync("policy_id")) + .RequestAsync(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync(new DeleteSnapshotLifecycleRequest("policy_id"))) + ; + } + } +} From 88c83757e5c4c9b8163f9dfdcd415a8b4a5971b0 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Fri, 11 Oct 2019 17:57:19 +1000 Subject: [PATCH 2/2] Split url tests out into separate classes --- .../DeleteLifecycleUrlTests.cs | 18 +++++++++++++ .../ExecuteLifecycleUrlTests.cs | 18 +++++++++++++ .../GetLifecycleUrlTests.cs} | 25 ++----------------- .../Slm/PutLifecycle/PutLifecycleUrlTests.cs | 18 +++++++++++++ 4 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 src/Tests/Tests/XPack/Slm/DeleteLifecycle/DeleteLifecycleUrlTests.cs create mode 100644 src/Tests/Tests/XPack/Slm/ExecuteLifecycle/ExecuteLifecycleUrlTests.cs rename src/Tests/Tests/XPack/Slm/{SlmUrlTests.cs => GetLifecycle/GetLifecycleUrlTests.cs} (53%) create mode 100644 src/Tests/Tests/XPack/Slm/PutLifecycle/PutLifecycleUrlTests.cs diff --git a/src/Tests/Tests/XPack/Slm/DeleteLifecycle/DeleteLifecycleUrlTests.cs b/src/Tests/Tests/XPack/Slm/DeleteLifecycle/DeleteLifecycleUrlTests.cs new file mode 100644 index 00000000000..f73397b4c38 --- /dev/null +++ b/src/Tests/Tests/XPack/Slm/DeleteLifecycle/DeleteLifecycleUrlTests.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using Nest; +using Tests.Framework.EndpointTests; +using static Tests.Framework.EndpointTests.UrlTester; + +namespace Tests.XPack.Slm.DeleteLifecycle +{ + public class DeleteLifecycleUrlTests : UrlTestsBase + { + [U] public override async Task Urls() => + await DELETE("/_slm/policy/policy_id") + .Fluent(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle("policy_id")) + .Request(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle(new DeleteSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync("policy_id")) + .RequestAsync(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync(new DeleteSnapshotLifecycleRequest("policy_id"))); + } +} diff --git a/src/Tests/Tests/XPack/Slm/ExecuteLifecycle/ExecuteLifecycleUrlTests.cs b/src/Tests/Tests/XPack/Slm/ExecuteLifecycle/ExecuteLifecycleUrlTests.cs new file mode 100644 index 00000000000..9891cc3ab81 --- /dev/null +++ b/src/Tests/Tests/XPack/Slm/ExecuteLifecycle/ExecuteLifecycleUrlTests.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using Nest; +using Tests.Framework.EndpointTests; +using static Tests.Framework.EndpointTests.UrlTester; + +namespace Tests.XPack.Slm.ExecuteLifecycle +{ + public class ExecuteLifecycleUrlTests : UrlTestsBase + { + [U] public override async Task Urls() => + await PUT("/_slm/policy/policy_id/_execute") + .Fluent(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle("policy_id")) + .Request(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle(new ExecuteSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync("policy_id")) + .RequestAsync(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync(new ExecuteSnapshotLifecycleRequest("policy_id"))); + } +} diff --git a/src/Tests/Tests/XPack/Slm/SlmUrlTests.cs b/src/Tests/Tests/XPack/Slm/GetLifecycle/GetLifecycleUrlTests.cs similarity index 53% rename from src/Tests/Tests/XPack/Slm/SlmUrlTests.cs rename to src/Tests/Tests/XPack/Slm/GetLifecycle/GetLifecycleUrlTests.cs index 951564aa777..8e82e7bdd83 100644 --- a/src/Tests/Tests/XPack/Slm/SlmUrlTests.cs +++ b/src/Tests/Tests/XPack/Slm/GetLifecycle/GetLifecycleUrlTests.cs @@ -4,19 +4,12 @@ using Tests.Framework.EndpointTests; using static Tests.Framework.EndpointTests.UrlTester; -namespace Tests.XPack.Slm +namespace Tests.XPack.Slm.GetLifecycle { - public class SlmUrlTests : UrlTestsBase + public class GetLifecycleUrlTests : UrlTestsBase { [U] public override async Task Urls() { - await PUT("/_slm/policy/policy_id") - .Fluent(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycle("policy_id")) - .Request(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycle(new PutSnapshotLifecycleRequest("policy_id"))) - .FluentAsync(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync("policy_id")) - .RequestAsync(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync(new PutSnapshotLifecycleRequest("policy_id"))) - ; - await GET("/_slm/policy/policy_id") .Fluent(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(g => g.PolicyId("policy_id"))) .Request(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycle(new GetSnapshotLifecycleRequest("policy_id"))) @@ -37,20 +30,6 @@ await GET("/_slm/policy") .FluentAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync()) .RequestAsync(c => c.SnapshotLifecycleManagement.GetSnapshotLifecycleAsync(new GetSnapshotLifecycleRequest())) ; - - await PUT("/_slm/policy/policy_id/_execute") - .Fluent(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle("policy_id")) - .Request(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycle(new ExecuteSnapshotLifecycleRequest("policy_id"))) - .FluentAsync(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync("policy_id")) - .RequestAsync(c => c.SnapshotLifecycleManagement.ExecuteSnapshotLifecycleAsync(new ExecuteSnapshotLifecycleRequest("policy_id"))) - ; - - await DELETE("/_slm/policy/policy_id") - .Fluent(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle("policy_id")) - .Request(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycle(new DeleteSnapshotLifecycleRequest("policy_id"))) - .FluentAsync(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync("policy_id")) - .RequestAsync(c => c.SnapshotLifecycleManagement.DeleteSnapshotLifecycleAsync(new DeleteSnapshotLifecycleRequest("policy_id"))) - ; } } } diff --git a/src/Tests/Tests/XPack/Slm/PutLifecycle/PutLifecycleUrlTests.cs b/src/Tests/Tests/XPack/Slm/PutLifecycle/PutLifecycleUrlTests.cs new file mode 100644 index 00000000000..bf20fba9602 --- /dev/null +++ b/src/Tests/Tests/XPack/Slm/PutLifecycle/PutLifecycleUrlTests.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using Nest; +using Tests.Framework.EndpointTests; +using static Tests.Framework.EndpointTests.UrlTester; + +namespace Tests.XPack.Slm.PutLifecycle +{ + public class PutLifecycleUrlTests : UrlTestsBase + { + [U] public override async Task Urls() => + await PUT("/_slm/policy/policy_id") + .Fluent(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycle("policy_id")) + .Request(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycle(new PutSnapshotLifecycleRequest("policy_id"))) + .FluentAsync(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync("policy_id")) + .RequestAsync(c => c.SnapshotLifecycleManagement.PutSnapshotLifecycleAsync(new PutSnapshotLifecycleRequest("policy_id"))); + } +}