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

/**
 * User Serializer for information a user can retrieve about themselves
 * @export
 * @interface UserSelf
 */
export interface UserSelf {
    /**
     *
     * @type {number}
     * @memberof UserSelf
     */
    readonly pk: number;
    /**
     * Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
     * @type {string}
     * @memberof UserSelf
     */
    username: string;
    /**
     * User's display name.
     * @type {string}
     * @memberof UserSelf
     */
    name: string;
    /**
     * Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
     * @type {boolean}
     * @memberof UserSelf
     */
    readonly isActive: boolean;
    /**
     *
     * @type {boolean}
     * @memberof UserSelf
     */
    readonly isSuperuser: boolean;
    /**
     *
     * @type {Array<UserSelfGroups>}
     * @memberof UserSelf
     */
    readonly groups: Array<UserSelfGroups>;
    /**
     *
     * @type {Array<UserSelfRoles>}
     * @memberof UserSelf
     */
    readonly roles: Array<UserSelfRoles>;
    /**
     *
     * @type {string}
     * @memberof UserSelf
     */
    email?: string;
    /**
     * User's avatar, either a http/https URL or a data URI
     * @type {string}
     * @memberof UserSelf
     */
    readonly avatar: string;
    /**
     *
     * @type {string}
     * @memberof UserSelf
     */
    readonly uid: string;
    /**
     * Get user settings with brand and group settings applied
     * @type {{ [key: string]: any; }}
     * @memberof UserSelf
     */
    readonly settings: { [key: string]: any };
    /**
     *
     * @type {UserTypeEnum}
     * @memberof UserSelf
     */
    type?: UserTypeEnum;
    /**
     * Get all system permissions assigned to the user
     * @type {Array<string>}
     * @memberof UserSelf
     */
    readonly systemPermissions: Array<string>;
}

/**
 * Check if a given object implements the UserSelf interface.
 */
export function instanceOfUserSelf(value: object): value is UserSelf {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("username" in value) || value["username"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("isActive" in value) || value["isActive"] === undefined) return false;
    if (!("isSuperuser" in value) || value["isSuperuser"] === undefined) return false;
    if (!("groups" in value) || value["groups"] === undefined) return false;
    if (!("roles" in value) || value["roles"] === undefined) return false;
    if (!("avatar" in value) || value["avatar"] === undefined) return false;
    if (!("uid" in value) || value["uid"] === undefined) return false;
    if (!("settings" in value) || value["settings"] === undefined) return false;
    if (!("systemPermissions" in value) || value["systemPermissions"] === undefined) return false;
    return true;
}

export function UserSelfFromJSON(json: any): UserSelf {
    return UserSelfFromJSONTyped(json, false);
}

export function UserSelfFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserSelf {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        username: json["username"],
        name: json["name"],
        isActive: json["is_active"],
        isSuperuser: json["is_superuser"],
        groups: (json["groups"] as Array<any>).map(UserSelfGroupsFromJSON),
        roles: (json["roles"] as Array<any>).map(UserSelfRolesFromJSON),
        email: json["email"] == null ? undefined : json["email"],
        avatar: json["avatar"],
        uid: json["uid"],
        settings: json["settings"],
        type: json["type"] == null ? undefined : UserTypeEnumFromJSON(json["type"]),
        systemPermissions: json["system_permissions"],
    };
}

export function UserSelfToJSON(json: any): UserSelf {
    return UserSelfToJSONTyped(json, false);
}

export function UserSelfToJSONTyped(
    value?: Omit<
        UserSelf,
        | "pk"
        | "is_active"
        | "is_superuser"
        | "groups"
        | "roles"
        | "avatar"
        | "uid"
        | "settings"
        | "system_permissions"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        username: value["username"],
        name: value["name"],
        email: value["email"],
        type: UserTypeEnumToJSON(value["type"]),
    };
}
