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

    Twilio - Video
    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 RecordingSettingsInstance(InstanceResource):
    """
    :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RecordingSettings resource.
    :ivar friendly_name: The string that you assigned to describe the resource and show the user in the console
    :ivar aws_credentials_sid: The SID of the stored Credential resource.
    :ivar aws_s3_url: The URL of the AWS S3 bucket where the recordings are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
    :ivar aws_storage_enabled: Whether all recordings are written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
    :ivar encryption_key_sid: The SID of the Public Key resource used for encryption.
    :ivar encryption_enabled: Whether all recordings are stored in an encrypted form. The default is `false`.
    :ivar url: The absolute URL of the resource.
    """

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

        self.account_sid: Optional[str] = payload.get("account_sid")
        self.friendly_name: Optional[str] = payload.get("friendly_name")
        self.aws_credentials_sid: Optional[str] = payload.get("aws_credentials_sid")
        self.aws_s3_url: Optional[str] = payload.get("aws_s3_url")
        self.aws_storage_enabled: Optional[bool] = payload.get("aws_storage_enabled")
        self.encryption_key_sid: Optional[str] = payload.get("encryption_key_sid")
        self.encryption_enabled: Optional[bool] = payload.get("encryption_enabled")
        self.url: Optional[str] = payload.get("url")

        self._context: Optional[RecordingSettingsContext] = None

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

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

    def create(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> "RecordingSettingsInstance":
        """
        Create the RecordingSettingsInstance

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: The created RecordingSettingsInstance
        """
        return self._proxy.create(
            friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )

    async def create_async(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> "RecordingSettingsInstance":
        """
        Asynchronous coroutine to create the RecordingSettingsInstance

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: The created RecordingSettingsInstance
        """
        return await self._proxy.create_async(
            friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )

    def create_with_http_info(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> ApiResponse:
        """
        Create the RecordingSettingsInstance with HTTP info

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.create_with_http_info(
            friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )

    async def create_with_http_info_async(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> ApiResponse:
        """
        Asynchronous coroutine to create the RecordingSettingsInstance with HTTP info

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.create_with_http_info_async(
            friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )

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


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

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


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

    def fetch_with_http_info(self) -> ApiResponse:
        """
        Fetch the RecordingSettingsInstance 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 RecordingSettingsInstance with HTTP info


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

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

        :returns: Machine friendly representation
        """

        return "<Twilio.Video.V1.RecordingSettingsInstance>"


class RecordingSettingsContext(InstanceContext):

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

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

        self._uri = "/RecordingSettings/Default"

    def _create(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> tuple:
        """
        Internal helper for create operation

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

        data = values.of(
            {
                "FriendlyName": friendly_name,
                "AwsCredentialsSid": aws_credentials_sid,
                "EncryptionKeySid": encryption_key_sid,
                "AwsS3Url": aws_s3_url,
                "AwsStorageEnabled": serialize.boolean_to_string(aws_storage_enabled),
                "EncryptionEnabled": serialize.boolean_to_string(encryption_enabled),
            }
        )
        headers = values.of({})

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

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

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

    def create(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> RecordingSettingsInstance:
        """
        Create the RecordingSettingsInstance

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: The created RecordingSettingsInstance
        """
        payload, _, _ = self._create(
            friendly_name=friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )
        return RecordingSettingsInstance(self._version, payload)

    def create_with_http_info(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> ApiResponse:
        """
        Create the RecordingSettingsInstance and return response metadata

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._create(
            friendly_name=friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )
        instance = RecordingSettingsInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _create_async(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> tuple:
        """
        Internal async helper for create operation

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

        data = values.of(
            {
                "FriendlyName": friendly_name,
                "AwsCredentialsSid": aws_credentials_sid,
                "EncryptionKeySid": encryption_key_sid,
                "AwsS3Url": aws_s3_url,
                "AwsStorageEnabled": serialize.boolean_to_string(aws_storage_enabled),
                "EncryptionEnabled": serialize.boolean_to_string(encryption_enabled),
            }
        )
        headers = values.of({})

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

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

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

    async def create_async(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> RecordingSettingsInstance:
        """
        Asynchronous coroutine to create the RecordingSettingsInstance

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: The created RecordingSettingsInstance
        """
        payload, _, _ = await self._create_async(
            friendly_name=friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )
        return RecordingSettingsInstance(self._version, payload)

    async def create_with_http_info_async(
        self,
        friendly_name: str,
        aws_credentials_sid: Union[str, object] = values.unset,
        encryption_key_sid: Union[str, object] = values.unset,
        aws_s3_url: Union[str, object] = values.unset,
        aws_storage_enabled: Union[bool, object] = values.unset,
        encryption_enabled: Union[bool, object] = values.unset,
    ) -> ApiResponse:
        """
        Asynchronous coroutine to create the RecordingSettingsInstance and return response metadata

        :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
        :param aws_credentials_sid: The SID of the stored Credential resource.
        :param encryption_key_sid: The SID of the Public Key resource to use for encryption.
        :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2).
        :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
        :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            friendly_name=friendly_name,
            aws_credentials_sid=aws_credentials_sid,
            encryption_key_sid=encryption_key_sid,
            aws_s3_url=aws_s3_url,
            aws_storage_enabled=aws_storage_enabled,
            encryption_enabled=encryption_enabled,
        )
        instance = RecordingSettingsInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    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) -> RecordingSettingsInstance:
        """
        Fetch the RecordingSettingsInstance


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

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


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._fetch()
        instance = RecordingSettingsInstance(
            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) -> RecordingSettingsInstance:
        """
        Asynchronous coroutine to fetch the RecordingSettingsInstance


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

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


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._fetch_async()
        instance = RecordingSettingsInstance(
            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.Video.V1.RecordingSettingsContext>"


class RecordingSettingsList(ListResource):

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

        :param version: Version that contains the resource

        """
        super().__init__(version)

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

        """
        return RecordingSettingsContext(self._version)

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

        """
        return RecordingSettingsContext(self._version)

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Video.V1.RecordingSettingsList>"
