1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

feat(server): add endpoint to get supported media types on the server (#3284)

* feat(server): add endpoint to get supported media types on the server

* api generation

* remove xmp format

* change dto

* openapi

* dev
This commit is contained in:
Alex 2023-07-15 20:24:46 -05:00 committed by GitHub
parent d5b96c0257
commit c254a04aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 243 additions and 2 deletions

View File

@ -2085,6 +2085,31 @@ export interface ServerInfoResponseDto {
*/ */
'diskAvailable': string; 'diskAvailable': string;
} }
/**
*
* @export
* @interface ServerMediaTypesResponseDto
*/
export interface ServerMediaTypesResponseDto {
/**
*
* @type {Array<string>}
* @memberof ServerMediaTypesResponseDto
*/
'video': Array<string>;
/**
*
* @type {Array<string>}
* @memberof ServerMediaTypesResponseDto
*/
'image': Array<string>;
/**
*
* @type {Array<string>}
* @memberof ServerMediaTypesResponseDto
*/
'sidecar': Array<string>;
}
/** /**
* *
* @export * @export
@ -9711,6 +9736,35 @@ export const ServerInfoApiAxiosParamCreator = function (configuration?: Configur
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getSupportedMediaTypes: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/server-info/media-types`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
setSearchParams(localVarUrlObj, localVarQueryParameter); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@ -9786,6 +9840,15 @@ export const ServerInfoApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getStats(options); const localVarAxiosArgs = await localVarAxiosParamCreator.getStats(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
}, },
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getSupportedMediaTypes(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ServerMediaTypesResponseDto>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getSupportedMediaTypes(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/** /**
* *
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
@ -9829,6 +9892,14 @@ export const ServerInfoApiFactory = function (configuration?: Configuration, bas
getStats(options?: AxiosRequestConfig): AxiosPromise<ServerStatsResponseDto> { getStats(options?: AxiosRequestConfig): AxiosPromise<ServerStatsResponseDto> {
return localVarFp.getStats(options).then((request) => request(axios, basePath)); return localVarFp.getStats(options).then((request) => request(axios, basePath));
}, },
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getSupportedMediaTypes(options?: AxiosRequestConfig): AxiosPromise<ServerMediaTypesResponseDto> {
return localVarFp.getSupportedMediaTypes(options).then((request) => request(axios, basePath));
},
/** /**
* *
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
@ -9877,6 +9948,16 @@ export class ServerInfoApi extends BaseAPI {
return ServerInfoApiFp(this.configuration).getStats(options).then((request) => request(this.axios, this.basePath)); return ServerInfoApiFp(this.configuration).getStats(options).then((request) => request(this.axios, this.basePath));
} }
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ServerInfoApi
*/
public getSupportedMediaTypes(options?: AxiosRequestConfig) {
return ServerInfoApiFp(this.configuration).getSupportedMediaTypes(options).then((request) => request(this.axios, this.basePath));
}
/** /**
* *
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.

View File

@ -88,6 +88,7 @@ doc/SearchFacetResponseDto.md
doc/SearchResponseDto.md doc/SearchResponseDto.md
doc/ServerInfoApi.md doc/ServerInfoApi.md
doc/ServerInfoResponseDto.md doc/ServerInfoResponseDto.md
doc/ServerMediaTypesResponseDto.md
doc/ServerPingResponse.md doc/ServerPingResponse.md
doc/ServerStatsResponseDto.md doc/ServerStatsResponseDto.md
doc/ServerVersionReponseDto.md doc/ServerVersionReponseDto.md
@ -221,6 +222,7 @@ lib/model/search_facet_count_response_dto.dart
lib/model/search_facet_response_dto.dart lib/model/search_facet_response_dto.dart
lib/model/search_response_dto.dart lib/model/search_response_dto.dart
lib/model/server_info_response_dto.dart lib/model/server_info_response_dto.dart
lib/model/server_media_types_response_dto.dart
lib/model/server_ping_response.dart lib/model/server_ping_response.dart
lib/model/server_stats_response_dto.dart lib/model/server_stats_response_dto.dart
lib/model/server_version_reponse_dto.dart lib/model/server_version_reponse_dto.dart
@ -337,6 +339,7 @@ test/search_facet_response_dto_test.dart
test/search_response_dto_test.dart test/search_response_dto_test.dart
test/server_info_api_test.dart test/server_info_api_test.dart
test/server_info_response_dto_test.dart test/server_info_response_dto_test.dart
test/server_media_types_response_dto_test.dart
test/server_ping_response_test.dart test/server_ping_response_test.dart
test/server_stats_response_dto_test.dart test/server_stats_response_dto_test.dart
test/server_version_reponse_dto_test.dart test/server_version_reponse_dto_test.dart

BIN
mobile/openapi/README.md generated

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3040,6 +3040,27 @@
] ]
} }
}, },
"/server-info/media-types": {
"get": {
"operationId": "getSupportedMediaTypes",
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ServerMediaTypesResponseDto"
}
}
}
}
},
"tags": [
"Server Info"
]
}
},
"/server-info/ping": { "/server-info/ping": {
"get": { "get": {
"operationId": "pingServer", "operationId": "pingServer",
@ -6118,6 +6139,34 @@
"diskAvailable" "diskAvailable"
] ]
}, },
"ServerMediaTypesResponseDto": {
"type": "object",
"properties": {
"video": {
"type": "array",
"items": {
"type": "string"
}
},
"image": {
"type": "array",
"items": {
"type": "string"
}
},
"sidecar": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"video",
"image",
"sidecar"
]
},
"ServerPingResponse": { "ServerPingResponse": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -25,3 +25,9 @@ export class ServerStatsResponseDto {
}) })
usageByUser: UsageByUserDto[] = []; usageByUser: UsageByUserDto[] = [];
} }
export class ServerMediaTypesResponseDto {
video!: string[];
image!: string[];
sidecar!: string[];
}

View File

@ -1,9 +1,15 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { serverVersion } from '../domain.constant'; import { mimeTypes, serverVersion } from '../domain.constant';
import { asHumanReadable } from '../domain.util'; import { asHumanReadable } from '../domain.util';
import { IStorageRepository, StorageCore, StorageFolder } from '../storage'; import { IStorageRepository, StorageCore, StorageFolder } from '../storage';
import { IUserRepository, UserStatsQueryResponse } from '../user'; import { IUserRepository, UserStatsQueryResponse } from '../user';
import { ServerInfoResponseDto, ServerPingResponse, ServerStatsResponseDto, UsageByUserDto } from './response-dto'; import {
ServerInfoResponseDto,
ServerMediaTypesResponseDto,
ServerPingResponse,
ServerStatsResponseDto,
UsageByUserDto,
} from './response-dto';
@Injectable() @Injectable()
export class ServerInfoService { export class ServerInfoService {
@ -60,4 +66,12 @@ export class ServerInfoService {
return serverStats; return serverStats;
} }
getSupportedMediaTypes(): ServerMediaTypesResponseDto {
return {
video: [...Object.keys(mimeTypes.video)],
image: [...Object.keys(mimeTypes.image)],
sidecar: [...Object.keys(mimeTypes.sidecar)],
};
}
} }

View File

@ -1,6 +1,7 @@
import { import {
ServerInfoResponseDto, ServerInfoResponseDto,
ServerInfoService, ServerInfoService,
ServerMediaTypesResponseDto,
ServerPingResponse, ServerPingResponse,
ServerStatsResponseDto, ServerStatsResponseDto,
ServerVersionReponseDto, ServerVersionReponseDto,
@ -39,4 +40,10 @@ export class ServerInfoController {
getStats(): Promise<ServerStatsResponseDto> { getStats(): Promise<ServerStatsResponseDto> {
return this.service.getStats(); return this.service.getStats();
} }
@PublicRoute()
@Get('/media-types')
getSupportedMediaTypes(): ServerMediaTypesResponseDto {
return this.service.getSupportedMediaTypes();
}
} }

View File

@ -2085,6 +2085,31 @@ export interface ServerInfoResponseDto {
*/ */
'diskAvailable': string; 'diskAvailable': string;
} }
/**
*
* @export
* @interface ServerMediaTypesResponseDto
*/
export interface ServerMediaTypesResponseDto {
/**
*
* @type {Array<string>}
* @memberof ServerMediaTypesResponseDto
*/
'video': Array<string>;
/**
*
* @type {Array<string>}
* @memberof ServerMediaTypesResponseDto
*/
'image': Array<string>;
/**
*
* @type {Array<string>}
* @memberof ServerMediaTypesResponseDto
*/
'sidecar': Array<string>;
}
/** /**
* *
* @export * @export
@ -9771,6 +9796,35 @@ export const ServerInfoApiAxiosParamCreator = function (configuration?: Configur
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getSupportedMediaTypes: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/server-info/media-types`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
setSearchParams(localVarUrlObj, localVarQueryParameter); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@ -9846,6 +9900,15 @@ export const ServerInfoApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getStats(options); const localVarAxiosArgs = await localVarAxiosParamCreator.getStats(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
}, },
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getSupportedMediaTypes(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ServerMediaTypesResponseDto>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getSupportedMediaTypes(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/** /**
* *
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
@ -9889,6 +9952,14 @@ export const ServerInfoApiFactory = function (configuration?: Configuration, bas
getStats(options?: any): AxiosPromise<ServerStatsResponseDto> { getStats(options?: any): AxiosPromise<ServerStatsResponseDto> {
return localVarFp.getStats(options).then((request) => request(axios, basePath)); return localVarFp.getStats(options).then((request) => request(axios, basePath));
}, },
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getSupportedMediaTypes(options?: any): AxiosPromise<ServerMediaTypesResponseDto> {
return localVarFp.getSupportedMediaTypes(options).then((request) => request(axios, basePath));
},
/** /**
* *
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
@ -9937,6 +10008,16 @@ export class ServerInfoApi extends BaseAPI {
return ServerInfoApiFp(this.configuration).getStats(options).then((request) => request(this.axios, this.basePath)); return ServerInfoApiFp(this.configuration).getStats(options).then((request) => request(this.axios, this.basePath));
} }
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ServerInfoApi
*/
public getSupportedMediaTypes(options?: AxiosRequestConfig) {
return ServerInfoApiFp(this.configuration).getSupportedMediaTypes(options).then((request) => request(this.axios, this.basePath));
}
/** /**
* *
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.