{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.ECS.Types.Device where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.DeviceCgroupPermission
import qualified Amazonka.Prelude as Prelude
data Device = Device'
{
Device -> Maybe Text
containerPath :: Prelude.Maybe Prelude.Text,
Device -> Maybe [DeviceCgroupPermission]
permissions :: Prelude.Maybe [DeviceCgroupPermission],
Device -> Text
hostPath :: Prelude.Text
}
deriving (Device -> Device -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Device -> Device -> Bool
$c/= :: Device -> Device -> Bool
== :: Device -> Device -> Bool
$c== :: Device -> Device -> Bool
Prelude.Eq, ReadPrec [Device]
ReadPrec Device
Int -> ReadS Device
ReadS [Device]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Device]
$creadListPrec :: ReadPrec [Device]
readPrec :: ReadPrec Device
$creadPrec :: ReadPrec Device
readList :: ReadS [Device]
$creadList :: ReadS [Device]
readsPrec :: Int -> ReadS Device
$creadsPrec :: Int -> ReadS Device
Prelude.Read, Int -> Device -> ShowS
[Device] -> ShowS
Device -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Device] -> ShowS
$cshowList :: [Device] -> ShowS
show :: Device -> String
$cshow :: Device -> String
showsPrec :: Int -> Device -> ShowS
$cshowsPrec :: Int -> Device -> ShowS
Prelude.Show, forall x. Rep Device x -> Device
forall x. Device -> Rep Device x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Device x -> Device
$cfrom :: forall x. Device -> Rep Device x
Prelude.Generic)
newDevice ::
Prelude.Text ->
Device
newDevice :: Text -> Device
newDevice Text
pHostPath_ =
Device'
{ $sel:containerPath:Device' :: Maybe Text
containerPath = forall a. Maybe a
Prelude.Nothing,
$sel:permissions:Device' :: Maybe [DeviceCgroupPermission]
permissions = forall a. Maybe a
Prelude.Nothing,
$sel:hostPath:Device' :: Text
hostPath = Text
pHostPath_
}
device_containerPath :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_containerPath :: Lens' Device (Maybe Text)
device_containerPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
containerPath :: Maybe Text
$sel:containerPath:Device' :: Device -> Maybe Text
containerPath} -> Maybe Text
containerPath) (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:containerPath:Device' :: Maybe Text
containerPath = Maybe Text
a} :: Device)
device_permissions :: Lens.Lens' Device (Prelude.Maybe [DeviceCgroupPermission])
device_permissions :: Lens' Device (Maybe [DeviceCgroupPermission])
device_permissions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe [DeviceCgroupPermission]
permissions :: Maybe [DeviceCgroupPermission]
$sel:permissions:Device' :: Device -> Maybe [DeviceCgroupPermission]
permissions} -> Maybe [DeviceCgroupPermission]
permissions) (\s :: Device
s@Device' {} Maybe [DeviceCgroupPermission]
a -> Device
s {$sel:permissions:Device' :: Maybe [DeviceCgroupPermission]
permissions = Maybe [DeviceCgroupPermission]
a} :: Device) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
device_hostPath :: Lens.Lens' Device Prelude.Text
device_hostPath :: Lens' Device Text
device_hostPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Text
hostPath :: Text
$sel:hostPath:Device' :: Device -> Text
hostPath} -> Text
hostPath) (\s :: Device
s@Device' {} Text
a -> Device
s {$sel:hostPath:Device' :: Text
hostPath = Text
a} :: Device)
instance Data.FromJSON Device where
parseJSON :: Value -> Parser Device
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Device"
( \Object
x ->
Maybe Text -> Maybe [DeviceCgroupPermission] -> Text -> Device
Device'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"containerPath")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"permissions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"hostPath")
)
instance Prelude.Hashable Device where
hashWithSalt :: Int -> Device -> Int
hashWithSalt Int
_salt Device' {Maybe [DeviceCgroupPermission]
Maybe Text
Text
hostPath :: Text
permissions :: Maybe [DeviceCgroupPermission]
containerPath :: Maybe Text
$sel:hostPath:Device' :: Device -> Text
$sel:permissions:Device' :: Device -> Maybe [DeviceCgroupPermission]
$sel:containerPath:Device' :: Device -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
containerPath
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DeviceCgroupPermission]
permissions
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hostPath
instance Prelude.NFData Device where
rnf :: Device -> ()
rnf Device' {Maybe [DeviceCgroupPermission]
Maybe Text
Text
hostPath :: Text
permissions :: Maybe [DeviceCgroupPermission]
containerPath :: Maybe Text
$sel:hostPath:Device' :: Device -> Text
$sel:permissions:Device' :: Device -> Maybe [DeviceCgroupPermission]
$sel:containerPath:Device' :: Device -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
containerPath
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [DeviceCgroupPermission]
permissions
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hostPath
instance Data.ToJSON Device where
toJSON :: Device -> Value
toJSON Device' {Maybe [DeviceCgroupPermission]
Maybe Text
Text
hostPath :: Text
permissions :: Maybe [DeviceCgroupPermission]
containerPath :: Maybe Text
$sel:hostPath:Device' :: Device -> Text
$sel:permissions:Device' :: Device -> Maybe [DeviceCgroupPermission]
$sel:containerPath:Device' :: Device -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"containerPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
containerPath,
(Key
"permissions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DeviceCgroupPermission]
permissions,
forall a. a -> Maybe a
Prelude.Just (Key
"hostPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hostPath)
]
)