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

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

-- | Specifies additional purposes for which the certified public key may be
-- used other than basic purposes indicated in the @KeyUsage@ extension.
--
-- /See:/ 'newExtendedKeyUsage' smart constructor.
data ExtendedKeyUsage = ExtendedKeyUsage'
  { -- | Specifies a standard @ExtendedKeyUsage@ as defined as in
    -- <https://tools.ietf.org/html/rfc5280#section-4.2.1.12 RFC 5280>.
    ExtendedKeyUsage -> Maybe ExtendedKeyUsageType
extendedKeyUsageType :: Prelude.Maybe ExtendedKeyUsageType,
    -- | Specifies a custom @ExtendedKeyUsage@ with an object identifier (OID).
    ExtendedKeyUsage -> Maybe Text
extendedKeyUsageObjectIdentifier :: Prelude.Maybe Prelude.Text
  }
  deriving (ExtendedKeyUsage -> ExtendedKeyUsage -> Bool
(ExtendedKeyUsage -> ExtendedKeyUsage -> Bool)
-> (ExtendedKeyUsage -> ExtendedKeyUsage -> Bool)
-> Eq ExtendedKeyUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExtendedKeyUsage -> ExtendedKeyUsage -> Bool
$c/= :: ExtendedKeyUsage -> ExtendedKeyUsage -> Bool
== :: ExtendedKeyUsage -> ExtendedKeyUsage -> Bool
$c== :: ExtendedKeyUsage -> ExtendedKeyUsage -> Bool
Prelude.Eq, ReadPrec [ExtendedKeyUsage]
ReadPrec ExtendedKeyUsage
Int -> ReadS ExtendedKeyUsage
ReadS [ExtendedKeyUsage]
(Int -> ReadS ExtendedKeyUsage)
-> ReadS [ExtendedKeyUsage]
-> ReadPrec ExtendedKeyUsage
-> ReadPrec [ExtendedKeyUsage]
-> Read ExtendedKeyUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExtendedKeyUsage]
$creadListPrec :: ReadPrec [ExtendedKeyUsage]
readPrec :: ReadPrec ExtendedKeyUsage
$creadPrec :: ReadPrec ExtendedKeyUsage
readList :: ReadS [ExtendedKeyUsage]
$creadList :: ReadS [ExtendedKeyUsage]
readsPrec :: Int -> ReadS ExtendedKeyUsage
$creadsPrec :: Int -> ReadS ExtendedKeyUsage
Prelude.Read, Int -> ExtendedKeyUsage -> ShowS
[ExtendedKeyUsage] -> ShowS
ExtendedKeyUsage -> String
(Int -> ExtendedKeyUsage -> ShowS)
-> (ExtendedKeyUsage -> String)
-> ([ExtendedKeyUsage] -> ShowS)
-> Show ExtendedKeyUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExtendedKeyUsage] -> ShowS
$cshowList :: [ExtendedKeyUsage] -> ShowS
show :: ExtendedKeyUsage -> String
$cshow :: ExtendedKeyUsage -> String
showsPrec :: Int -> ExtendedKeyUsage -> ShowS
$cshowsPrec :: Int -> ExtendedKeyUsage -> ShowS
Prelude.Show, (forall x. ExtendedKeyUsage -> Rep ExtendedKeyUsage x)
-> (forall x. Rep ExtendedKeyUsage x -> ExtendedKeyUsage)
-> Generic ExtendedKeyUsage
forall x. Rep ExtendedKeyUsage x -> ExtendedKeyUsage
forall x. ExtendedKeyUsage -> Rep ExtendedKeyUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExtendedKeyUsage x -> ExtendedKeyUsage
$cfrom :: forall x. ExtendedKeyUsage -> Rep ExtendedKeyUsage x
Prelude.Generic)

-- |
-- Create a value of 'ExtendedKeyUsage' 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:
--
-- 'extendedKeyUsageType', 'extendedKeyUsage_extendedKeyUsageType' - Specifies a standard @ExtendedKeyUsage@ as defined as in
-- <https://tools.ietf.org/html/rfc5280#section-4.2.1.12 RFC 5280>.
--
-- 'extendedKeyUsageObjectIdentifier', 'extendedKeyUsage_extendedKeyUsageObjectIdentifier' - Specifies a custom @ExtendedKeyUsage@ with an object identifier (OID).
newExtendedKeyUsage ::
  ExtendedKeyUsage
newExtendedKeyUsage :: ExtendedKeyUsage
newExtendedKeyUsage =
  ExtendedKeyUsage' :: Maybe ExtendedKeyUsageType -> Maybe Text -> ExtendedKeyUsage
