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

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.auto_join_rule_list_response import AutoJoinRuleListResponse
from ..types.auto_join_rule_response import AutoJoinRuleResponse
from ..types.join_all_toggle_response import JoinAllToggleResponse

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


class RawMeetingBuddyAutoJoinClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def get_join_all_status(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[JoinAllToggleResponse]:
        """
        Check whether auto-join-all is enabled for the authenticated user.

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

        Returns
        -------
        HttpResponse[JoinAllToggleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/join-all",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    JoinAllToggleResponse,
                    parse_obj_as(
                        type_=JoinAllToggleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def toggle_join_all_meetings(
        self,
        *,
        enabled: bool,
        bot_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[JoinAllToggleResponse]:
        """
        Enable or disable auto-joining every meeting with a meeting link.

        When enabled, creates a catch-all rule that matches all calendar events.
        When disabled, disables (but preserves) the catch-all rule.
        Other custom rules (never-join, keyword, organizer) still take precedence
        via priority ordering.

        Parameters
        ----------
        enabled : bool
            Whether to automatically join all meetings

        bot_name : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[JoinAllToggleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/join-all",
            method="POST",
            json={
                "enabled": enabled,
                "bot_name": bot_name,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    JoinAllToggleResponse,
                    parse_obj_as(
                        type_=JoinAllToggleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def list_auto_join_rules(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[AutoJoinRuleListResponse]:
        """
        List all auto-join rules for the authenticated user.

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

        Returns
        -------
        HttpResponse[AutoJoinRuleListResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/rules",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleListResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleListResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_auto_join_rule(
        self,
        *,
        name: str,
        calendar_provider: typing.Optional[str] = OMIT,
        match_mode: typing.Optional[str] = OMIT,
        keywords: typing.Optional[typing.Sequence[str]] = OMIT,
        organizer_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        exclude_patterns: typing.Optional[typing.Sequence[str]] = OMIT,
        min_attendees: typing.Optional[int] = OMIT,
        max_attendees: typing.Optional[int] = OMIT,
        time_window_start: typing.Optional[str] = OMIT,
        time_window_end: typing.Optional[str] = OMIT,
        days_of_week: typing.Optional[typing.Sequence[int]] = OMIT,
        timezone: typing.Optional[str] = OMIT,
        bot_name: typing.Optional[str] = OMIT,
        priority: typing.Optional[int] = OMIT,
        destination_vector_store_id: typing.Optional[str] = OMIT,
        auto_add_to_vector_store: typing.Optional[bool] = OMIT,
        participation_mode: typing.Optional[str] = OMIT,
        voice_profile_id: typing.Optional[str] = OMIT,
        auto_share_mode: typing.Optional[str] = OMIT,
        auto_share_department_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        attendee_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        assistant_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[AutoJoinRuleResponse]:
        """
        Create a new auto-join rule.

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

        calendar_provider : typing.Optional[str]

        match_mode : typing.Optional[str]

        keywords : typing.Optional[typing.Sequence[str]]

        organizer_emails : typing.Optional[typing.Sequence[str]]

        exclude_patterns : typing.Optional[typing.Sequence[str]]

        min_attendees : typing.Optional[int]

        max_attendees : typing.Optional[int]

        time_window_start : typing.Optional[str]

        time_window_end : typing.Optional[str]

        days_of_week : typing.Optional[typing.Sequence[int]]

        timezone : typing.Optional[str]

        bot_name : typing.Optional[str]

        priority : typing.Optional[int]

        destination_vector_store_id : typing.Optional[str]
            Vector store to auto-route meeting data to

        auto_add_to_vector_store : typing.Optional[bool]
            Automatically add meeting data to vector store on completion

        participation_mode : typing.Optional[str]
            'listener' or 'participant'. Overrides org default for sessions triggered by this rule.

        voice_profile_id : typing.Optional[str]
            Voice profile ID to use when participation_mode='participant'

        auto_share_mode : typing.Optional[str]
            Default visibility for sessions created by this rule: private, participants, department, organization

        auto_share_department_ids : typing.Optional[typing.Sequence[str]]
            Department IDs for department-level sharing on auto-created sessions

        attendee_emails : typing.Optional[typing.Sequence[str]]
            Trigger this rule when any of these emails are event attendees

        assistant_id : typing.Optional[str]
            Use this assistant's identity (name, voice, instructions) for sessions created by this rule

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

        Returns
        -------
        HttpResponse[AutoJoinRuleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/rules",
            method="POST",
            json={
                "name": name,
                "calendar_provider": calendar_provider,
                "match_mode": match_mode,
                "keywords": keywords,
                "organizer_emails": organizer_emails,
                "exclude_patterns": exclude_patterns,
                "min_attendees": min_attendees,
                "max_attendees": max_attendees,
                "time_window_start": time_window_start,
                "time_window_end": time_window_end,
                "days_of_week": days_of_week,
                "timezone": timezone,
                "bot_name": bot_name,
                "priority": priority,
                "destination_vector_store_id": destination_vector_store_id,
                "auto_add_to_vector_store": auto_add_to_vector_store,
                "participation_mode": participation_mode,
                "voice_profile_id": voice_profile_id,
                "auto_share_mode": auto_share_mode,
                "auto_share_department_ids": auto_share_department_ids,
                "attendee_emails": attendee_emails,
                "assistant_id": assistant_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete_auto_join_rule(
        self, rule_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[None]:
        """
        Delete an auto-join rule.

        Parameters
        ----------
        rule_id : str

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

        Returns
        -------
        HttpResponse[None]
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/auto-join/rules/{jsonable_encoder(rule_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return HttpResponse(response=_response, data=None)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def update_auto_join_rule(
        self,
        rule_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        is_enabled: typing.Optional[bool] = OMIT,
        calendar_provider: typing.Optional[str] = OMIT,
        match_mode: typing.Optional[str] = OMIT,
        keywords: typing.Optional[typing.Sequence[str]] = OMIT,
        organizer_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        exclude_patterns: typing.Optional[typing.Sequence[str]] = OMIT,
        min_attendees: typing.Optional[int] = OMIT,
        max_attendees: typing.Optional[int] = OMIT,
        time_window_start: typing.Optional[str] = OMIT,
        time_window_end: typing.Optional[str] = OMIT,
        days_of_week: typing.Optional[typing.Sequence[int]] = OMIT,
        timezone: typing.Optional[str] = OMIT,
        bot_name: typing.Optional[str] = OMIT,
        priority: typing.Optional[int] = OMIT,
        destination_vector_store_id: typing.Optional[str] = OMIT,
        auto_add_to_vector_store: typing.Optional[bool] = OMIT,
        participation_mode: typing.Optional[str] = OMIT,
        voice_profile_id: typing.Optional[str] = OMIT,
        auto_share_mode: typing.Optional[str] = OMIT,
        auto_share_department_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        attendee_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        assistant_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[AutoJoinRuleResponse]:
        """
        Update an existing auto-join rule.

        Parameters
        ----------
        rule_id : str

        name : typing.Optional[str]

        is_enabled : typing.Optional[bool]

        calendar_provider : typing.Optional[str]

        match_mode : typing.Optional[str]

        keywords : typing.Optional[typing.Sequence[str]]

        organizer_emails : typing.Optional[typing.Sequence[str]]

        exclude_patterns : typing.Optional[typing.Sequence[str]]

        min_attendees : typing.Optional[int]

        max_attendees : typing.Optional[int]

        time_window_start : typing.Optional[str]

        time_window_end : typing.Optional[str]

        days_of_week : typing.Optional[typing.Sequence[int]]

        timezone : typing.Optional[str]

        bot_name : typing.Optional[str]

        priority : typing.Optional[int]

        destination_vector_store_id : typing.Optional[str]

        auto_add_to_vector_store : typing.Optional[bool]

        participation_mode : typing.Optional[str]
            'listener' or 'participant'. Overrides org default for sessions triggered by this rule.

        voice_profile_id : typing.Optional[str]
            Voice profile ID to use when participation_mode='participant'

        auto_share_mode : typing.Optional[str]
            Default visibility for sessions created by this rule

        auto_share_department_ids : typing.Optional[typing.Sequence[str]]

        attendee_emails : typing.Optional[typing.Sequence[str]]

        assistant_id : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[AutoJoinRuleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/auto-join/rules/{jsonable_encoder(rule_id)}",
            method="PATCH",
            json={
                "name": name,
                "is_enabled": is_enabled,
                "calendar_provider": calendar_provider,
                "match_mode": match_mode,
                "keywords": keywords,
                "organizer_emails": organizer_emails,
                "exclude_patterns": exclude_patterns,
                "min_attendees": min_attendees,
                "max_attendees": max_attendees,
                "time_window_start": time_window_start,
                "time_window_end": time_window_end,
                "days_of_week": days_of_week,
                "timezone": timezone,
                "bot_name": bot_name,
                "priority": priority,
                "destination_vector_store_id": destination_vector_store_id,
                "auto_add_to_vector_store": auto_add_to_vector_store,
                "participation_mode": participation_mode,
                "voice_profile_id": voice_profile_id,
                "auto_share_mode": auto_share_mode,
                "auto_share_department_ids": auto_share_department_ids,
                "attendee_emails": attendee_emails,
                "assistant_id": assistant_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_auto_join_rule_from_event(
        self,
        *,
        event_id: str,
        action: str,
        match_by: typing.Optional[str] = OMIT,
        bot_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[AutoJoinRuleResponse]:
        """
        Create an auto-join rule based on a calendar event's properties.

        Use action='always_join' to always join similar meetings,
        or action='never_join' to never join similar meetings.

        Parameters
        ----------
        event_id : str
            Calendar event to base the rule on

        action : str
            Whether to always or never join meetings like this

        match_by : typing.Optional[str]
            Match by organizer email or title keywords

        bot_name : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[AutoJoinRuleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/rules/from-event",
            method="POST",
            json={
                "event_id": event_id,
                "action": action,
                "match_by": match_by,
                "bot_name": bot_name,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawMeetingBuddyAutoJoinClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def get_join_all_status(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[JoinAllToggleResponse]:
        """
        Check whether auto-join-all is enabled for the authenticated user.

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

        Returns
        -------
        AsyncHttpResponse[JoinAllToggleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/join-all",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    JoinAllToggleResponse,
                    parse_obj_as(
                        type_=JoinAllToggleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def toggle_join_all_meetings(
        self,
        *,
        enabled: bool,
        bot_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[JoinAllToggleResponse]:
        """
        Enable or disable auto-joining every meeting with a meeting link.

        When enabled, creates a catch-all rule that matches all calendar events.
        When disabled, disables (but preserves) the catch-all rule.
        Other custom rules (never-join, keyword, organizer) still take precedence
        via priority ordering.

        Parameters
        ----------
        enabled : bool
            Whether to automatically join all meetings

        bot_name : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[JoinAllToggleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/join-all",
            method="POST",
            json={
                "enabled": enabled,
                "bot_name": bot_name,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    JoinAllToggleResponse,
                    parse_obj_as(
                        type_=JoinAllToggleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def list_auto_join_rules(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[AutoJoinRuleListResponse]:
        """
        List all auto-join rules for the authenticated user.

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

        Returns
        -------
        AsyncHttpResponse[AutoJoinRuleListResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/rules",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleListResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleListResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create_auto_join_rule(
        self,
        *,
        name: str,
        calendar_provider: typing.Optional[str] = OMIT,
        match_mode: typing.Optional[str] = OMIT,
        keywords: typing.Optional[typing.Sequence[str]] = OMIT,
        organizer_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        exclude_patterns: typing.Optional[typing.Sequence[str]] = OMIT,
        min_attendees: typing.Optional[int] = OMIT,
        max_attendees: typing.Optional[int] = OMIT,
        time_window_start: typing.Optional[str] = OMIT,
        time_window_end: typing.Optional[str] = OMIT,
        days_of_week: typing.Optional[typing.Sequence[int]] = OMIT,
        timezone: typing.Optional[str] = OMIT,
        bot_name: typing.Optional[str] = OMIT,
        priority: typing.Optional[int] = OMIT,
        destination_vector_store_id: typing.Optional[str] = OMIT,
        auto_add_to_vector_store: typing.Optional[bool] = OMIT,
        participation_mode: typing.Optional[str] = OMIT,
        voice_profile_id: typing.Optional[str] = OMIT,
        auto_share_mode: typing.Optional[str] = OMIT,
        auto_share_department_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        attendee_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        assistant_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[AutoJoinRuleResponse]:
        """
        Create a new auto-join rule.

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

        calendar_provider : typing.Optional[str]

        match_mode : typing.Optional[str]

        keywords : typing.Optional[typing.Sequence[str]]

        organizer_emails : typing.Optional[typing.Sequence[str]]

        exclude_patterns : typing.Optional[typing.Sequence[str]]

        min_attendees : typing.Optional[int]

        max_attendees : typing.Optional[int]

        time_window_start : typing.Optional[str]

        time_window_end : typing.Optional[str]

        days_of_week : typing.Optional[typing.Sequence[int]]

        timezone : typing.Optional[str]

        bot_name : typing.Optional[str]

        priority : typing.Optional[int]

        destination_vector_store_id : typing.Optional[str]
            Vector store to auto-route meeting data to

        auto_add_to_vector_store : typing.Optional[bool]
            Automatically add meeting data to vector store on completion

        participation_mode : typing.Optional[str]
            'listener' or 'participant'. Overrides org default for sessions triggered by this rule.

        voice_profile_id : typing.Optional[str]
            Voice profile ID to use when participation_mode='participant'

        auto_share_mode : typing.Optional[str]
            Default visibility for sessions created by this rule: private, participants, department, organization

        auto_share_department_ids : typing.Optional[typing.Sequence[str]]
            Department IDs for department-level sharing on auto-created sessions

        attendee_emails : typing.Optional[typing.Sequence[str]]
            Trigger this rule when any of these emails are event attendees

        assistant_id : typing.Optional[str]
            Use this assistant's identity (name, voice, instructions) for sessions created by this rule

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

        Returns
        -------
        AsyncHttpResponse[AutoJoinRuleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/rules",
            method="POST",
            json={
                "name": name,
                "calendar_provider": calendar_provider,
                "match_mode": match_mode,
                "keywords": keywords,
                "organizer_emails": organizer_emails,
                "exclude_patterns": exclude_patterns,
                "min_attendees": min_attendees,
                "max_attendees": max_attendees,
                "time_window_start": time_window_start,
                "time_window_end": time_window_end,
                "days_of_week": days_of_week,
                "timezone": timezone,
                "bot_name": bot_name,
                "priority": priority,
                "destination_vector_store_id": destination_vector_store_id,
                "auto_add_to_vector_store": auto_add_to_vector_store,
                "participation_mode": participation_mode,
                "voice_profile_id": voice_profile_id,
                "auto_share_mode": auto_share_mode,
                "auto_share_department_ids": auto_share_department_ids,
                "attendee_emails": attendee_emails,
                "assistant_id": assistant_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete_auto_join_rule(
        self, rule_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[None]:
        """
        Delete an auto-join rule.

        Parameters
        ----------
        rule_id : str

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

        Returns
        -------
        AsyncHttpResponse[None]
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/auto-join/rules/{jsonable_encoder(rule_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return AsyncHttpResponse(response=_response, data=None)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def update_auto_join_rule(
        self,
        rule_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        is_enabled: typing.Optional[bool] = OMIT,
        calendar_provider: typing.Optional[str] = OMIT,
        match_mode: typing.Optional[str] = OMIT,
        keywords: typing.Optional[typing.Sequence[str]] = OMIT,
        organizer_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        exclude_patterns: typing.Optional[typing.Sequence[str]] = OMIT,
        min_attendees: typing.Optional[int] = OMIT,
        max_attendees: typing.Optional[int] = OMIT,
        time_window_start: typing.Optional[str] = OMIT,
        time_window_end: typing.Optional[str] = OMIT,
        days_of_week: typing.Optional[typing.Sequence[int]] = OMIT,
        timezone: typing.Optional[str] = OMIT,
        bot_name: typing.Optional[str] = OMIT,
        priority: typing.Optional[int] = OMIT,
        destination_vector_store_id: typing.Optional[str] = OMIT,
        auto_add_to_vector_store: typing.Optional[bool] = OMIT,
        participation_mode: typing.Optional[str] = OMIT,
        voice_profile_id: typing.Optional[str] = OMIT,
        auto_share_mode: typing.Optional[str] = OMIT,
        auto_share_department_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        attendee_emails: typing.Optional[typing.Sequence[str]] = OMIT,
        assistant_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[AutoJoinRuleResponse]:
        """
        Update an existing auto-join rule.

        Parameters
        ----------
        rule_id : str

        name : typing.Optional[str]

        is_enabled : typing.Optional[bool]

        calendar_provider : typing.Optional[str]

        match_mode : typing.Optional[str]

        keywords : typing.Optional[typing.Sequence[str]]

        organizer_emails : typing.Optional[typing.Sequence[str]]

        exclude_patterns : typing.Optional[typing.Sequence[str]]

        min_attendees : typing.Optional[int]

        max_attendees : typing.Optional[int]

        time_window_start : typing.Optional[str]

        time_window_end : typing.Optional[str]

        days_of_week : typing.Optional[typing.Sequence[int]]

        timezone : typing.Optional[str]

        bot_name : typing.Optional[str]

        priority : typing.Optional[int]

        destination_vector_store_id : typing.Optional[str]

        auto_add_to_vector_store : typing.Optional[bool]

        participation_mode : typing.Optional[str]
            'listener' or 'participant'. Overrides org default for sessions triggered by this rule.

        voice_profile_id : typing.Optional[str]
            Voice profile ID to use when participation_mode='participant'

        auto_share_mode : typing.Optional[str]
            Default visibility for sessions created by this rule

        auto_share_department_ids : typing.Optional[typing.Sequence[str]]

        attendee_emails : typing.Optional[typing.Sequence[str]]

        assistant_id : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[AutoJoinRuleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/auto-join/rules/{jsonable_encoder(rule_id)}",
            method="PATCH",
            json={
                "name": name,
                "is_enabled": is_enabled,
                "calendar_provider": calendar_provider,
                "match_mode": match_mode,
                "keywords": keywords,
                "organizer_emails": organizer_emails,
                "exclude_patterns": exclude_patterns,
                "min_attendees": min_attendees,
                "max_attendees": max_attendees,
                "time_window_start": time_window_start,
                "time_window_end": time_window_end,
                "days_of_week": days_of_week,
                "timezone": timezone,
                "bot_name": bot_name,
                "priority": priority,
                "destination_vector_store_id": destination_vector_store_id,
                "auto_add_to_vector_store": auto_add_to_vector_store,
                "participation_mode": participation_mode,
                "voice_profile_id": voice_profile_id,
                "auto_share_mode": auto_share_mode,
                "auto_share_department_ids": auto_share_department_ids,
                "attendee_emails": attendee_emails,
                "assistant_id": assistant_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create_auto_join_rule_from_event(
        self,
        *,
        event_id: str,
        action: str,
        match_by: typing.Optional[str] = OMIT,
        bot_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[AutoJoinRuleResponse]:
        """
        Create an auto-join rule based on a calendar event's properties.

        Use action='always_join' to always join similar meetings,
        or action='never_join' to never join similar meetings.

        Parameters
        ----------
        event_id : str
            Calendar event to base the rule on

        action : str
            Whether to always or never join meetings like this

        match_by : typing.Optional[str]
            Match by organizer email or title keywords

        bot_name : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[AutoJoinRuleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/meeting-buddy/auto-join/rules/from-event",
            method="POST",
            json={
                "event_id": event_id,
                "action": action,
                "match_by": match_by,
                "bot_name": bot_name,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AutoJoinRuleResponse,
                    parse_obj_as(
                        type_=AutoJoinRuleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
