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

import Amazonka.CertificateManagerPCA.Types.ExtendedKeyUsage
import Amazonka.CertificateManagerPCA.Types.GeneralName
import Amazonka.CertificateManagerPCA.Types.KeyUsage
import Amazonka.CertificateManagerPCA.Types.PolicyInformation
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains X.509 extension information for a certificate.
--
-- /See:/ 'newExtensions' smart constructor.
data Extensions = Extensions'
  { -- | The subject alternative name extension allows identities to be bound to
    -- the subject of the certificate. These identities may be included in
    -- addition to or in place of the identity in the subject field of the
    -- certificate.
    Extensions -> Maybe (NonEmpty GeneralName)
subjectAlternativeNames :: Prelude.Maybe (Prelude.NonEmpty GeneralName),
    Extensions -> Maybe KeyUsage
keyUsage :: Prelude.Maybe KeyUsage,
    -- | Specifies additional purposes for which the certified public key may be
    -- used other than basic purposes indicated in the @KeyUsage@ extension.
    Extensions -> Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage :: Prelude.Maybe (Prelude.NonEmpty ExtendedKeyUsage),
    -- | Contains a sequence of one or more policy information terms, each of
    -- which consists of an object identifier (OID) and optional qualifiers.
    -- For more information, see NIST\'s definition of
    -- <https://csrc.nist.gov/glossary/term/Object_Identifier Object Identifier (OID)>.
    --
    -- In an end-entity certificate, these terms indicate the policy under
    -- which the certificate was issued and the purposes for which it may be
    -- used. In a CA certificate, these terms limit the set of policies for
    -- certification paths that include this certificate.
    Extensions -> Maybe (NonEmpty PolicyInformation)
certificatePolicies :: Prelude.Maybe (Prelude.NonEmpty PolicyInformation)
  }
  deriving (Extensions -> Extensions -> Bool
(Extensions -> Extensions -> Bool)
-> (Extensions -> Extensions -> Bool) -> Eq Extensions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Extensions -> Extensions -> Bool
$c/= :: Extensions -> Extensions -> Bool
== :: Extensions -> Extensions -> Bool
$c== :: Extensions -> Extensions -> Bool
Prelude.Eq, ReadPrec [Extensions]
ReadPrec Extensions
Int -> ReadS Extensions
ReadS [Extensions]
(Int -> ReadS Extensions)
-> ReadS [Extensions]
-> ReadPrec Extensions
-> ReadPrec [Extensions]
-> Read Extensions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Extensions]
$creadListPrec :: ReadPrec [Extensions]
readPrec :: ReadPrec Extensions
$creadPrec :: ReadPrec Extensions
readList :: ReadS [Extensions]
$creadList :: ReadS [Extensions]
readsPrec :: Int -> ReadS Extensions
$creadsPrec :: Int -> ReadS Extensions
Prelude.Read, Int -> Extensions -> ShowS
[Extensions] -> ShowS
Extensions -> String
(Int -> Extensions -> ShowS)
-> (Extensions -> String)
-> ([Extensions] -> ShowS)
-> Show Extensions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Extensions] -> ShowS
$cshowList :: [Extensions] -> ShowS
show :: Extensions -> String
$cshow :: Extensions -> String
showsPrec :: Int -> Extensions -> ShowS
$cshowsPrec :: Int -> Extensions -> ShowS
Prelude.Show, (forall x. Extensions -> Rep Extensions x)
-> (forall x. Rep Extensions x -> Extensions) -> Generic Extensions
forall x. Rep Extensions x -> Extensions
forall x. Extensions -> Rep Extensions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Extensions x -> Extensions
$cfrom :: forall x. Extensions -> Rep Extensions x
Prelude.Generic)

