{-# 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 Amazonka.ECS.Types.DeviceCgroupPermission
import qualified Amazonka.Lens as Lens
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
(Device -> Device -> Bool)
-> (Device -> Device -> Bool) -> Eq Device
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]
(Int -> ReadS Device)
-> ReadS [Device]
-> ReadPrec Device
-> ReadPrec [Device]
-> Read 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
(Int -> Device -> ShowS)
-> (Device -> String) -> ([Device] -> ShowS) -> Show Device
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. Device -> Rep Device x)
-> (forall x. Rep Device x -> Device) -> Generic Device
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' :: Maybe Text -> Maybe [DeviceCgroupPermission] -> Text -> Device
Device'
{ $sel:containerPath:Device' :: Maybe Text
containerPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:permissions:Device' :: Maybe [DeviceCgroupPermission]
permissions = Maybe [DeviceCgroupPermission]
forall a. Maybe a
Prelude.Nothing,
$sel:hostPath:Device' :: Text
hostPath = Text
pHostPath_
}
device_containerPath :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_containerPath :: (Maybe Text -> f (Maybe Text)) -> Device -> f Device
device_containerPath = (Device -> Maybe Text)
-> (Device -> Maybe Text -> Device)
-> Lens Device Device (Maybe Text) (Maybe Text)
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 :: (Maybe [DeviceCgroupPermission]
-> f (Maybe [DeviceCgroupPermission]))
-> Device -> f Device
device_permissions = (Device -> Maybe [DeviceCgroupPermission])
-> (Device -> Maybe [DeviceCgroupPermission] -> Device)
-> Lens
Device
Device
(Maybe [DeviceCgroupPermission])
(Maybe [DeviceCgroupPermission])
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) ((Maybe [DeviceCgroupPermission]
-> f (Maybe [DeviceCgroupPermission]))
-> Device -> f Device)
-> ((Maybe [DeviceCgroupPermission]
-> f (Maybe [DeviceCgroupPermission]))
-> Maybe [DeviceCgroupPermission]
-> f (Maybe [DeviceCgroupPermission]))
-> (Maybe [DeviceCgroupPermission]
-> f (Maybe [DeviceCgroupPermission]))
-> Device
-> f Device
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[DeviceCgroupPermission]
[DeviceCgroupPermission]
[DeviceCgroupPermission]
[DeviceCgroupPermission]
-> Iso
(Maybe [DeviceCgroupPermission])
(Maybe [DeviceCgroupPermission])
(Maybe [DeviceCgroupPermission])
(Maybe [DeviceCgroupPermission])
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 AnIso
[DeviceCgroupPermission]
[DeviceCgroupPermission]
[DeviceCgroupPermission]
[DeviceCgroupPermission]
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 :: (Text -> f Text) -> Device -> f Device
device_hostPath = (Device -> Text)
-> (Device -> Text -> Device) -> Lens Device Device Text Text
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 Core.FromJSON Device where
parseJSON :: Value -> Parser Device
parseJSON =
String -> (Object -> Parser Device) -> Value -> Parser Device
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Device"
( \Object
x ->
Maybe Text -> Maybe [DeviceCgroupPermission] -> Text -> Device
Device'
(Maybe Text -> Maybe [DeviceCgroupPermission] -> Text -> Device)
-> Parser (Maybe Text)
-> Parser (Maybe [DeviceCgroupPermission] -> Text -> Device)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"containerPath")
Parser (Maybe [DeviceCgroupPermission] -> Text -> Device)
-> Parser (Maybe [DeviceCgroupPermission])
-> Parser (Text -> Device)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [DeviceCgroupPermission]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"permissions" Parser (Maybe (Maybe [DeviceCgroupPermission]))
-> Maybe [DeviceCgroupPermission]
-> Parser (Maybe [DeviceCgroupPermission])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DeviceCgroupPermission]
forall a. Monoid a => a
Prelude.mempty)
Parser (Text -> Device) -> Parser Text -> Parser Device
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"hostPath")
)
instance Prelude.Hashable Device
instance Prelude.NFData Device
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"containerPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
containerPath,
(Text
"permissions" Text -> [DeviceCgroupPermission] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DeviceCgroupPermission] -> Pair)
-> Maybe [DeviceCgroupPermission] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DeviceCgroupPermission]
permissions,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"hostPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hostPath)
]
)