{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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. Amazon Web Services
    -- 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
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]
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
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. 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. Amazon Web Services
-- 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'
    { $sel:policyQualifiers:PolicyInformation' :: Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers =
        forall a. Maybe a
Prelude.Nothing,
      $sel:certPolicyId:PolicyInformation' :: Text
certPolicyId = Text
pCertPolicyId_
    }

-- | Modifies the given @CertPolicyId@ with a qualifier. Amazon Web Services
-- Private CA supports the certification practice statement (CPS)
-- qualifier.
policyInformation_policyQualifiers :: Lens.Lens' PolicyInformation (Prelude.Maybe (Prelude.NonEmpty PolicyQualifierInfo))
policyInformation_policyQualifiers :: Lens' PolicyInformation (Maybe (NonEmpty PolicyQualifierInfo))
policyInformation_policyQualifiers = 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) 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

-- | 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 :: Lens' PolicyInformation Text
policyInformation_certPolicyId = 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 where
  hashWithSalt :: Int -> PolicyInformation -> Int
hashWithSalt Int
_salt PolicyInformation' {Maybe (NonEmpty PolicyQualifierInfo)
Text
certPolicyId :: Text
policyQualifiers :: Maybe (NonEmpty PolicyQualifierInfo)
$sel:certPolicyId:PolicyInformation' :: PolicyInformation -> Text
$sel:policyQualifiers:PolicyInformation' :: PolicyInformation -> Maybe (NonEmpty PolicyQualifierInfo)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certPolicyId

instance Prelude.NFData PolicyInformation where
  rnf :: PolicyInformation -> ()
rnf PolicyInformation' {Maybe (NonEmpty PolicyQualifierInfo)
Text
certPolicyId :: Text
policyQualifiers :: Maybe (NonEmpty PolicyQualifierInfo)
$sel:certPolicyId:PolicyInformation' :: PolicyInformation -> Text
$sel:policyQualifiers:PolicyInformation' :: PolicyInformation -> Maybe (NonEmpty PolicyQualifierInfo)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty PolicyQualifierInfo)
policyQualifiers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
certPolicyId

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"PolicyQualifiers" 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 (NonEmpty PolicyQualifierInfo)
policyQualifiers,
            forall a. a -> Maybe a
Prelude.Just (Key
"CertPolicyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
certPolicyId)
          ]
      )