{-# 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.APIGateway.Types.MutualTlsAuthentication
-- 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.APIGateway.Types.MutualTlsAuthentication 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 mutual TLS authentication configuration for a custom domain name. If
-- specified, API Gateway performs two-way authentication between the
-- client and the server. Clients must present a trusted certificate to
-- access your API.
--
-- /See:/ 'newMutualTlsAuthentication' smart constructor.
data MutualTlsAuthentication = MutualTlsAuthentication'
  { -- | An Amazon S3 URL that specifies the truststore for mutual TLS
    -- authentication, for example @s3:\/\/bucket-name\/key-name@. The
    -- truststore can contain certificates from public or private certificate
    -- authorities. To update the truststore, upload a new version to S3, and
    -- then update your custom domain name to use the new version. To update
    -- the truststore, you must have permissions to access the S3 object.
    MutualTlsAuthentication -> Maybe Text
truststoreUri :: Prelude.Maybe Prelude.Text,
    -- | The version of the S3 object that contains your truststore. To specify a
    -- version, you must have versioning enabled for the S3 bucket.
    MutualTlsAuthentication -> Maybe Text
truststoreVersion :: Prelude.Maybe Prelude.Text,
    -- | A list of warnings that API Gateway returns while processing your
    -- truststore. Invalid certificates produce warnings. Mutual TLS is still
    -- enabled, but some clients might not be able to access your API. To
    -- resolve warnings, upload a new truststore to S3, and then update you
    -- domain name to use the new version.
    MutualTlsAuthentication -> Maybe [Text]
truststoreWarnings :: Prelude.Maybe [Prelude.Text]
  }
  deriving (MutualTlsAuthentication -> MutualTlsAuthentication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MutualTlsAuthentication -> MutualTlsAuthentication -> Bool
$c/= :: MutualTlsAuthentication -> MutualTlsAuthentication -> Bool
== :: MutualTlsAuthentication -> MutualTlsAuthentication -> Bool
$c== :: MutualTlsAuthentication -> MutualTlsAuthentication -> Bool
Prelude.Eq, ReadPrec [MutualTlsAuthentication]
ReadPrec MutualTlsAuthentication
Int -> ReadS MutualTlsAuthentication
ReadS [MutualTlsAuthentication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MutualTlsAuthentication]
$creadListPrec :: ReadPrec [MutualTlsAuthentication]
readPrec :: ReadPrec MutualTlsAuthentication
$creadPrec :: ReadPrec MutualTlsAuthentication
readList :: ReadS [MutualTlsAuthentication]
$creadList :: ReadS [MutualTlsAuthentication]
readsPrec :: Int -> ReadS MutualTlsAuthentication
$creadsPrec :: Int -> ReadS MutualTlsAuthentication
Prelude.Read, Int -> MutualTlsAuthentication -> ShowS
[MutualTlsAuthentication] -> ShowS
MutualTlsAuthentication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MutualTlsAuthentication] -> ShowS
$cshowList :: [MutualTlsAuthentication] -> ShowS
show :: MutualTlsAuthentication -> String
$cshow :: MutualTlsAuthentication -> String
showsPrec :: Int -> MutualTlsAuthentication -> ShowS
$cshowsPrec :: Int -> MutualTlsAuthentication -> ShowS
Prelude.Show, forall x. Rep MutualTlsAuthentication x -> MutualTlsAuthentication
forall x. MutualTlsAuthentication -> Rep MutualTlsAuthentication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MutualTlsAuthentication x -> MutualTlsAuthentication
$cfrom :: forall x. MutualTlsAuthentication -> Rep MutualTlsAuthentication x
Prelude.Generic)

-- |
-- Create a value of 'MutualTlsAuthentication' 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:
--
-- 'truststoreUri', 'mutualTlsAuthentication_truststoreUri' - An Amazon S3 URL that specifies the truststore for mutual TLS
-- authentication, for example @s3:\/\/bucket-name\/key-name@. The
-- truststore can contain certificates from public or private certificate
-- authorities. To update the truststore, upload a new version to S3, and
-- then update your custom domain name to use the new version. To update
-- the truststore, you must have permissions to access the S3 object.
--
-- 'truststoreVersion', 'mutualTlsAuthentication_truststoreVersion' - The version of the S3 object that contains your truststore. To specify a
-- version, you must have versioning enabled for the S3 bucket.
--
-- 'truststoreWarnings', 'mutualTlsAuthentication_truststoreWarnings' - A list of warnings that API Gateway returns while processing your
-- truststore. Invalid certificates produce warnings. Mutual TLS is still
-- enabled, but some clients might not be able to access your API. To
-- resolve warnings, upload a new truststore to S3, and then update you
-- domain name to use the new version.
newMutualTlsAuthentication ::
  MutualTlsAuthentication
