{-# 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.Config.Types.StaticValue
-- 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.Config.Types.StaticValue where

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

-- | The static value of the resource.
--
-- /See:/ 'newStaticValue' smart constructor.
data StaticValue = StaticValue'
  { -- | A list of values. For example, the ARN of the assumed role.
    StaticValue -> [Text]
values :: [Prelude.Text]
  }
  deriving (StaticValue -> StaticValue -> Bool
(StaticValue -> StaticValue -> Bool)
-> (StaticValue -> StaticValue -> Bool) -> Eq StaticValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StaticValue -> StaticValue -> Bool
$c/= :: StaticValue -> StaticValue -> Bool
== :: StaticValue -> StaticValue -> Bool
$c== :: StaticValue -> StaticValue -> Bool
Prelude.Eq, ReadPrec [StaticValue]
ReadPrec StaticValue
Int -> ReadS StaticValue
ReadS [StaticValue]
(Int -> ReadS StaticValue)
-> ReadS [StaticValue]
-> ReadPrec StaticValue
-> ReadPrec [StaticValue]
-> Read StaticValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StaticValue]
$creadListPrec :: ReadPrec [StaticValue]
readPrec :: ReadPrec StaticValue
$creadPrec :: ReadPrec StaticValue
readList :: ReadS [StaticValue]
$creadList :: ReadS [StaticValue]
readsPrec :: Int -> ReadS StaticValue
$creadsPrec :: Int -> ReadS StaticValue
Prelude.Read, Int -> StaticValue -> ShowS
[StaticValue] -> ShowS
StaticValue -> String
(Int -> StaticValue -> ShowS)
-> (StaticValue -> String)
-> ([StaticValue] -> ShowS)
-> Show StaticValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StaticValue] -> ShowS
$cshowList :: [StaticValue] -> ShowS
show :: StaticValue -> String
$cshow :: StaticValue -> String
showsPrec :: Int -> StaticValue -> ShowS
$cshowsPrec :: Int -> StaticValue -> ShowS
Prelude.Show, (forall x. StaticValue -> Rep StaticValue x)
-> (forall x. Rep StaticValue x -> StaticValue)
-> Generic StaticValue
forall x. Rep StaticValue x -> StaticValue
forall x. StaticValue -> Rep StaticValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StaticValue x -> StaticValue
$cfrom :: forall x. StaticValue -> Rep StaticValue x
Prelude.Generic)

-- |
-- Create a value of 'StaticValue' 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:
--
-- 'values', 'staticValue_values' - A list of values. For example, the ARN of the assumed role.
newStaticValue ::
  StaticValue
newStaticValue :: StaticValue
newStaticValue =
  StaticValue' :: [Text] -> StaticValue
StaticValue' {$sel:values:StaticValue' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | A list of values. For example, the ARN of the assumed role.
staticValue_values :: Lens.Lens' StaticValue [Prelude.Text]
staticValue_values :: ([Text] -> f [Text]) -> StaticValue -> f StaticValue
staticValue_values = (StaticValue -> [Text])
-> (StaticValue -> [Text] -> StaticValue)
-> Lens StaticValue StaticValue [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticValue' {[Text]
values :: [Text]
$sel:values:StaticValue' :: StaticValue -> [Text]
values} -> [Text]
values) (\s :: StaticValue
s@StaticValue' {} [Text]
a -> StaticValue
s {$sel:values:StaticValue' :: [Text]
values = [Text]
a} :: StaticValue) (([Text] -> f [Text]) -> StaticValue -> f StaticValue)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> StaticValue
-> f StaticValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON StaticValue where
  parseJSON :: Value -> Parser StaticValue
parseJSON =
    String
-> (Object -> Parser StaticValue) -> Value -> Parser StaticValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StaticValue"
      ( \Object
x ->
          [Text] -> StaticValue
StaticValue'
            ([Text] -> StaticValue) -> Parser [Text] -> Parser StaticValue
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
"Values" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable StaticValue

instance Prelude.NFData StaticValue

instance Core.ToJSON StaticValue where
  toJSON :: StaticValue -> Value
toJSON StaticValue' {[Text]
values :: [Text]
$sel:values:StaticValue' :: StaticValue -> [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
"Values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
values)]
      )