/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2025.10.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 { UserObjectPermission } from './UserObjectPermission';
import {
    UserObjectPermissionFromJSON,
    UserObjectPermissionFromJSONTyped,
    UserObjectPermissionToJSON,
    UserObjectPermissionToJSONTyped,
} from './UserObjectPermission';

/**
 * Users assigned object permission serializer
 * @export
 * @interface UserAssignedObjectPermission
 */
export interface UserAssignedObjectPermission {
    /**
     * 
     * @type {number}
     * @memberof UserAssignedObjectPermission
     */
    readonly pk: number;
    /**
     * Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
     * @type {string}
     * @memberof UserAssignedObjectPermission
     */
    username: string;
    /**
     * User's display name.
     * @type {string}
     * @memberof UserAssignedObjectPermission
     */
    name: string;
    /**
     * Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
     * @type {boolean}
     * @memberof UserAssignedObjectPermission
     */
    isActive?: boolean;
    /**
     * 
     * @type {Date}
     * @memberof UserAssignedObjectPermission
     */
    lastLogin?: Date | null;
    /**
     * 
     * @type {string}
     * @memberof UserAssignedObjectPermission
     */
    email?: string;
    /**
     * 
     * @type {{ [key: string]: any; }}
     * @memberof UserAssignedObjectPermission
     */
    attributes?: { [key: string]: any; };
    /**
     * 
     * @type {string}
     * @memberof UserAssignedObjectPermission
     */
    readonly uid: string;
    /**
     * 
     * @type {Array<UserObjectPermission>}
     * @memberof UserAssignedObjectPermission
     */
    permissions: Array<UserObjectPermission>;
    /**
     * 
     * @type {boolean}
     * @memberof UserAssignedObjectPermission
     */
    isSuperuser: boolean;
}

/**
 * Check if a given object implements the UserAssignedObjectPermission interface.
 */
export function instanceOfUserAssignedObjectPermission(value: object): value is UserAssignedObjectPermission {
    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 (!('uid' in value) || value['uid'] === undefined) return false;
    if (!('permissions' in value) || value['permissions'] === undefined) return false;
    if (!('isSuperuser' in value) || value['isSuperuser'] === undefined) return false;
    return true;
}

export function UserAssignedObjectPermissionFromJSON(json: any): UserAssignedObjectPermission {
    return UserAssignedObjectPermissionFromJSONTyped(json, false);
}

export function UserAssignedObjectPermissionFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserAssignedObjectPermission {
    if (json == null) {
        return json;
    }
    return {
        
        'pk': json['pk'],
        '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'])),
        'email': json['email'] == null ? undefined : json['email'],
        'attributes': json['attributes'] == null ? undefined : json['attributes'],
        'uid': json['uid'],
        'permissions': ((json['permissions'] as Array<any>).map(UserObjectPermissionFromJSON)),
        'isSuperuser': json['is_superuser'],
    };
}

export function UserAssignedObjectPermissionToJSON(json: any): UserAssignedObjectPermission {
    return UserAssignedObjectPermissionToJSONTyped(json, false);
}

export function UserAssignedObjectPermissionToJSONTyped(value?: Omit<UserAssignedObjectPermission, 'pk'|'uid'> | 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 ? null : ((value['lastLogin'] as any)?.toISOString()),
        'email': value['email'],
        'attributes': value['attributes'],
        'permissions': ((value['permissions'] as Array<any>).map(UserObjectPermissionToJSON)),
        'is_superuser': value['isSuperuser'],
    };
}

