Skip to content

Commit

Permalink
Ensure generated code is in-line with the backported operations
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Dec 10, 2023
1 parent 87f7b08 commit e49af4e
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 62 deletions.
11 changes: 2 additions & 9 deletions src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,8 @@ public static class CodeConfiguration
new("{create,delete}_pit"),
new("{delete,get}_all_pits"),

new("cluster.*"),
new("dangling_indices.*"),

new("indices.{delete,exists,get,put}_index_template"),

new("ingest.*"),
new("nodes.*"),
new("snapshot.*"),
new("tasks.*")
new("cluster.{delete,exists,get,put}_component_template"),
new("indices.{delete,exists,get,put}_index_template")
};

public static bool IncludeOperation(string name) => OperationsToInclude.Any(g => g.IsMatch(name));
Expand Down
13 changes: 7 additions & 6 deletions src/ApiGenerator/OpenSearch.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -22364,7 +22364,7 @@
{
"name": "op_type",
"in": "query",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID.",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create` for requests without an explicit document ID.",
"schema": {
"$ref": "#/components/schemas/OpType"
}
Expand Down Expand Up @@ -22961,7 +22961,7 @@
{
"name": "op_type",
"in": "query",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID.",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create` for requests without an explicit document ID.",
"schema": {
"$ref": "#/components/schemas/OpType"
}
Expand Down Expand Up @@ -23109,7 +23109,7 @@
{
"name": "op_type",
"in": "query",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID.",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create` for requests without an explicit document ID.",
"schema": {
"$ref": "#/components/schemas/OpType"
}
Expand Down Expand Up @@ -26671,8 +26671,9 @@
"description": "Specify the keep alive for point in time.",
"schema": {
"type": "string",
"pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$",
"description": "Specify the keep alive for point in time.",
"x-data-type": "time"
"x-data-type": "time"
}
},
{
Expand Down Expand Up @@ -30720,7 +30721,7 @@
"pit_id": {
"type": "string"
},
"_shard": {
"_shards": {
"$ref": "#/components/schemas/ShardStatistics"
},
"creation_time": {
Expand Down Expand Up @@ -31513,7 +31514,7 @@
},
"OpType": {
"type": "string",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID.",
"description": "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create` for requests without an explicit document ID.",
"enum": [
"index",
"create"
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

using System.Text;
using OpenSearch.Net;
using OpenSearch.Net.Utf8Json;
using OpenSearch.Net.Specification.ClusterApi;
using OpenSearch.Net.Utf8Json;

// ReSharper disable RedundantBaseConstructorCall
// ReSharper disable UnusedTypeParameter
Expand Down
3 changes: 1 addition & 2 deletions src/OpenSearch.Client/_Generated/Descriptors.NoNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

using System.Text;
using OpenSearch.Net;
using OpenSearch.Net.Utf8Json;

Expand Down
50 changes: 50 additions & 0 deletions src/OpenSearch.Client/_Generated/Descriptors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// -----------------------------------------------
//
// 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
//
// -----------------------------------------------
using System.Collections.Generic;

namespace OpenSearch.Client
{
// ReSharper disable UnusedTypeParameter
public abstract partial class RequestDescriptorBase<TDescriptor, TParameters, TInterface> { }
}
2 changes: 1 addition & 1 deletion src/OpenSearch.Client/_Generated/IOpenSearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using OpenSearch.Client;
using OpenSearch.Client.Specification.ClusterApi;
using OpenSearch.Client.Specification.HttpApi;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSearch.Client/_Generated/Requests.Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Runtime.Serialization;
using System.Text;
using OpenSearch.Net;
using OpenSearch.Net.Utf8Json;
using OpenSearch.Net.Specification.ClusterApi;
using OpenSearch.Net.Utf8Json;

// ReSharper disable RedundantBaseConstructorCall
// ReSharper disable UnusedTypeParameter
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch.Client/_Generated/Requests.NoNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Runtime.Serialization;
using System.Text;
using OpenSearch.Net;
using OpenSearch.Net.Utf8Json;

Expand Down
40 changes: 4 additions & 36 deletions src/OpenSearch.Net/Api/Enums.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,6 @@ public enum DefaultOperator
Or
}

[StringEnum]
public enum ExpandWildcards
{
[EnumMember(Value = "open")]
Open,
[EnumMember(Value = "closed")]
Closed,
[EnumMember(Value = "hidden")]
Hidden,
[EnumMember(Value = "none")]
None,
[EnumMember(Value = "all")]
All
}

[StringEnum]
public enum SearchType
{
Expand Down Expand Up @@ -433,7 +418,7 @@ public enum GroupBy
None
}

public static class KnownEnums
public static partial class KnownEnums
{
private static readonly ConcurrentDictionary<Type, Func<Enum, string>> EnumStringResolvers = new ConcurrentDictionary<Type, Func<Enum, string>>();
static KnownEnums()
Expand All @@ -445,7 +430,6 @@ static KnownEnums()
EnumStringResolvers.TryAdd(typeof(NodesStatsIndexMetric), (e) => GetStringValue((NodesStatsIndexMetric)e));
EnumStringResolvers.TryAdd(typeof(NodesUsageMetric), (e) => GetStringValue((NodesUsageMetric)e));
EnumStringResolvers.TryAdd(typeof(DefaultOperator), (e) => GetStringValue((DefaultOperator)e));
EnumStringResolvers.TryAdd(typeof(ExpandWildcards), (e) => GetStringValue((ExpandWildcards)e));
EnumStringResolvers.TryAdd(typeof(SearchType), (e) => GetStringValue((SearchType)e));
EnumStringResolvers.TryAdd(typeof(SuggestMode), (e) => GetStringValue((SuggestMode)e));
EnumStringResolvers.TryAdd(typeof(Refresh), (e) => GetStringValue((Refresh)e));
Expand All @@ -462,8 +446,11 @@ static KnownEnums()
EnumStringResolvers.TryAdd(typeof(IndicesShardStoresStatus), (e) => GetStringValue((IndicesShardStoresStatus)e));
EnumStringResolvers.TryAdd(typeof(ThreadType), (e) => GetStringValue((ThreadType)e));
EnumStringResolvers.TryAdd(typeof(GroupBy), (e) => GetStringValue((GroupBy)e));
RegisterEnumStringResolvers();
}

static partial void RegisterEnumStringResolvers();

private class EnumDictionary : Dictionary<Enum, string>
{
public EnumDictionary(int capacity): base(capacity)
Expand Down Expand Up @@ -658,25 +645,6 @@ public static string GetStringValue(this DefaultOperator enumValue)
throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'DefaultOperator'");
}

public static string GetStringValue(this ExpandWildcards enumValue)
{
switch (enumValue)
{
case ExpandWildcards.Open:
return "open";
case ExpandWildcards.Closed:
return "closed";
case ExpandWildcards.Hidden:
return "hidden";
case ExpandWildcards.None:
return "none";
case ExpandWildcards.All:
return "all";
}

throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'ExpandWildcards'");
}

public static string GetStringValue(this SearchType enumValue)
{
switch (enumValue)
Expand Down
104 changes: 104 additions & 0 deletions src/OpenSearch.Net/_Generated/Api/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// -----------------------------------------------
//
// 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.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;

namespace OpenSearch.Net
{
[StringEnum]
public enum ExpandWildcards
{
[EnumMember(Value = "all")]
All,

[EnumMember(Value = "open")]
Open,

[EnumMember(Value = "closed")]
Closed,

[EnumMember(Value = "hidden")]
Hidden,

[EnumMember(Value = "none")]
None
}

public static partial class KnownEnums
{
static partial void RegisterEnumStringResolvers()
{
EnumStringResolvers.TryAdd(
typeof(ExpandWildcards),
e => GetStringValue((ExpandWildcards)e)
);
}

public static string GetStringValue(this ExpandWildcards enumValue)
{
switch (enumValue)
{
case ExpandWildcards.All:
return "all";
case ExpandWildcards.Open:
return "open";
case ExpandWildcards.Closed:
return "closed";
case ExpandWildcards.Hidden:
return "hidden";
case ExpandWildcards.None:
return "none";
}
throw new ArgumentException(
$"'{enumValue.ToString()}' is not a valid value for enum 'ExpandWildcards'"
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Text;

// ReSharper disable once CheckNamespace
namespace OpenSearch.Net.Specification.ClusterApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Text;

// ReSharper disable once CheckNamespace
namespace OpenSearch.Net
Expand Down

0 comments on commit e49af4e

Please sign in to comment.