{-# 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.AppRunner.Types.AuthenticationConfiguration
-- 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.AppRunner.Types.AuthenticationConfiguration 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

-- | Describes resources needed to authenticate access to some source
-- repositories. The specific resource depends on the repository provider.
--
-- /See:/ 'newAuthenticationConfiguration' smart constructor.
data AuthenticationConfiguration = AuthenticationConfiguration'
  { -- | The Amazon Resource Name (ARN) of the IAM role that grants the App
    -- Runner service access to a source repository. It\'s required for ECR
    -- image repositories (but not for ECR Public repositories).
    AuthenticationConfiguration -> Maybe Text
accessRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the App Runner connection that enables
    -- the App Runner service to connect to a source repository. It\'s required
    -- for GitHub code repositories.
    AuthenticationConfiguration -> Maybe Text
connectionArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AuthenticationConfiguration -> AuthenticationConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthenticationConfiguration -> AuthenticationConfiguration -> Bool
$c/= :: AuthenticationConfiguration -> AuthenticationConfiguration -> Bool
== :: AuthenticationConfiguration -> AuthenticationConfiguration -> Bool
$c== :: AuthenticationConfiguration -> AuthenticationConfiguration -> Bool
Prelude.Eq, ReadPrec [AuthenticationConfiguration]
ReadPrec AuthenticationConfiguration
Int -> ReadS AuthenticationConfiguration
ReadS [AuthenticationConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthenticationConfiguration]
$creadListPrec :: ReadPrec [AuthenticationConfiguration]
readPrec :: ReadPrec AuthenticationConfiguration
$creadPrec :: ReadPrec AuthenticationConfiguration
readList :: ReadS [AuthenticationConfiguration]
$creadList :: ReadS [AuthenticationConfiguration]
readsPrec :: Int -> ReadS AuthenticationConfiguration
$creadsPrec :: Int -> ReadS AuthenticationConfiguration
Prelude.Read, Int -> AuthenticationConfiguration -> ShowS
[AuthenticationConfiguration] -> ShowS
AuthenticationConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthenticationConfiguration] -> ShowS
$cshowList :: [AuthenticationConfiguration] -> ShowS
show :: AuthenticationConfiguration -> String
$cshow :: AuthenticationConfiguration -> String
showsPrec :: Int -> AuthenticationConfiguration -> ShowS
$cshowsPrec :: Int -> AuthenticationConfiguration -> ShowS
Prelude.Show, forall x.
Rep AuthenticationConfiguration x -> AuthenticationConfiguration
forall x.
AuthenticationConfiguration -> Rep AuthenticationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AuthenticationConfiguration x -> AuthenticationConfiguration
$cfrom :: forall x.
AuthenticationConfiguration -> Rep AuthenticationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AuthenticationConfiguration' 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:
--
-- 'accessRoleArn', 'authenticationConfiguration_accessRoleArn' - The Amazon Resource Name (ARN) of the IAM role that grants the App
-- Runner service access to a source repository. It\'s required for ECR
-- image repositories (but not for ECR Public repositories).
--
-- 'connectionArn', 'authenticationConfiguration_connectionArn' - The Amazon Resource Name (ARN) of the App Runner connection that enables
-- the App Runner service to connect to a source repository. It\'s required
-- for GitHub code repositories.
newAuthenticationConfiguration ::
  AuthenticationConfiguration
newAuthenticationConfiguration :: AuthenticationConfiguration
newAuthenticationConfiguration =
  AuthenticationConfiguration'
    { $sel:accessRoleArn:AuthenticationConfiguration' :: Maybe Text
accessRoleArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:connectionArn:AuthenticationConfiguration' :: Maybe Text
connectionArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the IAM role that grants the App
-- Runner service access to a source repository. It\'s required for ECR
-- image repositories (but not for ECR Public repositories).
authenticationConfiguration_accessRoleArn :: Lens.Lens' AuthenticationConfiguration (Prelude.Maybe Prelude.Text)
authenticationConfiguration_accessRoleArn :: Lens' AuthenticationConfiguration (Maybe Text)
authenticationConfiguration_accessRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfiguration' {Maybe Text
accessRoleArn :: Maybe Text
$sel:accessRoleArn:AuthenticationConfiguration' :: AuthenticationConfiguration -> Maybe Text
accessRoleArn} -> Maybe Text
accessRoleArn) (\s :: AuthenticationConfiguration
s@AuthenticationConfiguration' {} Maybe Text
a -> AuthenticationConfiguration
s {$sel:accessRoleArn:AuthenticationConfiguration' :: Maybe Text
accessRoleArn = Maybe Text
a} :: AuthenticationConfiguration)

-- | The Amazon Resource Name (ARN) of the App Runner connection that enables
-- the App Runner service to connect to a source repository. It\'s required
-- for GitHub code repositories.
authenticationConfiguration_connectionArn :: Lens.Lens' AuthenticationConfiguration (Prelude.Maybe Prelude.Text)
authenticationConfiguration_connectionArn :: Lens' AuthenticationConfiguration (Maybe Text)
authenticationConfiguration_connectionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfiguration' {Maybe Text
connectionArn :: Maybe Text
$sel:connectionArn:AuthenticationConfiguration' :: AuthenticationConfiguration -> Maybe Text
connectionArn} -> Maybe Text
connectionArn) (\s :: AuthenticationConfiguration
s@AuthenticationConfiguration' {} Maybe Text
a -> AuthenticationConfiguration
s {$sel:connectionArn:AuthenticationConfiguration' :: Maybe Text
connectionArn = Maybe Text
a} :: AuthenticationConfiguration)

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

instance Prelude.Hashable AuthenticationConfiguration where
  hashWithSalt :: Int -> AuthenticationConfiguration -> Int
hashWithSalt Int
_salt AuthenticationConfiguration' {Maybe Text
connectionArn :: Maybe Text
accessRoleArn :: Maybe Text
$sel:connectionArn:AuthenticationConfiguration' :: AuthenticationConfiguration -> Maybe Text
$sel:accessRoleArn:AuthenticationConfiguration' :: AuthenticationConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accessRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionArn

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

instance Data.ToJSON AuthenticationConfiguration where
  toJSON :: AuthenticationConfiguration -> Value
toJSON AuthenticationConfiguration' {Maybe Text
connectionArn :: Maybe Text
accessRoleArn :: Maybe Text
$sel:connectionArn:AuthenticationConfiguration' :: AuthenticationConfiguration -> Maybe Text
$sel:accessRoleArn:AuthenticationConfiguration' :: AuthenticationConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AccessRoleArn" 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
accessRoleArn,
            (Key
"ConnectionArn" 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
connectionArn
          ]
      )