{-# 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.Kendra.Types.BasicAuthenticationConfiguration
-- 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.Kendra.Types.BasicAuthenticationConfiguration 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

-- | Provides the configuration information to connect to websites that
-- require basic user authentication.
--
-- /See:/ 'newBasicAuthenticationConfiguration' smart constructor.
data BasicAuthenticationConfiguration = BasicAuthenticationConfiguration'
  { -- | The name of the website host you want to connect to using authentication
    -- credentials.
    --
    -- For example, the host name of https:\/\/a.example.com\/page1.html is
    -- \"a.example.com\".
    BasicAuthenticationConfiguration -> Text
host :: Prelude.Text,
    -- | The port number of the website host you want to connect to using
    -- authentication credentials.
    --
    -- For example, the port for https:\/\/a.example.com\/page1.html is 443,
    -- the standard port for HTTPS.
    BasicAuthenticationConfiguration -> Natural
port :: Prelude.Natural,
    -- | Your secret ARN, which you can create in
    -- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html Secrets Manager>
    --
    -- You use a secret if basic authentication credentials are required to
    -- connect to a website. The secret stores your credentials of user name
    -- and password.
    BasicAuthenticationConfiguration -> Text
credentials :: Prelude.Text
  }
  deriving (BasicAuthenticationConfiguration
-> BasicAuthenticationConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BasicAuthenticationConfiguration
-> BasicAuthenticationConfiguration -> Bool
$c/= :: BasicAuthenticationConfiguration
-> BasicAuthenticationConfiguration -> Bool
== :: BasicAuthenticationConfiguration
-> BasicAuthenticationConfiguration -> Bool
$c== :: BasicAuthenticationConfiguration
-> BasicAuthenticationConfiguration -> Bool
Prelude.Eq, ReadPrec [BasicAuthenticationConfiguration]
ReadPrec BasicAuthenticationConfiguration
Int -> ReadS BasicAuthenticationConfiguration
ReadS [BasicAuthenticationConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BasicAuthenticationConfiguration]
$creadListPrec :: ReadPrec [BasicAuthenticationConfiguration]
readPrec :: ReadPrec BasicAuthenticationConfiguration
$creadPrec :: ReadPrec BasicAuthenticationConfiguration
readList :: ReadS [BasicAuthenticationConfiguration]
$creadList :: ReadS [BasicAuthenticationConfiguration]
readsPrec :: Int -> ReadS BasicAuthenticationConfiguration
$creadsPrec :: Int -> ReadS BasicAuthenticationConfiguration
Prelude.Read, Int -> BasicAuthenticationConfiguration -> ShowS
[BasicAuthenticationConfiguration] -> ShowS
BasicAuthenticationConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BasicAuthenticationConfiguration] -> ShowS
$cshowList :: [BasicAuthenticationConfiguration] -> ShowS
show :: BasicAuthenticationConfiguration -> String
$cshow :: BasicAuthenticationConfiguration -> String
showsPrec :: Int -> BasicAuthenticationConfiguration -> ShowS
$cshowsPrec :: Int -> BasicAuthenticationConfiguration -> ShowS
Prelude.Show, forall x.
Rep BasicAuthenticationConfiguration x
-> BasicAuthenticationConfiguration
forall x.
BasicAuthenticationConfiguration
-> Rep BasicAuthenticationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BasicAuthenticationConfiguration x
-> BasicAuthenticationConfiguration
$cfrom :: forall x.
BasicAuthenticationConfiguration
-> Rep BasicAuthenticationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'BasicAuthenticationConfiguration' 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:
--
-- 'host', 'basicAuthenticationConfiguration_host' - The name of the website host you want to connect to using authentication
-- credentials.
--
-- For example, the host name of https:\/\/a.example.com\/page1.html is
-- \"a.example.com\".
--
-- 'port', 'basicAuthenticationConfiguration_port' - The port number of the website host you want to connect to using
-- authentication credentials.
--
-- For example, the port for https:\/\/a.example.com\/page1.html is 443,
-- the standard port for HTTPS.
--
-- 'credentials', 'basicAuthenticationConfiguration_credentials' - Your secret ARN, which you can create in
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html Secrets Manager>
--
-- You use a secret if basic authentication credentials are required to
-- connect to a website. The secret stores your credentials of user name
-- and password.
newBasicAuthenticationConfiguration ::
  -- | 'host'
  Prelude.Text ->
  -- | 'port'
  Prelude.Natural ->
  -- | 'credentials'
  Prelude.Text ->
  BasicAuthenticationConfiguration
newBasicAuthenticationConfiguration :: Text -> Natural -> Text -> BasicAuthenticationConfiguration
newBasicAuthenticationConfiguration
  Text
pHost_
  Natural
pPort_
  Text
pCredentials_ =
    BasicAuthenticationConfiguration'
      { $sel:host:BasicAuthenticationConfiguration' :: Text
host = Text
pHost_,
        $sel:port:BasicAuthenticationConfiguration' :: Natural
port = Natural
pPort_,
        $sel:credentials:BasicAuthenticationConfiguration' :: Text
credentials = Text
pCredentials_
      }

-- | The name of the website host you want to connect to using authentication
-- credentials.
--
-- For example, the host name of https:\/\/a.example.com\/page1.html is
-- \"a.example.com\".
basicAuthenticationConfiguration_host :: Lens.Lens' BasicAuthenticationConfiguration Prelude.Text
basicAuthenticationConfiguration_host :: Lens' BasicAuthenticationConfiguration Text
basicAuthenticationConfiguration_host = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicAuthenticationConfiguration' {Text
host :: Text
$sel:host:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
host} -> Text
host) (\s :: BasicAuthenticationConfiguration
s@BasicAuthenticationConfiguration' {} Text
a -> BasicAuthenticationConfiguration
s {$sel:host:BasicAuthenticationConfiguration' :: Text
host = Text
a} :: BasicAuthenticationConfiguration)

