Skip to content

Commit

Permalink
refactored models
Browse files Browse the repository at this point in the history
- added new plugin settings endpoints
  • Loading branch information
zAlweNy26 committed Jul 21, 2023
1 parent 3edc532 commit ab329b4
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 67 deletions.
7 changes: 7 additions & 0 deletions .changeset/stupid-onions-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"ccat-api": minor
---

Refactored models

- Added new plugin settings endpoints
6 changes: 4 additions & 2 deletions api/models/ConfigurationsResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
/* tslint:disable */
/* eslint-disable */

import type { Schema } from './Schema';
import type { JsonSchema } from './JsonSchema';
import type { Setting } from './Setting';

export type ConfigurationsResponse = {
status: string;
results: number;
settings: Array<Setting>;
schemas: Record<string, Schema>;
schemas: Record<string, (JsonSchema & {
name_human_readable?: string;
})>;
allowed_configurations: Array<string>;
selected_configuration: string;
};
1 change: 1 addition & 0 deletions api/models/FileResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* eslint-disable */

export type FileResponse = {
status: string;
filename: string;
content_type: string;
info: string;
Expand Down
4 changes: 2 additions & 2 deletions api/models/Schema.ts → api/models/JsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
/* tslint:disable */
/* eslint-disable */

export type Schema = {
export type JsonSchema = {
title: string;
type: string;
description: string;
properties: Record<string, any>;
required?: Array<string>;
additionalProperties: boolean;
name_human_readable: string;
};
12 changes: 0 additions & 12 deletions api/models/PluginResponse.ts

This file was deleted.

9 changes: 9 additions & 0 deletions api/models/PluginSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type PluginSettings = {
status: string;
settings: Record<string, any>;
};
13 changes: 6 additions & 7 deletions api/models/Setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
/* tslint:disable */
/* eslint-disable */

export type Setting = {
setting_id?: string;
name: string;
value: Record<string, any>;
category?: string;
updated_at?: number;
};
import type { SettingBody } from './SettingBody';

export type Setting = (SettingBody & {
setting_id: string;
updated_at: number;
});
10 changes: 10 additions & 0 deletions api/models/SettingBody.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type SettingBody = {
name: string;
value: Record<string, any>;
category?: string;
};
58 changes: 55 additions & 3 deletions api/services/PluginsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
/* eslint-disable */
import type { BodyUploadPlugin } from '../models/BodyUploadPlugin';
import type { DeleteResponse } from '../models/DeleteResponse';
import type { FileResponse } from '../models/FileResponse';
import type { JsonSchema } from '../models/JsonSchema';
import type { Plugin } from '../models/Plugin';
import type { PluginResponse } from '../models/PluginResponse';
import type { PluginSettings } from '../models/PluginSettings';
import type { PluginsList } from '../models/PluginsList';

import type { CancelablePromise } from '../core/CancelablePromise';
Expand All @@ -32,12 +34,12 @@ export class PluginsService {
* Upload Plugin
* Install a new plugin from a zip file
* @param formData
* @returns PluginResponse Successful Response
* @returns FileResponse Successful Response
* @throws ApiError
*/
public uploadPlugin(
formData: BodyUploadPlugin,
): CancelablePromise<PluginResponse> {
): CancelablePromise<FileResponse> {
return this.httpRequest.request({
method: 'POST',
url: '/plugins/upload/',
Expand Down Expand Up @@ -118,4 +120,54 @@ pluginId: string,
});
}

/**
* Get Plugin Settings
* Returns the settings of a specific plugin
* @param pluginId
* @returns any Successful Response
* @throws ApiError
*/
public getPluginSettings(
pluginId: string,
): CancelablePromise<(PluginSettings & {
schema: JsonSchema;
})> {
return this.httpRequest.request({
method: 'GET',
url: '/plugins/settings/{plugin_id}',
path: {
'plugin_id': pluginId,
},
errors: {
422: `Validation Error`,
},
});
}

/**
* Upsert Plugin Settings
* Updates the settings of a specific plugin
* @param pluginId
* @param requestBody
* @returns PluginSettings Successful Response
* @throws ApiError
*/
public upsertPluginSettings(
pluginId: string,
requestBody: Record<string, any>,
): CancelablePromise<PluginSettings> {
return this.httpRequest.request({
method: 'PUT',
url: '/plugins/settings/{plugin_id}',
path: {
'plugin_id': pluginId,
},
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}

}
6 changes: 3 additions & 3 deletions api/services/SettingsGeneralService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Setting } from '../models/Setting';
import type { SettingBody } from '../models/SettingBody';
import type { SettingResponse } from '../models/SettingResponse';
import type { SettingsList } from '../models/SettingsList';

Expand Down Expand Up @@ -43,7 +43,7 @@ search: string = '',
* @throws ApiError
*/
public createSetting(
requestBody: Setting,
requestBody: SettingBody,
): CancelablePromise<SettingResponse> {
return this.httpRequest.request({
method: 'POST',
Expand Down Expand Up @@ -110,7 +110,7 @@ settingId: string,
*/
public updateSetting(
settingId: string,
requestBody: Setting,
requestBody: SettingBody,
): CancelablePromise<SettingResponse> {
return this.httpRequest.request({
method: 'PUT',
Expand Down
Loading

0 comments on commit ab329b4

Please sign in to comment.