/* 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 {
    InitialPermissions,
    InitialPermissionsRequest,
    PaginatedExtraRoleObjectPermissionList,
    PaginatedInitialPermissionsList,
    PaginatedPermissionList,
    PaginatedRoleAssignedObjectPermissionList,
    PaginatedRoleList,
    PatchedInitialPermissionsRequest,
    PatchedPermissionAssignRequest,
    PatchedRoleRequest,
    Permission,
    PermissionAssignRequest,
    PermissionAssignResult,
    Role,
    RoleRequest,
    UsedBy,
    UserAccountSerializerForRoleRequest,
} from "../models/index";
import {
    InitialPermissionsFromJSON,
    InitialPermissionsRequestToJSON,
    PaginatedExtraRoleObjectPermissionListFromJSON,
    PaginatedInitialPermissionsListFromJSON,
    PaginatedPermissionListFromJSON,
    PaginatedRoleAssignedObjectPermissionListFromJSON,
    PaginatedRoleListFromJSON,
    PatchedInitialPermissionsRequestToJSON,
    PatchedPermissionAssignRequestToJSON,
    PatchedRoleRequestToJSON,
    PermissionAssignRequestToJSON,
    PermissionAssignResultFromJSON,
    PermissionFromJSON,
    RoleFromJSON,
    RoleRequestToJSON,
    UsedByFromJSON,
    UserAccountSerializerForRoleRequestToJSON,
} from "../models/index";
import * as runtime from "../runtime";

export interface RbacInitialPermissionsCreateRequest {
    initialPermissionsRequest: InitialPermissionsRequest;
}

export interface RbacInitialPermissionsDestroyRequest {
    id: number;
}

export interface RbacInitialPermissionsListRequest {
    name?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
}

export interface RbacInitialPermissionsPartialUpdateRequest {
    id: number;
    patchedInitialPermissionsRequest?: PatchedInitialPermissionsRequest;
}

export interface RbacInitialPermissionsRetrieveRequest {
    id: number;
}

export interface RbacInitialPermissionsUpdateRequest {
    id: number;
    initialPermissionsRequest: InitialPermissionsRequest;
}

export interface RbacInitialPermissionsUsedByListRequest {
    id: number;
}

export interface RbacPermissionsAssignedByRolesAssignRequest {
    uuid: string;
    permissionAssignRequest: PermissionAssignRequest;
}

export interface RbacPermissionsAssignedByRolesListRequest {
    model: string;
    objectPk?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
}

export interface RbacPermissionsAssignedByRolesUnassignPartialUpdateRequest {
    uuid: string;
    patchedPermissionAssignRequest?: PatchedPermissionAssignRequest;
}

export interface RbacPermissionsListRequest {
    codename?: string;
    contentTypeAppLabel?: string;
    contentTypeModel?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    role?: string;
    search?: string;
}

export interface RbacPermissionsRetrieveRequest {
    id: number;
}

export interface RbacPermissionsRolesListRequest {
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
    uuid?: string;
}

export interface RbacRolesAddUserCreateRequest {
    uuid: string;
    userAccountSerializerForRoleRequest: UserAccountSerializerForRoleRequest;
}

export interface RbacRolesCreateRequest {
    roleRequest: RoleRequest;
}

export interface RbacRolesDestroyRequest {
    uuid: string;
}

export interface RbacRolesListRequest {
    groups?: string;
    inherited?: boolean;
    managed?: Array<string>;
    managedIsnull?: boolean;
    name?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
    users?: number;
}

export interface RbacRolesPartialUpdateRequest {
    uuid: string;
    patchedRoleRequest?: PatchedRoleRequest;
}

export interface RbacRolesRemoveUserCreateRequest {
    uuid: string;
    userAccountSerializerForRoleRequest: UserAccountSerializerForRoleRequest;
}

export interface RbacRolesRetrieveRequest {
    uuid: string;
}

export interface RbacRolesUpdateRequest {
    uuid: string;
    roleRequest: RoleRequest;
}

export interface RbacRolesUsedByListRequest {
    uuid: string;
}

/**
 *
 */
