{-# 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.PolicyInformation
-- 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.PolicyInformation where

import Amazonka.CertificateManagerPCA.Types.PolicyQualifierInfo
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines the X.509 @CertificatePolicies@ extension.
--
-- /See:/ 'newPolicyInformation' smart constructor.
data PolicyInformation = PolicyInformation'
  { -- | Modifies the given @CertPolicyId@ with a qualifier. ACM Private CA
    -- supports the certification practice statement (CPS) qualifier.
    PolicyInformation -> Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers :: Prelude.Maybe (Prelude.NonEmpty PolicyQualifierInfo),
    -- | Specifies the object identifier (OID) of the certificate policy under
    -- which the certificate was issued. For more information, see NIST\'s
    -- definition of
    -- <https://csrc.nist.gov/glossary/term/Object_Identifier Object Identifier (OID)>.
    PolicyInformation -> Text
certPolicyId :: Prelude.Text
  }
  deriving (PolicyInformation -> PolicyInformation -> Bool
(PolicyInformation -> PolicyInformation -> Bool)
-> (PolicyInformation -> PolicyInformation -> Bool)
-> Eq PolicyInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyInformation -> PolicyInformation -> Bool
$c/= :: PolicyInformation -> PolicyInformation -> Bool
== :: PolicyInformation -> PolicyInformation -> Bool
$c== :: PolicyInformation -> PolicyInformation -> Bool
Prelude.Eq, ReadPrec [PolicyInformation]
ReadPrec PolicyInformation
Int -> ReadS PolicyInformation
ReadS [PolicyInformation]
(Int -> ReadS PolicyInformation)
-> ReadS [PolicyInformation]
-> ReadPrec PolicyInformation
-> ReadPrec [PolicyInformation]
-> Read PolicyInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyInformation]
$creadListPrec :: ReadPrec [PolicyInformation]
readPrec :: ReadPrec PolicyInformation
$creadPrec :: ReadPrec PolicyInformation
readList :: ReadS [PolicyInformation]
$creadList :: ReadS [PolicyInformation]
readsPrec :: Int -> ReadS PolicyInformation
$creadsPrec :: Int -> ReadS PolicyInformation
Prelude.Read, Int -> PolicyInformation -> ShowS
[PolicyInformation] -> ShowS
PolicyInformation -> String
(Int -> PolicyInformation -> ShowS)
-> (PolicyInformation -> String)
-> ([PolicyInformation] -> ShowS)
-> Show PolicyInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyInformation] -> ShowS
$cshowList :: [PolicyInformation] -> ShowS
show :: PolicyInformation -> String
$cshow :: PolicyInformation -> String
showsPrec :: Int -> PolicyInformation -> ShowS
$cshowsPrec :: Int -> PolicyInformation -> ShowS
Prelude.Show, (forall x. PolicyInformation -> Rep PolicyInformation x)
-> (forall x. Rep PolicyInformation x -> PolicyInformation)
-> Generic PolicyInformation
forall x. Rep PolicyInformation x -> PolicyInformation
forall x. PolicyInformation -> Rep PolicyInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyInformation x -> PolicyInformation
$cfrom :: forall x. PolicyInformation -> Rep PolicyInformation x
Prelude.Generic)

-- |
-- Create a value of 'PolicyInformation' 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:
--
-- 'policyQualifiers', 'policyInformation_policyQualifiers' - Modifies the given @CertPolicyId@ with a qualifier. ACM Private CA
-- supports the certification practice statement (CPS) qualifier.
--
-- 'certPolicyId', 'policyInformation_certPolicyId' - Specifies the object identifier (OID) of the certificate policy under
-- which the certificate was issued. For more information, see NIST\'s
-- definition of
-- <https://csrc.nist.gov/glossary/term/Object_Identifier Object Identifier (OID)>.
newPolicyInformation ::
  -- | 'certPolicyId'
  Prelude.Text ->
  PolicyInformation
newPolicyInformation :: Text -> PolicyInformation
newPolicyInformation Text
pCertPolicyId_ =
  PolicyInformation' :: Maybe (NonEmpty PolicyQualifierInfo) -> Text -> PolicyInformation
PolicyInformation'
    { $sel:policyQualifiers:PolicyInformation' :: Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers =
        Maybe (NonEmpty PolicyQualifierInfo)
forall a. Maybe a
Prelude.Nothing,
      $sel:certPolicyId:PolicyInformation' :: Text
certPolicyId = Text
pCertPolicyId_
    }

