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

    Twilio - Microvisor
    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 Optional
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 AppManifestInstance(InstanceResource):
    def __init__(self, version, payload, app_sid: str):
        """
        Initialize the AppManifestInstance

        :returns: twilio.rest.microvisor.v1.app.app_manifest.AppManifestInstance
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestInstance
        """
        super().__init__(version)

        self._properties = {
            "app_sid": payload.get("app_sid"),
            "hash": payload.get("hash"),
            "encoded_bytes": payload.get("encoded_bytes"),
            "url": payload.get("url"),
        }

        self._solution = {
            "app_sid": app_sid,
        }
        self._context: Optional[AppManifestContext] = None

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

        :returns: AppManifestContext for this AppManifestInstance
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        """
        if self._context is None:
            self._context = AppManifestContext(
                self._version,
                app_sid=self._solution["app_sid"],
            )
        return self._context

    @property
    def app_sid(self):
        """
        :returns: A 34-character string that uniquely identifies this App.
        :rtype: str
        """
        return self._properties["app_sid"]

    @property
    def hash(self):
        """
        :returns: App manifest hash represented as `hash_algorithm:hash_value`.
        :rtype: str
        """
        return self._properties["hash"]

    @property
    def encoded_bytes(self):
        """
        :returns: The base-64 encoded manifest
        :rtype: str
        """
        return self._properties["encoded_bytes"]

    @property
    def url(self):
        """
        :returns: The absolute URL of this Manifest.
        :rtype: str
        """
        return self._properties["url"]

    def fetch(self):
        """
        Fetch the AppManifestInstance


        :returns: The fetched AppManifestInstance
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestInstance
        """
        return self._proxy.fetch()

    async def fetch_async(self):
        """
        Asynchronous coroutine to fetch the AppManifestInstance


        :returns: The fetched AppManifestInstance
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestInstance
        """
        return await self._proxy.fetch_async()

    def __repr__(self):
        """
        Provide a friendly representation

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


class AppManifestContext(InstanceContext):
    def __init__(self, version: Version, app_sid: str):
        """
        Initialize the AppManifestContext

        :param Version version: Version that contains the resource
        :param app_sid: A 34-character string that uniquely identifies this App.

        :returns: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "app_sid": app_sid,
        }
        self._uri = "/Apps/{app_sid}/Manifest".format(**self._solution)

    def fetch(self):
        """
        Fetch the AppManifestInstance


        :returns: The fetched AppManifestInstance
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestInstance
        """

        payload = self._version.fetch(
            method="GET",
            uri=self._uri,
        )

        return AppManifestInstance(
            self._version,
            payload,
            app_sid=self._solution["app_sid"],
        )

    async def fetch_async(self):
        """
        Asynchronous coroutine to fetch the AppManifestInstance


        :returns: The fetched AppManifestInstance
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestInstance
        """

        payload = await self._version.fetch_async(
            method="GET",
            uri=self._uri,
        )

        return AppManifestInstance(
            self._version,
            payload,
            app_sid=self._solution["app_sid"],
        )

    def __repr__(self):
        """
        Provide a friendly representation

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


class AppManifestList(ListResource):
    def __init__(self, version: Version, app_sid: str):
        """
        Initialize the AppManifestList

        :param Version version: Version that contains the resource
        :param app_sid: A 34-character string that uniquely identifies this App.

        :returns: twilio.rest.microvisor.v1.app.app_manifest.AppManifestList
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestList
        """
        super().__init__(version)

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

    def get(self):
        """
        Constructs a AppManifestContext


        :returns: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        """
        return AppManifestContext(self._version, app_sid=self._solution["app_sid"])

    def __call__(self):
        """
        Constructs a AppManifestContext


        :returns: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        :rtype: twilio.rest.microvisor.v1.app.app_manifest.AppManifestContext
        """
        return AppManifestContext(self._version, app_sid=self._solution["app_sid"])

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return "<Twilio.Microvisor.V1.AppManifestList>"