-- |
-- Create a value of 'Extensions' 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:
--
-- 'subjectAlternativeNames', 'extensions_subjectAlternativeNames' - The subject alternative name extension allows identities to be bound to
-- the subject of the certificate. These identities may be included in
-- addition to or in place of the identity in the subject field of the
-- certificate.
--
-- 'keyUsage', 'extensions_keyUsage' - Undocumented member.
--
-- 'extendedKeyUsage', 'extensions_extendedKeyUsage' - Specifies additional purposes for which the certified public key may be
-- used other than basic purposes indicated in the @KeyUsage@ extension.
--
-- 'certificatePolicies', 'extensions_certificatePolicies' - Contains a sequence of one or more policy information terms, each of
-- which consists of an object identifier (OID) and optional qualifiers.
-- For more information, see NIST\'s definition of
-- <https://csrc.nist.gov/glossary/term/Object_Identifier Object Identifier (OID)>.
--
-- In an end-entity certificate, these terms indicate the policy under
-- which the certificate was issued and the purposes for which it may be
-- used. In a CA certificate, these terms limit the set of policies for
-- certification paths that include this certificate.
newExtensions ::
  Extensions
newExtensions :: Extensions
newExtensions =
  Extensions' :: Maybe (NonEmpty GeneralName)
-> Maybe KeyUsage
-> Maybe (NonEmpty ExtendedKeyUsage)
-> Maybe (NonEmpty PolicyInformation)
-> Extensions
Extensions'
    { $sel:subjectAlternativeNames:Extensions' :: Maybe (NonEmpty GeneralName)
subjectAlternativeNames =
        Maybe (NonEmpty GeneralName)
forall a. Maybe a
Prelude.Nothing,
      $sel:keyUsage:Extensions' :: Maybe KeyUsage
keyUsage = Maybe KeyUsage
forall a. Maybe a
Prelude.Nothing,
      $sel:extendedKeyUsage:Extensions' :: Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage = Maybe (NonEmpty ExtendedKeyUsage)
forall a. Maybe a
Prelude.Nothing,
      $sel:certificatePolicies:Extensions' :: Maybe (NonEmpty PolicyInformation)
certificatePolicies = Maybe (NonEmpty PolicyInformation)
forall a. Maybe a
Prelude.Nothing
    }

-- | The subject alternative name extension allows identities to be bound to
-- the subject of the certificate. These identities may be included in
-- addition to or in place of the identity in the subject field of the
-- certificate.
extensions_subjectAlternativeNames :: Lens.Lens' Extensions (Prelude.Maybe (Prelude.NonEmpty GeneralName))
extensions_subjectAlternativeNames :: (Maybe (NonEmpty GeneralName) -> f (Maybe (NonEmpty GeneralName)))
-> Extensions -> f Extensions
extensions_subjectAlternativeNames = (Extensions -> Maybe (NonEmpty GeneralName))
-> (Extensions -> Maybe (NonEmpty GeneralName) -> Extensions)
-> Lens
     Extensions
     Extensions
     (Maybe (NonEmpty GeneralName))
     (Maybe (NonEmpty GeneralName))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Extensions' {Maybe (NonEmpty GeneralName)
subjectAlternativeNames :: Maybe (NonEmpty GeneralName)
$sel:subjectAlternativeNames:Extensions' :: Extensions -> Maybe (NonEmpty GeneralName)
subjectAlternativeNames} -> Maybe (NonEmpty GeneralName)
subjectAlternativeNames) (\s :: Extensions
s@Extensions' {} Maybe (NonEmpty GeneralName)
a -> Extensions
s {$sel:subjectAlternativeNames:Extensions' :: Maybe (NonEmpty GeneralName)
subjectAlternativeNames = Maybe (NonEmpty GeneralName)
a} :: Extensions) ((Maybe (NonEmpty GeneralName) -> f (Maybe (NonEmpty GeneralName)))
 -> Extensions -> f Extensions)
-> ((Maybe (NonEmpty GeneralName)
     -> f (Maybe (NonEmpty GeneralName)))
    -> Maybe (NonEmpty GeneralName)
    -> f (Maybe (NonEmpty GeneralName)))
-> (Maybe (NonEmpty GeneralName)
    -> f (Maybe (NonEmpty GeneralName)))
-> Extensions
-> f Extensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty GeneralName)
  (NonEmpty GeneralName)
  (NonEmpty GeneralName)
  (NonEmpty GeneralName)
-> Iso
     (Maybe (NonEmpty GeneralName))
     (Maybe (NonEmpty GeneralName))
     (Maybe (NonEmpty GeneralName))
     (Maybe (NonEmpty GeneralName))
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 GeneralName)
  (NonEmpty GeneralName)
  (NonEmpty GeneralName)
  (NonEmpty GeneralName)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
