-
Notifications
You must be signed in to change notification settings - Fork 58
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
[Feature/extensions] Implement createDetector request in AD Extension #58
Comments
As we are looking into creating a SDKClient and calling the REST APIs associated with it to create the AD index
|
1 and 3 will be handled as part of #22 (or are already handled in #23). 2 looks like a dependency on the "user" stored with the detector which in our case will already be "null" so probably requires no action but might need some documentation. 4 is the AdminClient that I think we get for free with the AbstractClient inheritance. |
Opened up #63 to track item 2 above. The rest should be no problem. |
Keeping this on hold until #24 is finished. |
Hi @dbwiddis! To replicate prepareRequest for creating a detector. This issue requires |
#111 (and my PR #163) has implemented the param parts, but content parser is a bigger issue. It's the XContent parser in the existing I see #91 in draft but I don't think that directly solves the problem anyway. One possible solution is to entirely recreate the (JSON, at least) XContent parser on the SDK side of things. We can probably get smart by inheriting classes from OpenSearch but these should be instantiated on the SDK side so they are not passed as part of a RestRequest. I think this should be part of @ryanbogan CreateComponents piece, or at least a follow-on to that piece. |
This solution would require a few things. Digging into |
This is what I'm saying is ugly. I'm suggesting we generate the whole registry fresh on the SDK side. There are a fixed number of registries, see here: The registry is initialized in NamedXContentRegistry xContentRegistry = new NamedXContentRegistry(
Stream.of(
NetworkModule.getNamedXContents().stream(),
IndicesModule.getNamedXContents().stream(),
searchModule.getNamedXContents().stream(),
pluginsService.filterPlugins(Plugin.class).stream().flatMap(p -> p.getNamedXContent().stream()),
ClusterModule.getNamedXWriteables().stream()
).flatMap(Function.identity()).collect(toList())
); The ones starting from uppercase class names (Network, Indices, Cluster) are static and can be called from the SDK side exactly as they are here. |
OK, I'm overcomplicating this with the registries. Let's get back to the parsers. I think I can completely handle this in #163. The REST request will have an enum This enum can just be sent over transport, and then the content parser can be instantiated on the receiving side. So there is no crisis, I just need to add the params, content type enum, and content, and handle it. You may now return to your regular Friday Eve programming. |
Closing the loop here: #163 will send the XContentType to the extension. Because the Part of integrating things (#132) will be finding a new place (probably the |
#163 is now merged, so in an extension when processing an // must null-check request.getXContentType()
request.getXContentType().xContent().createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, content.streamInput()) To create the Add that to an empty registry as follows NamedXContentRegistry xContentRegistry() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, Collections.emptyList());
List<NamedXContentRegistry.Entry> entries = searchModule.getNamedXContents();
entries.addAll(getNamedXContent());
return new NamedXContentRegistry(entries);
} Creating the registry like the above will probably end up being a function of |
The current workflow of AD for creating a detector is:
Since we are using SDKClient which is based on OpenSearch java client, it requires mapping in the form of TypeMapping. To convert the json body of the request to TypeMapping, we are currently exploring the below approaches:
|
Created AD Index with mapping using JsonParser and JsonPMapper provided by java client
|
The next steps are:
|
Was able to create a detector opensearch-project/anomaly-detection#692
|
Create a Transport API for creating Index for AD extension
The text was updated successfully, but these errors were encountered: