/* 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 { RoleModelPermission } from "./RoleModelPermission";
import { RoleModelPermissionFromJSON, RoleModelPermissionToJSON } from "./RoleModelPermission";
import type { RoleObjectPermission } from "./RoleObjectPermission";
import { RoleObjectPermissionFromJSON, RoleObjectPermissionToJSON } from "./RoleObjectPermission";

/**
 * Roles assigned object permission serializer
 * @export
 * @interface RoleAssignedObjectPermission
 */
export interface RoleAssignedObjectPermission {
    /**
     *
     * @type {string}
     * @memberof RoleAssignedObjectPermission
     */
    readonly rolePk: string;
    /**
     *
     * @type {string}
     * @memberof RoleAssignedObjectPermission
     */
    readonly name: string;
    /**
     *
     * @type {Array<RoleObjectPermission>}
     * @memberof RoleAssignedObjectPermission
     */
    objectPermissions: Array<RoleObjectPermission>;
    /**
     *
     * @type {Array<RoleModelPermission>}
     * @memberof RoleAssignedObjectPermission
     */
    modelPermissions: Array<RoleModelPermission>;
}

/**
 * Check if a given object implements the RoleAssignedObjectPermission interface.
 */
export function instanceOfRoleAssignedObjectPermission(
    value: object,
): value is RoleAssignedObjectPermission {
    if (!("rolePk" in value) || value["rolePk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("objectPermissions" in value) || value["objectPermissions"] === undefined) return false;
    if (!("modelPermissions" in value) || value["modelPermissions"] === undefined) return false;
    return true;
}

export function RoleAssignedObjectPermissionFromJSON(json: any): RoleAssignedObjectPermission {
    return RoleAssignedObjectPermissionFromJSONTyped(json, false);
}

export function RoleAssignedObjectPermissionFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): RoleAssignedObjectPermission {
    if (json == null) {
        return json;
    }
    return {
        rolePk: json["role_pk"],
        name: json["name"],
        objectPermissions: (json["object_permissions"] as Array<any>).map(
            RoleObjectPermissionFromJSON,
        ),
        modelPermissions: (json["model_permissions"] as Array<any>).map(
            RoleModelPermissionFromJSON,
        ),
    };
}

export function RoleAssignedObjectPermissionToJSON(json: any): RoleAssignedObjectPermission {
    return RoleAssignedObjectPermissionToJSONTyped(json, false);
}

export function RoleAssignedObjectPermissionToJSONTyped(
    value?: Omit<RoleAssignedObjectPermission, "role_pk" | "name"> | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        object_permissions: (value["objectPermissions"] as Array<any>).map(
            RoleObjectPermissionToJSON,
        ),
        model_permissions: (value["modelPermissions"] as Array<any>).map(RoleModelPermissionToJSON),
    };
}
