{-# 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.HsmConfiguration
-- 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.HsmConfiguration 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 configuration, which is an object that
-- describes to Amazon Redshift clusters the information they require to
-- connect to an HSM where they can store database encryption keys.
--
-- /See:/ 'newHsmConfiguration' smart constructor.
data HsmConfiguration = HsmConfiguration'
  { -- | The name of the Amazon Redshift HSM configuration.
    HsmConfiguration -> Maybe Text
hsmConfigurationIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The name of the partition in the HSM where the Amazon Redshift clusters
    -- will store their database encryption keys.
    HsmConfiguration -> Maybe Text
hsmPartitionName :: Prelude.Maybe Prelude.Text,
    -- | A text description of the HSM configuration.
    HsmConfiguration -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The list of tags for the HSM configuration.
    HsmConfiguration -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The IP address that the Amazon Redshift cluster must use to access the
    -- HSM.
    HsmConfiguration -> Maybe Text
hsmIpAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (HsmConfiguration -> HsmConfiguration -> Bool
(HsmConfiguration -> HsmConfiguration -> Bool)
-> (HsmConfiguration -> HsmConfiguration -> Bool)
-> Eq HsmConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HsmConfiguration -> HsmConfiguration -> Bool
$c/= :: HsmConfiguration -> HsmConfiguration -> Bool
== :: HsmConfiguration -> HsmConfiguration -> Bool
$c== :: HsmConfiguration -> HsmConfiguration -> Bool
Prelude.Eq, ReadPrec [HsmConfiguration]
ReadPrec HsmConfiguration
Int -> ReadS HsmConfiguration
ReadS [HsmConfiguration]
(Int -> ReadS HsmConfiguration)
-> ReadS [HsmConfiguration]
-> ReadPrec HsmConfiguration
-> ReadPrec [HsmConfiguration]
-> Read HsmConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HsmConfiguration]
$creadListPrec :: ReadPrec [HsmConfiguration]
readPrec :: ReadPrec HsmConfiguration
$creadPrec :: ReadPrec HsmConfiguration
readList :: ReadS [HsmConfiguration]
$creadList :: ReadS [HsmConfiguration]
readsPrec :: Int -> ReadS HsmConfiguration
$creadsPrec :: Int -> ReadS HsmConfiguration
Prelude.Read, Int -> HsmConfiguration -> ShowS
[HsmConfiguration] -> ShowS
HsmConfiguration -> String
(Int -> HsmConfiguration -> ShowS)
-> (HsmConfiguration -> String)
-> ([HsmConfiguration] -> ShowS)
-> Show HsmConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HsmConfiguration] -> ShowS
$cshowList :: [HsmConfiguration] -> ShowS
show :: HsmConfiguration -> String
$cshow :: HsmConfiguration -> String
showsPrec :: Int -> HsmConfiguration -> ShowS
$cshowsPrec :: Int -> HsmConfiguration -> ShowS
Prelude.Show, (forall x. HsmConfiguration -> Rep HsmConfiguration x)
-> (forall x. Rep HsmConfiguration x -> HsmConfiguration)
-> Generic HsmConfiguration
forall x. Rep HsmConfiguration x -> HsmConfiguration
forall x. HsmConfiguration -> Rep HsmConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HsmConfiguration x -> HsmConfiguration
$cfrom :: forall x. HsmConfiguration -> Rep HsmConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'HsmConfiguration' 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:
--
-- 'hsmConfigurationIdentifier', 'hsmConfiguration_hsmConfigurationIdentifier' - The name of the Amazon Redshift HSM configuration.
--
-- 'hsmPartitionName', 'hsmConfiguration_hsmPartitionName' - The name of the partition in the HSM where the Amazon Redshift clusters
-- will store their database encryption keys.
--
-- 'description', 'hsmConfiguration_description' - A text description of the HSM configuration.
--
-- 'tags', 'hsmConfiguration_tags' - The list of tags for the HSM configuration.
--
-- 'hsmIpAddress', 'hsmConfiguration_hsmIpAddress' - The IP address that the Amazon Redshift cluster must use to access the
-- HSM.
newHsmConfiguration ::
  HsmConfiguration
newHsmConfiguration :: HsmConfiguration
newHsmConfiguration =
  HsmConfiguration' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Maybe Text
-> HsmConfiguration
HsmConfiguration'
    { $sel:hsmConfigurationIdentifier:HsmConfiguration' :: Maybe Text
hsmConfigurationIdentifier =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hsmPartitionName:HsmConfiguration' :: Maybe Text
hsmPartitionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:HsmConfiguration' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:HsmConfiguration' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:hsmIpAddress:HsmConfiguration' :: Maybe Text
hsmIpAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the Amazon Redshift HSM configuration.
hsmConfiguration_hsmConfigurationIdentifier :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_hsmConfigurationIdentifier :: (Maybe Text -> f (Maybe Text))
-> HsmConfiguration -> f HsmConfiguration
hsmConfiguration_hsmConfigurationIdentifier = (HsmConfiguration -> Maybe Text)
-> (HsmConfiguration -> Maybe Text -> HsmConfiguration)
-> Lens HsmConfiguration HsmConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmConfiguration' {Maybe Text
hsmConfigurationIdentifier :: Maybe Text
$sel:hsmConfigurationIdentifier:HsmConfiguration' :: HsmConfiguration -> Maybe Text
hsmConfigurationIdentifier} -> Maybe Text
hsmConfigurationIdentifier) (\s :: HsmConfiguration
s@HsmConfiguration' {} Maybe Text
a -> HsmConfiguration
s {$sel:hsmConfigurationIdentifier:HsmConfiguration' :: Maybe Text
hsmConfigurationIdentifier = Maybe Text
a} :: HsmConfiguration)