extensions_keyUsage :: Lens.Lens' Extensions (Prelude.Maybe KeyUsage)
extensions_keyUsage :: (Maybe KeyUsage -> f (Maybe KeyUsage))
-> Extensions -> f Extensions
extensions_keyUsage = (Extensions -> Maybe KeyUsage)
-> (Extensions -> Maybe KeyUsage -> Extensions)
-> Lens Extensions Extensions (Maybe KeyUsage) (Maybe KeyUsage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Extensions' {Maybe KeyUsage
keyUsage :: Maybe KeyUsage
$sel:keyUsage:Extensions' :: Extensions -> Maybe KeyUsage
keyUsage} -> Maybe KeyUsage
keyUsage) (\s :: Extensions
s@Extensions' {} Maybe KeyUsage
a -> Extensions
s {$sel:keyUsage:Extensions' :: Maybe KeyUsage
keyUsage = Maybe KeyUsage
a} :: Extensions)

-- | Specifies additional purposes for which the certified public key may be
-- used other than basic purposes indicated in the @KeyUsage@ extension.
extensions_extendedKeyUsage :: Lens.Lens' Extensions (Prelude.Maybe (Prelude.NonEmpty ExtendedKeyUsage))
extensions_extendedKeyUsage :: (Maybe (NonEmpty ExtendedKeyUsage)
 -> f (Maybe (NonEmpty ExtendedKeyUsage)))
-> Extensions -> f Extensions
extensions_extendedKeyUsage = (Extensions -> Maybe (NonEmpty ExtendedKeyUsage))
-> (Extensions -> Maybe (NonEmpty ExtendedKeyUsage) -> Extensions)
-> Lens
     Extensions
     Extensions
     (Maybe (NonEmpty ExtendedKeyUsage))
     (Maybe (NonEmpty ExtendedKeyUsage))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Extensions' {Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage :: Maybe (NonEmpty ExtendedKeyUsage)
$sel:extendedKeyUsage:Extensions' :: Extensions -> Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage} -> Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage) (\s :: Extensions
s@Extensions' {} Maybe (NonEmpty ExtendedKeyUsage)
a -> Extensions
s {$sel:extendedKeyUsage:Extensions' :: Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage = Maybe (NonEmpty ExtendedKeyUsage)
a} :: Extensions) ((Maybe (NonEmpty ExtendedKeyUsage)
  -> f (Maybe (NonEmpty ExtendedKeyUsage)))
 -> Extensions -> f Extensions)
-> ((Maybe (NonEmpty ExtendedKeyUsage)
     -> f (Maybe (NonEmpty ExtendedKeyUsage)))
    -> Maybe (NonEmpty ExtendedKeyUsage)
    -> f (Maybe (NonEmpty ExtendedKeyUsage)))
-> (Maybe (NonEmpty ExtendedKeyUsage)
    -> f (Maybe (NonEmpty ExtendedKeyUsage)))
-> Extensions
-> f Extensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ExtendedKeyUsage)
  (NonEmpty ExtendedKeyUsage)
  (NonEmpty ExtendedKeyUsage)
  (NonEmpty ExtendedKeyUsage)
-> Iso
     (Maybe (NonEmpty ExtendedKeyUsage))
     (Maybe (NonEmpty ExtendedKeyUsage))
     (Maybe (NonEmpty ExtendedKeyUsage))
     (Maybe (NonEmpty ExtendedKeyUsage))
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 ExtendedKeyUsage)
  (NonEmpty ExtendedKeyUsage)
  (NonEmpty ExtendedKeyUsage)
  (NonEmpty ExtendedKeyUsage)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains a sequence of one or more policy information terms, each of
-- which consists of an object identifier (OID) and optional qualifiers.
-- For more information, see NIST\'s definition of
-- <https://csrc.nist.gov/glossary/term/Object_Identifier Object Identifier (OID)>.
--
-- In an end-entity certificate, these terms indicate the policy under
-- which the certificate was issued and the purposes for which it may be
-- used. In a CA certificate, these terms limit the set of policies for
-- certification paths that include this certificate.
extensions_certificatePolicies :: Lens.Lens' Extensions (Prelude.Maybe (Prelude.NonEmpty PolicyInformation))
extensions_certificatePolicies :: (Maybe (NonEmpty PolicyInformation)
 -> f (Maybe (NonEmpty PolicyInformation)))
