{-# 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.Redshift.Types.HsmClientCertificate
-- 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.Redshift.Types.HsmClientCertificate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.Tag

-- | Returns information about an HSM client certificate. The certificate is
-- stored in a secure Hardware Storage Module (HSM), and used by the Amazon
-- Redshift cluster to encrypt data files.
--
-- /See:/ 'newHsmClientCertificate' smart constructor.
data HsmClientCertificate = HsmClientCertificate'
  { -- | The identifier of the HSM client certificate.
    HsmClientCertificate -> Maybe Text
hsmClientCertificateIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The public key that the Amazon Redshift cluster will use to connect to
    -- the HSM. You must register the public key in the HSM.
    HsmClientCertificate -> Maybe Text
hsmClientCertificatePublicKey :: Prelude.Maybe Prelude.Text,
    -- | The list of tags for the HSM client certificate.
    HsmClientCertificate -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (HsmClientCertificate -> HsmClientCertificate -> Bool
(HsmClientCertificate -> HsmClientCertificate -> Bool)
-> (HsmClientCertificate -> HsmClientCertificate -> Bool)
-> Eq HsmClientCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HsmClientCertificate -> HsmClientCertificate -> Bool
$c/= :: HsmClientCertificate -> HsmClientCertificate -> Bool
== :: HsmClientCertificate -> HsmClientCertificate -> Bool
$c== :: HsmClientCertificate -> HsmClientCertificate -> Bool
Prelude.Eq, ReadPrec [HsmClientCertificate]
ReadPrec HsmClientCertificate
Int -> ReadS HsmClientCertificate
ReadS [HsmClientCertificate]
(Int -> ReadS HsmClientCertificate)
-> ReadS [HsmClientCertificate]
-> ReadPrec HsmClientCertificate
-> ReadPrec [HsmClientCertificate]
-> Read HsmClientCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HsmClientCertificate]
$creadListPrec :: ReadPrec [HsmClientCertificate]
readPrec :: ReadPrec HsmClientCertificate
$creadPrec :: ReadPrec HsmClientCertificate
readList :: ReadS [HsmClientCertificate]
$creadList :: ReadS [HsmClientCertificate]
readsPrec :: Int -> ReadS HsmClientCertificate
$creadsPrec :: Int -> ReadS HsmClientCertificate
Prelude.Read, Int -> HsmClientCertificate -> ShowS
[HsmClientCertificate] -> ShowS
HsmClientCertificate -> String
(Int -> HsmClientCertificate -> ShowS)
-> (HsmClientCertificate -> String)
-> ([HsmClientCertificate] -> ShowS)
-> Show HsmClientCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HsmClientCertificate] -> ShowS
$cshowList :: [HsmClientCertificate] -> ShowS
show :: HsmClientCertificate -> String
$cshow :: HsmClientCertificate -> String
showsPrec :: Int -> HsmClientCertificate -> ShowS
$cshowsPrec :: Int -> HsmClientCertificate -> ShowS
Prelude.Show, (forall x. HsmClientCertificate -> Rep HsmClientCertificate x)
-> (forall x. Rep HsmClientCertificate x -> HsmClientCertificate)
-> Generic HsmClientCertificate
forall x. Rep HsmClientCertificate x -> HsmClientCertificate
forall x. HsmClientCertificate -> Rep HsmClientCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HsmClientCertificate x -> HsmClientCertificate
$cfrom :: forall x. HsmClientCertificate -> Rep HsmClientCertificate x
Prelude.Generic)

-- |
-- Create a value of 'HsmClientCertificate' 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:
--
-- 'hsmClientCertificateIdentifier', 'hsmClientCertificate_hsmClientCertificateIdentifier' - The identifier of the HSM client certificate.
--
-- 'hsmClientCertificatePublicKey', 'hsmClientCertificate_hsmClientCertificatePublicKey' - The public key that the Amazon Redshift cluster will use to connect to
-- the HSM. You must register the public key in the HSM.
--
-- 'tags', 'hsmClientCertificate_tags' - The list of tags for the HSM client certificate.
newHsmClientCertificate ::
  HsmClientCertificate
newHsmClientCertificate :: HsmClientCertificate
newHsmClientCertificate =
  HsmClientCertificate' :: Maybe Text -> Maybe Text -> Maybe [Tag] -> HsmClientCertificate
