/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2025.10.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  Domain,
  DomainRequest,
  GenericError,
  PaginatedDomainList,
  PaginatedTenantList,
  PatchedDomainRequest,
  PatchedTenantRequest,
  Tenant,
  TenantAdminGroupRequestRequest,
  TenantRecoveryKeyRequestRequest,
  TenantRecoveryKeyResponse,
  TenantRequest,
  ValidationError,
} from '../models/index';
import {
    DomainFromJSON,
    DomainToJSON,
    DomainRequestFromJSON,
    DomainRequestToJSON,
    GenericErrorFromJSON,
    GenericErrorToJSON,
    PaginatedDomainListFromJSON,
    PaginatedDomainListToJSON,
    PaginatedTenantListFromJSON,
    PaginatedTenantListToJSON,
    PatchedDomainRequestFromJSON,
    PatchedDomainRequestToJSON,
    PatchedTenantRequestFromJSON,
    PatchedTenantRequestToJSON,
    TenantFromJSON,
    TenantToJSON,
    TenantAdminGroupRequestRequestFromJSON,
    TenantAdminGroupRequestRequestToJSON,
    TenantRecoveryKeyRequestRequestFromJSON,
    TenantRecoveryKeyRequestRequestToJSON,
    TenantRecoveryKeyResponseFromJSON,
    TenantRecoveryKeyResponseToJSON,
    TenantRequestFromJSON,
    TenantRequestToJSON,
    ValidationErrorFromJSON,
    ValidationErrorToJSON,
} from '../models/index';

export interface TenantsDomainsCreateRequest {
    domainRequest: DomainRequest;
}

export interface TenantsDomainsDestroyRequest {
    id: number;
}

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

export interface TenantsDomainsPartialUpdateRequest {
    id: number;
    patchedDomainRequest?: PatchedDomainRequest;
}

export interface TenantsDomainsRetrieveRequest {
    id: number;
}

export interface TenantsDomainsUpdateRequest {
    id: number;
    domainRequest: DomainRequest;
}

export interface TenantsTenantsCreateRequest {
    tenantRequest: TenantRequest;
}

export interface TenantsTenantsCreateAdminGroupCreateRequest {
    tenantUuid: string;
    tenantAdminGroupRequestRequest: TenantAdminGroupRequestRequest;
}

export interface TenantsTenantsCreateRecoveryKeyCreateRequest {
    tenantUuid: string;
    tenantRecoveryKeyRequestRequest: TenantRecoveryKeyRequestRequest;
}

export interface TenantsTenantsDestroyRequest {
    tenantUuid: string;
}

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

export interface TenantsTenantsPartialUpdateRequest {
    tenantUuid: string;
    patchedTenantRequest?: PatchedTenantRequest;
}

export interface TenantsTenantsRetrieveRequest {
    tenantUuid: string;
}

export interface TenantsTenantsUpdateRequest {
    tenantUuid: string;
    tenantRequest: TenantRequest;
}

/**
 * 
 */
export class TenantsApi extends runtime.BaseAPI {