-- | The port number of the website host you want to connect to using
-- authentication credentials.
--
-- For example, the port for https:\/\/a.example.com\/page1.html is 443,
-- the standard port for HTTPS.
basicAuthenticationConfiguration_port :: Lens.Lens' BasicAuthenticationConfiguration Prelude.Natural
basicAuthenticationConfiguration_port :: Lens' BasicAuthenticationConfiguration Natural
basicAuthenticationConfiguration_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicAuthenticationConfiguration' {Natural
port :: Natural
$sel:port:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Natural
port} -> Natural
port) (\s :: BasicAuthenticationConfiguration
s@BasicAuthenticationConfiguration' {} Natural
a -> BasicAuthenticationConfiguration
s {$sel:port:BasicAuthenticationConfiguration' :: Natural
port = Natural
a} :: BasicAuthenticationConfiguration)

-- | Your secret ARN, which you can create in
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html Secrets Manager>
--
-- You use a secret if basic authentication credentials are required to
-- connect to a website. The secret stores your credentials of user name
-- and password.
basicAuthenticationConfiguration_credentials :: Lens.Lens' BasicAuthenticationConfiguration Prelude.Text
basicAuthenticationConfiguration_credentials :: Lens' BasicAuthenticationConfiguration Text
basicAuthenticationConfiguration_credentials = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicAuthenticationConfiguration' {Text
credentials :: Text
$sel:credentials:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
credentials} -> Text
credentials) (\s :: BasicAuthenticationConfiguration
s@BasicAuthenticationConfiguration' {} Text
a -> BasicAuthenticationConfiguration
s {$sel:credentials:BasicAuthenticationConfiguration' :: Text
credentials = Text
a} :: BasicAuthenticationConfiguration)

instance
  Data.FromJSON
    BasicAuthenticationConfiguration
  where
  parseJSON :: Value -> Parser BasicAuthenticationConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BasicAuthenticationConfiguration"
      ( \Object
x ->
          Text -> Natural -> Text -> BasicAuthenticationConfiguration
BasicAuthenticationConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Host")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Port")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Credentials")
      )

instance
  Prelude.Hashable
    BasicAuthenticationConfiguration
  where
  hashWithSalt :: Int -> BasicAuthenticationConfiguration -> Int
hashWithSalt
    Int
_salt
    BasicAuthenticationConfiguration' {Natural
Text
credentials :: Text
port :: Natural
host :: Text
$sel:credentials:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
$sel:port:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Natural
$sel:host:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
host
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
port
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
credentials

instance
  Prelude.NFData
    BasicAuthenticationConfiguration
  where
  rnf :: BasicAuthenticationConfiguration -> ()
rnf BasicAuthenticationConfiguration' {Natural
Text
credentials :: Text
port :: Natural
host :: Text
$sel:credentials:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
$sel:port:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Natural
$sel:host:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
host
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
port
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
credentials

instance Data.ToJSON BasicAuthenticationConfiguration where
  toJSON :: BasicAuthenticationConfiguration -> Value
toJSON BasicAuthenticationConfiguration' {Natural
Text
credentials :: Text
port :: Natural
host :: Text
$sel:credentials:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
$sel:port:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Natural
$sel:host:BasicAuthenticationConfiguration' :: BasicAuthenticationConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Host" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
host),
            forall a. a -> Maybe a
Prelude.Just (Key
"Port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
port),
            forall a. a -> Maybe a
Prelude.Just (Key
"Credentials" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
credentials)
          ]
      )