-- | Modifies the given @CertPolicyId@ with a qualifier. ACM Private CA
-- supports the certification practice statement (CPS) qualifier.
policyInformation_policyQualifiers :: Lens.Lens' PolicyInformation (Prelude.Maybe (Prelude.NonEmpty PolicyQualifierInfo))
policyInformation_policyQualifiers :: (Maybe (NonEmpty PolicyQualifierInfo)
 -> f (Maybe (NonEmpty PolicyQualifierInfo)))
-> PolicyInformation -> f PolicyInformation
policyInformation_policyQualifiers = (PolicyInformation -> Maybe (NonEmpty PolicyQualifierInfo))
-> (PolicyInformation
    -> Maybe (NonEmpty PolicyQualifierInfo) -> PolicyInformation)
-> Lens
     PolicyInformation
     PolicyInformation
     (Maybe (NonEmpty PolicyQualifierInfo))
     (Maybe (NonEmpty PolicyQualifierInfo))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyInformation' {Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers :: Maybe (NonEmpty PolicyQualifierInfo)
$sel:policyQualifiers:PolicyInformation' :: PolicyInformation -> Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers} -> Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers) (\s :: PolicyInformation
s@PolicyInformation' {} Maybe (NonEmpty PolicyQualifierInfo)
a -> PolicyInformation
s {$sel:policyQualifiers:PolicyInformation' :: Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers = Maybe (NonEmpty PolicyQualifierInfo)
a} :: PolicyInformation) ((Maybe (NonEmpty PolicyQualifierInfo)
  -> f (Maybe (NonEmpty PolicyQualifierInfo)))
 -> PolicyInformation -> f PolicyInformation)
-> ((Maybe (NonEmpty PolicyQualifierInfo)
     -> f (Maybe (NonEmpty PolicyQualifierInfo)))
    -> Maybe (NonEmpty PolicyQualifierInfo)
    -> f (Maybe (NonEmpty PolicyQualifierInfo)))
-> (Maybe (NonEmpty PolicyQualifierInfo)
    -> f (Maybe (NonEmpty PolicyQualifierInfo)))
-> PolicyInformation
-> f PolicyInformation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty PolicyQualifierInfo)
  (NonEmpty PolicyQualifierInfo)
  (NonEmpty PolicyQualifierInfo)
  (NonEmpty PolicyQualifierInfo)
-> Iso
     (Maybe (NonEmpty PolicyQualifierInfo))
     (Maybe (NonEmpty PolicyQualifierInfo))
     (Maybe (NonEmpty PolicyQualifierInfo))
     (Maybe (NonEmpty PolicyQualifierInfo))
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
  (NonEmpty PolicyQualifierInfo)
  (NonEmpty PolicyQualifierInfo)
  (NonEmpty PolicyQualifierInfo)
  (NonEmpty PolicyQualifierInfo)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the object identifier (OID) of the certificate policy under
-- which the certificate was issued. For more information, see NIST\'s
-- definition of
-- <https://csrc.nist.gov/glossary/term/Object_Identifier Object Identifier (OID)>.
policyInformation_certPolicyId :: Lens.Lens' PolicyInformation Prelude.Text
policyInformation_certPolicyId :: (Text -> f Text) -> PolicyInformation -> f PolicyInformation
policyInformation_certPolicyId = (PolicyInformation -> Text)
-> (PolicyInformation -> Text -> PolicyInformation)
-> Lens PolicyInformation PolicyInformation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyInformation' {Text
certPolicyId :: Text
$sel:certPolicyId:PolicyInformation' :: PolicyInformation -> Text
certPolicyId} -> Text
certPolicyId) (\s :: PolicyInformation
s@PolicyInformation' {} Text
a -> PolicyInformation
s {$sel:certPolicyId:PolicyInformation' :: Text
certPolicyId = Text
a} :: PolicyInformation)

instance Prelude.Hashable PolicyInformation

instance Prelude.NFData PolicyInformation

instance Core.ToJSON PolicyInformation where
  toJSON :: PolicyInformation -> Value
toJSON PolicyInformation' {Maybe (NonEmpty PolicyQualifierInfo)
Text
certPolicyId :: Text
policyQualifiers :: Maybe (NonEmpty PolicyQualifierInfo)
$sel:certPolicyId:PolicyInformation' :: PolicyInformation -> Text
$sel:policyQualifiers:PolicyInformation' :: PolicyInformation -> Maybe (NonEmpty PolicyQualifierInfo)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PolicyQualifiers" Text -> NonEmpty PolicyQualifierInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty PolicyQualifierInfo -> Pair)
-> Maybe (NonEmpty PolicyQualifierInfo) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"CertPolicyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certPolicyId)
          ]
      )