export class RbacApi extends runtime.BaseAPI {
    /**
     * Creates request options for rbacInitialPermissionsCreate without sending the request
     */
    async rbacInitialPermissionsCreateRequestOpts(
        requestParameters: RbacInitialPermissionsCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["initialPermissionsRequest"] == null) {
            throw new runtime.RequiredError(
                "initialPermissionsRequest",
                'Required parameter "initialPermissionsRequest" was null or undefined when calling rbacInitialPermissionsCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/`;

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: InitialPermissionsRequestToJSON(requestParameters["initialPermissionsRequest"]),
        };
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsCreateRaw(
        requestParameters: RbacInitialPermissionsCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<InitialPermissions>> {
        const requestOptions =
            await this.rbacInitialPermissionsCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            InitialPermissionsFromJSON(jsonValue),
        );
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsCreate(
        requestParameters: RbacInitialPermissionsCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<InitialPermissions> {
        const response = await this.rbacInitialPermissionsCreateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacInitialPermissionsDestroy without sending the request
     */
    async rbacInitialPermissionsDestroyRequestOpts(
        requestParameters: RbacInitialPermissionsDestroyRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["id"] == null) {
            throw new runtime.RequiredError(
                "id",
                'Required parameter "id" was null or undefined when calling rbacInitialPermissionsDestroy().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

        return {
            path: urlPath,
            method: "DELETE",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsDestroyRaw(
        requestParameters: RbacInitialPermissionsDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions =
            await this.rbacInitialPermissionsDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsDestroy(
        requestParameters: RbacInitialPermissionsDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.rbacInitialPermissionsDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for rbacInitialPermissionsList without sending the request
     */
    async rbacInitialPermissionsListRequestOpts(
        requestParameters: RbacInitialPermissionsListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["name"] != null) {
            queryParameters["name"] = requestParameters["name"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsListRaw(
        requestParameters: RbacInitialPermissionsListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedInitialPermissionsList>> {
        const requestOptions = await this.rbacInitialPermissionsListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedInitialPermissionsListFromJSON(jsonValue),
        );
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsList(
        requestParameters: RbacInitialPermissionsListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedInitialPermissionsList> {
        const response = await this.rbacInitialPermissionsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacInitialPermissionsPartialUpdate without sending the request
     */
    async rbacInitialPermissionsPartialUpdateRequestOpts(
        requestParameters: RbacInitialPermissionsPartialUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["id"] == null) {
            throw new runtime.RequiredError(
                "id",
                'Required parameter "id" was null or undefined when calling rbacInitialPermissionsPartialUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

        return {
            path: urlPath,
            method: "PATCH",
            headers: headerParameters,
            query: queryParameters,
            body: PatchedInitialPermissionsRequestToJSON(
                requestParameters["patchedInitialPermissionsRequest"],
            ),
        };
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsPartialUpdateRaw(
        requestParameters: RbacInitialPermissionsPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<InitialPermissions>> {
        const requestOptions =
            await this.rbacInitialPermissionsPartialUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            InitialPermissionsFromJSON(jsonValue),
        );
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsPartialUpdate(
        requestParameters: RbacInitialPermissionsPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<InitialPermissions> {
        const response = await this.rbacInitialPermissionsPartialUpdateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacInitialPermissionsRetrieve without sending the request
     */
    async rbacInitialPermissionsRetrieveRequestOpts(
        requestParameters: RbacInitialPermissionsRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["id"] == null) {
            throw new runtime.RequiredError(
                "id",
                'Required parameter "id" was null or undefined when calling rbacInitialPermissionsRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsRetrieveRaw(
        requestParameters: RbacInitialPermissionsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<InitialPermissions>> {
        const requestOptions =
            await this.rbacInitialPermissionsRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            InitialPermissionsFromJSON(jsonValue),
        );
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsRetrieve(
        requestParameters: RbacInitialPermissionsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<InitialPermissions> {
        const response = await this.rbacInitialPermissionsRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacInitialPermissionsUpdate without sending the request
     */
    async rbacInitialPermissionsUpdateRequestOpts(
        requestParameters: RbacInitialPermissionsUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["id"] == null) {
            throw new runtime.RequiredError(
                "id",
                'Required parameter "id" was null or undefined when calling rbacInitialPermissionsUpdate().',
            );
        }

        if (requestParameters["initialPermissionsRequest"] == null) {
            throw new runtime.RequiredError(
                "initialPermissionsRequest",
                'Required parameter "initialPermissionsRequest" was null or undefined when calling rbacInitialPermissionsUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

        return {
            path: urlPath,
            method: "PUT",
            headers: headerParameters,
            query: queryParameters,
            body: InitialPermissionsRequestToJSON(requestParameters["initialPermissionsRequest"]),
        };
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsUpdateRaw(
        requestParameters: RbacInitialPermissionsUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<InitialPermissions>> {
        const requestOptions =
            await this.rbacInitialPermissionsUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            InitialPermissionsFromJSON(jsonValue),
        );
    }

    /**
     * InitialPermissions viewset
     */
    async rbacInitialPermissionsUpdate(
        requestParameters: RbacInitialPermissionsUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<InitialPermissions> {
        const response = await this.rbacInitialPermissionsUpdateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacInitialPermissionsUsedByList without sending the request
     */
    async rbacInitialPermissionsUsedByListRequestOpts(
        requestParameters: RbacInitialPermissionsUsedByListRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["id"] == null) {
            throw new runtime.RequiredError(
                "id",
                'Required parameter "id" was null or undefined when calling rbacInitialPermissionsUsedByList().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/initial_permissions/{id}/used_by/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get a list of all objects that use this object
     */
    async rbacInitialPermissionsUsedByListRaw(
        requestParameters: RbacInitialPermissionsUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions =
            await this.rbacInitialPermissionsUsedByListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UsedByFromJSON));
    }

    /**
     * Get a list of all objects that use this object
     */
    async rbacInitialPermissionsUsedByList(
        requestParameters: RbacInitialPermissionsUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.rbacInitialPermissionsUsedByListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacPermissionsAssignedByRolesAssign without sending the request
     */
    async rbacPermissionsAssignedByRolesAssignRequestOpts(
        requestParameters: RbacPermissionsAssignedByRolesAssignRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacPermissionsAssignedByRolesAssign().',
            );
        }

        if (requestParameters["permissionAssignRequest"] == null) {
            throw new runtime.RequiredError(
                "permissionAssignRequest",
                'Required parameter "permissionAssignRequest" was null or undefined when calling rbacPermissionsAssignedByRolesAssign().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/permissions/assigned_by_roles/{uuid}/assign/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: PermissionAssignRequestToJSON(requestParameters["permissionAssignRequest"]),
        };
    }

    /**
     * Assign permission(s) to role. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
     */
    async rbacPermissionsAssignedByRolesAssignRaw(
        requestParameters: RbacPermissionsAssignedByRolesAssignRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<PermissionAssignResult>>> {
        const requestOptions =
            await this.rbacPermissionsAssignedByRolesAssignRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            jsonValue.map(PermissionAssignResultFromJSON),
        );
    }

    /**
     * Assign permission(s) to role. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
     */
    async rbacPermissionsAssignedByRolesAssign(
        requestParameters: RbacPermissionsAssignedByRolesAssignRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<PermissionAssignResult>> {
        const response = await this.rbacPermissionsAssignedByRolesAssignRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacPermissionsAssignedByRolesList without sending the request
     */
    async rbacPermissionsAssignedByRolesListRequestOpts(
        requestParameters: RbacPermissionsAssignedByRolesListRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["model"] == null) {
            throw new runtime.RequiredError(
                "model",
                'Required parameter "model" was null or undefined when calling rbacPermissionsAssignedByRolesList().',
            );
        }

        const queryParameters: any = {};

        if (requestParameters["model"] != null) {
            queryParameters["model"] = requestParameters["model"];
        }

        if (requestParameters["objectPk"] != null) {
            queryParameters["object_pk"] = requestParameters["objectPk"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/permissions/assigned_by_roles/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get assigned object permissions for a single object
     */
    async rbacPermissionsAssignedByRolesListRaw(
        requestParameters: RbacPermissionsAssignedByRolesListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedRoleAssignedObjectPermissionList>> {
        const requestOptions =
            await this.rbacPermissionsAssignedByRolesListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedRoleAssignedObjectPermissionListFromJSON(jsonValue),
        );
    }

    /**
     * Get assigned object permissions for a single object
     */
    async rbacPermissionsAssignedByRolesList(
        requestParameters: RbacPermissionsAssignedByRolesListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedRoleAssignedObjectPermissionList> {
        const response = await this.rbacPermissionsAssignedByRolesListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for rbacPermissionsAssignedByRolesUnassignPartialUpdate without sending the request
     */
    async rbacPermissionsAssignedByRolesUnassignPartialUpdateRequestOpts(
        requestParameters: RbacPermissionsAssignedByRolesUnassignPartialUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacPermissionsAssignedByRolesUnassignPartialUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/permissions/assigned_by_roles/{uuid}/unassign/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "PATCH",
            headers: headerParameters,
            query: queryParameters,
            body: PatchedPermissionAssignRequestToJSON(
                requestParameters["patchedPermissionAssignRequest"],
            ),
        };
    }

    /**
     * Unassign permission(s) to role. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
     */
    async rbacPermissionsAssignedByRolesUnassignPartialUpdateRaw(
        requestParameters: RbacPermissionsAssignedByRolesUnassignPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions =
            await this.rbacPermissionsAssignedByRolesUnassignPartialUpdateRequestOpts(
                requestParameters,
            );
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Unassign permission(s) to role. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
     */
    async rbacPermissionsAssignedByRolesUnassignPartialUpdate(
        requestParameters: RbacPermissionsAssignedByRolesUnassignPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.rbacPermissionsAssignedByRolesUnassignPartialUpdateRaw(
            requestParameters,
            initOverrides,
        );
    }

    /**
     * Creates request options for rbacPermissionsList without sending the request
     */
    async rbacPermissionsListRequestOpts(
        requestParameters: RbacPermissionsListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["codename"] != null) {
            queryParameters["codename"] = requestParameters["codename"];
        }

        if (requestParameters["contentTypeAppLabel"] != null) {
            queryParameters["content_type__app_label"] = requestParameters["contentTypeAppLabel"];
        }

        if (requestParameters["contentTypeModel"] != null) {
            queryParameters["content_type__model"] = requestParameters["contentTypeModel"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["role"] != null) {
            queryParameters["role"] = requestParameters["role"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/permissions/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Read-only list of all permissions, filterable by model and app
     */
    async rbacPermissionsListRaw(
        requestParameters: RbacPermissionsListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedPermissionList>> {
        const requestOptions = await this.rbacPermissionsListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedPermissionListFromJSON(jsonValue),
        );
    }

    /**
     * Read-only list of all permissions, filterable by model and app
     */
    async rbacPermissionsList(
        requestParameters: RbacPermissionsListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedPermissionList> {
        const response = await this.rbacPermissionsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacPermissionsRetrieve without sending the request
     */
    async rbacPermissionsRetrieveRequestOpts(
        requestParameters: RbacPermissionsRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["id"] == null) {
            throw new runtime.RequiredError(
                "id",
                'Required parameter "id" was null or undefined when calling rbacPermissionsRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/permissions/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Read-only list of all permissions, filterable by model and app
     */
    async rbacPermissionsRetrieveRaw(
        requestParameters: RbacPermissionsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Permission>> {
        const requestOptions = await this.rbacPermissionsRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => PermissionFromJSON(jsonValue));
    }

    /**
     * Read-only list of all permissions, filterable by model and app
     */
    async rbacPermissionsRetrieve(
        requestParameters: RbacPermissionsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Permission> {
        const response = await this.rbacPermissionsRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacPermissionsRolesList without sending the request
     */
    async rbacPermissionsRolesListRequestOpts(
        requestParameters: RbacPermissionsRolesListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        if (requestParameters["uuid"] != null) {
            queryParameters["uuid"] = requestParameters["uuid"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/permissions/roles/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get a role\'s assigned object permissions
     */
    async rbacPermissionsRolesListRaw(
        requestParameters: RbacPermissionsRolesListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedExtraRoleObjectPermissionList>> {
        const requestOptions = await this.rbacPermissionsRolesListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedExtraRoleObjectPermissionListFromJSON(jsonValue),
        );
    }

    /**
     * Get a role\'s assigned object permissions
     */
    async rbacPermissionsRolesList(
        requestParameters: RbacPermissionsRolesListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedExtraRoleObjectPermissionList> {
        const response = await this.rbacPermissionsRolesListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacRolesAddUserCreate without sending the request
     */
    async rbacRolesAddUserCreateRequestOpts(
        requestParameters: RbacRolesAddUserCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesAddUserCreate().',
            );
        }

        if (requestParameters["userAccountSerializerForRoleRequest"] == null) {
            throw new runtime.RequiredError(
                "userAccountSerializerForRoleRequest",
                'Required parameter "userAccountSerializerForRoleRequest" was null or undefined when calling rbacRolesAddUserCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/add_user/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: UserAccountSerializerForRoleRequestToJSON(
                requestParameters["userAccountSerializerForRoleRequest"],
            ),
        };
    }

    /**
     * Add user to role
     */
    async rbacRolesAddUserCreateRaw(
        requestParameters: RbacRolesAddUserCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.rbacRolesAddUserCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Add user to role
     */
    async rbacRolesAddUserCreate(
        requestParameters: RbacRolesAddUserCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.rbacRolesAddUserCreateRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for rbacRolesCreate without sending the request
     */
    async rbacRolesCreateRequestOpts(
        requestParameters: RbacRolesCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["roleRequest"] == null) {
            throw new runtime.RequiredError(
                "roleRequest",
                'Required parameter "roleRequest" was null or undefined when calling rbacRolesCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/`;

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: RoleRequestToJSON(requestParameters["roleRequest"]),
        };
    }

    /**
     * Role viewset
     */
    async rbacRolesCreateRaw(
        requestParameters: RbacRolesCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Role>> {
        const requestOptions = await this.rbacRolesCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => RoleFromJSON(jsonValue));
    }

    /**
     * Role viewset
     */
    async rbacRolesCreate(
        requestParameters: RbacRolesCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Role> {
        const response = await this.rbacRolesCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacRolesDestroy without sending the request
     */
    async rbacRolesDestroyRequestOpts(
        requestParameters: RbacRolesDestroyRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesDestroy().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "DELETE",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Role viewset
     */
    async rbacRolesDestroyRaw(
        requestParameters: RbacRolesDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.rbacRolesDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Role viewset
     */
    async rbacRolesDestroy(
        requestParameters: RbacRolesDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.rbacRolesDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for rbacRolesList without sending the request
     */
    async rbacRolesListRequestOpts(
        requestParameters: RbacRolesListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["groups"] != null) {
            queryParameters["groups"] = requestParameters["groups"];
        }

        if (requestParameters["inherited"] != null) {
            queryParameters["inherited"] = requestParameters["inherited"];
        }

        if (requestParameters["managed"] != null) {
            queryParameters["managed"] = requestParameters["managed"];
        }

        if (requestParameters["managedIsnull"] != null) {
            queryParameters["managed__isnull"] = requestParameters["managedIsnull"];
        }

        if (requestParameters["name"] != null) {
            queryParameters["name"] = requestParameters["name"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        if (requestParameters["users"] != null) {
            queryParameters["users"] = requestParameters["users"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Role viewset
     */
    async rbacRolesListRaw(
        requestParameters: RbacRolesListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedRoleList>> {
        const requestOptions = await this.rbacRolesListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedRoleListFromJSON(jsonValue),
        );
    }

    /**
     * Role viewset
     */
    async rbacRolesList(
        requestParameters: RbacRolesListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedRoleList> {
        const response = await this.rbacRolesListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacRolesPartialUpdate without sending the request
     */
    async rbacRolesPartialUpdateRequestOpts(
        requestParameters: RbacRolesPartialUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesPartialUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "PATCH",
            headers: headerParameters,
            query: queryParameters,
            body: PatchedRoleRequestToJSON(requestParameters["patchedRoleRequest"]),
        };
    }

    /**
     * Role viewset
     */
    async rbacRolesPartialUpdateRaw(
        requestParameters: RbacRolesPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Role>> {
        const requestOptions = await this.rbacRolesPartialUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => RoleFromJSON(jsonValue));
    }

    /**
     * Role viewset
     */
    async rbacRolesPartialUpdate(
        requestParameters: RbacRolesPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Role> {
        const response = await this.rbacRolesPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacRolesRemoveUserCreate without sending the request
     */
    async rbacRolesRemoveUserCreateRequestOpts(
        requestParameters: RbacRolesRemoveUserCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesRemoveUserCreate().',
            );
        }

        if (requestParameters["userAccountSerializerForRoleRequest"] == null) {
            throw new runtime.RequiredError(
                "userAccountSerializerForRoleRequest",
                'Required parameter "userAccountSerializerForRoleRequest" was null or undefined when calling rbacRolesRemoveUserCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/remove_user/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: UserAccountSerializerForRoleRequestToJSON(
                requestParameters["userAccountSerializerForRoleRequest"],
            ),
        };
    }

    /**
     * Remove user from role
     */
    async rbacRolesRemoveUserCreateRaw(
        requestParameters: RbacRolesRemoveUserCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.rbacRolesRemoveUserCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Remove user from role
     */
    async rbacRolesRemoveUserCreate(
        requestParameters: RbacRolesRemoveUserCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.rbacRolesRemoveUserCreateRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for rbacRolesRetrieve without sending the request
     */
    async rbacRolesRetrieveRequestOpts(
        requestParameters: RbacRolesRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Role viewset
     */
    async rbacRolesRetrieveRaw(
        requestParameters: RbacRolesRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Role>> {
        const requestOptions = await this.rbacRolesRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => RoleFromJSON(jsonValue));
    }

    /**
     * Role viewset
     */
    async rbacRolesRetrieve(
        requestParameters: RbacRolesRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Role> {
        const response = await this.rbacRolesRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacRolesUpdate without sending the request
     */
    async rbacRolesUpdateRequestOpts(
        requestParameters: RbacRolesUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesUpdate().',
            );
        }

        if (requestParameters["roleRequest"] == null) {
            throw new runtime.RequiredError(
                "roleRequest",
                'Required parameter "roleRequest" was null or undefined when calling rbacRolesUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "PUT",
            headers: headerParameters,
            query: queryParameters,
            body: RoleRequestToJSON(requestParameters["roleRequest"]),
        };
    }

    /**
     * Role viewset
     */
    async rbacRolesUpdateRaw(
        requestParameters: RbacRolesUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Role>> {
        const requestOptions = await this.rbacRolesUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => RoleFromJSON(jsonValue));
    }

    /**
     * Role viewset
     */
    async rbacRolesUpdate(
        requestParameters: RbacRolesUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Role> {
        const response = await this.rbacRolesUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for rbacRolesUsedByList without sending the request
     */
    async rbacRolesUsedByListRequestOpts(
        requestParameters: RbacRolesUsedByListRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["uuid"] == null) {
            throw new runtime.RequiredError(
                "uuid",
                'Required parameter "uuid" was null or undefined when calling rbacRolesUsedByList().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/rbac/roles/{uuid}/used_by/`;
        urlPath = urlPath.replace(
            `{${"uuid"}}`,
            encodeURIComponent(String(requestParameters["uuid"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get a list of all objects that use this object
     */
    async rbacRolesUsedByListRaw(
        requestParameters: RbacRolesUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions = await this.rbacRolesUsedByListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UsedByFromJSON));
    }

    /**
     * Get a list of all objects that use this object
     */
    async rbacRolesUsedByList(
        requestParameters: RbacRolesUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.rbacRolesUsedByListRaw(requestParameters, initOverrides);
        return await response.value();
    }
}
