# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.change_preset_response import ChangePresetResponse
from ..types.organization_domain_response import OrganizationDomainResponse
from ..types.organization_list_response import OrganizationListResponse
from ..types.organization_model_settings_response import OrganizationModelSettingsResponse
from ..types.organization_response import OrganizationResponse
from ..types.permission_preset_response import PermissionPresetResponse
from ..types.provider_response import ProviderResponse
from ..types.provider_validation_response import ProviderValidationResponse
from ..types.role_response import RoleResponse
from ..types.status_response import StatusResponse
from .raw_client import AsyncRawOrganizationsClient, RawOrganizationsClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class OrganizationsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawOrganizationsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawOrganizationsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawOrganizationsClient
        """
        return self._raw_client

    def list_organizations(
        self,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        active_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationListResponse:
        """
        List all organizations the current user belongs to.

        Automatically checks if user's email domain matches any organization domains
        and grants access to new organizations if eligible.
        Results are cached per user for 30 seconds to reduce database load.

        Parameters
        ----------
        skip : typing.Optional[int]
            Number of records to skip

        limit : typing.Optional[int]
            Maximum number of records

        active_only : typing.Optional[bool]
            Only return active organizations

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.list_organizations()
        """
        _response = self._raw_client.list_organizations(
            skip=skip, limit=limit, active_only=active_only, request_options=request_options
        )
        return _response.data

    def create_organization(
        self,
        *,
        name: str,
        type: str,
        description: typing.Optional[str] = OMIT,
        website: typing.Optional[str] = OMIT,
        industry: typing.Optional[str] = OMIT,
        company_size: typing.Optional[str] = OMIT,
        logo_image: typing.Optional[str] = OMIT,
        use_system_provider_keys: typing.Optional[bool] = OMIT,
        domains: typing.Optional[typing.Sequence[str]] = OMIT,
        permission_preset: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationResponse:
        """
        Create a new organization.

        The current user will be set as the owner.

        Parameters
        ----------
        name : str
            Organization name

        type : str
            Organization type (Work, Personal, School)

        description : typing.Optional[str]
            Organization description

        website : typing.Optional[str]
            Website URL

        industry : typing.Optional[str]
            Industry

        company_size : typing.Optional[str]
            Company size range

        logo_image : typing.Optional[str]
            Base64 encoded logo

        use_system_provider_keys : typing.Optional[bool]
            Whether to use system-wide AI provider keys

        domains : typing.Optional[typing.Sequence[str]]
            Email domains for automatic member access (e.g., ['company.com'])

        permission_preset : typing.Optional[str]
            Permission preset for the organization (collaborative, balanced, controlled)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.create_organization(
            name="name",
            type="type",
        )
        """
        _response = self._raw_client.create_organization(
            name=name,
            type=type,
            description=description,
            website=website,
            industry=industry,
            company_size=company_size,
            logo_image=logo_image,
            use_system_provider_keys=use_system_provider_keys,
            domains=domains,
            permission_preset=permission_preset,
            request_options=request_options,
        )
        return _response.data

    def get_organization(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationResponse:
        """
        Get organization details by ID.

        User must be a member of the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.get_organization(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.get_organization(organization_id, request_options=request_options)
        return _response.data

    def delete_organization(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft delete an organization.

        User must be the Owner of the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.delete_organization(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.delete_organization(organization_id, request_options=request_options)
        return _response.data

    def update_organization(
        self,
        organization_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        website: typing.Optional[str] = OMIT,
        industry: typing.Optional[str] = OMIT,
        company_size: typing.Optional[str] = OMIT,
        logo_image: typing.Optional[str] = OMIT,
        image_url: typing.Optional[str] = OMIT,
        is_active: typing.Optional[bool] = OMIT,
        api_usage_limit: typing.Optional[float] = OMIT,
        api_key_usage_limit: typing.Optional[float] = OMIT,
        domains: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationResponse:
        """
        Update organization details.

        User must be an Admin or Owner of the organization.
        Invalidates limit caches when api_usage_limit or api_key_usage_limit is updated.
        Handles domain updates through OrganizationDomain relationship.

        Parameters
        ----------
        organization_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        website : typing.Optional[str]

        industry : typing.Optional[str]

        company_size : typing.Optional[str]

        logo_image : typing.Optional[str]

        image_url : typing.Optional[str]

        is_active : typing.Optional[bool]

        api_usage_limit : typing.Optional[float]
            API spending limit in CHF

        api_key_usage_limit : typing.Optional[float]
            Monthly spending limit for all API keys combined (CHF)

        domains : typing.Optional[typing.Sequence[str]]
            Email domains for automatic member access (e.g., ['company.com'])

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.update_organization(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.update_organization(
            organization_id,
            name=name,
            description=description,
            website=website,
            industry=industry,
            company_size=company_size,
            logo_image=logo_image,
            image_url=image_url,
            is_active=is_active,
            api_usage_limit=api_usage_limit,
            api_key_usage_limit=api_key_usage_limit,
            domains=domains,
            request_options=request_options,
        )
        return _response.data

    def list_providers(
        self,
        organization_id: str,
        *,
        active_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[ProviderResponse]:
        """
        List all AI providers configured for the organization.

        Parameters
        ----------
        organization_id : str

        active_only : typing.Optional[bool]
            Only return active providers

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[ProviderResponse]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.list_providers(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_providers(
            organization_id, active_only=active_only, request_options=request_options
        )
        return _response.data

    def validate_providers(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, ProviderValidationResponse]:
        """
        Validate all provider configurations for the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, ProviderValidationResponse]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.validate_providers(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.validate_providers(organization_id, request_options=request_options)
        return _response.data

    def update_provider(
        self,
        organization_id: str,
        provider_name: str,
        *,
        is_active: typing.Optional[bool] = OMIT,
        api_key: typing.Optional[str] = OMIT,
        org_id: typing.Optional[str] = OMIT,
        project_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Update provider configuration (enable/disable, update credentials).

        User must be an Admin or Owner of the organization.

        Parameters
        ----------
        organization_id : str

        provider_name : str

        is_active : typing.Optional[bool]
            Enable/disable provider

        api_key : typing.Optional[str]
            Provider API key (BYOK)

        org_id : typing.Optional[str]
            Provider organization ID

        project_id : typing.Optional[str]
            Provider project ID

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.update_provider(
            organization_id="organization_id",
            provider_name="provider_name",
        )
        """
        _response = self._raw_client.update_provider(
            organization_id,
            provider_name,
            is_active=is_active,
            api_key=api_key,
            org_id=org_id,
            project_id=project_id,
            request_options=request_options,
        )
        return _response.data

    def list_roles(
        self,
        organization_id: str,
        *,
        include_global: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[RoleResponse]:
        """
        List all roles available for the organization.

        Parameters
        ----------
        organization_id : str

        include_global : typing.Optional[bool]
            Include global roles

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[RoleResponse]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.list_roles(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_roles(
            organization_id, include_global=include_global, request_options=request_options
        )
        return _response.data

    def list_statuses(
        self,
        organization_id: str,
        *,
        active_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[StatusResponse]:
        """
        List all user statuses for the organization.

        Parameters
        ----------
        organization_id : str

        active_only : typing.Optional[bool]
            Only return active statuses

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[StatusResponse]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.list_statuses(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_statuses(
            organization_id, active_only=active_only, request_options=request_options
        )
        return _response.data

    def get_model_settings(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationModelSettingsResponse:
        """
        Get the model availability settings for an organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationModelSettingsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.get_model_settings(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.get_model_settings(organization_id, request_options=request_options)
        return _response.data

    def update_model_settings(
        self,
        organization_id: str,
        *,
        disabled_providers: typing.Optional[typing.Sequence[str]] = OMIT,
        disabled_models: typing.Optional[typing.Sequence[str]] = OMIT,
        default_model_key: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationModelSettingsResponse:
        """
        Update which AI models/providers are available in the organization.

        Parameters
        ----------
        organization_id : str

        disabled_providers : typing.Optional[typing.Sequence[str]]
            List of provider slugs to disable (e.g., ['google', 'mistral'])

        disabled_models : typing.Optional[typing.Sequence[str]]
            List of model keys to disable (e.g., ['gpt-4o-mini'])

        default_model_key : typing.Optional[str]
            Default model key for the organization

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationModelSettingsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.update_model_settings(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.update_model_settings(
            organization_id,
            disabled_providers=disabled_providers,
            disabled_models=disabled_models,
            default_model_key=default_model_key,
            request_options=request_options,
        )
        return _response.data

    def get_permission_preset(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PermissionPresetResponse:
        """
        Get the current permission preset and available options.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PermissionPresetResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.get_permission_preset(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.get_permission_preset(organization_id, request_options=request_options)
        return _response.data

    def change_permission_preset(
        self, organization_id: str, *, preset: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ChangePresetResponse:
        """
        Change the permission preset and retroactively update Member role capabilities.

        Parameters
        ----------
        organization_id : str

        preset : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ChangePresetResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.change_permission_preset(
            organization_id="organization_id",
            preset="preset",
        )
        """
        _response = self._raw_client.change_permission_preset(
            organization_id, preset=preset, request_options=request_options
        )
        return _response.data

    def list_domains(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[OrganizationDomainResponse]:
        """
        List all active email domains configured for the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[OrganizationDomainResponse]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.list_domains(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_domains(organization_id, request_options=request_options)
        return _response.data

    def add_domain(
        self, organization_id: str, *, domain: str, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationDomainResponse:
        """
        Add an email domain; users with a matching address will get automatic access.

        Parameters
        ----------
        organization_id : str

        domain : str
            Email domain (e.g., 'company.com')

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationDomainResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.add_domain(
            organization_id="organization_id",
            domain="domain",
        )
        """
        _response = self._raw_client.add_domain(organization_id, domain=domain, request_options=request_options)
        return _response.data

    def remove_domain(
        self, organization_id: str, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Remove an email domain; new users with that address will no longer get automatic access.

        Parameters
        ----------
        organization_id : str

        domain_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.organizations.remove_domain(
            organization_id="organization_id",
            domain_id="domain_id",
        )
        """
        _response = self._raw_client.remove_domain(organization_id, domain_id, request_options=request_options)
        return _response.data


class AsyncOrganizationsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawOrganizationsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawOrganizationsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawOrganizationsClient
        """
        return self._raw_client

    async def list_organizations(
        self,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        active_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationListResponse:
        """
        List all organizations the current user belongs to.

        Automatically checks if user's email domain matches any organization domains
        and grants access to new organizations if eligible.
        Results are cached per user for 30 seconds to reduce database load.

        Parameters
        ----------
        skip : typing.Optional[int]
            Number of records to skip

        limit : typing.Optional[int]
            Maximum number of records

        active_only : typing.Optional[bool]
            Only return active organizations

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.list_organizations()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_organizations(
            skip=skip, limit=limit, active_only=active_only, request_options=request_options
        )
        return _response.data

    async def create_organization(
        self,
        *,
        name: str,
        type: str,
        description: typing.Optional[str] = OMIT,
        website: typing.Optional[str] = OMIT,
        industry: typing.Optional[str] = OMIT,
        company_size: typing.Optional[str] = OMIT,
        logo_image: typing.Optional[str] = OMIT,
        use_system_provider_keys: typing.Optional[bool] = OMIT,
        domains: typing.Optional[typing.Sequence[str]] = OMIT,
        permission_preset: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationResponse:
        """
        Create a new organization.

        The current user will be set as the owner.

        Parameters
        ----------
        name : str
            Organization name

        type : str
            Organization type (Work, Personal, School)

        description : typing.Optional[str]
            Organization description

        website : typing.Optional[str]
            Website URL

        industry : typing.Optional[str]
            Industry

        company_size : typing.Optional[str]
            Company size range

        logo_image : typing.Optional[str]
            Base64 encoded logo

        use_system_provider_keys : typing.Optional[bool]
            Whether to use system-wide AI provider keys

        domains : typing.Optional[typing.Sequence[str]]
            Email domains for automatic member access (e.g., ['company.com'])

        permission_preset : typing.Optional[str]
            Permission preset for the organization (collaborative, balanced, controlled)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.create_organization(
                name="name",
                type="type",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_organization(
            name=name,
            type=type,
            description=description,
            website=website,
            industry=industry,
            company_size=company_size,
            logo_image=logo_image,
            use_system_provider_keys=use_system_provider_keys,
            domains=domains,
            permission_preset=permission_preset,
            request_options=request_options,
        )
        return _response.data

    async def get_organization(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationResponse:
        """
        Get organization details by ID.

        User must be a member of the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.get_organization(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_organization(organization_id, request_options=request_options)
        return _response.data

    async def delete_organization(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft delete an organization.

        User must be the Owner of the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.delete_organization(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_organization(organization_id, request_options=request_options)
        return _response.data

    async def update_organization(
        self,
        organization_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        website: typing.Optional[str] = OMIT,
        industry: typing.Optional[str] = OMIT,
        company_size: typing.Optional[str] = OMIT,
        logo_image: typing.Optional[str] = OMIT,
        image_url: typing.Optional[str] = OMIT,
        is_active: typing.Optional[bool] = OMIT,
        api_usage_limit: typing.Optional[float] = OMIT,
        api_key_usage_limit: typing.Optional[float] = OMIT,
        domains: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationResponse:
        """
        Update organization details.

        User must be an Admin or Owner of the organization.
        Invalidates limit caches when api_usage_limit or api_key_usage_limit is updated.
        Handles domain updates through OrganizationDomain relationship.

        Parameters
        ----------
        organization_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        website : typing.Optional[str]

        industry : typing.Optional[str]

        company_size : typing.Optional[str]

        logo_image : typing.Optional[str]

        image_url : typing.Optional[str]

        is_active : typing.Optional[bool]

        api_usage_limit : typing.Optional[float]
            API spending limit in CHF

        api_key_usage_limit : typing.Optional[float]
            Monthly spending limit for all API keys combined (CHF)

        domains : typing.Optional[typing.Sequence[str]]
            Email domains for automatic member access (e.g., ['company.com'])

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.update_organization(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_organization(
            organization_id,
            name=name,
            description=description,
            website=website,
            industry=industry,
            company_size=company_size,
            logo_image=logo_image,
            image_url=image_url,
            is_active=is_active,
            api_usage_limit=api_usage_limit,
            api_key_usage_limit=api_key_usage_limit,
            domains=domains,
            request_options=request_options,
        )
        return _response.data

    async def list_providers(
        self,
        organization_id: str,
        *,
        active_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[ProviderResponse]:
        """
        List all AI providers configured for the organization.

        Parameters
        ----------
        organization_id : str

        active_only : typing.Optional[bool]
            Only return active providers

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[ProviderResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.list_providers(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_providers(
            organization_id, active_only=active_only, request_options=request_options
        )
        return _response.data

    async def validate_providers(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, ProviderValidationResponse]:
        """
        Validate all provider configurations for the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, ProviderValidationResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.validate_providers(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.validate_providers(organization_id, request_options=request_options)
        return _response.data

    async def update_provider(
        self,
        organization_id: str,
        provider_name: str,
        *,
        is_active: typing.Optional[bool] = OMIT,
        api_key: typing.Optional[str] = OMIT,
        org_id: typing.Optional[str] = OMIT,
        project_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Update provider configuration (enable/disable, update credentials).

        User must be an Admin or Owner of the organization.

        Parameters
        ----------
        organization_id : str

        provider_name : str

        is_active : typing.Optional[bool]
            Enable/disable provider

        api_key : typing.Optional[str]
            Provider API key (BYOK)

        org_id : typing.Optional[str]
            Provider organization ID

        project_id : typing.Optional[str]
            Provider project ID

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.update_provider(
                organization_id="organization_id",
                provider_name="provider_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_provider(
            organization_id,
            provider_name,
            is_active=is_active,
            api_key=api_key,
            org_id=org_id,
            project_id=project_id,
            request_options=request_options,
        )
        return _response.data

    async def list_roles(
        self,
        organization_id: str,
        *,
        include_global: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[RoleResponse]:
        """
        List all roles available for the organization.

        Parameters
        ----------
        organization_id : str

        include_global : typing.Optional[bool]
            Include global roles

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[RoleResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.list_roles(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_roles(
            organization_id, include_global=include_global, request_options=request_options
        )
        return _response.data

    async def list_statuses(
        self,
        organization_id: str,
        *,
        active_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[StatusResponse]:
        """
        List all user statuses for the organization.

        Parameters
        ----------
        organization_id : str

        active_only : typing.Optional[bool]
            Only return active statuses

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[StatusResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.list_statuses(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_statuses(
            organization_id, active_only=active_only, request_options=request_options
        )
        return _response.data

    async def get_model_settings(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationModelSettingsResponse:
        """
        Get the model availability settings for an organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationModelSettingsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.get_model_settings(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_model_settings(organization_id, request_options=request_options)
        return _response.data

    async def update_model_settings(
        self,
        organization_id: str,
        *,
        disabled_providers: typing.Optional[typing.Sequence[str]] = OMIT,
        disabled_models: typing.Optional[typing.Sequence[str]] = OMIT,
        default_model_key: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationModelSettingsResponse:
        """
        Update which AI models/providers are available in the organization.

        Parameters
        ----------
        organization_id : str

        disabled_providers : typing.Optional[typing.Sequence[str]]
            List of provider slugs to disable (e.g., ['google', 'mistral'])

        disabled_models : typing.Optional[typing.Sequence[str]]
            List of model keys to disable (e.g., ['gpt-4o-mini'])

        default_model_key : typing.Optional[str]
            Default model key for the organization

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationModelSettingsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.update_model_settings(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_model_settings(
            organization_id,
            disabled_providers=disabled_providers,
            disabled_models=disabled_models,
            default_model_key=default_model_key,
            request_options=request_options,
        )
        return _response.data

    async def get_permission_preset(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PermissionPresetResponse:
        """
        Get the current permission preset and available options.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PermissionPresetResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.get_permission_preset(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_permission_preset(organization_id, request_options=request_options)
        return _response.data

    async def change_permission_preset(
        self, organization_id: str, *, preset: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ChangePresetResponse:
        """
        Change the permission preset and retroactively update Member role capabilities.

        Parameters
        ----------
        organization_id : str

        preset : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ChangePresetResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.change_permission_preset(
                organization_id="organization_id",
                preset="preset",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.change_permission_preset(
            organization_id, preset=preset, request_options=request_options
        )
        return _response.data

    async def list_domains(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[OrganizationDomainResponse]:
        """
        List all active email domains configured for the organization.

        Parameters
        ----------
        organization_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[OrganizationDomainResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.list_domains(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_domains(organization_id, request_options=request_options)
        return _response.data

    async def add_domain(
        self, organization_id: str, *, domain: str, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationDomainResponse:
        """
        Add an email domain; users with a matching address will get automatic access.

        Parameters
        ----------
        organization_id : str

        domain : str
            Email domain (e.g., 'company.com')

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationDomainResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.add_domain(
                organization_id="organization_id",
                domain="domain",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.add_domain(organization_id, domain=domain, request_options=request_options)
        return _response.data

    async def remove_domain(
        self, organization_id: str, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Remove an email domain; new users with that address will no longer get automatic access.

        Parameters
        ----------
        organization_id : str

        domain_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.organizations.remove_domain(
                organization_id="organization_id",
                domain_id="domain_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.remove_domain(organization_id, domain_id, request_options=request_options)
        return _response.data
