{-# 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.CertificateManager.Types.KeyUsage
-- 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.CertificateManager.Types.KeyUsage where

import Amazonka.CertificateManager.Types.KeyUsageName
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The Key Usage X.509 v3 extension defines the purpose of the public key
-- contained in the certificate.
--
-- /See:/ 'newKeyUsage' smart constructor.
data KeyUsage = KeyUsage'
  { -- | A string value that contains a Key Usage extension name.
    KeyUsage -> Maybe KeyUsageName
name :: Prelude.Maybe KeyUsageName
  }
  deriving (KeyUsage -> KeyUsage -> Bool
(KeyUsage -> KeyUsage -> Bool)
-> (KeyUsage -> KeyUsage -> Bool) -> Eq KeyUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyUsage -> KeyUsage -> Bool
$c/= :: KeyUsage -> KeyUsage -> Bool
== :: KeyUsage -> KeyUsage -> Bool
$c== :: KeyUsage -> KeyUsage -> Bool
Prelude.Eq, ReadPrec [KeyUsage]
ReadPrec KeyUsage
Int -> ReadS KeyUsage
ReadS [KeyUsage]
(Int -> ReadS KeyUsage)
-> ReadS [KeyUsage]
-> ReadPrec KeyUsage
-> ReadPrec [KeyUsage]
-> Read KeyUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyUsage]
$creadListPrec :: ReadPrec [KeyUsage]
readPrec :: ReadPrec KeyUsage
$creadPrec :: ReadPrec KeyUsage
readList :: ReadS [KeyUsage]
$creadList :: ReadS [KeyUsage]
readsPrec :: Int -> ReadS KeyUsage
$creadsPrec :: Int -> ReadS KeyUsage
Prelude.Read, Int -> KeyUsage -> ShowS
[KeyUsage] -> ShowS
KeyUsage -> String
(Int -> KeyUsage -> ShowS)
-> (KeyUsage -> String) -> ([KeyUsage] -> ShowS) -> Show KeyUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyUsage] -> ShowS
$cshowList :: [KeyUsage] -> ShowS
show :: KeyUsage -> String
$cshow :: KeyUsage -> String
showsPrec :: Int -> KeyUsage -> ShowS
$cshowsPrec :: Int -> KeyUsage -> ShowS
Prelude.Show, (forall x. KeyUsage -> Rep KeyUsage x)
-> (forall x. Rep KeyUsage x -> KeyUsage) -> Generic KeyUsage
forall x. Rep KeyUsage x -> KeyUsage
forall x. KeyUsage -> Rep KeyUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyUsage x -> KeyUsage
$cfrom :: forall x. KeyUsage -> Rep KeyUsage x
Prelude.Generic)

-- |
-- Create a value of 'KeyUsage' 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:
--
-- 'name', 'keyUsage_name' - A string value that contains a Key Usage extension name.
newKeyUsage ::
  KeyUsage
newKeyUsage :: KeyUsage
newKeyUsage = KeyUsage' :: Maybe KeyUsageName -> KeyUsage
KeyUsage' {$sel:name:KeyUsage' :: Maybe KeyUsageName
name = Maybe KeyUsageName
forall a. Maybe a
Prelude.Nothing}

-- | A string value that contains a Key Usage extension name.
keyUsage_name :: Lens.Lens' KeyUsage (Prelude.Maybe KeyUsageName)
keyUsage_name :: (Maybe KeyUsageName -> f (Maybe KeyUsageName))
-> KeyUsage -> f KeyUsage
keyUsage_name = (KeyUsage -> Maybe KeyUsageName)
-> (KeyUsage -> Maybe KeyUsageName -> KeyUsage)
-> Lens KeyUsage KeyUsage (Maybe KeyUsageName) (Maybe KeyUsageName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyUsage' {Maybe KeyUsageName
name :: Maybe KeyUsageName
$sel:name:KeyUsage' :: KeyUsage -> Maybe KeyUsageName
name} -> Maybe KeyUsageName
name) (\s :: KeyUsage
s@KeyUsage' {} Maybe KeyUsageName
a -> KeyUsage
s {$sel:name:KeyUsage' :: Maybe KeyUsageName
name = Maybe KeyUsageName
a} :: KeyUsage)

instance Core.FromJSON KeyUsage where
  parseJSON :: Value -> Parser KeyUsage
parseJSON =
    String -> (Object -> Parser KeyUsage) -> Value -> Parser KeyUsage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KeyUsage"
      (\Object
x -> Maybe KeyUsageName -> KeyUsage
KeyUsage' (Maybe KeyUsageName -> KeyUsage)
-> Parser (Maybe KeyUsageName) -> Parser KeyUsage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe KeyUsageName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name"))

instance Prelude.Hashable KeyUsage

instance Prelude.NFData KeyUsage