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

    Twilio - Assistants
    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 datetime import datetime
from typing import Any, Dict, Optional
from twilio.base import deserialize, 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 KnowledgeStatusInstance(InstanceResource):
    """
    :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource.
    :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED')
    :ivar last_status: The last status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED')
    :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
    """

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

        self.account_sid: Optional[str] = payload.get("account_sid")
        self.status: Optional[str] = payload.get("status")
        self.last_status: Optional[str] = payload.get("last_status")
        self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("date_updated")
        )

        self._solution = {
            "id": id,
        }
        self._context: Optional[KnowledgeStatusContext] = None

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

        :returns: KnowledgeStatusContext for this KnowledgeStatusInstance
        """
        if self._context is None:
            self._context = KnowledgeStatusContext(
                self._version,
                id=self._solution["id"],
            )
        return self._context

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


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

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


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

    def fetch_with_http_info(self) -> ApiResponse:
        """
        Fetch the KnowledgeStatusInstance 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 KnowledgeStatusInstance 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
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Assistants.V1.KnowledgeStatusInstance {}>".format(context)


class KnowledgeStatusContext(InstanceContext):

    def __init__(self, version: Version, id: str):
        """
        Initialize the KnowledgeStatusContext

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

        # Path Solution
        self._solution = {
            "id": id,
        }
        self._uri = "/Knowledge/{id}/Status".format(**self._solution)

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


        :returns: The fetched KnowledgeStatusInstance
        """
        payload, _, _ = self._fetch()
        return KnowledgeStatusInstance(
            self._version,
            payload,
            id=self._solution["id"],
        )

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


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


        :returns: The fetched KnowledgeStatusInstance
        """
        payload, _, _ = await self._fetch_async()
        return KnowledgeStatusInstance(
            self._version,
            payload,
            id=self._solution["id"],
        )

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


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._fetch_async()
        instance = KnowledgeStatusInstance(
            self._version,
            payload,
            id=self._solution["id"],
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

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

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Assistants.V1.KnowledgeStatusContext {}>".format(context)


class KnowledgeStatusList(ListResource):

    def __init__(self, version: Version, id: str):
        """
        Initialize the KnowledgeStatusList

        :param version: Version that contains the resource
        :param id: the Knowledge ID.

        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "id": id,
        }

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

        """
        return KnowledgeStatusContext(self._version, id=self._solution["id"])

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

        """
        return KnowledgeStatusContext(self._version, id=self._solution["id"])

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Assistants.V1.KnowledgeStatusList>"
