/* 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 {
    ExpiringBaseGrantModel,
    PaginatedExpiringBaseGrantModelList,
    PaginatedTokenModelList,
    TokenModel,
    UsedBy,
} from "../models/index";
import {
    ExpiringBaseGrantModelFromJSON,
    PaginatedExpiringBaseGrantModelListFromJSON,
    PaginatedTokenModelListFromJSON,
    TokenModelFromJSON,
    UsedByFromJSON,
} from "../models/index";
import * as runtime from "../runtime";

export interface Oauth2AccessTokensDestroyRequest {
    id: number;
}

export interface Oauth2AccessTokensListRequest {
    ordering?: string;
    page?: number;
    pageSize?: number;
    provider?: number;
    search?: string;
    user?: number;
}

export interface Oauth2AccessTokensRetrieveRequest {
    id: number;
}

export interface Oauth2AccessTokensUsedByListRequest {
    id: number;
}

export interface Oauth2AuthorizationCodesDestroyRequest {
    id: number;
}

export interface Oauth2AuthorizationCodesListRequest {
    ordering?: string;
    page?: number;
    pageSize?: number;
    provider?: number;
    search?: string;
    user?: number;
}

export interface Oauth2AuthorizationCodesRetrieveRequest {
    id: number;
}

export interface Oauth2AuthorizationCodesUsedByListRequest {
    id: number;
}

export interface Oauth2RefreshTokensDestroyRequest {
    id: number;
}

export interface Oauth2RefreshTokensListRequest {
    ordering?: string;
    page?: number;
    pageSize?: number;
    provider?: number;
    search?: string;
    user?: number;
}

export interface Oauth2RefreshTokensRetrieveRequest {
    id: number;
}

export interface Oauth2RefreshTokensUsedByListRequest {
    id: number;
}

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

        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 = `/oauth2/access_tokens/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

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

    /**
     * AccessToken Viewset
     */
    async oauth2AccessTokensDestroyRaw(
        requestParameters: Oauth2AccessTokensDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.oauth2AccessTokensDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * AccessToken Viewset
     */
    async oauth2AccessTokensDestroy(
        requestParameters: Oauth2AccessTokensDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.oauth2AccessTokensDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for oauth2AccessTokensList without sending the request
     */
    async oauth2AccessTokensListRequestOpts(
        requestParameters: Oauth2AccessTokensListRequest,
    ): 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["provider"] != null) {
            queryParameters["provider"] = requestParameters["provider"];
        }

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

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

        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 = `/oauth2/access_tokens/`;

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

    /**
     * AccessToken Viewset
     */
    async oauth2AccessTokensListRaw(
        requestParameters: Oauth2AccessTokensListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedTokenModelList>> {
        const requestOptions = await this.oauth2AccessTokensListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * AccessToken Viewset
     */
    async oauth2AccessTokensList(
        requestParameters: Oauth2AccessTokensListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedTokenModelList> {
        const response = await this.oauth2AccessTokensListRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

        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 = `/oauth2/access_tokens/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

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

    /**
     * AccessToken Viewset
     */
    async oauth2AccessTokensRetrieveRaw(
        requestParameters: Oauth2AccessTokensRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<TokenModel>> {
        const requestOptions = await this.oauth2AccessTokensRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * AccessToken Viewset
     */
    async oauth2AccessTokensRetrieve(
        requestParameters: Oauth2AccessTokensRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<TokenModel> {
        const response = await this.oauth2AccessTokensRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

        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 = `/oauth2/access_tokens/{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 oauth2AccessTokensUsedByListRaw(
        requestParameters: Oauth2AccessTokensUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions =
            await this.oauth2AccessTokensUsedByListRequestOpts(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 oauth2AccessTokensUsedByList(
        requestParameters: Oauth2AccessTokensUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.oauth2AccessTokensUsedByListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/oauth2/authorization_codes/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

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

    /**
     * AuthorizationCode Viewset
     */
    async oauth2AuthorizationCodesDestroyRaw(
        requestParameters: Oauth2AuthorizationCodesDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions =
            await this.oauth2AuthorizationCodesDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * AuthorizationCode Viewset
     */
    async oauth2AuthorizationCodesDestroy(
        requestParameters: Oauth2AuthorizationCodesDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.oauth2AuthorizationCodesDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for oauth2AuthorizationCodesList without sending the request
     */
    async oauth2AuthorizationCodesListRequestOpts(
        requestParameters: Oauth2AuthorizationCodesListRequest,
    ): 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["provider"] != null) {
            queryParameters["provider"] = requestParameters["provider"];
        }

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

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

        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 = `/oauth2/authorization_codes/`;

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

    /**
     * AuthorizationCode Viewset
     */
    async oauth2AuthorizationCodesListRaw(
        requestParameters: Oauth2AuthorizationCodesListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedExpiringBaseGrantModelList>> {
        const requestOptions =
            await this.oauth2AuthorizationCodesListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * AuthorizationCode Viewset
     */
    async oauth2AuthorizationCodesList(
        requestParameters: Oauth2AuthorizationCodesListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedExpiringBaseGrantModelList> {
        const response = await this.oauth2AuthorizationCodesListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/oauth2/authorization_codes/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

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

    /**
     * AuthorizationCode Viewset
     */
    async oauth2AuthorizationCodesRetrieveRaw(
        requestParameters: Oauth2AuthorizationCodesRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<ExpiringBaseGrantModel>> {
        const requestOptions =
            await this.oauth2AuthorizationCodesRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * AuthorizationCode Viewset
     */
    async oauth2AuthorizationCodesRetrieve(
        requestParameters: Oauth2AuthorizationCodesRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<ExpiringBaseGrantModel> {
        const response = await this.oauth2AuthorizationCodesRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/oauth2/authorization_codes/{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 oauth2AuthorizationCodesUsedByListRaw(
        requestParameters: Oauth2AuthorizationCodesUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions =
            await this.oauth2AuthorizationCodesUsedByListRequestOpts(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 oauth2AuthorizationCodesUsedByList(
        requestParameters: Oauth2AuthorizationCodesUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.oauth2AuthorizationCodesUsedByListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/oauth2/refresh_tokens/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

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

    /**
     * RefreshToken Viewset
     */
    async oauth2RefreshTokensDestroyRaw(
        requestParameters: Oauth2RefreshTokensDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.oauth2RefreshTokensDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * RefreshToken Viewset
     */
    async oauth2RefreshTokensDestroy(
        requestParameters: Oauth2RefreshTokensDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.oauth2RefreshTokensDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for oauth2RefreshTokensList without sending the request
     */
    async oauth2RefreshTokensListRequestOpts(
        requestParameters: Oauth2RefreshTokensListRequest,
    ): 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["provider"] != null) {
            queryParameters["provider"] = requestParameters["provider"];
        }

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

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

        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 = `/oauth2/refresh_tokens/`;

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

    /**
     * RefreshToken Viewset
     */
    async oauth2RefreshTokensListRaw(
        requestParameters: Oauth2RefreshTokensListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedTokenModelList>> {
        const requestOptions = await this.oauth2RefreshTokensListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * RefreshToken Viewset
     */
    async oauth2RefreshTokensList(
        requestParameters: Oauth2RefreshTokensListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedTokenModelList> {
        const response = await this.oauth2RefreshTokensListRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

        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 = `/oauth2/refresh_tokens/{id}/`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));

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

    /**
     * RefreshToken Viewset
     */
    async oauth2RefreshTokensRetrieveRaw(
        requestParameters: Oauth2RefreshTokensRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<TokenModel>> {
        const requestOptions = await this.oauth2RefreshTokensRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * RefreshToken Viewset
     */
    async oauth2RefreshTokensRetrieve(
        requestParameters: Oauth2RefreshTokensRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<TokenModel> {
        const response = await this.oauth2RefreshTokensRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/oauth2/refresh_tokens/{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 oauth2RefreshTokensUsedByListRaw(
        requestParameters: Oauth2RefreshTokensUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions =
            await this.oauth2RefreshTokensUsedByListRequestOpts(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 oauth2RefreshTokensUsedByList(
        requestParameters: Oauth2RefreshTokensUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.oauth2RefreshTokensUsedByListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }
}
