Skip to content

Commit

Permalink
feat(api): openAPI code generator - poc (wip)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Gfeller <[email protected]>
  • Loading branch information
pgfeller committed Dec 27, 2024
1 parent edebc03 commit dbc5453
Show file tree
Hide file tree
Showing 2,196 changed files with 308,273 additions and 321,195 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/bash

set -e

VERSIONS=("10.8.13" "10.10.3")
REQUIRED=("wget" "yq" "openapi-generator-cli")

function checkEnvironment() {
for i in "${REQUIRED[@]}"; do
if ! type $i &>/dev/null; then
echo "⚠️ [${i}] could not be found"
exit 127
fi
done
}

checkEnvironment

for i in "${VERSIONS[@]}"; do
echo "ℹ️ - API Version to generate: $i"

FILENAME_JSON="./specifications/json/jellyfin-openapi-${i}.json"
FILENAME_YAML="./specifications/yaml/jellyfin-openapi-${i}.yaml"

if [ ! -e "${FILENAME_JSON}" ]; then
echo "⏬ - Downloading OPENAPI definition for Version ${i}"

SERVER=https://repo.jellyfin.org/files/openapi/stable/jellyfin-openapi-${i}.json

wget \
--no-verbose \
--output-document=${FILENAME_JSON} \
${SERVER}

if [ ! -e "${FILENAME_YAML}" ]; then
echo "⚙️ - json ➡️ yaml"
yq -oy ${FILENAME_JSON} >${FILENAME_YAML}
fi
fi

echo "⚙️ - generate code for API ${i}"

# TODO: config.yaml - https://openapi-generator.tech/docs/customization
openapi-generator-cli generate -g java \
--global-property models,modelTests=false,apis,apiTests=false,library=native,serializationLibrary=jackson,apiPackage=org.openhab.binding.jellyfin.internal.api.${i} \
--input-spec ${FILENAME_YAML} -o ./generated/${i} 1>/dev/null
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ActivityLogApi

All URIs are relative to *http://localhost*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**getLogEntries**](ActivityLogApi.md#getLogEntries) | **GET** /System/ActivityLog/Entries | Gets activity log entries. |


<a id="getLogEntries"></a>
# **getLogEntries**
> ActivityLogEntryQueryResult getLogEntries(startIndex, limit, minDate, hasUserId)
Gets activity log entries.

### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.auth.*;
import org.openapitools.client.models.*;
import org.openapitools.client.api.ActivityLogApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");

// Configure API key authorization: CustomAuthentication
ApiKeyAuth CustomAuthentication = (ApiKeyAuth) defaultClient.getAuthentication("CustomAuthentication");
CustomAuthentication.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//CustomAuthentication.setApiKeyPrefix("Token");

ActivityLogApi apiInstance = new ActivityLogApi(defaultClient);
Integer startIndex = 56; // Integer | Optional. The record index to start at. All items with a lower index will be dropped from the results.
Integer limit = 56; // Integer | Optional. The maximum number of records to return.
OffsetDateTime minDate = OffsetDateTime.now(); // OffsetDateTime | Optional. The minimum date. Format = ISO.
Boolean hasUserId = true; // Boolean | Optional. Filter log entries if it has user id, or not.
try {
ActivityLogEntryQueryResult result = apiInstance.getLogEntries(startIndex, limit, minDate, hasUserId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivityLogApi#getLogEntries");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **startIndex** | **Integer**| Optional. The record index to start at. All items with a lower index will be dropped from the results. | [optional] |
| **limit** | **Integer**| Optional. The maximum number of records to return. | [optional] |
| **minDate** | **OffsetDateTime**| Optional. The minimum date. Format &#x3D; ISO. | [optional] |
| **hasUserId** | **Boolean**| Optional. Filter log entries if it has user id, or not. | [optional] |

### Return type

[**ActivityLogEntryQueryResult**](ActivityLogEntryQueryResult.md)

### Authorization

[CustomAuthentication](../README.md#CustomAuthentication)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json, application/json; profile=CamelCase, application/json; profile=PascalCase

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Activity log returned. | - |
| **401** | Unauthorized | - |
| **403** | Forbidden | - |

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


# ActivityLogEntryMessage

Activity log created message.

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**data** | [**List&lt;ActivityLogEntry&gt;**](ActivityLogEntry.md) | Gets or sets the data. | [optional] |
|**messageId** | **UUID** | Gets or sets the message id. | [optional] |
|**messageType** | **SessionMessageType** | The different kinds of messages that are used in the WebSocket api. | [optional] [readonly] |



Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# ActivityLogEntryQueryResult

Query result container.

## Properties

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# ActivityLogEntryStartMessage

Activity log entry start message. Data is the timing data encoded as \"$initialDelay,$interval\" in ms.

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**data** | **String** | Gets or sets the data. | [optional] |
|**messageType** | **SessionMessageType** | The different kinds of messages that are used in the WebSocket api. | [optional] [readonly] |



Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# ActivityLogEntryStopMessage

Activity log entry stop message.

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**messageType** | **SessionMessageType** | The different kinds of messages that are used in the WebSocket api. | [optional] [readonly] |



Loading

0 comments on commit dbc5453

Please sign in to comment.