{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppSync.Types.AwsIamConfig where

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

-- | The Identity and Access Management (IAM) configuration.
--
-- /See:/ 'newAwsIamConfig' smart constructor.
data AwsIamConfig = AwsIamConfig'
  { -- | The signing Amazon Web Services Region for IAM authorization.
    AwsIamConfig -> Maybe Text
signingRegion :: Prelude.Maybe Prelude.Text,
    -- | The signing service name for IAM authorization.
    AwsIamConfig -> Maybe Text
signingServiceName :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsIamConfig -> AwsIamConfig -> Bool
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]
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
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. 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:
--
-- 'signingRegion', 'awsIamConfig_signingRegion' - The signing Amazon Web Services Region for IAM authorization.
--
-- 'signingServiceName', 'awsIamConfig_signingServiceName' - The signing service name for IAM authorization.
newAwsIamConfig ::
  AwsIamConfig
newAwsIamConfig :: AwsIamConfig
newAwsIamConfig =
  AwsIamConfig'
    { $sel:signingRegion:AwsIamConfig' :: Maybe Text
signingRegion = forall a. Maybe a
Prelude.Nothing,
      $sel:signingServiceName:AwsIamConfig' :: Maybe Text
signingServiceName = forall a. Maybe a
Prelude.Nothing
    }

-- | The signing Amazon Web Services Region for IAM authorization.
awsIamConfig_signingRegion :: Lens.Lens' AwsIamConfig (Prelude.Maybe Prelude.Text)
awsIamConfig_signingRegion :: Lens' AwsIamConfig (Maybe Text)
awsIamConfig_signingRegion = 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)

-- | The signing service name for IAM authorization.
awsIamConfig_signingServiceName :: Lens.Lens' AwsIamConfig (Prelude.Maybe Prelude.Text)
awsIamConfig_signingServiceName :: Lens' AwsIamConfig (Maybe Text)
awsIamConfig_signingServiceName = 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)

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

instance Prelude.Hashable AwsIamConfig where
  hashWithSalt :: Int -> AwsIamConfig -> Int
hashWithSalt Int
_salt AwsIamConfig' {Maybe Text
signingServiceName :: Maybe Text
signingRegion :: Maybe Text
$sel:signingServiceName:AwsIamConfig' :: AwsIamConfig -> Maybe Text
$sel:signingRegion:AwsIamConfig' :: AwsIamConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
signingRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
signingServiceName

instance Prelude.NFData AwsIamConfig where
  rnf :: AwsIamConfig -> ()
rnf AwsIamConfig' {Maybe Text
signingServiceName :: Maybe Text
signingRegion :: Maybe Text
$sel:signingServiceName:AwsIamConfig' :: AwsIamConfig -> Maybe Text
$sel:signingRegion:AwsIamConfig' :: AwsIamConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
signingRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
signingServiceName

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