mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
adds action listings to AIS response
This commit is contained in:
committed by
Aiden McClelland
parent
39867478d0
commit
54ae7f82d6
@@ -29,7 +29,7 @@ import qualified Data.String as String
|
||||
import Lib.Algebra.Domain.AppMgr.Types
|
||||
import Lib.Algebra.Domain.AppMgr.TH
|
||||
import Lib.Error
|
||||
import Lib.External.AppManifest
|
||||
import qualified Lib.External.AppManifest as Manifest
|
||||
import Lib.TyFam.ConditionalData
|
||||
import Lib.Types.Core ( AppId(..)
|
||||
, AppContainerStatus(..)
|
||||
@@ -65,8 +65,9 @@ data InfoRes a = InfoRes
|
||||
:: Include
|
||||
(Either_ (DefaultEqSym1 'OnlyDependencies) (ElemSym1 'IncludeDependencies) a)
|
||||
(HM.HashMap AppId DependencyInfo)
|
||||
, infoResManifest :: Include (Either_ (DefaultEqSym1 'OnlyManifest) (ElemSym1 'IncludeManifest) a) AppManifest
|
||||
, infoResStatus :: Include (Either_ (DefaultEqSym1 'OnlyStatus) (ElemSym1 'IncludeStatus) a) AppContainerStatus
|
||||
, infoResManifest
|
||||
:: Include (Either_ (DefaultEqSym1 'OnlyManifest) (ElemSym1 'IncludeManifest) a) Manifest.AppManifest
|
||||
, infoResStatus :: Include (Either_ (DefaultEqSym1 'OnlyStatus) (ElemSym1 'IncludeStatus) a) AppContainerStatus
|
||||
}
|
||||
instance SingI (a :: Either OnlyInfoFlag [IncludeInfoFlag]) => FromJSON (InfoRes a) where
|
||||
parseJSON = withObject "AppMgr Info/List Response" $ \o -> do
|
||||
|
||||
28
agent/src/Lib/External/AppManifest.hs
vendored
28
agent/src/Lib/External/AppManifest.hs
vendored
@@ -47,6 +47,32 @@ instance FromJSON AssetMapping where
|
||||
assetMappingOverwrite <- o .: "overwrite"
|
||||
pure $ AssetMapping { .. }
|
||||
|
||||
data Action = Action
|
||||
{ actionId :: Text
|
||||
, actionName :: Text
|
||||
, actionDescription :: Text
|
||||
, actionWarning :: Maybe Text
|
||||
, actionAllowedStatuses :: [AppContainerStatus]
|
||||
}
|
||||
instance FromJSON Action where
|
||||
parseJSON = withObject "AppAction" $ \o -> do
|
||||
actionId <- o .: "id"
|
||||
actionName <- o .: "name"
|
||||
actionDescription <- o .: "description"
|
||||
actionWarning <- o .:? "warning"
|
||||
actionAllowedStatuses <- o .: "allowed-statuses"
|
||||
pure Action { .. }
|
||||
instance ToJSON Action where
|
||||
toJSON Action {..} =
|
||||
object
|
||||
$ [ "id" .= actionId
|
||||
, "name" .= actionName
|
||||
, "description" .= actionDescription
|
||||
, "allowedStatuses" .= actionAllowedStatuses
|
||||
]
|
||||
<> maybeToList (("warning" .=) <$> actionWarning)
|
||||
|
||||
|
||||
data AppManifest where
|
||||
AppManifest ::{ appManifestId :: AppId
|
||||
, appManifestVersion :: Version
|
||||
@@ -62,6 +88,7 @@ data AppManifest where
|
||||
, appManifestDependencies :: HM.HashMap AppId VersionRange
|
||||
, appManifestUninstallAlert :: Maybe Text
|
||||
, appManifestRestoreAlert :: Maybe Text
|
||||
, appManifestActions :: [Action]
|
||||
} -> AppManifest
|
||||
|
||||
uiAvailable :: AppManifest -> Bool
|
||||
@@ -83,6 +110,7 @@ instance FromJSON AppManifest where
|
||||
appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo
|
||||
appManifestUninstallAlert <- o .:? "uninstall-alert"
|
||||
appManifestRestoreAlert <- o .:? "restore-alert"
|
||||
appManifestActions <- o .: "actions"
|
||||
pure $ AppManifest { .. }
|
||||
where
|
||||
parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal")
|
||||
|
||||
Reference in New Issue
Block a user