HsmClientCertificate'
    { $sel:hsmClientCertificateIdentifier:HsmClientCertificate' :: Maybe Text
hsmClientCertificateIdentifier =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hsmClientCertificatePublicKey:HsmClientCertificate' :: Maybe Text
hsmClientCertificatePublicKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:HsmClientCertificate' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the HSM client certificate.
hsmClientCertificate_hsmClientCertificateIdentifier :: Lens.Lens' HsmClientCertificate (Prelude.Maybe Prelude.Text)
hsmClientCertificate_hsmClientCertificateIdentifier :: (Maybe Text -> f (Maybe Text))
-> HsmClientCertificate -> f HsmClientCertificate
hsmClientCertificate_hsmClientCertificateIdentifier = (HsmClientCertificate -> Maybe Text)
-> (HsmClientCertificate -> Maybe Text -> HsmClientCertificate)
-> Lens
     HsmClientCertificate HsmClientCertificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmClientCertificate' {Maybe Text
hsmClientCertificateIdentifier :: Maybe Text
$sel:hsmClientCertificateIdentifier:HsmClientCertificate' :: HsmClientCertificate -> Maybe Text
hsmClientCertificateIdentifier} -> Maybe Text
hsmClientCertificateIdentifier) (\s :: HsmClientCertificate
s@HsmClientCertificate' {} Maybe Text
a -> HsmClientCertificate
s {$sel:hsmClientCertificateIdentifier:HsmClientCertificate' :: Maybe Text
hsmClientCertificateIdentifier = Maybe Text
a} :: HsmClientCertificate)

-- | The public key that the Amazon Redshift cluster will use to connect to
-- the HSM. You must register the public key in the HSM.
hsmClientCertificate_hsmClientCertificatePublicKey :: Lens.Lens' HsmClientCertificate (Prelude.Maybe Prelude.Text)
hsmClientCertificate_hsmClientCertificatePublicKey :: (Maybe Text -> f (Maybe Text))
-> HsmClientCertificate -> f HsmClientCertificate
hsmClientCertificate_hsmClientCertificatePublicKey = (HsmClientCertificate -> Maybe Text)
-> (HsmClientCertificate -> Maybe Text -> HsmClientCertificate)
-> Lens
     HsmClientCertificate HsmClientCertificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmClientCertificate' {Maybe Text
hsmClientCertificatePublicKey :: Maybe Text
$sel:hsmClientCertificatePublicKey:HsmClientCertificate' :: HsmClientCertificate -> Maybe Text
hsmClientCertificatePublicKey} -> Maybe Text
hsmClientCertificatePublicKey) (\s :: HsmClientCertificate
s@HsmClientCertificate' {} Maybe Text
a -> HsmClientCertificate
s {$sel:hsmClientCertificatePublicKey:HsmClientCertificate' :: Maybe Text
hsmClientCertificatePublicKey = Maybe Text
a} :: HsmClientCertificate)

-- | The list of tags for the HSM client certificate.
hsmClientCertificate_tags :: Lens.Lens' HsmClientCertificate (Prelude.Maybe [Tag])
hsmClientCertificate_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> HsmClientCertificate -> f HsmClientCertificate
hsmClientCertificate_tags = (HsmClientCertificate -> Maybe [Tag])
-> (HsmClientCertificate -> Maybe [Tag] -> HsmClientCertificate)
-> Lens
     HsmClientCertificate
     HsmClientCertificate
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmClientCertificate' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:HsmClientCertificate' :: HsmClientCertificate -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: HsmClientCertificate
s@HsmClientCertificate' {} Maybe [Tag]
a -> HsmClientCertificate
s {$sel:tags:HsmClientCertificate' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: HsmClientCertificate) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> HsmClientCertificate -> f HsmClientCertificate)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> HsmClientCertificate
-> f HsmClientCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML HsmClientCertificate where
  parseXML :: [Node] -> Either String HsmClientCertificate
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe [Tag] -> HsmClientCertificate
HsmClientCertificate'
      (Maybe Text -> Maybe Text -> Maybe [Tag] -> HsmClientCertificate)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe [Tag] -> HsmClientCertificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HsmClientCertificateIdentifier")
      Either String (Maybe Text -> Maybe [Tag] -> HsmClientCertificate)
-> Either String (Maybe Text)
-> Either String (Maybe [Tag] -> HsmClientCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HsmClientCertificatePublicKey")
      Either String (Maybe [Tag] -> HsmClientCertificate)
-> Either String (Maybe [Tag])
-> Either String HsmClientCertificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Tags" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Tag]))
-> Either String (Maybe [Tag])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Tag])
-> [Node] -> Either String (Maybe [Tag])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Tag]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Tag")
                  )

instance Prelude.Hashable HsmClientCertificate

instance Prelude.NFData HsmClientCertificate