module Ceilometer.Types.Image
(
PFImageStatus(..), pfImageStatus
, PFImageVerb(..), pfImageVerb
, PDImage(..), pdImage
, PDImagePollster(..), pdImagePollster
, imageStatus, imageVerb, imageVal
) where
import Control.Applicative
import Control.Lens
import Data.Binary (Word8)
import Data.Text (Text)
import Ceilometer.Types.Base
import Ceilometer.Types.TH
import Vaultaire.Types
$(declarePF "Image"
("Status", ''Word8)
[ ("Active" , 1)
, ("Saving" , 2)
, ("Deleted" , 3)
, ("Queued" , 4)
, ("PendingDelete", 5)
, ("Killed" , 6) ]
[ ''Show, ''Read, ''Eq, ''Bounded, ''Enum ])
$(declarePF "Image"
("Verb", ''Word8)
[ ("Serve" , 1)
, ("Update" , 2)
, ("Upload" , 3)
, ("Download", 4)
, ("Delete" , 5) ]
[ ''Show, ''Read, ''Eq, ''Bounded, ''Enum ])
data PDImage = PDImage
{ _imageStatus :: PFImageStatus
, _imageVerb :: PFImageVerb
, _imageEndpoint :: PFEndpoint
, _imageVal :: PFValue32 }
deriving (Eq, Show, Read)
$(makeLenses ''PDImage)
pdImage :: Prism' PRCompoundEvent PDImage
pdImage = prism' pretty parse
where parse raw
= PDImage
<$> (raw ^? eventStatus . pfImageStatus)
<*> (raw ^? eventVerb . pfImageVerb)
<*> (raw ^? eventEndpoint . pfEndpoint)
<*> (raw ^? eventVal )
pretty (PDImage status verb ep val)
= PRCompoundEvent
val
(ep ^. re pfEndpoint)
(verb ^. re pfImageVerb)
(status ^. re pfImageStatus)
newtype PDImagePollster = PDImagePollster { _pdImagePollsterVal :: PFValue64 }
deriving (Show, Read, Eq)
pdImagePollster :: Iso' PRSimple PDImagePollster
pdImagePollster = iso (PDImagePollster . _prSimpleVal) (PRSimple . _pdImagePollsterVal)