# 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.access_grant_list_response import AccessGrantListResponse
from ..types.access_grant_response import AccessGrantResponse
from ..types.access_overview_response import AccessOverviewResponse
from ..types.bulk_grant_entry import BulkGrantEntry
from ..types.resolved_access_response import ResolvedAccessResponse
from ..types.users_with_access_response import UsersWithAccessResponse
from .raw_client import AsyncRawAccessControlClient, RawAccessControlClient

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


class AccessControlClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAccessControlClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAccessControlClient
        """
        return self._raw_client

    def list_grants(
        self,
        organization_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        entity_id: typing.Optional[str] = None,
        grantee_type: typing.Optional[str] = None,
        grantee_id: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists access grants for an organization with optional filters by entity and grantee. Includes both real grant records and synthesized grants from legacy access modes. Supports pagination and returns enriched grantee names.

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

        entity_type : typing.Optional[str]
            Filter by entity type (e.g. 'knowledge_slice', 'vector_store', 'assistant')

        entity_id : typing.Optional[str]
            Filter by specific entity ID

        grantee_type : typing.Optional[str]
            Filter by grantee type (user, department, role, organization)

        grantee_id : typing.Optional[str]
            Filter by specific grantee ID

        skip : typing.Optional[int]
            Number of results to skip for pagination

        limit : typing.Optional[int]
            Maximum number of results to return

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

        Returns
        -------
        AccessGrantListResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.list_grants(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_grants(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            grantee_type=grantee_type,
            grantee_id=grantee_id,
            skip=skip,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    def create_grant(
        self,
        organization_id: str,
        *,
        entity_type: str,
        entity_id: str,
        grantee_type: str,
        grantee_id: str,
        access_level: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantResponse:
        """
        Creates a new access grant that gives a user, department, role, or organization access to an entity. The grant specifies the entity type, entity ID, grantee, and access level. Requires the MANAGE_ACCESS_CONTROL capability.

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

        entity_type : str
            Type of entity to grant access to: 'knowledge_slice', 'vector_store', or 'assistant'

        entity_id : str
            ID of the entity to grant access to

        grantee_type : str
            Type of grantee receiving access: 'user', 'department', or 'role'

        grantee_id : str
            ID of the grantee receiving access

        access_level : str
            Access level to grant: 'read', 'write', or 'admin'

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

        Returns
        -------
        AccessGrantResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.create_grant(
            organization_id="organization_id",
            entity_type="entity_type",
            entity_id="entity_id",
            grantee_type="grantee_type",
            grantee_id="grantee_id",
            access_level="access_level",
        )
        """
        _response = self._raw_client.create_grant(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            grantee_type=grantee_type,
            grantee_id=grantee_id,
            access_level=access_level,
            request_options=request_options,
        )
        return _response.data

    def get_access_overview(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AccessOverviewResponse:
        """
        Returns a role-scoped access overview for the Access Overview page. Admins see all slices, stores, and grants. Regular users see only entities they can access. Includes slice-store mappings and composite member relationships.

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

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

        Returns
        -------
        AccessOverviewResponse
            Successful Response

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

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

    def list_slice_grants(
        self,
        organization_id: str,
        slice_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists all access grants for a specific knowledge slice, including both real grant records and synthesized grants from legacy access modes on the slice's stores. Requires access to the slice.

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

        slice_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AccessGrantListResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.list_slice_grants(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.list_slice_grants(
            organization_id, slice_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    def list_store_grants(
        self,
        organization_id: str,
        store_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists all access grants for a specific vector store, including both real grant records and synthesized grants from legacy access modes. Requires access to the store.

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

        store_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AccessGrantListResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.list_store_grants(
            organization_id="organization_id",
            store_id="store_id",
        )
        """
        _response = self._raw_client.list_store_grants(
            organization_id, store_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    def list_assistant_grants(
        self,
        organization_id: str,
        assistant_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists all access grants for a specific assistant. Returns paginated results with enriched grantee names. Requires organization membership.

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

        assistant_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AccessGrantListResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.list_assistant_grants(
            organization_id="organization_id",
            assistant_id="assistant_id",
        )
        """
        _response = self._raw_client.list_assistant_grants(
            organization_id, assistant_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    def get_resolved_access(
        self,
        organization_id: str,
        user_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResolvedAccessResponse:
        """
        Computes the effective access for a user across all entity types by resolving direct grants, department grants, role grants, and composite inheritance. Returns separate lists for slice and store access with grant path details.

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

        user_id : str

        entity_type : typing.Optional[str]

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

        Returns
        -------
        ResolvedAccessResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.get_resolved_access(
            organization_id="organization_id",
            user_id="user_id",
        )
        """
        _response = self._raw_client.get_resolved_access(
            organization_id, user_id, entity_type=entity_type, request_options=request_options
        )
        return _response.data

    def get_users_with_access(
        self,
        organization_id: str,
        *,
        entity_type: str,
        entity_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersWithAccessResponse:
        """
        Returns all users who have access to a specific entity, including direct grants, department-inherited grants, and role-inherited grants. Requires the MANAGE_ACCESS_CONTROL capability.

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

        entity_type : str
            Entity type to check access for

        entity_id : str
            Entity ID to check access for

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

        Returns
        -------
        UsersWithAccessResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.get_users_with_access(
            organization_id="organization_id",
            entity_type="entity_type",
            entity_id="entity_id",
        )
        """
        _response = self._raw_client.get_users_with_access(
            organization_id, entity_type=entity_type, entity_id=entity_id, request_options=request_options
        )
        return _response.data

    def bulk_create_grants(
        self,
        organization_id: str,
        *,
        entity_type: str,
        entity_id: str,
        grants: typing.Sequence[BulkGrantEntry],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AccessGrantResponse]:
        """
        Creates multiple access grants for the same entity in a single request. All grants share the same entity type and entity ID but can have different grantees and access levels. Requires the MANAGE_ACCESS_CONTROL capability.

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

        entity_type : str
            Type of entity to grant access to: 'knowledge_slice', 'vector_store', or 'assistant'

        entity_id : str
            ID of the entity to grant access to

        grants : typing.Sequence[BulkGrantEntry]
            List of access grants to create in bulk

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

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

        Examples
        --------
        from aitronos import Aitronos, BulkGrantEntry

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.bulk_create_grants(
            organization_id="organization_id",
            entity_type="entity_type",
            entity_id="entity_id",
            grants=[
                BulkGrantEntry(
                    grantee_type="grantee_type",
                    grantee_id="grantee_id",
                    access_level="access_level",
                )
            ],
        )
        """
        _response = self._raw_client.bulk_create_grants(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            grants=grants,
            request_options=request_options,
        )
        return _response.data

    def revoke_grant(
        self, organization_id: str, grant_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft-deletes an access grant, removing the grantee's access to the entity. The grant record is preserved for audit purposes but no longer enforced. Requires the MANAGE_ACCESS_CONTROL capability.

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

        grant_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.access_control.revoke_grant(
            organization_id="organization_id",
            grant_id="grant_id",
        )
        """
        _response = self._raw_client.revoke_grant(organization_id, grant_id, request_options=request_options)
        return _response.data

    def update_grant(
        self,
        organization_id: str,
        grant_id: str,
        *,
        access_level: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantResponse:
        """
        Updates the access level of an existing access grant. Only the access level can be changed; to change the grantee or entity, revoke and re-create. Requires the MANAGE_ACCESS_CONTROL capability.

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

        grant_id : str

        access_level : str
            Updated access level: 'read', 'write', or 'admin'

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

        Returns
        -------
        AccessGrantResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.access_control.update_grant(
            organization_id="organization_id",
            grant_id="grant_id",
            access_level="access_level",
        )
        """
        _response = self._raw_client.update_grant(
            organization_id, grant_id, access_level=access_level, request_options=request_options
        )
        return _response.data


class AsyncAccessControlClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAccessControlClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAccessControlClient
        """
        return self._raw_client

    async def list_grants(
        self,
        organization_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        entity_id: typing.Optional[str] = None,
        grantee_type: typing.Optional[str] = None,
        grantee_id: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists access grants for an organization with optional filters by entity and grantee. Includes both real grant records and synthesized grants from legacy access modes. Supports pagination and returns enriched grantee names.

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

        entity_type : typing.Optional[str]
            Filter by entity type (e.g. 'knowledge_slice', 'vector_store', 'assistant')

        entity_id : typing.Optional[str]
            Filter by specific entity ID

        grantee_type : typing.Optional[str]
            Filter by grantee type (user, department, role, organization)

        grantee_id : typing.Optional[str]
            Filter by specific grantee ID

        skip : typing.Optional[int]
            Number of results to skip for pagination

        limit : typing.Optional[int]
            Maximum number of results to return

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

        Returns
        -------
        AccessGrantListResponse
            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.access_control.list_grants(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_grants(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            grantee_type=grantee_type,
            grantee_id=grantee_id,
            skip=skip,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    async def create_grant(
        self,
        organization_id: str,
        *,
        entity_type: str,
        entity_id: str,
        grantee_type: str,
        grantee_id: str,
        access_level: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantResponse:
        """
        Creates a new access grant that gives a user, department, role, or organization access to an entity. The grant specifies the entity type, entity ID, grantee, and access level. Requires the MANAGE_ACCESS_CONTROL capability.

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

        entity_type : str
            Type of entity to grant access to: 'knowledge_slice', 'vector_store', or 'assistant'

        entity_id : str
            ID of the entity to grant access to

        grantee_type : str
            Type of grantee receiving access: 'user', 'department', or 'role'

        grantee_id : str
            ID of the grantee receiving access

        access_level : str
            Access level to grant: 'read', 'write', or 'admin'

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

        Returns
        -------
        AccessGrantResponse
            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.access_control.create_grant(
                organization_id="organization_id",
                entity_type="entity_type",
                entity_id="entity_id",
                grantee_type="grantee_type",
                grantee_id="grantee_id",
                access_level="access_level",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_grant(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            grantee_type=grantee_type,
            grantee_id=grantee_id,
            access_level=access_level,
            request_options=request_options,
        )
        return _response.data

    async def get_access_overview(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AccessOverviewResponse:
        """
        Returns a role-scoped access overview for the Access Overview page. Admins see all slices, stores, and grants. Regular users see only entities they can access. Includes slice-store mappings and composite member relationships.

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

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

        Returns
        -------
        AccessOverviewResponse
            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.access_control.get_access_overview(
                organization_id="organization_id",
            )


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

    async def list_slice_grants(
        self,
        organization_id: str,
        slice_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists all access grants for a specific knowledge slice, including both real grant records and synthesized grants from legacy access modes on the slice's stores. Requires access to the slice.

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

        slice_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AccessGrantListResponse
            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.access_control.list_slice_grants(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_slice_grants(
            organization_id, slice_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    async def list_store_grants(
        self,
        organization_id: str,
        store_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists all access grants for a specific vector store, including both real grant records and synthesized grants from legacy access modes. Requires access to the store.

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

        store_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AccessGrantListResponse
            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.access_control.list_store_grants(
                organization_id="organization_id",
                store_id="store_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_store_grants(
            organization_id, store_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    async def list_assistant_grants(
        self,
        organization_id: str,
        assistant_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantListResponse:
        """
        Lists all access grants for a specific assistant. Returns paginated results with enriched grantee names. Requires organization membership.

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

        assistant_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AccessGrantListResponse
            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.access_control.list_assistant_grants(
                organization_id="organization_id",
                assistant_id="assistant_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_assistant_grants(
            organization_id, assistant_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    async def get_resolved_access(
        self,
        organization_id: str,
        user_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResolvedAccessResponse:
        """
        Computes the effective access for a user across all entity types by resolving direct grants, department grants, role grants, and composite inheritance. Returns separate lists for slice and store access with grant path details.

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

        user_id : str

        entity_type : typing.Optional[str]

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

        Returns
        -------
        ResolvedAccessResponse
            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.access_control.get_resolved_access(
                organization_id="organization_id",
                user_id="user_id",
            )


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

    async def get_users_with_access(
        self,
        organization_id: str,
        *,
        entity_type: str,
        entity_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersWithAccessResponse:
        """
        Returns all users who have access to a specific entity, including direct grants, department-inherited grants, and role-inherited grants. Requires the MANAGE_ACCESS_CONTROL capability.

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

        entity_type : str
            Entity type to check access for

        entity_id : str
            Entity ID to check access for

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

        Returns
        -------
        UsersWithAccessResponse
            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.access_control.get_users_with_access(
                organization_id="organization_id",
                entity_type="entity_type",
                entity_id="entity_id",
            )


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

    async def bulk_create_grants(
        self,
        organization_id: str,
        *,
        entity_type: str,
        entity_id: str,
        grants: typing.Sequence[BulkGrantEntry],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AccessGrantResponse]:
        """
        Creates multiple access grants for the same entity in a single request. All grants share the same entity type and entity ID but can have different grantees and access levels. Requires the MANAGE_ACCESS_CONTROL capability.

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

        entity_type : str
            Type of entity to grant access to: 'knowledge_slice', 'vector_store', or 'assistant'

        entity_id : str
            ID of the entity to grant access to

        grants : typing.Sequence[BulkGrantEntry]
            List of access grants to create in bulk

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

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

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos, BulkGrantEntry

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


        async def main() -> None:
            await client.access_control.bulk_create_grants(
                organization_id="organization_id",
                entity_type="entity_type",
                entity_id="entity_id",
                grants=[
                    BulkGrantEntry(
                        grantee_type="grantee_type",
                        grantee_id="grantee_id",
                        access_level="access_level",
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.bulk_create_grants(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            grants=grants,
            request_options=request_options,
        )
        return _response.data

    async def revoke_grant(
        self, organization_id: str, grant_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft-deletes an access grant, removing the grantee's access to the entity. The grant record is preserved for audit purposes but no longer enforced. Requires the MANAGE_ACCESS_CONTROL capability.

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

        grant_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.access_control.revoke_grant(
                organization_id="organization_id",
                grant_id="grant_id",
            )


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

    async def update_grant(
        self,
        organization_id: str,
        grant_id: str,
        *,
        access_level: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccessGrantResponse:
        """
        Updates the access level of an existing access grant. Only the access level can be changed; to change the grantee or entity, revoke and re-create. Requires the MANAGE_ACCESS_CONTROL capability.

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

        grant_id : str

        access_level : str
            Updated access level: 'read', 'write', or 'admin'

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

        Returns
        -------
        AccessGrantResponse
            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.access_control.update_grant(
                organization_id="organization_id",
                grant_id="grant_id",
                access_level="access_level",
            )


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