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

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

-- | The owner setting for downloaded machine learning resources.
--
-- /See:/ 'newResourceDownloadOwnerSetting' smart constructor.
data ResourceDownloadOwnerSetting = ResourceDownloadOwnerSetting'
  { -- | The group owner of the resource. This is the name of an existing Linux
    -- OS group on the system or a GID. The group\'s permissions are added to
    -- the Lambda process.
    ResourceDownloadOwnerSetting -> Text
groupOwner :: Prelude.Text,
    -- | The permissions that the group owner has to the resource. Valid values
    -- are \'\'rw\'\' (read\/write) or \'\'ro\'\' (read-only).
    ResourceDownloadOwnerSetting -> Permission
groupPermission :: Permission
  }
  deriving (ResourceDownloadOwnerSetting
-> ResourceDownloadOwnerSetting -> Bool
(ResourceDownloadOwnerSetting
 -> ResourceDownloadOwnerSetting -> Bool)
-> (ResourceDownloadOwnerSetting
    -> ResourceDownloadOwnerSetting -> Bool)
-> Eq ResourceDownloadOwnerSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceDownloadOwnerSetting
-> ResourceDownloadOwnerSetting -> Bool
$c/= :: ResourceDownloadOwnerSetting
-> ResourceDownloadOwnerSetting -> Bool
== :: ResourceDownloadOwnerSetting
-> ResourceDownloadOwnerSetting -> Bool
$c== :: ResourceDownloadOwnerSetting
-> ResourceDownloadOwnerSetting -> Bool
Prelude.Eq, ReadPrec [ResourceDownloadOwnerSetting]
ReadPrec ResourceDownloadOwnerSetting
Int -> ReadS ResourceDownloadOwnerSetting
ReadS [ResourceDownloadOwnerSetting]
(Int -> ReadS ResourceDownloadOwnerSetting)
-> ReadS [ResourceDownloadOwnerSetting]
-> ReadPrec ResourceDownloadOwnerSetting
-> ReadPrec [ResourceDownloadOwnerSetting]
-> Read ResourceDownloadOwnerSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceDownloadOwnerSetting]
$creadListPrec :: ReadPrec [ResourceDownloadOwnerSetting]
readPrec :: ReadPrec ResourceDownloadOwnerSetting
$creadPrec :: ReadPrec ResourceDownloadOwnerSetting
readList :: ReadS [ResourceDownloadOwnerSetting]
$creadList :: ReadS [ResourceDownloadOwnerSetting]
readsPrec :: Int -> ReadS ResourceDownloadOwnerSetting
$creadsPrec :: Int -> ReadS ResourceDownloadOwnerSetting
Prelude.Read, Int -> ResourceDownloadOwnerSetting -> ShowS
[ResourceDownloadOwnerSetting] -> ShowS
ResourceDownloadOwnerSetting -> String
(Int -> ResourceDownloadOwnerSetting -> ShowS)
-> (ResourceDownloadOwnerSetting -> String)
-> ([ResourceDownloadOwnerSetting] -> ShowS)
-> Show ResourceDownloadOwnerSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceDownloadOwnerSetting] -> ShowS
$cshowList :: [ResourceDownloadOwnerSetting] -> ShowS
show :: ResourceDownloadOwnerSetting -> String
$cshow :: ResourceDownloadOwnerSetting -> String
showsPrec :: Int -> ResourceDownloadOwnerSetting -> ShowS
$cshowsPrec :: Int -> ResourceDownloadOwnerSetting -> ShowS
Prelude.Show, (forall x.
 ResourceDownloadOwnerSetting -> Rep ResourceDownloadOwnerSetting x)
-> (forall x.
    Rep ResourceDownloadOwnerSetting x -> ResourceDownloadOwnerSetting)
-> Generic ResourceDownloadOwnerSetting
forall x.
Rep ResourceDownloadOwnerSetting x -> ResourceDownloadOwnerSetting
forall x.
ResourceDownloadOwnerSetting -> Rep ResourceDownloadOwnerSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResourceDownloadOwnerSetting x -> ResourceDownloadOwnerSetting
$cfrom :: forall x.
ResourceDownloadOwnerSetting -> Rep ResourceDownloadOwnerSetting x
Prelude.Generic)

-- |
-- Create a value of 'ResourceDownloadOwnerSetting' 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:
--
-- 'groupOwner', 'resourceDownloadOwnerSetting_groupOwner' - The group owner of the resource. This is the name of an existing Linux
-- OS group on the system or a GID. The group\'s permissions are added to
-- the Lambda process.
--
-- 'groupPermission', 'resourceDownloadOwnerSetting_groupPermission' - The permissions that the group owner has to the resource. Valid values
-- are \'\'rw\'\' (read\/write) or \'\'ro\'\' (read-only).
newResourceDownloadOwnerSetting ::
  -- | 'groupOwner'
  Prelude.Text ->
  -- | 'groupPermission'
  Permission ->
  ResourceDownloadOwnerSetting
