{-# 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.AppSync.Types.AwsIamConfig
-- 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.AppSync.Types.AwsIamConfig where

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

-- | The Identity and Access Management configuration.
--
-- /See:/ 'newAwsIamConfig' smart constructor.
data AwsIamConfig = AwsIamConfig'
  { -- | The signing service name for Identity and Access Management
    -- authorization.
    AwsIamConfig -> Maybe Text
signingServiceName :: Prelude.Maybe Prelude.Text,
    -- | The signing region for Identity and Access Management authorization.
    AwsIamConfig -> Maybe Text
signingRegion :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsIamConfig -> AwsIamConfig -> Bool
(AwsIamConfig -> AwsIamConfig -> Bool)
-> (AwsIamConfig -> AwsIamConfig -> Bool) -> Eq AwsIamConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsIamConfig -> AwsIamConfig -> Bool
$c/= :: AwsIamConfig -> AwsIamConfig -> Bool
== :: AwsIamConfig -> AwsIamConfig -> Bool
$c== :: AwsIamConfig -> AwsIamConfig -> Bool
Prelude.Eq, ReadPrec [AwsIamConfig]
ReadPrec AwsIamConfig
Int -> ReadS AwsIamConfig
ReadS [AwsIamConfig]
(Int -> ReadS AwsIamConfig)
-> ReadS [AwsIamConfig]
-> ReadPrec AwsIamConfig
-> ReadPrec [AwsIamConfig]
-> Read AwsIamConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsIamConfig]
$creadListPrec :: ReadPrec [AwsIamConfig]
readPrec :: ReadPrec AwsIamConfig
$creadPrec :: ReadPrec AwsIamConfig
readList :: ReadS [AwsIamConfig]
$creadList :: ReadS [AwsIamConfig]
readsPrec :: Int -> ReadS AwsIamConfig
$creadsPrec :: Int -> ReadS AwsIamConfig
Prelude.Read, Int -> AwsIamConfig -> ShowS
[AwsIamConfig] -> ShowS
AwsIamConfig -> String
(Int -> AwsIamConfig -> ShowS)
-> (AwsIamConfig -> String)
-> ([AwsIamConfig] -> ShowS)
-> Show AwsIamConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsIamConfig] -> ShowS
$cshowList :: [AwsIamConfig] -> ShowS
show :: AwsIamConfig -> String
$cshow :: AwsIamConfig -> String
showsPrec :: Int -> AwsIamConfig -> ShowS
$cshowsPrec :: Int -> AwsIamConfig -> ShowS
Prelude.Show, (forall x. AwsIamConfig -> Rep AwsIamConfig x)
-> (forall x. Rep AwsIamConfig x -> AwsIamConfig)
-> Generic AwsIamConfig
forall x. Rep AwsIamConfig x -> AwsIamConfig
forall x. AwsIamConfig -> Rep AwsIamConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsIamConfig x -> AwsIamConfig
$cfrom :: forall x. AwsIamConfig -> Rep AwsIamConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsIamConfig' 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:
--
-- 'signingServiceName', 'awsIamConfig_signingServiceName' - The signing service name for Identity and Access Management
-- authorization.
--
-- 'signingRegion', 'awsIamConfig_signingRegion' - The signing region for Identity and Access Management authorization.
newAwsIamConfig ::
  AwsIamConfig
newAwsIamConfig :: AwsIamConfig
newAwsIamConfig =
  AwsIamConfig' :: Maybe Text -> Maybe Text -> AwsIamConfig
AwsIamConfig'
    { $sel:signingServiceName:AwsIamConfig' :: Maybe Text
signingServiceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:signingRegion:AwsIamConfig' :: Maybe Text
signingRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The signing service name for Identity and Access Management
-- authorization.
awsIamConfig_signingServiceName :: Lens.Lens' AwsIamConfig (Prelude.Maybe Prelude.Text)
awsIamConfig_signingServiceName :: (Maybe Text -> f (Maybe Text)) -> AwsIamConfig -> f AwsIamConfig
awsIamConfig_signingServiceName = (AwsIamConfig -> Maybe Text)
-> (AwsIamConfig -> Maybe Text -> AwsIamConfig)
-> Lens AwsIamConfig AwsIamConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamConfig' {Maybe Text
signingServiceName :: Maybe Text
$sel:signingServiceName:AwsIamConfig' :: AwsIamConfig -> Maybe Text
signingServiceName} -> Maybe Text
signingServiceName) (\s :: AwsIamConfig
s@AwsIamConfig' {} Maybe Text
a -> AwsIamConfig
s {$sel:signingServiceName:AwsIamConfig' :: Maybe Text
signingServiceName = Maybe Text
a} :: AwsIamConfig)

-- | The signing region for Identity and Access Management authorization.
awsIamConfig_signingRegion :: Lens.Lens' AwsIamConfig (Prelude.Maybe Prelude.Text)
awsIamConfig_signingRegion :: (Maybe Text -> f (Maybe Text)) -> AwsIamConfig -> f AwsIamConfig
awsIamConfig_signingRegion = (AwsIamConfig -> Maybe Text)
-> (AwsIamConfig -> Maybe Text -> AwsIamConfig)
-> Lens AwsIamConfig AwsIamConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamConfig' {Maybe Text
signingRegion :: Maybe Text
$sel:signingRegion:AwsIamConfig' :: AwsIamConfig -> Maybe Text
signingRegion} -> Maybe Text
signingRegion) (\s :: AwsIamConfig
s@AwsIamConfig' {} Maybe Text
a -> AwsIamConfig
s {$sel:signingRegion:AwsIamConfig' :: Maybe Text
signingRegion = Maybe Text
a} :: AwsIamConfig)

instance Core.FromJSON AwsIamConfig where
  parseJSON :: Value -> Parser AwsIamConfig
parseJSON =
    String
-> (Object -> Parser AwsIamConfig) -> Value -> Parser AwsIamConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsIamConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AwsIamConfig
AwsIamConfig'
            (Maybe Text -> Maybe Text -> AwsIamConfig)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AwsIamConfig)
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
"signingServiceName")
            Parser (Maybe Text -> AwsIamConfig)
-> Parser (Maybe Text) -> Parser AwsIamConfig
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
"signingRegion")
      )

instance Prelude.Hashable AwsIamConfig

instance Prelude.NFData AwsIamConfig

instance Core.ToJSON AwsIamConfig where
  toJSON :: AwsIamConfig -> Value
toJSON AwsIamConfig' {Maybe Text
signingRegion :: Maybe Text
signingServiceName :: Maybe Text
$sel:signingRegion:AwsIamConfig' :: AwsIamConfig -> Maybe Text
$sel:signingServiceName:AwsIamConfig' :: AwsIamConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"signingServiceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
signingServiceName,
            (Text
"signingRegion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
signingRegion
          ]
      )