newMutualTlsAuthentication :: MutualTlsAuthentication
newMutualTlsAuthentication =
  MutualTlsAuthentication'
    { $sel:truststoreUri:MutualTlsAuthentication' :: Maybe Text
truststoreUri =
        forall a. Maybe a
Prelude.Nothing,
      $sel:truststoreVersion:MutualTlsAuthentication' :: Maybe Text
truststoreVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:truststoreWarnings:MutualTlsAuthentication' :: Maybe [Text]
truststoreWarnings = forall a. Maybe a
Prelude.Nothing
    }

-- | An Amazon S3 URL that specifies the truststore for mutual TLS
-- authentication, for example @s3:\/\/bucket-name\/key-name@. The
-- truststore can contain certificates from public or private certificate
-- authorities. To update the truststore, upload a new version to S3, and
-- then update your custom domain name to use the new version. To update
-- the truststore, you must have permissions to access the S3 object.
mutualTlsAuthentication_truststoreUri :: Lens.Lens' MutualTlsAuthentication (Prelude.Maybe Prelude.Text)
mutualTlsAuthentication_truststoreUri :: Lens' MutualTlsAuthentication (Maybe Text)
mutualTlsAuthentication_truststoreUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MutualTlsAuthentication' {Maybe Text
truststoreUri :: Maybe Text
$sel:truststoreUri:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe Text
truststoreUri} -> Maybe Text
truststoreUri) (\s :: MutualTlsAuthentication
s@MutualTlsAuthentication' {} Maybe Text
a -> MutualTlsAuthentication
s {$sel:truststoreUri:MutualTlsAuthentication' :: Maybe Text
truststoreUri = Maybe Text
a} :: MutualTlsAuthentication)

-- | The version of the S3 object that contains your truststore. To specify a
-- version, you must have versioning enabled for the S3 bucket.
mutualTlsAuthentication_truststoreVersion :: Lens.Lens' MutualTlsAuthentication (Prelude.Maybe Prelude.Text)
mutualTlsAuthentication_truststoreVersion :: Lens' MutualTlsAuthentication (Maybe Text)
mutualTlsAuthentication_truststoreVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MutualTlsAuthentication' {Maybe Text
truststoreVersion :: Maybe Text
$sel:truststoreVersion:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe Text
truststoreVersion} -> Maybe Text
truststoreVersion) (\s :: MutualTlsAuthentication
s@MutualTlsAuthentication' {} Maybe Text
a -> MutualTlsAuthentication
s {$sel:truststoreVersion:MutualTlsAuthentication' :: Maybe Text
truststoreVersion = Maybe Text
a} :: MutualTlsAuthentication)

-- | A list of warnings that API Gateway returns while processing your
-- truststore. Invalid certificates produce warnings. Mutual TLS is still
-- enabled, but some clients might not be able to access your API. To
-- resolve warnings, upload a new truststore to S3, and then update you
-- domain name to use the new version.
mutualTlsAuthentication_truststoreWarnings :: Lens.Lens' MutualTlsAuthentication (Prelude.Maybe [Prelude.Text])
mutualTlsAuthentication_truststoreWarnings :: Lens' MutualTlsAuthentication (Maybe [Text])
mutualTlsAuthentication_truststoreWarnings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MutualTlsAuthentication' {Maybe [Text]
truststoreWarnings :: Maybe [Text]
$sel:truststoreWarnings:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe [Text]
truststoreWarnings} -> Maybe [Text]
truststoreWarnings) (\s :: MutualTlsAuthentication
s@MutualTlsAuthentication' {} Maybe [Text]
a -> MutualTlsAuthentication
s {$sel:truststoreWarnings:MutualTlsAuthentication' :: Maybe [Text]
truststoreWarnings = Maybe [Text]
a} :: MutualTlsAuthentication) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON MutualTlsAuthentication where
  parseJSON :: Value -> Parser MutualTlsAuthentication
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MutualTlsAuthentication"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe [Text] -> MutualTlsAuthentication
MutualTlsAuthentication'
            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
"truststoreUri")
            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
"truststoreVersion")
            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
"truststoreWarnings"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable MutualTlsAuthentication where
  hashWithSalt :: Int -> MutualTlsAuthentication -> Int
hashWithSalt Int
_salt MutualTlsAuthentication' {Maybe [Text]
Maybe Text
truststoreWarnings :: Maybe [Text]
truststoreVersion :: Maybe Text
truststoreUri :: Maybe Text
$sel:truststoreWarnings:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe [Text]
$sel:truststoreVersion:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe Text
$sel:truststoreUri:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
truststoreUri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
truststoreVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
truststoreWarnings

instance Prelude.NFData MutualTlsAuthentication where
  rnf :: MutualTlsAuthentication -> ()
rnf MutualTlsAuthentication' {Maybe [Text]
Maybe Text
truststoreWarnings :: Maybe [Text]
truststoreVersion :: Maybe Text
truststoreUri :: Maybe Text
$sel:truststoreWarnings:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe [Text]
$sel:truststoreVersion:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe Text
$sel:truststoreUri:MutualTlsAuthentication' :: MutualTlsAuthentication -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
truststoreUri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
truststoreVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
truststoreWarnings