{-# 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.CloudHSMV2.Types.Certificates
-- 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.CloudHSMV2.Types.Certificates where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains one or more certificates or a certificate signing request
-- (CSR).
--
-- /See:/ 'newCertificates' smart constructor.
data Certificates = Certificates'
  { -- | The HSM hardware certificate issued (signed) by the hardware
    -- manufacturer.
    Certificates -> Maybe Text
manufacturerHardwareCertificate :: Prelude.Maybe Prelude.Text,
    -- | The cluster\'s certificate signing request (CSR). The CSR exists only
    -- when the cluster\'s state is @UNINITIALIZED@.
    Certificates -> Maybe Text
clusterCsr :: Prelude.Maybe Prelude.Text,
    -- | The HSM certificate issued (signed) by the HSM hardware.
    Certificates -> Maybe Text
hsmCertificate :: Prelude.Maybe Prelude.Text,
    -- | The cluster certificate issued (signed) by the issuing certificate
    -- authority (CA) of the cluster\'s owner.
    Certificates -> Maybe Text
clusterCertificate :: Prelude.Maybe Prelude.Text,
    -- | The HSM hardware certificate issued (signed) by AWS CloudHSM.
    Certificates -> Maybe Text
awsHardwareCertificate :: Prelude.Maybe Prelude.Text
  }
  deriving (Certificates -> Certificates -> Bool
(Certificates -> Certificates -> Bool)
-> (Certificates -> Certificates -> Bool) -> Eq Certificates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Certificates -> Certificates -> Bool
$c/= :: Certificates -> Certificates -> Bool
== :: Certificates -> Certificates -> Bool
$c== :: Certificates -> Certificates -> Bool
Prelude.Eq, ReadPrec [Certificates]
ReadPrec Certificates
Int -> ReadS Certificates
ReadS [Certificates]
(Int -> ReadS Certificates)
-> ReadS [Certificates]
-> ReadPrec Certificates
-> ReadPrec [Certificates]
-> Read Certificates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Certificates]
$creadListPrec :: ReadPrec [Certificates]
readPrec :: ReadPrec Certificates
$creadPrec :: ReadPrec Certificates
readList :: ReadS [Certificates]
$creadList :: ReadS [Certificates]
readsPrec :: Int -> ReadS Certificates
$creadsPrec :: Int -> ReadS Certificates
Prelude.Read, Int -> Certificates -> ShowS
[Certificates] -> ShowS
Certificates -> String
(Int -> Certificates -> ShowS)
-> (Certificates -> String)
-> ([Certificates] -> ShowS)
-> Show Certificates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Certificates] -> ShowS
$cshowList :: [Certificates] -> ShowS
show :: Certificates -> String
$cshow :: Certificates -> String
showsPrec :: Int -> Certificates -> ShowS
$cshowsPrec :: Int -> Certificates -> ShowS
Prelude.Show, (forall x. Certificates -> Rep Certificates x)
-> (forall x. Rep Certificates x -> Certificates)
-> Generic Certificates
forall x. Rep Certificates x -> Certificates
forall x. Certificates -> Rep Certificates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Certificates x -> Certificates
$cfrom :: forall x. Certificates -> Rep Certificates x
Prelude.Generic)

-- |
-- Create a value of 'Certificates' 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:
--
-- 'manufacturerHardwareCertificate', 'certificates_manufacturerHardwareCertificate' - The HSM hardware certificate issued (signed) by the hardware
-- manufacturer.
--
-- 'clusterCsr', 'certificates_clusterCsr' - The cluster\'s certificate signing request (CSR). The CSR exists only
-- when the cluster\'s state is @UNINITIALIZED@.
--
-- 'hsmCertificate', 'certificates_hsmCertificate' - The HSM certificate issued (signed) by the HSM hardware.
--
-- 'clusterCertificate', 'certificates_clusterCertificate' - The cluster certificate issued (signed) by the issuing certificate
-- authority (CA) of the cluster\'s owner.
--
-- 'awsHardwareCertificate', 'certificates_awsHardwareCertificate' - The HSM hardware certificate issued (signed) by AWS CloudHSM.
newCertificates ::
  Certificates
newCertificates :: Certificates
newCertificates =
  Certificates' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Certificates
Certificates'
    { $sel:manufacturerHardwareCertificate:Certificates' :: Maybe Text
manufacturerHardwareCertificate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterCsr:Certificates' :: Maybe Text
clusterCsr = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hsmCertificate:Certificates' :: Maybe Text
hsmCertificate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterCertificate:Certificates' :: Maybe Text
clusterCertificate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:awsHardwareCertificate:Certificates' :: Maybe Text
awsHardwareCertificate = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The HSM hardware certificate issued (signed) by the hardware
-- manufacturer.
certificates_manufacturerHardwareCertificate :: Lens.Lens' Certificates (Prelude.Maybe Prelude.Text)
certificates_manufacturerHardwareCertificate :: (Maybe Text -> f (Maybe Text)) -> Certificates -> f Certificates
certificates_manufacturerHardwareCertificate = (Certificates -> Maybe Text)
-> (Certificates -> Maybe Text -> Certificates)
-> Lens Certificates Certificates (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificates' {Maybe Text
manufacturerHardwareCertificate :: Maybe Text
$sel:manufacturerHardwareCertificate:Certificates' :: Certificates -> Maybe Text
manufacturerHardwareCertificate} -> Maybe Text
manufacturerHardwareCertificate) (\s :: Certificates
s@Certificates' {} Maybe Text
a -> Certificates
s {$sel:manufacturerHardwareCertificate:Certificates' :: Maybe Text
manufacturerHardwareCertificate = Maybe Text
a} :: Certificates)

