{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Greengrass.Types.LocalDeviceResourceData
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Greengrass.Types.LocalDeviceResourceData where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types.GroupOwnerSetting
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Attributes that define a local device resource.
--
-- /See:/ 'newLocalDeviceResourceData' smart constructor.
data LocalDeviceResourceData = LocalDeviceResourceData'
  { -- | Group\/owner related settings for local resources.
    LocalDeviceResourceData -> Maybe GroupOwnerSetting
groupOwnerSetting :: Prelude.Maybe GroupOwnerSetting,
    -- | The local absolute path of the device resource. The source path for a
    -- device resource can refer only to a character device or block device
    -- under \'\'\/dev\'\'.
    LocalDeviceResourceData -> Maybe Text
sourcePath :: Prelude.Maybe Prelude.Text
  }
  deriving (LocalDeviceResourceData -> LocalDeviceResourceData -> Bool
(LocalDeviceResourceData -> LocalDeviceResourceData -> Bool)
-> (LocalDeviceResourceData -> LocalDeviceResourceData -> Bool)
-> Eq LocalDeviceResourceData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocalDeviceResourceData -> LocalDeviceResourceData -> Bool
$c/= :: LocalDeviceResourceData -> LocalDeviceResourceData -> Bool
== :: LocalDeviceResourceData -> LocalDeviceResourceData -> Bool
$c== :: LocalDeviceResourceData -> LocalDeviceResourceData -> Bool
Prelude.Eq, ReadPrec [LocalDeviceResourceData]
ReadPrec LocalDeviceResourceData
Int -> ReadS LocalDeviceResourceData
ReadS [LocalDeviceResourceData]
(Int -> ReadS LocalDeviceResourceData)
-> ReadS [LocalDeviceResourceData]
-> ReadPrec LocalDeviceResourceData
-> ReadPrec [LocalDeviceResourceData]
-> Read LocalDeviceResourceData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LocalDeviceResourceData]
$creadListPrec :: ReadPrec [LocalDeviceResourceData]
readPrec :: ReadPrec LocalDeviceResourceData
$creadPrec :: ReadPrec LocalDeviceResourceData
readList :: ReadS [LocalDeviceResourceData]
$creadList :: ReadS [LocalDeviceResourceData]
readsPrec :: Int -> ReadS LocalDeviceResourceData
$creadsPrec :: Int -> ReadS LocalDeviceResourceData
Prelude.Read, Int -> LocalDeviceResourceData -> ShowS
[LocalDeviceResourceData] -> ShowS
LocalDeviceResourceData -> String
(Int -> LocalDeviceResourceData -> ShowS)
-> (LocalDeviceResourceData -> String)
-> ([LocalDeviceResourceData] -> ShowS)
-> Show LocalDeviceResourceData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocalDeviceResourceData] -> ShowS
$cshowList :: [LocalDeviceResourceData] -> ShowS
show :: LocalDeviceResourceData -> String
$cshow :: LocalDeviceResourceData -> String
showsPrec :: Int -> LocalDeviceResourceData -> ShowS
$cshowsPrec :: Int -> LocalDeviceResourceData -> ShowS
Prelude.Show, (forall x.
 LocalDeviceResourceData -> Rep LocalDeviceResourceData x)
-> (forall x.
    Rep LocalDeviceResourceData x -> LocalDeviceResourceData)
-> Generic LocalDeviceResourceData
forall x. Rep LocalDeviceResourceData x -> LocalDeviceResourceData
forall x. LocalDeviceResourceData -> Rep LocalDeviceResourceData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LocalDeviceResourceData x -> LocalDeviceResourceData
$cfrom :: forall x. LocalDeviceResourceData -> Rep LocalDeviceResourceData x
Prelude.Generic)

-- |
-- Create a value of 'LocalDeviceResourceData' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'groupOwnerSetting', 'localDeviceResourceData_groupOwnerSetting' - Group\/owner related settings for local resources.
--
-- 'sourcePath', 'localDeviceResourceData_sourcePath' - The local absolute path of the device resource. The source path for a
-- device resource can refer only to a character device or block device
-- under \'\'\/dev\'\'.
newLocalDeviceResourceData ::
  LocalDeviceResourceData
newLocalDeviceResourceData :: LocalDeviceResourceData
newLocalDeviceResourceData =
  LocalDeviceResourceData' :: Maybe GroupOwnerSetting -> Maybe Text -> LocalDeviceResourceData
