Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-generate snapshot namespace #351

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static class CodeConfiguration
// e.g. new Glob("nodes.*"),
new("dangling_indices.*"),
new("ingest.*"),
new("snapshot.*"),
new("tasks.*")
};

Expand Down
17 changes: 7 additions & 10 deletions src/ApiGenerator/Domain/Specification/ApiEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ public class ApiEndpoint
HttpMethod = PreferredHttpMethod
};

public string PreferredHttpMethod
{
get
public string PreferredHttpMethod =>
HttpMethods.OrderByDescending(m => m switch
{
var first = HttpMethods.First();
if (HttpMethods.Count > 1 && first.ToUpperInvariant() == "GET")
return HttpMethods.Last();

return first;
}
}
"GET" => 0,
"POST" => 1,
"PUT" or "DELETE" or "PATCH" or "HEAD" => 2, // Prefer "resource" methods over GET/POST methods
_ => -1
}).First();

public string HighLevelMethodXmlDocDescription =>
$"<c>{PreferredHttpMethod}</c> request to the <c>{Name}</c> API, read more about this API online:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class HighLevelClientImplementationGenerator : RazorGeneratorBase
public override async Task Generate(RestApiSpec spec, ProgressBar progressBar, CancellationToken token)
{
var view = ViewLocations.HighLevel("Client", "Implementation", "OpenSearchClient.cshtml");
var target = GeneratorLocations.HighLevel($"OpenSearchClient.{CsharpNames.RootNamespace}.cs");
var target = GeneratorLocations.HighLevel($"OpenSearchClient.cs");
await DoRazor(spec, view, target, token);

string Target(string id) => GeneratorLocations.HighLevel($"OpenSearchClient.{id}.cs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LowLevelClientImplementationGenerator : RazorGeneratorBase
public override async Task Generate(RestApiSpec spec, ProgressBar progressBar, CancellationToken token)
{
var view = ViewLocations.LowLevel("Client", "Implementation", "OpenSearchLowLevelClient.cshtml");
var target = GeneratorLocations.LowLevel($"OpenSearchLowLevelClient.{CsharpNames.RootNamespace}.cs");
var target = GeneratorLocations.LowLevel("OpenSearchLowLevelClient.cs");
await DoRazor(spec, view, target, token);

var namespaced = spec.EndpointsPerNamespaceLowLevel.Where(kv => kv.Key != CsharpNames.RootNamespace).ToList();
Expand Down
11 changes: 0 additions & 11 deletions src/OpenSearch.Client/ApiUrlsLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,6 @@ internal static partial class ApiUrlsLookups
internal static ApiUrls NoNamespaceSearch = new ApiUrls(new[]{"_search", "{index}/_search"});
internal static ApiUrls NoNamespaceSearchShards = new ApiUrls(new[]{"_search_shards", "{index}/_search_shards"});
internal static ApiUrls NoNamespaceSearchTemplate = new ApiUrls(new[]{"_search/template", "{index}/_search/template"});
internal static ApiUrls SnapshotCleanupRepository = new ApiUrls(new[]{"_snapshot/{repository}/_cleanup"});
internal static ApiUrls SnapshotClone = new ApiUrls(new[]{"_snapshot/{repository}/{snapshot}/_clone/{target_snapshot}"});
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}"});
internal static ApiUrls SnapshotDeleteRepository = new ApiUrls(new[]{"_snapshot/{repository}"});
internal static ApiUrls SnapshotGet = new ApiUrls(new[]{"_snapshot/{repository}/{snapshot}"});
internal static ApiUrls SnapshotGetRepository = new ApiUrls(new[]{"_snapshot", "_snapshot/{repository}"});
internal static ApiUrls SnapshotRestore = new ApiUrls(new[]{"_snapshot/{repository}/{snapshot}/_restore"});
internal static ApiUrls SnapshotStatus = new ApiUrls(new[]{"_snapshot/_status", "_snapshot/{repository}/_status", "_snapshot/{repository}/{snapshot}/_status"});
internal static ApiUrls SnapshotVerifyRepository = new ApiUrls(new[]{"_snapshot/{repository}/_verify"});
internal static ApiUrls NoNamespaceTermVectors = new ApiUrls(new[]{"{index}/_termvectors/{id}", "{index}/_termvectors"});
internal static ApiUrls NoNamespaceUpdate = new ApiUrls(new[]{"{index}/_update/{id}"});
internal static ApiUrls NoNamespaceUpdateByQuery = new ApiUrls(new[]{"{index}/_update_by_query"});
Expand Down
402 changes: 0 additions & 402 deletions src/OpenSearch.Client/Descriptors.Snapshot.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/OpenSearch.Client/IOpenSearchClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,11 +1024,5 @@ Task<UpdateByQueryResponse> UpdateByQueryAsync<TDocument>(Func<UpdateByQueryDesc
/// <a href = "https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/update-by-query/">https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/update-by-query/</a>
/// </summary>
Task<ListTasksResponse> UpdateByQueryRethrottleAsync(IUpdateByQueryRethrottleRequest request, CancellationToken ct = default);

///<summary>Snapshot APIs</summary>
SnapshotNamespace Snapshot
{
get;
}
}
}
4 changes: 4 additions & 0 deletions src/OpenSearch.Client/OpenSearch.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@
<AutoGen>True</AutoGen>
<DependentUpon>OpenSearchClient.cs</DependentUpon>
</Compile>
<Compile Update="_Generated\OpenSearchClient.*.cs">
<AutoGen>True</AutoGen>
<DependentUpon>OpenSearchClient.cs</DependentUpon>
</Compile>
</ItemGroup>
</Project>
8 changes: 0 additions & 8 deletions src/OpenSearch.Client/OpenSearchClient.NoNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,12 @@ public NodesNamespace Nodes
private set;
}

///<summary>Snapshot APIs</summary>
public SnapshotNamespace Snapshot
{
get;
private set;
}

partial void SetupNamespaces()
{
Cat = new CatNamespace(this);
Cluster = new ClusterNamespace(this);
Indices = new IndicesNamespace(this);
Nodes = new NodesNamespace(this);
Snapshot = new SnapshotNamespace(this);
}

/// <summary>
Expand Down
Loading
Loading