{-# 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.CertificateManagerPCA.Types.ApiPassthrough
-- 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.CertificateManagerPCA.Types.ApiPassthrough where

import Amazonka.CertificateManagerPCA.Types.ASN1Subject
import Amazonka.CertificateManagerPCA.Types.Extensions
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains X.509 certificate information to be placed in an issued
-- certificate. An @APIPassthrough@ or @APICSRPassthrough@ template variant
-- must be selected, or else this parameter is ignored.
--
-- If conflicting or duplicate certificate information is supplied from
-- other sources, ACM Private CA applies
-- <https://docs.aws.amazon.com/acm-pca/latest/userguide/UsingTemplates.html#template-order-of-operations order of operation rules>
-- to determine what information is used.
--
-- /See:/ 'newApiPassthrough' smart constructor.
data ApiPassthrough = ApiPassthrough'
  { ApiPassthrough -> Maybe ASN1Subject
subject :: Prelude.Maybe ASN1Subject,
    -- | Specifies X.509 extension information for a certificate.
    ApiPassthrough -> Maybe Extensions
extensions :: Prelude.Maybe Extensions
  }
  deriving (ApiPassthrough -> ApiPassthrough -> Bool
(ApiPassthrough -> ApiPassthrough -> Bool)
-> (ApiPassthrough -> ApiPassthrough -> Bool) -> Eq ApiPassthrough
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApiPassthrough -> ApiPassthrough -> Bool
$c/= :: ApiPassthrough -> ApiPassthrough -> Bool
== :: ApiPassthrough -> ApiPassthrough -> Bool
$c== :: ApiPassthrough -> ApiPassthrough -> Bool
Prelude.Eq, ReadPrec [ApiPassthrough]
ReadPrec ApiPassthrough
Int -> ReadS ApiPassthrough
ReadS [ApiPassthrough]
(Int -> ReadS ApiPassthrough)
-> ReadS [ApiPassthrough]
-> ReadPrec ApiPassthrough
-> ReadPrec [ApiPassthrough]
-> Read ApiPassthrough
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApiPassthrough]
$creadListPrec :: ReadPrec [ApiPassthrough]
readPrec :: ReadPrec ApiPassthrough
$creadPrec :: ReadPrec ApiPassthrough
readList :: ReadS [ApiPassthrough]
$creadList :: ReadS [ApiPassthrough]
readsPrec :: Int -> ReadS ApiPassthrough
$creadsPrec :: Int -> ReadS ApiPassthrough
Prelude.Read, Int -> ApiPassthrough -> ShowS
[ApiPassthrough] -> ShowS
ApiPassthrough -> String
(Int -> ApiPassthrough -> ShowS)
-> (ApiPassthrough -> String)
-> ([ApiPassthrough] -> ShowS)
-> Show ApiPassthrough
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApiPassthrough] -> ShowS
$cshowList :: [ApiPassthrough] -> ShowS
show :: ApiPassthrough -> String
$cshow :: ApiPassthrough -> String
showsPrec :: Int -> ApiPassthrough -> ShowS
$cshowsPrec :: Int -> ApiPassthrough -> ShowS
Prelude.Show, (forall x. ApiPassthrough -> Rep ApiPassthrough x)
-> (forall x. Rep ApiPassthrough x -> ApiPassthrough)
-> Generic ApiPassthrough
forall x. Rep ApiPassthrough x -> ApiPassthrough
forall x. ApiPassthrough -> Rep ApiPassthrough x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApiPassthrough x -> ApiPassthrough
$cfrom :: forall x. ApiPassthrough -> Rep ApiPassthrough x
Prelude.Generic)

-- |
-- Create a value of 'ApiPassthrough' 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:
--
-- 'subject', 'apiPassthrough_subject' - Undocumented member.
--
-- 'extensions', 'apiPassthrough_extensions' - Specifies X.509 extension information for a certificate.
newApiPassthrough ::
  ApiPassthrough
newApiPassthrough :: ApiPassthrough
newApiPassthrough =
  ApiPassthrough' :: Maybe ASN1Subject -> Maybe Extensions -> ApiPassthrough
ApiPassthrough'
    { $sel:subject:ApiPassthrough' :: Maybe ASN1Subject
subject = Maybe ASN1Subject
forall a. Maybe a
Prelude.Nothing,
      $sel:extensions:ApiPassthrough' :: Maybe Extensions
extensions = Maybe Extensions
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
apiPassthrough_subject :: Lens.Lens' ApiPassthrough (Prelude.Maybe ASN1Subject)
apiPassthrough_subject :: (Maybe ASN1Subject -> f (Maybe ASN1Subject))
-> ApiPassthrough -> f ApiPassthrough
apiPassthrough_subject = (ApiPassthrough -> Maybe ASN1Subject)
-> (ApiPassthrough -> Maybe ASN1Subject -> ApiPassthrough)
-> Lens
     ApiPassthrough
     ApiPassthrough
     (Maybe ASN1Subject)
     (Maybe ASN1Subject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiPassthrough' {Maybe ASN1Subject
subject :: Maybe ASN1Subject
$sel:subject:ApiPassthrough' :: ApiPassthrough -> Maybe ASN1Subject
subject} -> Maybe ASN1Subject
subject) (\s :: ApiPassthrough
s@ApiPassthrough' {} Maybe ASN1Subject
a -> ApiPassthrough
s {$sel:subject:ApiPassthrough' :: Maybe ASN1Subject
subject = Maybe ASN1Subject
a} :: ApiPassthrough)

-- | Specifies X.509 extension information for a certificate.
apiPassthrough_extensions :: Lens.Lens' ApiPassthrough (Prelude.Maybe Extensions)
apiPassthrough_extensions :: (Maybe Extensions -> f (Maybe Extensions))
-> ApiPassthrough -> f ApiPassthrough
apiPassthrough_extensions = (ApiPassthrough -> Maybe Extensions)
-> (ApiPassthrough -> Maybe Extensions -> ApiPassthrough)
-> Lens
     ApiPassthrough ApiPassthrough (Maybe Extensions) (Maybe Extensions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiPassthrough' {Maybe Extensions
extensions :: Maybe Extensions
$sel:extensions:ApiPassthrough' :: ApiPassthrough -> Maybe Extensions
extensions} -> Maybe Extensions
extensions) (\s :: ApiPassthrough
s@ApiPassthrough' {} Maybe Extensions
a -> ApiPassthrough
s {$sel:extensions:ApiPassthrough' :: Maybe Extensions
extensions = Maybe Extensions
a} :: ApiPassthrough)

instance Prelude.Hashable ApiPassthrough

instance Prelude.NFData ApiPassthrough

instance Core.ToJSON ApiPassthrough where
  toJSON :: ApiPassthrough -> Value
toJSON ApiPassthrough' {Maybe ASN1Subject
Maybe Extensions
extensions :: Maybe Extensions
subject :: Maybe ASN1Subject
$sel:extensions:ApiPassthrough' :: ApiPassthrough -> Maybe Extensions
$sel:subject:ApiPassthrough' :: ApiPassthrough -> Maybe ASN1Subject
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Subject" Text -> ASN1Subject -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ASN1Subject -> Pair) -> Maybe ASN1Subject -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ASN1Subject
subject,
            (Text
"Extensions" Text -> Extensions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Extensions -> Pair) -> Maybe Extensions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Extensions
extensions
          ]
      )