{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Greengrass.Types.GroupOwnerSetting where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:autoAddGroupOwner:GroupOwnerSetting' :: Maybe Bool
autoAddGroupOwner =
        forall a. Maybe a
Prelude.Nothing,
      $sel:groupOwner:GroupOwnerSetting' :: Maybe Text
groupOwner = 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 :: Lens' GroupOwnerSetting (Maybe Bool)
groupOwnerSetting_autoAddGroupOwner = 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 :: Lens' GroupOwnerSetting (Maybe Text)
groupOwnerSetting_groupOwner = 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 Data.FromJSON GroupOwnerSetting where
  parseJSON :: Value -> Parser GroupOwnerSetting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GroupOwnerSetting"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> GroupOwnerSetting
GroupOwnerSetting'
            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
"AutoAddGroupOwner")
            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
"GroupOwner")
      )

instance Prelude.Hashable GroupOwnerSetting where
  hashWithSalt :: Int -> GroupOwnerSetting -> Int
hashWithSalt Int
_salt GroupOwnerSetting' {Maybe Bool
Maybe Text
groupOwner :: Maybe Text
autoAddGroupOwner :: Maybe Bool
$sel:groupOwner:GroupOwnerSetting' :: GroupOwnerSetting -> Maybe Text
$sel:autoAddGroupOwner:GroupOwnerSetting' :: GroupOwnerSetting -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
autoAddGroupOwner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupOwner

instance Prelude.NFData GroupOwnerSetting where
  rnf :: GroupOwnerSetting -> ()
rnf GroupOwnerSetting' {Maybe Bool
Maybe Text
groupOwner :: Maybe Text
autoAddGroupOwner :: Maybe Bool
$sel:groupOwner:GroupOwnerSetting' :: GroupOwnerSetting -> Maybe Text
$sel:autoAddGroupOwner:GroupOwnerSetting' :: GroupOwnerSetting -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
autoAddGroupOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupOwner

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AutoAddGroupOwner" 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 Bool
autoAddGroupOwner,
            (Key
"GroupOwner" 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
groupOwner
          ]
      )