from os.path import join
from enum import Enum
from typing import Dict, List  # NOQA

from n0core.model import Model
from n0core.model import _Dependency # NOQA


class Volume(Model):
    """Volume manage persistent volume resource.

    Example:
        ```yaml
        type: resource/volume/file
        id: 486274b2-49e4-4bcd-a60d-4f627ce8c041
        state: allocated
        name: hogehoge
        size: 10 * 1024 * 1024 * 1024
        url: file:///data/hoge
        ```

    States:
        allocated: Allocate volume size and share volume.
        deleted: Delete volume resource, but not delete data in volume.
        destroyed: Destroy data in volume.

    Meta:

    Labels:

    Property:

    Args:
        id: UUID
        type:
        state:
        name: Name of volume.
        size: Size of volume.
        url: URL which is sharing like file:///data/hoge and nfs://hobge/data/hoge
        meta:
        dependencies: List of dependency to
    """

    STATES = Enum("STATES", ["POWEROFF", "RUNNING", "SAVED", "DELETED"])

    def __init__(self,
                 id,              # type: str
                 type,            # type: str
                 state,           # type: Enum
                 name,            # type: str
                 size,            # type: int
                 url,             # type: str
                 meta={},         # type: Dict[str, str]
                 dependencies=[]  # type: List[_Dependency]
                 ):
        # type: (...) -> None
        super().__init__(id=id,
                         type=join("resource/volume", type),
                         state=state,
                         name=name,
                         meta=meta,
                         dependencies=dependencies)

        self.__size = size
        self.url = url

    @property
    def size(self):
        # type: () -> int
        return self.__size

@@ -995,42 +995,34 @@
 , %5B%22
-POWEROFF%22, %22RUNNING%22, %22SAV
+ALLOCATED%22, %22DELET
 ED%22, %22DE
 LETE
@@ -1017,19 +1017,21 @@
 ED%22, %22DE
-LET
+STROY
 ED%22%5D)%0A%0A 

fix volume model