ExtendedKeyUsage'
    { $sel:extendedKeyUsageType:ExtendedKeyUsage' :: Maybe ExtendedKeyUsageType
extendedKeyUsageType =
        Maybe ExtendedKeyUsageType
forall a. Maybe a
Prelude.Nothing,
      $sel:extendedKeyUsageObjectIdentifier:ExtendedKeyUsage' :: Maybe Text
extendedKeyUsageObjectIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies a standard @ExtendedKeyUsage@ as defined as in
-- <https://tools.ietf.org/html/rfc5280#section-4.2.1.12 RFC 5280>.
extendedKeyUsage_extendedKeyUsageType :: Lens.Lens' ExtendedKeyUsage (Prelude.Maybe ExtendedKeyUsageType)
extendedKeyUsage_extendedKeyUsageType :: (Maybe ExtendedKeyUsageType -> f (Maybe ExtendedKeyUsageType))
-> ExtendedKeyUsage -> f ExtendedKeyUsage
extendedKeyUsage_extendedKeyUsageType = (ExtendedKeyUsage -> Maybe ExtendedKeyUsageType)
-> (ExtendedKeyUsage
    -> Maybe ExtendedKeyUsageType -> ExtendedKeyUsage)
-> Lens
     ExtendedKeyUsage
     ExtendedKeyUsage
     (Maybe ExtendedKeyUsageType)
     (Maybe ExtendedKeyUsageType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExtendedKeyUsage' {Maybe ExtendedKeyUsageType
extendedKeyUsageType :: Maybe ExtendedKeyUsageType
$sel:extendedKeyUsageType:ExtendedKeyUsage' :: ExtendedKeyUsage -> Maybe ExtendedKeyUsageType
extendedKeyUsageType} -> Maybe ExtendedKeyUsageType
extendedKeyUsageType) (\s :: ExtendedKeyUsage
s@ExtendedKeyUsage' {} Maybe ExtendedKeyUsageType
a -> ExtendedKeyUsage
s {$sel:extendedKeyUsageType:ExtendedKeyUsage' :: Maybe ExtendedKeyUsageType
extendedKeyUsageType = Maybe ExtendedKeyUsageType
a} :: ExtendedKeyUsage)

-- | Specifies a custom @ExtendedKeyUsage@ with an object identifier (OID).
extendedKeyUsage_extendedKeyUsageObjectIdentifier :: Lens.Lens' ExtendedKeyUsage (Prelude.Maybe Prelude.Text)
extendedKeyUsage_extendedKeyUsageObjectIdentifier :: (Maybe Text -> f (Maybe Text))
-> ExtendedKeyUsage -> f ExtendedKeyUsage
extendedKeyUsage_extendedKeyUsageObjectIdentifier = (ExtendedKeyUsage -> Maybe Text)
-> (ExtendedKeyUsage -> Maybe Text -> ExtendedKeyUsage)
-> Lens ExtendedKeyUsage ExtendedKeyUsage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExtendedKeyUsage' {Maybe Text
extendedKeyUsageObjectIdentifier :: Maybe Text
$sel:extendedKeyUsageObjectIdentifier:ExtendedKeyUsage' :: ExtendedKeyUsage -> Maybe Text
extendedKeyUsageObjectIdentifier} -> Maybe Text
extendedKeyUsageObjectIdentifier) (\s :: ExtendedKeyUsage
s@ExtendedKeyUsage' {} Maybe Text
a -> ExtendedKeyUsage
s {$sel:extendedKeyUsageObjectIdentifier:ExtendedKeyUsage' :: Maybe Text
extendedKeyUsageObjectIdentifier = Maybe Text
a} :: ExtendedKeyUsage)

instance Prelude.Hashable ExtendedKeyUsage

instance Prelude.NFData ExtendedKeyUsage

instance Core.ToJSON ExtendedKeyUsage where
  toJSON :: ExtendedKeyUsage -> Value
toJSON ExtendedKeyUsage' {Maybe Text
Maybe ExtendedKeyUsageType
extendedKeyUsageObjectIdentifier :: Maybe Text
extendedKeyUsageType :: Maybe ExtendedKeyUsageType
$sel:extendedKeyUsageObjectIdentifier:ExtendedKeyUsage' :: ExtendedKeyUsage -> Maybe Text
$sel:extendedKeyUsageType:ExtendedKeyUsage' :: ExtendedKeyUsage -> Maybe ExtendedKeyUsageType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ExtendedKeyUsageType" Text -> ExtendedKeyUsageType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ExtendedKeyUsageType -> Pair)
-> Maybe ExtendedKeyUsageType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExtendedKeyUsageType
extendedKeyUsageType,
            (Text
"ExtendedKeyUsageObjectIdentifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
extendedKeyUsageObjectIdentifier
          ]
      )