-> Extensions -> f Extensions
extensions_certificatePolicies = (Extensions -> Maybe (NonEmpty PolicyInformation))
-> (Extensions -> Maybe (NonEmpty PolicyInformation) -> Extensions)
-> Lens
     Extensions
     Extensions
     (Maybe (NonEmpty PolicyInformation))
     (Maybe (NonEmpty PolicyInformation))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Extensions' {Maybe (NonEmpty PolicyInformation)
certificatePolicies :: Maybe (NonEmpty PolicyInformation)
$sel:certificatePolicies:Extensions' :: Extensions -> Maybe (NonEmpty PolicyInformation)
certificatePolicies} -> Maybe (NonEmpty PolicyInformation)
certificatePolicies) (\s :: Extensions
s@Extensions' {} Maybe (NonEmpty PolicyInformation)
a -> Extensions
s {$sel:certificatePolicies:Extensions' :: Maybe (NonEmpty PolicyInformation)
certificatePolicies = Maybe (NonEmpty PolicyInformation)
a} :: Extensions) ((Maybe (NonEmpty PolicyInformation)
  -> f (Maybe (NonEmpty PolicyInformation)))
 -> Extensions -> f Extensions)
-> ((Maybe (NonEmpty PolicyInformation)
     -> f (Maybe (NonEmpty PolicyInformation)))
    -> Maybe (NonEmpty PolicyInformation)
    -> f (Maybe (NonEmpty PolicyInformation)))
-> (Maybe (NonEmpty PolicyInformation)
    -> f (Maybe (NonEmpty PolicyInformation)))
-> Extensions
-> f Extensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty PolicyInformation)
  (NonEmpty PolicyInformation)
  (NonEmpty PolicyInformation)
  (NonEmpty PolicyInformation)
-> Iso
     (Maybe (NonEmpty PolicyInformation))
     (Maybe (NonEmpty PolicyInformation))
     (Maybe (NonEmpty PolicyInformation))
     (Maybe (NonEmpty PolicyInformation))
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 PolicyInformation)
  (NonEmpty PolicyInformation)
  (NonEmpty PolicyInformation)
  (NonEmpty PolicyInformation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable Extensions

instance Prelude.NFData Extensions

instance Core.ToJSON Extensions where
  toJSON :: Extensions -> Value
toJSON Extensions' {Maybe (NonEmpty ExtendedKeyUsage)
Maybe (NonEmpty GeneralName)
Maybe (NonEmpty PolicyInformation)
Maybe KeyUsage
certificatePolicies :: Maybe (NonEmpty PolicyInformation)
extendedKeyUsage :: Maybe (NonEmpty ExtendedKeyUsage)
keyUsage :: Maybe KeyUsage
subjectAlternativeNames :: Maybe (NonEmpty GeneralName)
$sel:certificatePolicies:Extensions' :: Extensions -> Maybe (NonEmpty PolicyInformation)
$sel:extendedKeyUsage:Extensions' :: Extensions -> Maybe (NonEmpty ExtendedKeyUsage)
$sel:keyUsage:Extensions' :: Extensions -> Maybe KeyUsage
$sel:subjectAlternativeNames:Extensions' :: Extensions -> Maybe (NonEmpty GeneralName)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SubjectAlternativeNames" Text -> NonEmpty GeneralName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty GeneralName -> Pair)
-> Maybe (NonEmpty GeneralName) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty GeneralName)
subjectAlternativeNames,
            (Text
"KeyUsage" Text -> KeyUsage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (KeyUsage -> Pair) -> Maybe KeyUsage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KeyUsage
keyUsage,
            (Text
"ExtendedKeyUsage" Text -> NonEmpty ExtendedKeyUsage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty ExtendedKeyUsage -> Pair)
-> Maybe (NonEmpty ExtendedKeyUsage) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ExtendedKeyUsage)
extendedKeyUsage,
            (Text
"CertificatePolicies" Text -> NonEmpty PolicyInformation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty PolicyInformation -> Pair)
-> Maybe (NonEmpty PolicyInformation) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty PolicyInformation)
certificatePolicies
          ]
      )