{-# 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.ApiGatewayV2.Types.MutualTlsAuthentication
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ApiGatewayV2.Types.MutualTlsAuthentication where

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

-- | /See:/ 'newMutualTlsAuthentication' smart constructor.
data MutualTlsAuthentication = 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 -> Maybe [Text]
truststoreWarnings :: Prelude.Maybe [Prelude.Text],
    -- | 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
  }
  deriving (MutualTlsAuthentication -> MutualTlsAuthentication -> Bool
(MutualTlsAuthentication -> MutualTlsAuthentication -> Bool)
-> (MutualTlsAuthentication -> MutualTlsAuthentication -> Bool)
-> Eq MutualTlsAuthentication
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]
(Int -> ReadS MutualTlsAuthentication)
-> ReadS [MutualTlsAuthentication]
-> ReadPrec MutualTlsAuthentication
-> ReadPrec [MutualTlsAuthentication]
-> Read 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
(Int -> MutualTlsAuthentication -> ShowS)
-> (MutualTlsAuthentication -> String)
-> ([MutualTlsAuthentication] -> ShowS)
-> Show MutualTlsAuthentication
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.
 MutualTlsAuthentication -> Rep MutualTlsAuthentication x)
-> (forall x.
    Rep MutualTlsAuthentication x -> MutualTlsAuthentication)
-> Generic MutualTlsAuthentication
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:
--
-- '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.
--
-- '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.
newMutualTlsAuthentication ::
  MutualTlsAuthentication
newMutualTlsAuthentication :: MutualTlsAuthentication
newMutualTlsAuthentication =
  MutualTlsAuthentication' :: Maybe [Text] -> Maybe Text -> Maybe Text -> MutualTlsAuthentication
MutualTlsAuthentication'
    { $sel:truststoreWarnings:MutualTlsAuthentication' :: Maybe [Text]
truststoreWarnings =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:truststoreUri:MutualTlsAuthentication' :: Maybe Text
truststoreUri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:truststoreVersion:MutualTlsAuthentication' :: Maybe Text
truststoreVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text]))
-> MutualTlsAuthentication -> f MutualTlsAuthentication
mutualTlsAuthentication_truststoreWarnings = (MutualTlsAuthentication -> Maybe [Text])
-> (MutualTlsAuthentication
    -> Maybe [Text] -> MutualTlsAuthentication)
-> Lens
     MutualTlsAuthentication
     MutualTlsAuthentication
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> MutualTlsAuthentication -> f MutualTlsAuthentication)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> MutualTlsAuthentication
-> f MutualTlsAuthentication
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> MutualTlsAuthentication -> f MutualTlsAuthentication
mutualTlsAuthentication_truststoreUri = (MutualTlsAuthentication -> Maybe Text)
-> (MutualTlsAuthentication
    -> Maybe Text -> MutualTlsAuthentication)
-> Lens
     MutualTlsAuthentication
     MutualTlsAuthentication
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> MutualTlsAuthentication -> f MutualTlsAuthentication
mutualTlsAuthentication_truststoreVersion = (MutualTlsAuthentication -> Maybe Text)
-> (MutualTlsAuthentication
    -> Maybe Text -> MutualTlsAuthentication)
-> Lens
     MutualTlsAuthentication
     MutualTlsAuthentication
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON MutualTlsAuthentication where
  parseJSON :: Value -> Parser MutualTlsAuthentication
parseJSON =
    String
-> (Object -> Parser MutualTlsAuthentication)
-> Value
-> Parser MutualTlsAuthentication
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MutualTlsAuthentication"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> Maybe Text -> MutualTlsAuthentication
MutualTlsAuthentication'
            (Maybe [Text]
 -> Maybe Text -> Maybe Text -> MutualTlsAuthentication)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe Text -> MutualTlsAuthentication)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"truststoreWarnings"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe Text -> MutualTlsAuthentication)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> MutualTlsAuthentication)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"truststoreUri")
            Parser (Maybe Text -> MutualTlsAuthentication)
-> Parser (Maybe Text) -> Parser MutualTlsAuthentication
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"truststoreVersion")
      )

instance Prelude.Hashable MutualTlsAuthentication

instance Prelude.NFData MutualTlsAuthentication