Files
immich/mobile-v2/openapi/lib/src/api/job_api.dart
shenlong-tanwen 11cef4ec9a 🚀
2025-02-26 08:58:18 +05:30

227 lines
6.7 KiB
Dart

//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'dart:async';
import 'package:built_value/serializer.dart';
import 'package:dio/dio.dart';
import 'package:openapi/src/api_util.dart';
import 'package:openapi/src/model/all_job_status_response_dto.dart';
import 'package:openapi/src/model/job_command_dto.dart';
import 'package:openapi/src/model/job_name.dart';
import 'package:openapi/src/model/job_status_dto.dart';
class JobApi {
final Dio _dio;
final Serializers _serializers;
const JobApi(this._dio, this._serializers);
/// getAllJobsStatus
///
///
/// Parameters:
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [AllJobStatusResponseDto] as data
/// Throws [DioException] if API call or serialization fails
Future<Response<AllJobStatusResponseDto>> getAllJobsStatus({
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/jobs';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'apiKey',
'name': 'cookie',
'keyName': 'immich_access_token',
'where': '',
},{
'type': 'apiKey',
'name': 'api_key',
'keyName': 'x-api-key',
'where': 'header',
},{
'type': 'http',
'scheme': 'Bearer',
'name': 'bearer',
},
],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_path,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
AllJobStatusResponseDto? _responseData;
try {
final rawResponse = _response.data;
_responseData = rawResponse == null ? null : _serializers.deserialize(
rawResponse,
specifiedType: const FullType(AllJobStatusResponseDto),
) as AllJobStatusResponseDto;
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<AllJobStatusResponseDto>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// sendJobCommand
///
///
/// Parameters:
/// * [id]
/// * [jobCommandDto]
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [JobStatusDto] as data
/// Throws [DioException] if API call or serialization fails
Future<Response<JobStatusDto>> sendJobCommand({
required JobName id,
required JobCommandDto jobCommandDto,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/jobs/{id}'.replaceAll('{' r'id' '}', encodeQueryParameter(_serializers, id, const FullType(JobName)).toString());
final _options = Options(
method: r'PUT',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'apiKey',
'name': 'cookie',
'keyName': 'immich_access_token',
'where': '',
},{
'type': 'apiKey',
'name': 'api_key',
'keyName': 'x-api-key',
'where': 'header',
},{
'type': 'http',
'scheme': 'Bearer',
'name': 'bearer',
},
],
...?extra,
},
contentType: 'application/json',
validateStatus: validateStatus,
);
dynamic _bodyData;
try {
const _type = FullType(JobCommandDto);
_bodyData = _serializers.serialize(jobCommandDto, specifiedType: _type);
} catch(error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
_path,
),
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
final _response = await _dio.request<Object>(
_path,
data: _bodyData,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
JobStatusDto? _responseData;
try {
final rawResponse = _response.data;
_responseData = rawResponse == null ? null : _serializers.deserialize(
rawResponse,
specifiedType: const FullType(JobStatusDto),
) as JobStatusDto;
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<JobStatusDto>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}