-- | The cluster\'s certificate signing request (CSR). The CSR exists only
-- when the cluster\'s state is @UNINITIALIZED@.
certificates_clusterCsr :: Lens.Lens' Certificates (Prelude.Maybe Prelude.Text)
certificates_clusterCsr :: (Maybe Text -> f (Maybe Text)) -> Certificates -> f Certificates
certificates_clusterCsr = (Certificates -> Maybe Text)
-> (Certificates -> Maybe Text -> Certificates)
-> Lens Certificates Certificates (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificates' {Maybe Text
clusterCsr :: Maybe Text
$sel:clusterCsr:Certificates' :: Certificates -> Maybe Text
clusterCsr} -> Maybe Text
clusterCsr) (\s :: Certificates
s@Certificates' {} Maybe Text
a -> Certificates
s {$sel:clusterCsr:Certificates' :: Maybe Text
clusterCsr = Maybe Text
a} :: Certificates)

-- | The HSM certificate issued (signed) by the HSM hardware.
certificates_hsmCertificate :: Lens.Lens' Certificates (Prelude.Maybe Prelude.Text)
certificates_hsmCertificate :: (Maybe Text -> f (Maybe Text)) -> Certificates -> f Certificates
certificates_hsmCertificate = (Certificates -> Maybe Text)
-> (Certificates -> Maybe Text -> Certificates)
-> Lens Certificates Certificates (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificates' {Maybe Text
hsmCertificate :: Maybe Text
$sel:hsmCertificate:Certificates' :: Certificates -> Maybe Text
hsmCertificate} -> Maybe Text
hsmCertificate) (\s :: Certificates
s@Certificates' {} Maybe Text
a -> Certificates
s {$sel:hsmCertificate:Certificates' :: Maybe Text
hsmCertificate = Maybe Text
a} :: Certificates)

-- | The cluster certificate issued (signed) by the issuing certificate
-- authority (CA) of the cluster\'s owner.
certificates_clusterCertificate :: Lens.Lens' Certificates (Prelude.Maybe Prelude.Text)
certificates_clusterCertificate :: (Maybe Text -> f (Maybe Text)) -> Certificates -> f Certificates
certificates_clusterCertificate = (Certificates -> Maybe Text)
-> (Certificates -> Maybe Text -> Certificates)
-> Lens Certificates Certificates (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificates' {Maybe Text
clusterCertificate :: Maybe Text
$sel:clusterCertificate:Certificates' :: Certificates -> Maybe Text
clusterCertificate} -> Maybe Text
clusterCertificate) (\s :: Certificates
s@Certificates' {} Maybe Text
a -> Certificates
s {$sel:clusterCertificate:Certificates' :: Maybe Text
clusterCertificate = Maybe Text
a} :: Certificates)

-- | The HSM hardware certificate issued (signed) by AWS CloudHSM.
certificates_awsHardwareCertificate :: Lens.Lens' Certificates (Prelude.Maybe Prelude.Text)
certificates_awsHardwareCertificate :: (Maybe Text -> f (Maybe Text)) -> Certificates -> f Certificates
certificates_awsHardwareCertificate = (Certificates -> Maybe Text)
-> (Certificates -> Maybe Text -> Certificates)
-> Lens Certificates Certificates (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificates' {Maybe Text
awsHardwareCertificate :: Maybe Text
$sel:awsHardwareCertificate:Certificates' :: Certificates -> Maybe Text
awsHardwareCertificate} -> Maybe Text
awsHardwareCertificate) (\s :: Certificates
s@Certificates' {} Maybe Text
a -> Certificates
s {$sel:awsHardwareCertificate:Certificates' :: Maybe Text
awsHardwareCertificate = Maybe Text
a} :: Certificates)

instance Core.FromJSON Certificates where
  parseJSON :: Value -> Parser Certificates
parseJSON =
    String
-> (Object -> Parser Certificates) -> Value -> Parser Certificates
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Certificates"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Certificates
Certificates'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Certificates)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> Certificates)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ManufacturerHardwareCertificate")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> Certificates)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Certificates)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClusterCsr")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Certificates)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Certificates)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HsmCertificate")
            Parser (Maybe Text -> Maybe Text -> Certificates)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Certificates)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClusterCertificate")
            Parser (Maybe Text -> Certificates)
-> Parser (Maybe Text) -> Parser Certificates
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AwsHardwareCertificate")
      )

instance Prelude.Hashable Certificates

instance Prelude.NFData Certificates