{-# 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.ECS.Types.Setting
-- 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.ECS.Types.Setting where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.SettingName
import qualified Amazonka.Prelude as Prelude

-- | The current account setting for a resource.
--
-- /See:/ 'newSetting' smart constructor.
data Setting = Setting'
  { -- | The Amazon ECS resource name.
    Setting -> Maybe SettingName
name :: Prelude.Maybe SettingName,
    -- | The ARN of the principal. It can be an IAM user, IAM role, or the root
    -- user. If this field is omitted, the authenticated user is assumed.
    Setting -> Maybe Text
principalArn :: Prelude.Maybe Prelude.Text,
    -- | Determines whether the account setting is enabled or disabled for the
    -- specified resource.
    Setting -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (Setting -> Setting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Setting -> Setting -> Bool
$c/= :: Setting -> Setting -> Bool
== :: Setting -> Setting -> Bool
$c== :: Setting -> Setting -> Bool
Prelude.Eq, ReadPrec [Setting]
ReadPrec Setting
Int -> ReadS Setting
ReadS [Setting]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Setting]
$creadListPrec :: ReadPrec [Setting]
readPrec :: ReadPrec Setting
$creadPrec :: ReadPrec Setting
readList :: ReadS [Setting]
$creadList :: ReadS [Setting]
readsPrec :: Int -> ReadS Setting
$creadsPrec :: Int -> ReadS Setting
Prelude.Read, Int -> Setting -> ShowS
[Setting] -> ShowS
Setting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Setting] -> ShowS
$cshowList :: [Setting] -> ShowS
show :: Setting -> String
$cshow :: Setting -> String
showsPrec :: Int -> Setting -> ShowS
$cshowsPrec :: Int -> Setting -> ShowS
Prelude.Show, forall x. Rep Setting x -> Setting
forall x. Setting -> Rep Setting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Setting x -> Setting
$cfrom :: forall x. Setting -> Rep Setting x
Prelude.Generic)

-- |
-- Create a value of 'Setting' 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:
--
-- 'name', 'setting_name' - The Amazon ECS resource name.
--
-- 'principalArn', 'setting_principalArn' - The ARN of the principal. It can be an IAM user, IAM role, or the root
-- user. If this field is omitted, the authenticated user is assumed.
--
-- 'value', 'setting_value' - Determines whether the account setting is enabled or disabled for the
-- specified resource.
newSetting ::
  Setting
newSetting :: Setting
newSetting =
  Setting'
    { $sel:name:Setting' :: Maybe SettingName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:principalArn:Setting' :: Maybe Text
principalArn = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Setting' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon ECS resource name.
setting_name :: Lens.Lens' Setting (Prelude.Maybe SettingName)
setting_name :: Lens' Setting (Maybe SettingName)
setting_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Setting' {Maybe SettingName
name :: Maybe SettingName
$sel:name:Setting' :: Setting -> Maybe SettingName
name} -> Maybe SettingName
name) (\s :: Setting
s@Setting' {} Maybe SettingName
a -> Setting
s {$sel:name:Setting' :: Maybe SettingName
name = Maybe SettingName
a} :: Setting)

-- | The ARN of the principal. It can be an IAM user, IAM role, or the root
-- user. If this field is omitted, the authenticated user is assumed.
setting_principalArn :: Lens.Lens' Setting (Prelude.Maybe Prelude.Text)
setting_principalArn :: Lens' Setting (Maybe Text)
setting_principalArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Setting' {Maybe Text
principalArn :: Maybe Text
$sel:principalArn:Setting' :: Setting -> Maybe Text
principalArn} -> Maybe Text
principalArn) (\s :: Setting
s@Setting' {} Maybe Text
a -> Setting
s {$sel:principalArn:Setting' :: Maybe Text
principalArn = Maybe Text
a} :: Setting)

-- | Determines whether the account setting is enabled or disabled for the
-- specified resource.
setting_value :: Lens.Lens' Setting (Prelude.Maybe Prelude.Text)
setting_value :: Lens' Setting (Maybe Text)
setting_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Setting' {Maybe Text
value :: Maybe Text
$sel:value:Setting' :: Setting -> Maybe Text
value} -> Maybe Text
value) (\s :: Setting
s@Setting' {} Maybe Text
a -> Setting
s {$sel:value:Setting' :: Maybe Text
value = Maybe Text
a} :: Setting)

instance Data.FromJSON Setting where
  parseJSON :: Value -> Parser Setting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Setting"
      ( \Object
x ->
          Maybe SettingName -> Maybe Text -> Maybe Text -> Setting
Setting'
            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
"name")
            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
"principalArn")
            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
"value")
      )

instance Prelude.Hashable Setting where
  hashWithSalt :: Int -> Setting -> Int
hashWithSalt Int
_salt Setting' {Maybe Text
Maybe SettingName
value :: Maybe Text
principalArn :: Maybe Text
name :: Maybe SettingName
$sel:value:Setting' :: Setting -> Maybe Text
$sel:principalArn:Setting' :: Setting -> Maybe Text
$sel:name:Setting' :: Setting -> Maybe SettingName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SettingName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principalArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData Setting where
  rnf :: Setting -> ()
rnf Setting' {Maybe Text
Maybe SettingName
value :: Maybe Text
principalArn :: Maybe Text
name :: Maybe SettingName
$sel:value:Setting' :: Setting -> Maybe Text
$sel:principalArn:Setting' :: Setting -> Maybe Text
$sel:name:Setting' :: Setting -> Maybe SettingName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SettingName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principalArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value