/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.2.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import { mapValues } from '../runtime';
import type { LogEvent } from './LogEvent';
import {
    LogEventFromJSON,
    LogEventFromJSONTyped,
    LogEventToJSON,
    LogEventToJSONTyped,
} from './LogEvent';
import type { StateEnum } from './StateEnum';
import {
    StateEnumFromJSON,
    StateEnumFromJSONTyped,
    StateEnumToJSON,
    StateEnumToJSONTyped,
} from './StateEnum';
import type { TaskAggregatedStatusEnum } from './TaskAggregatedStatusEnum';
import {
    TaskAggregatedStatusEnumFromJSON,
    TaskAggregatedStatusEnumFromJSONTyped,
    TaskAggregatedStatusEnumToJSON,
    TaskAggregatedStatusEnumToJSONTyped,
} from './TaskAggregatedStatusEnum';

/**
 * 
 * @export
 * @interface Task
 */
export interface Task {
    /**
     * 
     * @type {string}
     * @memberof Task
     */
    messageId?: string;
    /**
     * Queue name
     * @type {string}
     * @memberof Task
     */
    queueName?: string;
    /**
     * Dramatiq actor name
     * @type {string}
     * @memberof Task
     */
    actorName: string;
    /**
     * Task status
     * @type {StateEnum}
     * @memberof Task
     */
    state?: StateEnum;
    /**
     * Task last modified time
     * @type {Date}
     * @memberof Task
     */
    mtime?: Date;
    /**
     * Number of retries
     * @type {number}
     * @memberof Task
     */
    retries?: number;
    /**
     * Planned execution time
     * @type {Date}
     * @memberof Task
     */
    eta?: Date | null;
    /**
     * 
     * @type {string}
     * @memberof Task
     */
    readonly relObjAppLabel: string;
    /**
     * 
     * @type {string}
     * @memberof Task
     */
    readonly relObjModel: string;
    /**
     * 
     * @type {string}
     * @memberof Task
     */
    relObjId?: string | null;
    /**
     * 
     * @type {string}
     * @memberof Task
     */
    readonly uid: string;
    /**
     * 
     * @type {Array<LogEvent>}
     * @memberof Task
     */
    readonly logs: Array<LogEvent>;
    /**
     * 
     * @type {Array<LogEvent>}
     * @memberof Task
     */
    readonly previousLogs: Array<LogEvent>;
    /**
     * 
     * @type {TaskAggregatedStatusEnum}
     * @memberof Task
     */
    aggregatedStatus: TaskAggregatedStatusEnum;
    /**
     * 
     * @type {string}
     * @memberof Task
     */
    readonly description: string | null;
}



/**
 * Check if a given object implements the Task interface.
 */
export function instanceOfTask(value: object): value is Task {
    if (!('actorName' in value) || value['actorName'] === undefined) return false;
    if (!('relObjAppLabel' in value) || value['relObjAppLabel'] === undefined) return false;
    if (!('relObjModel' in value) || value['relObjModel'] === undefined) return false;
    if (!('uid' in value) || value['uid'] === undefined) return false;
    if (!('logs' in value) || value['logs'] === undefined) return false;
    if (!('previousLogs' in value) || value['previousLogs'] === undefined) return false;
    if (!('aggregatedStatus' in value) || value['aggregatedStatus'] === undefined) return false;
    if (!('description' in value) || value['description'] === undefined) return false;
    return true;
}

export function TaskFromJSON(json: any): Task {
    return TaskFromJSONTyped(json, false);
}

export function TaskFromJSONTyped(json: any, ignoreDiscriminator: boolean): Task {
    if (json == null) {
        return json;
    }
    return {
        
        'messageId': json['message_id'] == null ? undefined : json['message_id'],
        'queueName': json['queue_name'] == null ? undefined : json['queue_name'],
        'actorName': json['actor_name'],
        'state': json['state'] == null ? undefined : StateEnumFromJSON(json['state']),
        'mtime': json['mtime'] == null ? undefined : (new Date(json['mtime'])),
        'retries': json['retries'] == null ? undefined : json['retries'],
        'eta': json['eta'] == null ? undefined : (new Date(json['eta'])),
        'relObjAppLabel': json['rel_obj_app_label'],
        'relObjModel': json['rel_obj_model'],
        'relObjId': json['rel_obj_id'] == null ? undefined : json['rel_obj_id'],
        'uid': json['uid'],
        'logs': ((json['logs'] as Array<any>).map(LogEventFromJSON)),
        'previousLogs': ((json['previous_logs'] as Array<any>).map(LogEventFromJSON)),
        'aggregatedStatus': TaskAggregatedStatusEnumFromJSON(json['aggregated_status']),
        'description': json['description'],
    };
}

export function TaskToJSON(json: any): Task {
    return TaskToJSONTyped(json, false);
}

export function TaskToJSONTyped(value?: Omit<Task, 'rel_obj_app_label'|'rel_obj_model'|'uid'|'logs'|'previous_logs'|'description'> | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'message_id': value['messageId'],
        'queue_name': value['queueName'],
        'actor_name': value['actorName'],
        'state': StateEnumToJSON(value['state']),
        'mtime': value['mtime'] == null ? value['mtime'] : value['mtime'].toISOString(),
        'retries': value['retries'],
        'eta': value['eta'] == null ? value['eta'] : value['eta'].toISOString(),
        'rel_obj_id': value['relObjId'],
        'aggregated_status': TaskAggregatedStatusEnumToJSON(value['aggregatedStatus']),
    };
}

