r"""
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Twilio - Voice
    This is the public Twilio REST API.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
"""

from typing import Any, Dict, Optional, Union
from twilio.base import serialize, values
from twilio.base.api_response import ApiResponse
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version


class SettingsInstance(InstanceResource):
    """
    :ivar dialing_permissions_inheritance: `true` if the sub-account will inherit voice dialing permissions from the Master Project; otherwise `false`.
    :ivar url: The absolute URL of this resource.
    """

    def __init__(self, version: Version, payload: Dict[str, Any]):
        super().__init__(version)

        self.dialing_permissions_inheritance: Optional[bool] = payload.get(
            "dialing_permissions_inheritance"
        )
        self.url: Optional[str] = payload.get("url")

        self._context: Optional[SettingsContext] = None

    @property
    def _proxy(self) -> "SettingsContext":
        """
        Generate an instance context for the instance, the context is capable of
        performing various actions. All instance actions are proxied to the context

        :returns: SettingsContext for this SettingsInstance
        """
        if self._context is None:
            self._context = SettingsContext(
                self._version,
            )
        return self._context

    def fetch(self) -> "SettingsInstance":
        """
        Fetch the SettingsInstance


        :returns: The fetched SettingsInstance
        """
        return self._proxy.fetch()

    async def fetch_async(self) -> "SettingsInstance":
        """
        Asynchronous coroutine to fetch the SettingsInstance


        :returns: The fetched SettingsInstance
        """
        return await self._proxy.fetch_async()

    def fetch_with_http_info(self) -> ApiResponse:
        """
        Fetch the SettingsInstance with HTTP info


        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.fetch_with_http_info()

    async def fetch_with_http_info_async(self) -> ApiResponse:
        """
        Asynchronous coroutine to fetch the SettingsInstance with HTTP info


        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.fetch_with_http_info_async()

    def update(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> "SettingsInstance":
        """
        Update the SettingsInstance

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: The updated SettingsInstance
        """
        return self._proxy.update(
            dialing_permissions_inheritance=dialing_permissions_inheritance,
        )

    async def update_async(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> "SettingsInstance":
        """
        Asynchronous coroutine to update the SettingsInstance

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: The updated SettingsInstance
        """
        return await self._proxy.update_async(
            dialing_permissions_inheritance=dialing_permissions_inheritance,
        )

    def update_with_http_info(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Update the SettingsInstance with HTTP info

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.update_with_http_info(
            dialing_permissions_inheritance=dialing_permissions_inheritance,
        )

    async def update_with_http_info_async(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronous coroutine to update the SettingsInstance with HTTP info

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.update_with_http_info_async(
            dialing_permissions_inheritance=dialing_permissions_inheritance,
        )

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """

        return "<Twilio.Voice.V1.SettingsInstance>"


class SettingsContext(InstanceContext):

    def __init__(self, version: Version):
        """
        Initialize the SettingsContext

        :param version: Version that contains the resource
        """
        super().__init__(version)

        self._uri = "/Settings"

    def _fetch(self) -> tuple:
        """
        Internal helper for fetch operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        headers = values.of({})

        headers["Accept"] = "application/json"

        return self._version.fetch_with_response_info(
            method="GET", uri=self._uri, headers=headers
        )

    def fetch(self) -> SettingsInstance:
        """
        Fetch the SettingsInstance


        :returns: The fetched SettingsInstance
        """
        payload, _, _ = self._fetch()
        return SettingsInstance(
            self._version,
            payload,
        )

    def fetch_with_http_info(self) -> ApiResponse:
        """
        Fetch the SettingsInstance and return response metadata


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._fetch()
        instance = SettingsInstance(
            self._version,
            payload,
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _fetch_async(self) -> tuple:
        """
        Internal async helper for fetch operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        headers = values.of({})

        headers["Accept"] = "application/json"

        return await self._version.fetch_with_response_info_async(
            method="GET", uri=self._uri, headers=headers
        )

    async def fetch_async(self) -> SettingsInstance:
        """
        Asynchronous coroutine to fetch the SettingsInstance


        :returns: The fetched SettingsInstance
        """
        payload, _, _ = await self._fetch_async()
        return SettingsInstance(
            self._version,
            payload,
        )

    async def fetch_with_http_info_async(self) -> ApiResponse:
        """
        Asynchronous coroutine to fetch the SettingsInstance and return response metadata


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._fetch_async()
        instance = SettingsInstance(
            self._version,
            payload,
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    def _update(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> tuple:
        """
        Internal helper for update operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        data = values.of(
            {
                "DialingPermissionsInheritance": serialize.boolean_to_string(
                    dialing_permissions_inheritance
                ),
            }
        )
        headers = values.of({})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        return self._version.update_with_response_info(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    def update(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> SettingsInstance:
        """
        Update the SettingsInstance

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: The updated SettingsInstance
        """
        payload, _, _ = self._update(
            dialing_permissions_inheritance=dialing_permissions_inheritance
        )
        return SettingsInstance(self._version, payload)

    def update_with_http_info(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Update the SettingsInstance and return response metadata

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._update(
            dialing_permissions_inheritance=dialing_permissions_inheritance
        )
        instance = SettingsInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _update_async(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> tuple:
        """
        Internal async helper for update operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        data = values.of(
            {
                "DialingPermissionsInheritance": serialize.boolean_to_string(
                    dialing_permissions_inheritance
                ),
            }
        )
        headers = values.of({})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        return await self._version.update_with_response_info_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    async def update_async(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> SettingsInstance:
        """
        Asynchronous coroutine to update the SettingsInstance

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: The updated SettingsInstance
        """
        payload, _, _ = await self._update_async(
            dialing_permissions_inheritance=dialing_permissions_inheritance
        )
        return SettingsInstance(self._version, payload)

    async def update_with_http_info_async(
        self, dialing_permissions_inheritance: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronous coroutine to update the SettingsInstance and return response metadata

        :param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._update_async(
            dialing_permissions_inheritance=dialing_permissions_inheritance
        )
        instance = SettingsInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """

        return "<Twilio.Voice.V1.SettingsContext>"


class SettingsList(ListResource):

    def __init__(self, version: Version):
        """
        Initialize the SettingsList

        :param version: Version that contains the resource

        """
        super().__init__(version)

    def get(self) -> SettingsContext:
        """
        Constructs a SettingsContext

        """
        return SettingsContext(self._version)

    def __call__(self) -> SettingsContext:
        """
        Constructs a SettingsContext

        """
        return SettingsContext(self._version)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        return "<Twilio.Voice.V1.SettingsList>"
