/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.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 type { IntentEnum } from "./IntentEnum";
import { IntentEnumFromJSON, IntentEnumToJSON } from "./IntentEnum";

/**
 * Token Serializer
 * @export
 * @interface TokenRequest
 */
export interface TokenRequest {
    /**
     * Objects that are managed by authentik. These objects are created and updated automatically. This flag only indicates that an object can be overwritten by migrations. You can still modify the objects via the API, but expect changes to be overwritten in a later update.
     * @type {string}
     * @memberof TokenRequest
     */
    managed?: string | null;
    /**
     *
     * @type {string}
     * @memberof TokenRequest
     */
    identifier: string;
    /**
     *
     * @type {IntentEnum}
     * @memberof TokenRequest
     */
    intent?: IntentEnum;
    /**
     *
     * @type {number}
     * @memberof TokenRequest
     */
    user?: number;
    /**
     *
     * @type {string}
     * @memberof TokenRequest
     */
    description?: string;
    /**
     *
     * @type {Date}
     * @memberof TokenRequest
     */
    expires?: Date | null;
    /**
     *
     * @type {boolean}
     * @memberof TokenRequest
     */
    expiring?: boolean;
}

/**
 * Check if a given object implements the TokenRequest interface.
 */
export function instanceOfTokenRequest(value: object): value is TokenRequest {
    if (!("identifier" in value) || value["identifier"] === undefined) return false;
    return true;
}

export function TokenRequestFromJSON(json: any): TokenRequest {
    return TokenRequestFromJSONTyped(json, false);
}

export function TokenRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): TokenRequest {
    if (json == null) {
        return json;
    }
    return {
        managed: json["managed"] == null ? undefined : json["managed"],
        identifier: json["identifier"],
        intent: json["intent"] == null ? undefined : IntentEnumFromJSON(json["intent"]),
        user: json["user"] == null ? undefined : json["user"],
        description: json["description"] == null ? undefined : json["description"],
        expires: json["expires"] == null ? undefined : new Date(json["expires"]),
        expiring: json["expiring"] == null ? undefined : json["expiring"],
    };
}

export function TokenRequestToJSON(json: any): TokenRequest {
    return TokenRequestToJSONTyped(json, false);
}

export function TokenRequestToJSONTyped(
    value?: TokenRequest | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        managed: value["managed"],
        identifier: value["identifier"],
        intent: IntentEnumToJSON(value["intent"]),
        user: value["user"],
        description: value["description"],
        expires: value["expires"] == null ? value["expires"] : value["expires"].toISOString(),
        expiring: value["expiring"],
    };
}