    /**
     * Domain ViewSet
     */
    async tenantsDomainsCreateRaw(requestParameters: TenantsDomainsCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Domain>> {
        if (requestParameters['domainRequest'] == null) {
            throw new runtime.RequiredError(
                'domainRequest',
                'Required parameter "domainRequest" was null or undefined when calling tenantsDomainsCreate().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


        let urlPath = `/tenants/domains/`;

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: DomainRequestToJSON(requestParameters['domainRequest']),
        }, initOverrides);

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

    /**
     * Domain ViewSet
     */
    async tenantsDomainsCreate(requestParameters: TenantsDomainsCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Domain> {
        const response = await this.tenantsDomainsCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Domain ViewSet
     */
    async tenantsDomainsDestroyRaw(requestParameters: TenantsDomainsDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling tenantsDomainsDestroy().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


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

        const response = await this.request({
            path: urlPath,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Domain ViewSet
     */
    async tenantsDomainsDestroy(requestParameters: TenantsDomainsDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.tenantsDomainsDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Domain ViewSet
     */
    async tenantsDomainsListRaw(requestParameters: TenantsDomainsListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PaginatedDomainList>> {
        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'];
        }

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/tenants/domains/`;

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Domain ViewSet
     */
    async tenantsDomainsList(requestParameters: TenantsDomainsListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PaginatedDomainList> {
        const response = await this.tenantsDomainsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Domain ViewSet
     */
    async tenantsDomainsPartialUpdateRaw(requestParameters: TenantsDomainsPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Domain>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling tenantsDomainsPartialUpdate().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


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

        const response = await this.request({
            path: urlPath,
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: PatchedDomainRequestToJSON(requestParameters['patchedDomainRequest']),
        }, initOverrides);

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

    /**
     * Domain ViewSet
     */
    async tenantsDomainsPartialUpdate(requestParameters: TenantsDomainsPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Domain> {
        const response = await this.tenantsDomainsPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Domain ViewSet
     */
    async tenantsDomainsRetrieveRaw(requestParameters: TenantsDomainsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Domain>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling tenantsDomainsRetrieve().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


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

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Domain ViewSet
     */
    async tenantsDomainsRetrieve(requestParameters: TenantsDomainsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Domain> {
        const response = await this.tenantsDomainsRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Domain ViewSet
     */
    async tenantsDomainsUpdateRaw(requestParameters: TenantsDomainsUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Domain>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling tenantsDomainsUpdate().'
            );
        }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


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

        const response = await this.request({
            path: urlPath,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
            body: DomainRequestToJSON(requestParameters['domainRequest']),
        }, initOverrides);

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

    /**
     * Domain ViewSet
     */
    async tenantsDomainsUpdate(requestParameters: TenantsDomainsUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Domain> {
        const response = await this.tenantsDomainsUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsCreateRaw(requestParameters: TenantsTenantsCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Tenant>> {
        if (requestParameters['tenantRequest'] == null) {
            throw new runtime.RequiredError(
                'tenantRequest',
                'Required parameter "tenantRequest" was null or undefined when calling tenantsTenantsCreate().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


        let urlPath = `/tenants/tenants/`;

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: TenantRequestToJSON(requestParameters['tenantRequest']),
        }, initOverrides);

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

    /**
     * Tenant Viewset
     */
    async tenantsTenantsCreate(requestParameters: TenantsTenantsCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Tenant> {
        const response = await this.tenantsTenantsCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Create admin group and add user to it.
     */
    async tenantsTenantsCreateAdminGroupCreateRaw(requestParameters: TenantsTenantsCreateAdminGroupCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['tenantUuid'] == null) {
            throw new runtime.RequiredError(
                'tenantUuid',
                'Required parameter "tenantUuid" was null or undefined when calling tenantsTenantsCreateAdminGroupCreate().'
            );
        }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


        let urlPath = `/tenants/tenants/{tenant_uuid}/create_admin_group/`;
        urlPath = urlPath.replace(`{${"tenant_uuid"}}`, encodeURIComponent(String(requestParameters['tenantUuid'])));

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: TenantAdminGroupRequestRequestToJSON(requestParameters['tenantAdminGroupRequestRequest']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create admin group and add user to it.
     */
    async tenantsTenantsCreateAdminGroupCreate(requestParameters: TenantsTenantsCreateAdminGroupCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.tenantsTenantsCreateAdminGroupCreateRaw(requestParameters, initOverrides);
    }

    /**
     * Create recovery key for user.
     */
    async tenantsTenantsCreateRecoveryKeyCreateRaw(requestParameters: TenantsTenantsCreateRecoveryKeyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TenantRecoveryKeyResponse>> {
        if (requestParameters['tenantUuid'] == null) {
            throw new runtime.RequiredError(
                'tenantUuid',
                'Required parameter "tenantUuid" was null or undefined when calling tenantsTenantsCreateRecoveryKeyCreate().'
            );
        }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


        let urlPath = `/tenants/tenants/{tenant_uuid}/create_recovery_key/`;
        urlPath = urlPath.replace(`{${"tenant_uuid"}}`, encodeURIComponent(String(requestParameters['tenantUuid'])));

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: TenantRecoveryKeyRequestRequestToJSON(requestParameters['tenantRecoveryKeyRequestRequest']),
        }, initOverrides);

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

    /**
     * Create recovery key for user.
     */
    async tenantsTenantsCreateRecoveryKeyCreate(requestParameters: TenantsTenantsCreateRecoveryKeyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TenantRecoveryKeyResponse> {
        const response = await this.tenantsTenantsCreateRecoveryKeyCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsDestroyRaw(requestParameters: TenantsTenantsDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['tenantUuid'] == null) {
            throw new runtime.RequiredError(
                'tenantUuid',
                'Required parameter "tenantUuid" was null or undefined when calling tenantsTenantsDestroy().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/tenants/tenants/{tenant_uuid}/`;
        urlPath = urlPath.replace(`{${"tenant_uuid"}}`, encodeURIComponent(String(requestParameters['tenantUuid'])));

        const response = await this.request({
            path: urlPath,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsDestroy(requestParameters: TenantsTenantsDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.tenantsTenantsDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsListRaw(requestParameters: TenantsTenantsListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PaginatedTenantList>> {
        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'];
        }

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/tenants/tenants/`;

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Tenant Viewset
     */
    async tenantsTenantsList(requestParameters: TenantsTenantsListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PaginatedTenantList> {
        const response = await this.tenantsTenantsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsPartialUpdateRaw(requestParameters: TenantsTenantsPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Tenant>> {
        if (requestParameters['tenantUuid'] == null) {
            throw new runtime.RequiredError(
                'tenantUuid',
                'Required parameter "tenantUuid" was null or undefined when calling tenantsTenantsPartialUpdate().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


        let urlPath = `/tenants/tenants/{tenant_uuid}/`;
        urlPath = urlPath.replace(`{${"tenant_uuid"}}`, encodeURIComponent(String(requestParameters['tenantUuid'])));

        const response = await this.request({
            path: urlPath,
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: PatchedTenantRequestToJSON(requestParameters['patchedTenantRequest']),
        }, initOverrides);

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

    /**
     * Tenant Viewset
     */
    async tenantsTenantsPartialUpdate(requestParameters: TenantsTenantsPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Tenant> {
        const response = await this.tenantsTenantsPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsRetrieveRaw(requestParameters: TenantsTenantsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Tenant>> {
        if (requestParameters['tenantUuid'] == null) {
            throw new runtime.RequiredError(
                'tenantUuid',
                'Required parameter "tenantUuid" was null or undefined when calling tenantsTenantsRetrieve().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/tenants/tenants/{tenant_uuid}/`;
        urlPath = urlPath.replace(`{${"tenant_uuid"}}`, encodeURIComponent(String(requestParameters['tenantUuid'])));

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Tenant Viewset
     */
    async tenantsTenantsRetrieve(requestParameters: TenantsTenantsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Tenant> {
        const response = await this.tenantsTenantsRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Tenant Viewset
     */
    async tenantsTenantsUpdateRaw(requestParameters: TenantsTenantsUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Tenant>> {
        if (requestParameters['tenantUuid'] == null) {
            throw new runtime.RequiredError(
                'tenantUuid',
                'Required parameter "tenantUuid" was null or undefined when calling tenantsTenantsUpdate().'
            );
        }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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


        let urlPath = `/tenants/tenants/{tenant_uuid}/`;
        urlPath = urlPath.replace(`{${"tenant_uuid"}}`, encodeURIComponent(String(requestParameters['tenantUuid'])));

        const response = await this.request({
            path: urlPath,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
            body: TenantRequestToJSON(requestParameters['tenantRequest']),
        }, initOverrides);

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

    /**
     * Tenant Viewset
     */
    async tenantsTenantsUpdate(requestParameters: TenantsTenantsUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Tenant> {
        const response = await this.tenantsTenantsUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
