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

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

-- | The current account setting for a resource.
--
-- /See:/ 'newSetting' smart constructor.
data Setting = Setting'
  { -- | Whether the account setting is enabled or disabled for the specified
    -- resource.
    Setting -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The Amazon ECS resource name.
    Setting -> Maybe SettingName
name :: Prelude.Maybe SettingName,
    -- | The ARN of the principal, which 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
  }
  deriving (Setting -> Setting -> Bool
(Setting -> Setting -> Bool)
-> (Setting -> Setting -> Bool) -> Eq Setting
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]
(Int -> ReadS Setting)
-> ReadS [Setting]
-> ReadPrec Setting
-> ReadPrec [Setting]
-> Read 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
(Int -> Setting -> ShowS)
-> (Setting -> String) -> ([Setting] -> ShowS) -> Show Setting
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. Setting -> Rep Setting x)
-> (forall x. Rep Setting x -> Setting) -> Generic Setting
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:
--
-- 'value', 'setting_value' - Whether the account setting is enabled or disabled for the specified
-- resource.
--
-- 'name', 'setting_name' - The Amazon ECS resource name.
--
-- 'principalArn', 'setting_principalArn' - The ARN of the principal, which can be an IAM user, IAM role, or the
-- root user. If this field is omitted, the authenticated user is assumed.
newSetting ::
  Setting
newSetting :: Setting
newSetting =
  Setting' :: Maybe Text -> Maybe SettingName -> Maybe Text -> Setting
Setting'
    { $sel:value:Setting' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Setting' :: Maybe SettingName
name = Maybe SettingName
forall a. Maybe a
Prelude.Nothing,
      $sel:principalArn:Setting' :: Maybe Text
principalArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the account setting is enabled or disabled for the specified
-- resource.
setting_value :: Lens.Lens' Setting (Prelude.Maybe Prelude.Text)
setting_value :: (Maybe Text -> f (Maybe Text)) -> Setting -> f Setting
setting_value = (Setting -> Maybe Text)
-> (Setting -> Maybe Text -> Setting)
-> Lens Setting Setting (Maybe Text) (Maybe Text)
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)

-- | The Amazon ECS resource name.
setting_name :: Lens.Lens' Setting (Prelude.Maybe SettingName)
setting_name :: (Maybe SettingName -> f (Maybe SettingName))
-> Setting -> f Setting
setting_name = (Setting -> Maybe SettingName)
-> (Setting -> Maybe SettingName -> Setting)
-> Lens Setting Setting (Maybe SettingName) (Maybe SettingName)
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, which 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 :: (Maybe Text -> f (Maybe Text)) -> Setting -> f Setting
setting_principalArn = (Setting -> Maybe Text)
-> (Setting -> Maybe Text -> Setting)
-> Lens Setting Setting (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable Setting

instance Prelude.NFData Setting