-- | The name of the partition in the HSM where the Amazon Redshift clusters
-- will store their database encryption keys.
hsmConfiguration_hsmPartitionName :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_hsmPartitionName :: (Maybe Text -> f (Maybe Text))
-> HsmConfiguration -> f HsmConfiguration
hsmConfiguration_hsmPartitionName = (HsmConfiguration -> Maybe Text)
-> (HsmConfiguration -> Maybe Text -> HsmConfiguration)
-> Lens HsmConfiguration HsmConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmConfiguration' {Maybe Text
hsmPartitionName :: Maybe Text
$sel:hsmPartitionName:HsmConfiguration' :: HsmConfiguration -> Maybe Text
hsmPartitionName} -> Maybe Text
hsmPartitionName) (\s :: HsmConfiguration
s@HsmConfiguration' {} Maybe Text
a -> HsmConfiguration
s {$sel:hsmPartitionName:HsmConfiguration' :: Maybe Text
hsmPartitionName = Maybe Text
a} :: HsmConfiguration)

-- | A text description of the HSM configuration.
hsmConfiguration_description :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_description :: (Maybe Text -> f (Maybe Text))
-> HsmConfiguration -> f HsmConfiguration
hsmConfiguration_description = (HsmConfiguration -> Maybe Text)
-> (HsmConfiguration -> Maybe Text -> HsmConfiguration)
-> Lens HsmConfiguration HsmConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmConfiguration' {Maybe Text
description :: Maybe Text
$sel:description:HsmConfiguration' :: HsmConfiguration -> Maybe Text
description} -> Maybe Text
description) (\s :: HsmConfiguration
s@HsmConfiguration' {} Maybe Text
a -> HsmConfiguration
s {$sel:description:HsmConfiguration' :: Maybe Text
description = Maybe Text
a} :: HsmConfiguration)

-- | The list of tags for the HSM configuration.
hsmConfiguration_tags :: Lens.Lens' HsmConfiguration (Prelude.Maybe [Tag])
hsmConfiguration_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> HsmConfiguration -> f HsmConfiguration
hsmConfiguration_tags = (HsmConfiguration -> Maybe [Tag])
-> (HsmConfiguration -> Maybe [Tag] -> HsmConfiguration)
-> Lens
     HsmConfiguration HsmConfiguration (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmConfiguration' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:HsmConfiguration' :: HsmConfiguration -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: HsmConfiguration
s@HsmConfiguration' {} Maybe [Tag]
a -> HsmConfiguration
s {$sel:tags:HsmConfiguration' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: HsmConfiguration) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> HsmConfiguration -> f HsmConfiguration)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> HsmConfiguration
-> f HsmConfiguration
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

-- | The IP address that the Amazon Redshift cluster must use to access the
-- HSM.
hsmConfiguration_hsmIpAddress :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_hsmIpAddress :: (Maybe Text -> f (Maybe Text))
-> HsmConfiguration -> f HsmConfiguration
hsmConfiguration_hsmIpAddress = (HsmConfiguration -> Maybe Text)
-> (HsmConfiguration -> Maybe Text -> HsmConfiguration)
-> Lens HsmConfiguration HsmConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HsmConfiguration' {Maybe Text
hsmIpAddress :: Maybe Text
$sel:hsmIpAddress:HsmConfiguration' :: HsmConfiguration -> Maybe Text
hsmIpAddress} -> Maybe Text
hsmIpAddress) (\s :: HsmConfiguration
s@HsmConfiguration' {} Maybe Text
a -> HsmConfiguration
s {$sel:hsmIpAddress:HsmConfiguration' :: Maybe Text
hsmIpAddress = Maybe Text
a} :: HsmConfiguration)

instance Core.FromXML HsmConfiguration where
  parseXML :: [Node] -> Either String HsmConfiguration
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Maybe Text
-> HsmConfiguration
HsmConfiguration'
      (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Tag]
 -> Maybe Text
 -> HsmConfiguration)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe [Tag] -> Maybe Text -> HsmConfiguration)
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
"HsmConfigurationIdentifier")
      Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe [Tag] -> Maybe Text -> HsmConfiguration)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe [Tag] -> Maybe Text -> HsmConfiguration)
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
"HsmPartitionName")
      Either
  String
  (Maybe Text -> Maybe [Tag] -> Maybe Text -> HsmConfiguration)
-> Either String (Maybe Text)
-> Either String (Maybe [Tag] -> Maybe Text -> HsmConfiguration)
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
"Description")
      Either String (Maybe [Tag] -> Maybe Text -> HsmConfiguration)
-> Either String (Maybe [Tag])
-> Either String (Maybe Text -> HsmConfiguration)
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")
                  )
      Either String (Maybe Text -> HsmConfiguration)
-> Either String (Maybe Text) -> Either String HsmConfiguration
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
"HsmIpAddress")

instance Prelude.Hashable HsmConfiguration

instance Prelude.NFData HsmConfiguration