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

import typing
import urllib.parse
from json.decoder import JSONDecodeError

from ...core.api_error import ApiError
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.jsonable_encoder import jsonable_encoder
from ...core.pydantic_utilities import pydantic_v1
from ...core.query_encoder import encode_query
from ...core.remove_none_from_dict import remove_none_from_dict
from ...core.request_options import RequestOptions
from ...types.create_scim_directory_response import CreateScimDirectoryResponse
from ...types.get_scim_directory_response import GetScimDirectoryResponse
from ...types.list_scim_directories_response import ListScimDirectoriesResponse
from ...types.rotate_scim_directory_bearer_token_response import RotateScimDirectoryBearerTokenResponse
from ...types.update_scim_directory_response import UpdateScimDirectoryResponse

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


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

    def list_scim_directories(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        page_token: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListScimDirectoriesResponse:
        """
        Parameters
        ----------
        organization_id : typing.Optional[str]

        page_token : typing.Optional[str]

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

        Returns
        -------
        ListScimDirectoriesResponse
            OK

        Examples
        --------
        from ssoready.client import SSOReady

        client = SSOReady(
            api_key="YOUR_API_KEY",
        )
        client.management.scim_directories.list_scim_directories()
        """
        _response = self._client_wrapper.httpx_client.request(
            method="GET",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/scim-directories"),
            params=encode_query(
                jsonable_encoder(
                    remove_none_from_dict(
                        {
                            "organizationId": organization_id,
                            "pageToken": page_token,
                            **(
                                request_options.get("additional_query_parameters", {})
                                if request_options is not None
                                else {}
                            ),
                        }
                    )
                )
            ),
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ListScimDirectoriesResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def create_scim_directory(
        self,
        *,
        id: typing.Optional[str] = OMIT,
        organization_id: typing.Optional[str] = OMIT,
        primary: typing.Optional[bool] = OMIT,
        scim_base_url: typing.Optional[str] = OMIT,
        client_bearer_token: typing.Optional[str] = OMIT,
        has_client_bearer_token: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateScimDirectoryResponse:
        """
        Parameters
        ----------
        id : typing.Optional[str]

        organization_id : typing.Optional[str]

        primary : typing.Optional[bool]

        scim_base_url : typing.Optional[str]

        client_bearer_token : typing.Optional[str]

        has_client_bearer_token : typing.Optional[bool]

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

        Returns
        -------
        CreateScimDirectoryResponse
            OK

        Examples
        --------
        from ssoready.client import SSOReady

        client = SSOReady(
            api_key="YOUR_API_KEY",
        )
        client.management.scim_directories.create_scim_directory()
        """
        _request: typing.Dict[str, typing.Any] = {}
        if id is not OMIT:
            _request["id"] = id
        if organization_id is not OMIT:
            _request["organizationId"] = organization_id
        if primary is not OMIT:
            _request["primary"] = primary
        if scim_base_url is not OMIT:
            _request["scimBaseUrl"] = scim_base_url
        if client_bearer_token is not OMIT:
            _request["clientBearerToken"] = client_bearer_token
        if has_client_bearer_token is not OMIT:
            _request["hasClientBearerToken"] = has_client_bearer_token
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/scim-directories"),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(CreateScimDirectoryResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_scim_directory(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetScimDirectoryResponse:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        GetScimDirectoryResponse
            OK

        Examples
        --------
        from ssoready.client import SSOReady

        client = SSOReady(
            api_key="YOUR_API_KEY",
        )
        client.management.scim_directories.get_scim_directory(
            id="id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="GET",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/", f"v1/scim-directories/{jsonable_encoder(id)}"
            ),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(GetScimDirectoryResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def update_scim_directory(
        self,
        id_: str,
        *,
        id: typing.Optional[str] = OMIT,
        organization_id: typing.Optional[str] = OMIT,
        primary: typing.Optional[bool] = OMIT,
        scim_base_url: typing.Optional[str] = OMIT,
        client_bearer_token: typing.Optional[str] = OMIT,
        has_client_bearer_token: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateScimDirectoryResponse:
        """
        Parameters
        ----------
        id_ : str

        id : typing.Optional[str]

        organization_id : typing.Optional[str]

        primary : typing.Optional[bool]

        scim_base_url : typing.Optional[str]

        client_bearer_token : typing.Optional[str]

        has_client_bearer_token : typing.Optional[bool]

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

        Returns
        -------
        UpdateScimDirectoryResponse
            OK

        Examples
        --------
        from ssoready.client import SSOReady

        client = SSOReady(
            api_key="YOUR_API_KEY",
        )
        client.management.scim_directories.update_scim_directory(
            id_="id",
        )
        """
        _request: typing.Dict[str, typing.Any] = {}
        if id is not OMIT:
            _request["id"] = id
        if organization_id is not OMIT:
            _request["organizationId"] = organization_id
        if primary is not OMIT:
            _request["primary"] = primary
        if scim_base_url is not OMIT:
            _request["scimBaseUrl"] = scim_base_url
        if client_bearer_token is not OMIT:
            _request["clientBearerToken"] = client_bearer_token
        if has_client_bearer_token is not OMIT:
            _request["hasClientBearerToken"] = has_client_bearer_token
        _response = self._client_wrapper.httpx_client.request(
            method="PATCH",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/", f"v1/scim-directories/{jsonable_encoder(id_)}"
            ),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(UpdateScimDirectoryResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def rotate_scim_directory_bearer_token(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RotateScimDirectoryBearerTokenResponse:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        RotateScimDirectoryBearerTokenResponse
            OK

        Examples
        --------
        from ssoready.client import SSOReady

        client = SSOReady(
            api_key="YOUR_API_KEY",
        )
        client.management.scim_directories.rotate_scim_directory_bearer_token(
            id="id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/",
                f"v1/scim-directories/{jsonable_encoder(id)}/rotate-bearer-token",
            ),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
            if request_options is not None
            else None,
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(RotateScimDirectoryBearerTokenResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


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

    async def list_scim_directories(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        page_token: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListScimDirectoriesResponse:
        """
        Parameters
        ----------
        organization_id : typing.Optional[str]

        page_token : typing.Optional[str]

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

        Returns
        -------
        ListScimDirectoriesResponse
            OK

        Examples
        --------
        from ssoready.client import AsyncSSOReady

        client = AsyncSSOReady(
            api_key="YOUR_API_KEY",
        )
        await client.management.scim_directories.list_scim_directories()
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="GET",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/scim-directories"),
            params=encode_query(
                jsonable_encoder(
                    remove_none_from_dict(
                        {
                            "organizationId": organization_id,
                            "pageToken": page_token,
                            **(
                                request_options.get("additional_query_parameters", {})
                                if request_options is not None
                                else {}
                            ),
                        }
                    )
                )
            ),
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ListScimDirectoriesResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def create_scim_directory(
        self,
        *,
        id: typing.Optional[str] = OMIT,
        organization_id: typing.Optional[str] = OMIT,
        primary: typing.Optional[bool] = OMIT,
        scim_base_url: typing.Optional[str] = OMIT,
        client_bearer_token: typing.Optional[str] = OMIT,
        has_client_bearer_token: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateScimDirectoryResponse:
        """
        Parameters
        ----------
        id : typing.Optional[str]

        organization_id : typing.Optional[str]

        primary : typing.Optional[bool]

        scim_base_url : typing.Optional[str]

        client_bearer_token : typing.Optional[str]

        has_client_bearer_token : typing.Optional[bool]

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

        Returns
        -------
        CreateScimDirectoryResponse
            OK

        Examples
        --------
        from ssoready.client import AsyncSSOReady

        client = AsyncSSOReady(
            api_key="YOUR_API_KEY",
        )
        await client.management.scim_directories.create_scim_directory()
        """
        _request: typing.Dict[str, typing.Any] = {}
        if id is not OMIT:
            _request["id"] = id
        if organization_id is not OMIT:
            _request["organizationId"] = organization_id
        if primary is not OMIT:
            _request["primary"] = primary
        if scim_base_url is not OMIT:
            _request["scimBaseUrl"] = scim_base_url
        if client_bearer_token is not OMIT:
            _request["clientBearerToken"] = client_bearer_token
        if has_client_bearer_token is not OMIT:
            _request["hasClientBearerToken"] = has_client_bearer_token
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/scim-directories"),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(CreateScimDirectoryResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_scim_directory(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetScimDirectoryResponse:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        GetScimDirectoryResponse
            OK

        Examples
        --------
        from ssoready.client import AsyncSSOReady

        client = AsyncSSOReady(
            api_key="YOUR_API_KEY",
        )
        await client.management.scim_directories.get_scim_directory(
            id="id",
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="GET",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/", f"v1/scim-directories/{jsonable_encoder(id)}"
            ),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(GetScimDirectoryResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def update_scim_directory(
        self,
        id_: str,
        *,
        id: typing.Optional[str] = OMIT,
        organization_id: typing.Optional[str] = OMIT,
        primary: typing.Optional[bool] = OMIT,
        scim_base_url: typing.Optional[str] = OMIT,
        client_bearer_token: typing.Optional[str] = OMIT,
        has_client_bearer_token: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateScimDirectoryResponse:
        """
        Parameters
        ----------
        id_ : str

        id : typing.Optional[str]

        organization_id : typing.Optional[str]

        primary : typing.Optional[bool]

        scim_base_url : typing.Optional[str]

        client_bearer_token : typing.Optional[str]

        has_client_bearer_token : typing.Optional[bool]

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

        Returns
        -------
        UpdateScimDirectoryResponse
            OK

        Examples
        --------
        from ssoready.client import AsyncSSOReady

        client = AsyncSSOReady(
            api_key="YOUR_API_KEY",
        )
        await client.management.scim_directories.update_scim_directory(
            id_="id",
        )
        """
        _request: typing.Dict[str, typing.Any] = {}
        if id is not OMIT:
            _request["id"] = id
        if organization_id is not OMIT:
            _request["organizationId"] = organization_id
        if primary is not OMIT:
            _request["primary"] = primary
        if scim_base_url is not OMIT:
            _request["scimBaseUrl"] = scim_base_url
        if client_bearer_token is not OMIT:
            _request["clientBearerToken"] = client_bearer_token
        if has_client_bearer_token is not OMIT:
            _request["hasClientBearerToken"] = has_client_bearer_token
        _response = await self._client_wrapper.httpx_client.request(
            method="PATCH",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/", f"v1/scim-directories/{jsonable_encoder(id_)}"
            ),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(UpdateScimDirectoryResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def rotate_scim_directory_bearer_token(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RotateScimDirectoryBearerTokenResponse:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        RotateScimDirectoryBearerTokenResponse
            OK

        Examples
        --------
        from ssoready.client import AsyncSSOReady

        client = AsyncSSOReady(
            api_key="YOUR_API_KEY",
        )
        await client.management.scim_directories.rotate_scim_directory_bearer_token(
            id="id",
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/",
                f"v1/scim-directories/{jsonable_encoder(id)}/rotate-bearer-token",
            ),
            params=encode_query(
                jsonable_encoder(
                    request_options.get("additional_query_parameters") if request_options is not None else None
                )
            ),
            json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
            if request_options is not None
            else None,
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(RotateScimDirectoryBearerTokenResponse, _response.json())  # type: ignore
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
