/* 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 { UserTypeEnum } from "./UserTypeEnum";
import { UserTypeEnumFromJSON, UserTypeEnumToJSON } from "./UserTypeEnum";

/**
 * User Serializer
 * @export
 * @interface UserRequest
 */
export interface UserRequest {
    /**
     *
     * @type {string}
     * @memberof UserRequest
     */
    username: string;
    /**
     * User's display name.
     * @type {string}
     * @memberof UserRequest
     */
    name: string;
    /**
     * Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
     * @type {boolean}
     * @memberof UserRequest
     */
    isActive?: boolean;
    /**
     *
     * @type {Date}
     * @memberof UserRequest
     */
    lastLogin?: Date | null;
    /**
     *
     * @type {Array<string>}
     * @memberof UserRequest
     */
    groups?: Array<string>;
    /**
     *
     * @type {Array<string>}
     * @memberof UserRequest
     */
    roles?: Array<string>;
    /**
     *
     * @type {string}
     * @memberof UserRequest
     */
    email?: string;
    /**
     *
     * @type {{ [key: string]: any; }}
     * @memberof UserRequest
     */
    attributes?: { [key: string]: any };
    /**
     *
     * @type {string}
     * @memberof UserRequest
     */
    path?: string;
    /**
     *
     * @type {UserTypeEnum}
     * @memberof UserRequest
     */
    type?: UserTypeEnum;
}

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

export function UserRequestFromJSON(json: any): UserRequest {
    return UserRequestFromJSONTyped(json, false);
}

export function UserRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserRequest {
    if (json == null) {
        return json;
    }
    return {
        username: json["username"],
        name: json["name"],
        isActive: json["is_active"] == null ? undefined : json["is_active"],
        lastLogin: json["last_login"] == null ? undefined : new Date(json["last_login"]),
        groups: json["groups"] == null ? undefined : json["groups"],
        roles: json["roles"] == null ? undefined : json["roles"],
        email: json["email"] == null ? undefined : json["email"],
        attributes: json["attributes"] == null ? undefined : json["attributes"],
        path: json["path"] == null ? undefined : json["path"],
        type: json["type"] == null ? undefined : UserTypeEnumFromJSON(json["type"]),
    };
}

export function UserRequestToJSON(json: any): UserRequest {
    return UserRequestToJSONTyped(json, false);
}

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

    return {
        username: value["username"],
        name: value["name"],
        is_active: value["isActive"],
        last_login:
            value["lastLogin"] == null ? value["lastLogin"] : value["lastLogin"].toISOString(),
        groups: value["groups"],
        roles: value["roles"],
        email: value["email"],
        attributes: value["attributes"],
        path: value["path"],
        type: UserTypeEnumToJSON(value["type"]),
    };
}
