{-# 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.ProxyConfiguration
-- 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.ProxyConfiguration 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 for a web proxy to connect to
-- website hosts.
--
-- /See:/ 'newProxyConfiguration' smart constructor.
data ProxyConfiguration = ProxyConfiguration'
  { -- | Your secret ARN, which you can create in
    -- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html Secrets Manager>
    --
    -- The credentials are optional. You use a secret if web proxy credentials
    -- are required to connect to a website host. Amazon Kendra currently
    -- support basic authentication to connect to a web proxy server. The
    -- secret stores your credentials.
    ProxyConfiguration -> Maybe Text
credentials :: Prelude.Maybe Prelude.Text,
    -- | The name of the website host you want to connect to via a web proxy
    -- server.
    --
    -- For example, the host name of https:\/\/a.example.com\/page1.html is
    -- \"a.example.com\".
    ProxyConfiguration -> Text
host :: Prelude.Text,
    -- | The port number of the website host you want to connect to via a web
    -- proxy server.
    --
    -- For example, the port for https:\/\/a.example.com\/page1.html is 443,
    -- the standard port for HTTPS.
    ProxyConfiguration -> Natural
port :: Prelude.Natural
  }
  deriving (ProxyConfiguration -> ProxyConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProxyConfiguration -> ProxyConfiguration -> Bool
$c/= :: ProxyConfiguration -> ProxyConfiguration -> Bool
== :: ProxyConfiguration -> ProxyConfiguration -> Bool
$c== :: ProxyConfiguration -> ProxyConfiguration -> Bool
Prelude.Eq, ReadPrec [ProxyConfiguration]
ReadPrec ProxyConfiguration
Int -> ReadS ProxyConfiguration
ReadS [ProxyConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProxyConfiguration]
$creadListPrec :: ReadPrec [ProxyConfiguration]
readPrec :: ReadPrec ProxyConfiguration
$creadPrec :: ReadPrec ProxyConfiguration
readList :: ReadS [ProxyConfiguration]
$creadList :: ReadS [ProxyConfiguration]
readsPrec :: Int -> ReadS ProxyConfiguration
$creadsPrec :: Int -> ReadS ProxyConfiguration
Prelude.Read, Int -> ProxyConfiguration -> ShowS
[ProxyConfiguration] -> ShowS
ProxyConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProxyConfiguration] -> ShowS
$cshowList :: [ProxyConfiguration] -> ShowS
show :: ProxyConfiguration -> String
$cshow :: ProxyConfiguration -> String
showsPrec :: Int -> ProxyConfiguration -> ShowS
$cshowsPrec :: Int -> ProxyConfiguration -> ShowS
Prelude.Show, forall x. Rep ProxyConfiguration x -> ProxyConfiguration
forall x. ProxyConfiguration -> Rep ProxyConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProxyConfiguration x -> ProxyConfiguration
$cfrom :: forall x. ProxyConfiguration -> Rep ProxyConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ProxyConfiguration' 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:
--
-- 'credentials', 'proxyConfiguration_credentials' - Your secret ARN, which you can create in
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html Secrets Manager>
--
-- The credentials are optional. You use a secret if web proxy credentials
-- are required to connect to a website host. Amazon Kendra currently
-- support basic authentication to connect to a web proxy server. The
-- secret stores your credentials.
--
-- 'host', 'proxyConfiguration_host' - The name of the website host you want to connect to via a web proxy
-- server.
--
-- For example, the host name of https:\/\/a.example.com\/page1.html is
-- \"a.example.com\".
--
-- 'port', 'proxyConfiguration_port' - The port number of the website host you want to connect to via a web
-- proxy server.
--
-- For example, the port for https:\/\/a.example.com\/page1.html is 443,
-- the standard port for HTTPS.
newProxyConfiguration ::
  -- | 'host'
  Prelude.Text ->
  -- | 'port'
  Prelude.Natural ->
  ProxyConfiguration
newProxyConfiguration :: Text -> Natural -> ProxyConfiguration
newProxyConfiguration Text
pHost_ Natural
pPort_ =
  ProxyConfiguration'
    { $sel:credentials:ProxyConfiguration' :: Maybe Text
credentials = forall a. Maybe a
Prelude.Nothing,
      $sel:host:ProxyConfiguration' :: Text
host = Text
pHost_,
      $sel:port:ProxyConfiguration' :: Natural
port = Natural
pPort_
    }

-- | Your secret ARN, which you can create in
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html Secrets Manager>
--
-- The credentials are optional. You use a secret if web proxy credentials
-- are required to connect to a website host. Amazon Kendra currently
-- support basic authentication to connect to a web proxy server. The
-- secret stores your credentials.
proxyConfiguration_credentials :: Lens.Lens' ProxyConfiguration (Prelude.Maybe Prelude.Text)
proxyConfiguration_credentials :: Lens' ProxyConfiguration (Maybe Text)
proxyConfiguration_credentials = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProxyConfiguration' {Maybe Text
credentials :: Maybe Text
$sel:credentials:ProxyConfiguration' :: ProxyConfiguration -> Maybe Text
credentials} -> Maybe Text
credentials) (\s :: ProxyConfiguration
s@ProxyConfiguration' {} Maybe Text
a -> ProxyConfiguration
s {$sel:credentials:ProxyConfiguration' :: Maybe Text
credentials = Maybe Text
a} :: ProxyConfiguration)

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

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

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

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

instance Prelude.NFData ProxyConfiguration where
  rnf :: ProxyConfiguration -> ()
rnf ProxyConfiguration' {Natural
Maybe Text
Text
port :: Natural
host :: Text
credentials :: Maybe Text
$sel:port:ProxyConfiguration' :: ProxyConfiguration -> Natural
$sel:host:ProxyConfiguration' :: ProxyConfiguration -> Text
$sel:credentials:ProxyConfiguration' :: ProxyConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
credentials
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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

instance Data.ToJSON ProxyConfiguration where
  toJSON :: ProxyConfiguration -> Value
toJSON ProxyConfiguration' {Natural
Maybe Text
Text
port :: Natural
host :: Text
credentials :: Maybe Text
$sel:port:ProxyConfiguration' :: ProxyConfiguration -> Natural
$sel:host:ProxyConfiguration' :: ProxyConfiguration -> Text
$sel:credentials:ProxyConfiguration' :: ProxyConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Credentials" 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
credentials,
            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)
          ]
      )