{-# 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.GroupOwnerSetting
-- 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.GroupOwnerSetting where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Group owner related settings for local resources.
--
-- /See:/ 'newGroupOwnerSetting' smart constructor.
data GroupOwnerSetting = GroupOwnerSetting'
  { -- | If true, AWS IoT Greengrass automatically adds the specified Linux OS
    -- group owner of the resource to the Lambda process privileges. Thus the
    -- Lambda process will have the file access permissions of the added Linux
    -- group.
    GroupOwnerSetting -> Maybe Bool
autoAddGroupOwner :: Prelude.Maybe Prelude.Bool,
    -- | The name of the Linux OS group whose privileges will be added to the
    -- Lambda process. This field is optional.
    GroupOwnerSetting -> Maybe Text
groupOwner :: Prelude.Maybe Prelude.Text
  }
  deriving (GroupOwnerSetting -> GroupOwnerSetting -> Bool
(GroupOwnerSetting -> GroupOwnerSetting -> Bool)
-> (GroupOwnerSetting -> GroupOwnerSetting -> Bool)
-> Eq GroupOwnerSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupOwnerSetting -> GroupOwnerSetting -> Bool
$c/= :: GroupOwnerSetting -> GroupOwnerSetting -> Bool
== :: GroupOwnerSetting -> GroupOwnerSetting -> Bool
$c== :: GroupOwnerSetting -> GroupOwnerSetting -> Bool
Prelude.Eq, ReadPrec [GroupOwnerSetting]
ReadPrec GroupOwnerSetting
Int -> ReadS GroupOwnerSetting
ReadS [GroupOwnerSetting]
(Int -> ReadS GroupOwnerSetting)
-> ReadS [GroupOwnerSetting]
-> ReadPrec GroupOwnerSetting
-> ReadPrec [GroupOwnerSetting]
-> Read GroupOwnerSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupOwnerSetting]
$creadListPrec :: ReadPrec [GroupOwnerSetting]
readPrec :: ReadPrec GroupOwnerSetting
$creadPrec :: ReadPrec GroupOwnerSetting
readList :: ReadS [GroupOwnerSetting]
$creadList :: ReadS [GroupOwnerSetting]
readsPrec :: Int -> ReadS GroupOwnerSetting
$creadsPrec :: Int -> ReadS GroupOwnerSetting
Prelude.Read, Int -> GroupOwnerSetting -> ShowS
[GroupOwnerSetting] -> ShowS
GroupOwnerSetting -> String
(Int -> GroupOwnerSetting -> ShowS)
-> (GroupOwnerSetting -> String)
-> ([GroupOwnerSetting] -> ShowS)
-> Show GroupOwnerSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupOwnerSetting] -> ShowS
$cshowList :: [GroupOwnerSetting] -> ShowS
show :: GroupOwnerSetting -> String
$cshow :: GroupOwnerSetting -> String
showsPrec :: Int -> GroupOwnerSetting -> ShowS
$cshowsPrec :: Int -> GroupOwnerSetting -> ShowS
Prelude.Show, (forall x. GroupOwnerSetting -> Rep GroupOwnerSetting x)
-> (forall x. Rep GroupOwnerSetting x -> GroupOwnerSetting)
-> Generic GroupOwnerSetting
forall x. Rep GroupOwnerSetting x -> GroupOwnerSetting
forall x. GroupOwnerSetting -> Rep GroupOwnerSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupOwnerSetting x -> GroupOwnerSetting
$cfrom :: forall x. GroupOwnerSetting -> Rep GroupOwnerSetting x
Prelude.Generic)

-- |
-- Create a value of 'GroupOwnerSetting' 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:
--
-- 'autoAddGroupOwner', 'groupOwnerSetting_autoAddGroupOwner' - If true, AWS IoT Greengrass automatically adds the specified Linux OS
-- group owner of the resource to the Lambda process privileges. Thus the
-- Lambda process will have the file access permissions of the added Linux
-- group.
--
-- 'groupOwner', 'groupOwnerSetting_groupOwner' - The name of the Linux OS group whose privileges will be added to the
-- Lambda process. This field is optional.
newGroupOwnerSetting ::
  GroupOwnerSetting
newGroupOwnerSetting :: GroupOwnerSetting
newGroupOwnerSetting =
  GroupOwnerSetting' :: Maybe Bool -> Maybe Text -> GroupOwnerSetting
GroupOwnerSetting'
    { $sel:autoAddGroupOwner:GroupOwnerSetting' :: Maybe Bool
autoAddGroupOwner =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:groupOwner:GroupOwnerSetting' :: Maybe Text
groupOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | If true, AWS IoT Greengrass automatically adds the specified Linux OS
-- group owner of the resource to the Lambda process privileges. Thus the
-- Lambda process will have the file access permissions of the added Linux
-- group.
groupOwnerSetting_autoAddGroupOwner :: Lens.Lens' GroupOwnerSetting (Prelude.Maybe Prelude.Bool)
groupOwnerSetting_autoAddGroupOwner :: (Maybe Bool -> f (Maybe Bool))
-> GroupOwnerSetting -> f GroupOwnerSetting
groupOwnerSetting_autoAddGroupOwner = (GroupOwnerSetting -> Maybe Bool)
-> (GroupOwnerSetting -> Maybe Bool -> GroupOwnerSetting)
-> Lens
     GroupOwnerSetting GroupOwnerSetting (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupOwnerSetting' {Maybe Bool
autoAddGroupOwner :: Maybe Bool
$sel:autoAddGroupOwner:GroupOwnerSetting' :: GroupOwnerSetting -> Maybe Bool
autoAddGroupOwner} -> Maybe Bool
autoAddGroupOwner) (\s :: GroupOwnerSetting
s@GroupOwnerSetting' {} Maybe Bool
a -> GroupOwnerSetting
s {$sel:autoAddGroupOwner:GroupOwnerSetting' :: Maybe Bool
autoAddGroupOwner = Maybe Bool
a} :: GroupOwnerSetting)

-- | The name of the Linux OS group whose privileges will be added to the
-- Lambda process. This field is optional.
groupOwnerSetting_groupOwner :: Lens.Lens' GroupOwnerSetting (Prelude.Maybe Prelude.Text)
groupOwnerSetting_groupOwner :: (Maybe Text -> f (Maybe Text))
-> GroupOwnerSetting -> f GroupOwnerSetting
groupOwnerSetting_groupOwner = (GroupOwnerSetting -> Maybe Text)
-> (GroupOwnerSetting -> Maybe Text -> GroupOwnerSetting)
-> Lens
     GroupOwnerSetting GroupOwnerSetting (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupOwnerSetting' {Maybe Text
groupOwner :: Maybe Text
$sel:groupOwner:GroupOwnerSetting' :: GroupOwnerSetting -> Maybe Text
groupOwner} -> Maybe Text
groupOwner) (\s :: GroupOwnerSetting
s@GroupOwnerSetting' {} Maybe Text
a -> GroupOwnerSetting
s {$sel:groupOwner:GroupOwnerSetting' :: Maybe Text
groupOwner = Maybe Text
a} :: GroupOwnerSetting)

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

instance Prelude.Hashable GroupOwnerSetting

instance Prelude.NFData GroupOwnerSetting

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