module Cachix.Types.Deployment where

import Data.Aeson
  ( FromJSON,
    ToJSON,
  )
import Data.Swagger (ToSchema)
import Data.Time.Clock (UTCTime)
import Data.UUID (UUID)
import Protolude

data Status
  = Pending
  | InProgress
  | Cancelled
  | Failed
  | Succeeded
  deriving stock (Status -> Status -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Status -> Status -> Bool
$c/= :: Status -> Status -> Bool
== :: Status -> Status -> Bool
$c== :: Status -> Status -> Bool
Eq, forall x. Rep Status x -> Status
forall x. Status -> Rep Status x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Status x -> Status
$cfrom :: forall x. Status -> Rep Status x
Generic, Int -> Status -> ShowS
[Status] -> ShowS
Status -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Status] -> ShowS
$cshowList :: [Status] -> ShowS
show :: Status -> String
$cshow :: Status -> String
showsPrec :: Int -> Status -> ShowS
$cshowsPrec :: Int -> Status -> ShowS
Show)
  deriving anyclass (Value -> Parser [Status]
Value -> Parser Status
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Status]
$cparseJSONList :: Value -> Parser [Status]
parseJSON :: Value -> Parser Status
$cparseJSON :: Value -> Parser Status
FromJSON, [Status] -> Encoding
[Status] -> Value
Status -> Encoding
Status -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Status] -> Encoding
$ctoEncodingList :: [Status] -> Encoding
toJSONList :: [Status] -> Value
$ctoJSONList :: [Status] -> Value
toEncoding :: Status -> Encoding
$ctoEncoding :: Status -> Encoding
toJSON :: Status -> Value
$ctoJSON :: Status -> Value
ToJSON, Proxy Status -> Declare (Definitions Schema) NamedSchema
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
declareNamedSchema :: Proxy Status -> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: Proxy Status -> Declare (Definitions Schema) NamedSchema
ToSchema, Status -> ()
forall a. (a -> ()) -> NFData a
rnf :: Status -> ()
$crnf :: Status -> ()
NFData)

data Deployment = Deployment
  { Deployment -> UUID
id :: UUID,
    Deployment -> Int64
index :: Int64,
    Deployment -> UTCTime
createdOn :: UTCTime,
    Deployment -> Maybe UTCTime
startedOn :: Maybe UTCTime,
    Deployment -> Text
storePath :: Text,
    Deployment -> Maybe Int64
closureSize :: Maybe Int64,
    Deployment -> Status
status :: Status
  }
  deriving stock (Int -> Deployment -> ShowS
[Deployment] -> ShowS
Deployment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Deployment] -> ShowS
$cshowList :: [Deployment] -> ShowS
show :: Deployment -> String
$cshow :: Deployment -> String
showsPrec :: Int -> Deployment -> ShowS
$cshowsPrec :: Int -> Deployment -> ShowS
Show, forall x. Rep Deployment x -> Deployment
forall x. Deployment -> Rep Deployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Deployment x -> Deployment
$cfrom :: forall x. Deployment -> Rep Deployment x
Generic)
  deriving anyclass (Value -> Parser [Deployment]
Value -> Parser Deployment
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Deployment]
$cparseJSONList :: Value -> Parser [Deployment]
parseJSON :: Value -> Parser Deployment
$cparseJSON :: Value -> Parser Deployment
FromJSON, [Deployment] -> Encoding
[Deployment] -> Value
Deployment -> Encoding
Deployment -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Deployment] -> Encoding
$ctoEncodingList :: [Deployment] -> Encoding
toJSONList :: [Deployment] -> Value
$ctoJSONList :: [Deployment] -> Value
toEncoding :: Deployment -> Encoding
$ctoEncoding :: Deployment -> Encoding
toJSON :: Deployment -> Value
$ctoJSON :: Deployment -> Value
ToJSON, Proxy Deployment -> Declare (Definitions Schema) NamedSchema
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
declareNamedSchema :: Proxy Deployment -> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: Proxy Deployment -> Declare (Definitions Schema) NamedSchema
ToSchema, Deployment -> ()
forall a. (a -> ()) -> NFData a
rnf :: Deployment -> ()
$crnf :: Deployment -> ()
NFData)