LocalDeviceResourceData'
    { $sel:groupOwnerSetting:LocalDeviceResourceData' :: Maybe GroupOwnerSetting
groupOwnerSetting =
        Maybe GroupOwnerSetting
forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePath:LocalDeviceResourceData' :: Maybe Text
sourcePath = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Group\/owner related settings for local resources.
localDeviceResourceData_groupOwnerSetting :: Lens.Lens' LocalDeviceResourceData (Prelude.Maybe GroupOwnerSetting)
localDeviceResourceData_groupOwnerSetting :: (Maybe GroupOwnerSetting -> f (Maybe GroupOwnerSetting))
-> LocalDeviceResourceData -> f LocalDeviceResourceData
localDeviceResourceData_groupOwnerSetting = (LocalDeviceResourceData -> Maybe GroupOwnerSetting)
-> (LocalDeviceResourceData
    -> Maybe GroupOwnerSetting -> LocalDeviceResourceData)
-> Lens
     LocalDeviceResourceData
     LocalDeviceResourceData
     (Maybe GroupOwnerSetting)
     (Maybe GroupOwnerSetting)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalDeviceResourceData' {Maybe GroupOwnerSetting
groupOwnerSetting :: Maybe GroupOwnerSetting
$sel:groupOwnerSetting:LocalDeviceResourceData' :: LocalDeviceResourceData -> Maybe GroupOwnerSetting
groupOwnerSetting} -> Maybe GroupOwnerSetting
groupOwnerSetting) (\s :: LocalDeviceResourceData
s@LocalDeviceResourceData' {} Maybe GroupOwnerSetting
a -> LocalDeviceResourceData
s {$sel:groupOwnerSetting:LocalDeviceResourceData' :: Maybe GroupOwnerSetting
groupOwnerSetting = Maybe GroupOwnerSetting
a} :: LocalDeviceResourceData)

-- | The local absolute path of the device resource. The source path for a
-- device resource can refer only to a character device or block device
-- under \'\'\/dev\'\'.
localDeviceResourceData_sourcePath :: Lens.Lens' LocalDeviceResourceData (Prelude.Maybe Prelude.Text)
localDeviceResourceData_sourcePath :: (Maybe Text -> f (Maybe Text))
-> LocalDeviceResourceData -> f LocalDeviceResourceData
localDeviceResourceData_sourcePath = (LocalDeviceResourceData -> Maybe Text)
-> (LocalDeviceResourceData
    -> Maybe Text -> LocalDeviceResourceData)
-> Lens
     LocalDeviceResourceData
     LocalDeviceResourceData
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocalDeviceResourceData' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:LocalDeviceResourceData' :: LocalDeviceResourceData -> Maybe Text
sourcePath} -> Maybe Text
sourcePath) (\s :: LocalDeviceResourceData
s@LocalDeviceResourceData' {} Maybe Text
a -> LocalDeviceResourceData
s {$sel:sourcePath:LocalDeviceResourceData' :: Maybe Text
sourcePath = Maybe Text
a} :: LocalDeviceResourceData)

instance Core.FromJSON LocalDeviceResourceData where
  parseJSON :: Value -> Parser LocalDeviceResourceData
parseJSON =
    String
-> (Object -> Parser LocalDeviceResourceData)
-> Value
-> Parser LocalDeviceResourceData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LocalDeviceResourceData"
      ( \Object
x ->
          Maybe GroupOwnerSetting -> Maybe Text -> LocalDeviceResourceData
LocalDeviceResourceData'
            (Maybe GroupOwnerSetting -> Maybe Text -> LocalDeviceResourceData)
-> Parser (Maybe GroupOwnerSetting)
-> Parser (Maybe Text -> LocalDeviceResourceData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GroupOwnerSetting)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GroupOwnerSetting")
            Parser (Maybe Text -> LocalDeviceResourceData)
-> Parser (Maybe Text) -> Parser LocalDeviceResourceData
forall (f :: * -> *) a b. Applicative f => 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
"SourcePath")
      )

instance Prelude.Hashable LocalDeviceResourceData

instance Prelude.NFData LocalDeviceResourceData

instance Core.ToJSON LocalDeviceResourceData where
  toJSON :: LocalDeviceResourceData -> Value
toJSON LocalDeviceResourceData' {Maybe Text
Maybe GroupOwnerSetting
sourcePath :: Maybe Text
groupOwnerSetting :: Maybe GroupOwnerSetting
$sel:sourcePath:LocalDeviceResourceData' :: LocalDeviceResourceData -> Maybe Text
$sel:groupOwnerSetting:LocalDeviceResourceData' :: LocalDeviceResourceData -> Maybe GroupOwnerSetting
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"GroupOwnerSetting" Text -> GroupOwnerSetting -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (GroupOwnerSetting -> Pair)
-> Maybe GroupOwnerSetting -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GroupOwnerSetting
groupOwnerSetting,
            (Text
"SourcePath" 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
sourcePath
          ]
      )