newResourceDownloadOwnerSetting :: Text -> Permission -> ResourceDownloadOwnerSetting
newResourceDownloadOwnerSetting
  Text
pGroupOwner_
  Permission
pGroupPermission_ =
    ResourceDownloadOwnerSetting' :: Text -> Permission -> ResourceDownloadOwnerSetting
ResourceDownloadOwnerSetting'
      { $sel:groupOwner:ResourceDownloadOwnerSetting' :: Text
groupOwner =
          Text
pGroupOwner_,
        $sel:groupPermission:ResourceDownloadOwnerSetting' :: Permission
groupPermission = Permission
pGroupPermission_
      }

-- | The group owner of the resource. This is the name of an existing Linux
-- OS group on the system or a GID. The group\'s permissions are added to
-- the Lambda process.
resourceDownloadOwnerSetting_groupOwner :: Lens.Lens' ResourceDownloadOwnerSetting Prelude.Text
resourceDownloadOwnerSetting_groupOwner :: (Text -> f Text)
-> ResourceDownloadOwnerSetting -> f ResourceDownloadOwnerSetting
resourceDownloadOwnerSetting_groupOwner = (ResourceDownloadOwnerSetting -> Text)
-> (ResourceDownloadOwnerSetting
    -> Text -> ResourceDownloadOwnerSetting)
-> Lens
     ResourceDownloadOwnerSetting ResourceDownloadOwnerSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDownloadOwnerSetting' {Text
groupOwner :: Text
$sel:groupOwner:ResourceDownloadOwnerSetting' :: ResourceDownloadOwnerSetting -> Text
groupOwner} -> Text
groupOwner) (\s :: ResourceDownloadOwnerSetting
s@ResourceDownloadOwnerSetting' {} Text
a -> ResourceDownloadOwnerSetting
s {$sel:groupOwner:ResourceDownloadOwnerSetting' :: Text
groupOwner = Text
a} :: ResourceDownloadOwnerSetting)

-- | The permissions that the group owner has to the resource. Valid values
-- are \'\'rw\'\' (read\/write) or \'\'ro\'\' (read-only).
resourceDownloadOwnerSetting_groupPermission :: Lens.Lens' ResourceDownloadOwnerSetting Permission
resourceDownloadOwnerSetting_groupPermission :: (Permission -> f Permission)
-> ResourceDownloadOwnerSetting -> f ResourceDownloadOwnerSetting
resourceDownloadOwnerSetting_groupPermission = (ResourceDownloadOwnerSetting -> Permission)
-> (ResourceDownloadOwnerSetting
    -> Permission -> ResourceDownloadOwnerSetting)
-> Lens
     ResourceDownloadOwnerSetting
     ResourceDownloadOwnerSetting
     Permission
     Permission
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDownloadOwnerSetting' {Permission
groupPermission :: Permission
$sel:groupPermission:ResourceDownloadOwnerSetting' :: ResourceDownloadOwnerSetting -> Permission
groupPermission} -> Permission
groupPermission) (\s :: ResourceDownloadOwnerSetting
s@ResourceDownloadOwnerSetting' {} Permission
a -> ResourceDownloadOwnerSetting
s {$sel:groupPermission:ResourceDownloadOwnerSetting' :: Permission
groupPermission = Permission
a} :: ResourceDownloadOwnerSetting)

instance Core.FromJSON ResourceDownloadOwnerSetting where
  parseJSON :: Value -> Parser ResourceDownloadOwnerSetting
parseJSON =
    String
-> (Object -> Parser ResourceDownloadOwnerSetting)
-> Value
-> Parser ResourceDownloadOwnerSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceDownloadOwnerSetting"
      ( \Object
x ->
          Text -> Permission -> ResourceDownloadOwnerSetting
ResourceDownloadOwnerSetting'
            (Text -> Permission -> ResourceDownloadOwnerSetting)
-> Parser Text
-> Parser (Permission -> ResourceDownloadOwnerSetting)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GroupOwner")
            Parser (Permission -> ResourceDownloadOwnerSetting)
-> Parser Permission -> Parser ResourceDownloadOwnerSetting
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Permission
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GroupPermission")
      )

instance
  Prelude.Hashable
    ResourceDownloadOwnerSetting

instance Prelude.NFData ResourceDownloadOwnerSetting

instance Core.ToJSON ResourceDownloadOwnerSetting where
  toJSON :: ResourceDownloadOwnerSetting -> Value
toJSON ResourceDownloadOwnerSetting' {Text
Permission
groupPermission :: Permission
groupOwner :: Text
$sel:groupPermission:ResourceDownloadOwnerSetting' :: ResourceDownloadOwnerSetting -> Permission
$sel:groupOwner:ResourceDownloadOwnerSetting' :: ResourceDownloadOwnerSetting -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupOwner" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupOwner),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"GroupPermission" Text -> Permission -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Permission
groupPermission)
          ]
      )