> For the complete documentation index, see [llms.txt](https://botes.gitbook.io/botes-dataset/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://botes.gitbook.io/botes-dataset/botes-enrichement/poc-code.md).

# POC Code

POC code can be find on Github here: <https://github.com/NybbleHub/BOTES-Enrichment>

## Code details

Code contains few comments but let's explain some parts

### AsyncDataStream&#x20;

The following line is used to create an asynchronous DataStream :

```
DataStream<String> enrichmentStreamFile = AsyncDataStream.unorderedWait
    (logsStreamFile, new AsyncRedisFileEnrichment(), 
    5000, TimeUnit.MILLISECONDS).setParallelism(4);
```

Asynchronous DataStream options/parameters are the following :

* **unorderedwait:** with this mode, results of async functions are emitted as soon as the async requests finish. So order will maybe not conserved.
* **logsStreamFile:** it's the source DataStream used to create the new AsyncDataSteam.
* **new AsyncRedisFileEnrichment():** It's the asynchronous function which wil be called for processing logic on stream.
* **5000, TimeUnit.MILLISECONDS:** Time after an asynchronous call is declared as timed out.
* **setParallelism:** set the parallelism for the asynchronous function.

### AsynHttpRequest

```java
AsyncHttpClient onypheAsyncClient = asyncHttpClient();
Future<Response> onypheGetRequest = onypheAsyncClient.prepareGet(
    "https://www.onyphe.io/api/ip/" + onypheQueryIP + "?apikey=" + onypheAPIKey).execute();

onypheGetBody = mapper.readValue(onypheGetRequest.get().getResponseBody(), ObjectNode.class);
if (!onypheGetBody.has("results")) {
    return "{}";
} else {
    if (!onypheGetBody.get("results").hasNonNull(1)) {
        return "{}";
    } else {
        onypheResult = processOnypheGetResult(onypheGetBody);
        return onypheResult;
    }
}
```

Purpose of this code is to make asynchronous API call to get result on an IP or File hash.

* Line 1: Create AsyncHttpClient
* Line 2: Launch a request on Onyphe API to get result on IP address.
* Line 5: Get the result of API call from Response Body.
* Line 6 -11: Check if response contains results or if response is not null (In case of no more credits to call API).
* Line 12-13: Call "processOnypheGetResult" function to extract relevant information from Onyphe (JSON) results and return a new JSON with fields formatted to be compliant with ECS format. &#x20;

Comments this section if you want more details on specific parts of code.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://botes.gitbook.io/botes-dataset/botes-enrichement/poc-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
