{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Redshift.Types.HsmConfiguration where

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

-- | A text description of the HSM configuration.
hsmConfiguration_description :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_description :: Lens' HsmConfiguration (Maybe Text)
hsmConfiguration_description = 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 name of the Amazon Redshift HSM configuration.
hsmConfiguration_hsmConfigurationIdentifier :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_hsmConfigurationIdentifier :: Lens' HsmConfiguration (Maybe Text)
hsmConfiguration_hsmConfigurationIdentifier = 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 IP address that the Amazon Redshift cluster must use to access the
-- HSM.
hsmConfiguration_hsmIpAddress :: Lens.Lens' HsmConfiguration (Prelude.Maybe Prelude.Text)
hsmConfiguration_hsmIpAddress :: Lens' HsmConfiguration (Maybe Text)
hsmConfiguration_hsmIpAddress = 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)

-- | 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 :: Lens' HsmConfiguration (Maybe Text)
hsmConfiguration_hsmPartitionName = 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)

-- | The list of tags for the HSM configuration.
hsmConfiguration_tags :: Lens.Lens' HsmConfiguration (Prelude.Maybe [Tag])
hsmConfiguration_tags :: Lens' HsmConfiguration (Maybe [Tag])
hsmConfiguration_tags = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable HsmConfiguration where
  hashWithSalt :: Int -> HsmConfiguration -> Int
hashWithSalt Int
_salt HsmConfiguration' {Maybe [Tag]
Maybe Text
tags :: Maybe [Tag]
hsmPartitionName :: Maybe Text
hsmIpAddress :: Maybe Text
hsmConfigurationIdentifier :: Maybe Text
description :: Maybe Text
$sel:tags:HsmConfiguration' :: HsmConfiguration -> Maybe [Tag]
$sel:hsmPartitionName:HsmConfiguration' :: HsmConfiguration -> Maybe Text
$sel:hsmIpAddress:HsmConfiguration' :: HsmConfiguration -> Maybe Text
$sel:hsmConfigurationIdentifier:HsmConfiguration' :: HsmConfiguration -> Maybe Text
$sel:description:HsmConfiguration' :: HsmConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hsmConfigurationIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hsmIpAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hsmPartitionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags

instance Prelude.NFData HsmConfiguration where
  rnf :: HsmConfiguration -> ()
rnf HsmConfiguration' {Maybe [Tag]
Maybe Text
tags :: Maybe [Tag]
hsmPartitionName :: Maybe Text
hsmIpAddress :: Maybe Text
hsmConfigurationIdentifier :: Maybe Text
description :: Maybe Text
$sel:tags:HsmConfiguration' :: HsmConfiguration -> Maybe [Tag]
$sel:hsmPartitionName:HsmConfiguration' :: HsmConfiguration -> Maybe Text
$sel:hsmIpAddress:HsmConfiguration' :: HsmConfiguration -> Maybe Text
$sel:hsmConfigurationIdentifier:HsmConfiguration' :: HsmConfiguration -> Maybe Text
$sel:description:HsmConfiguration' :: HsmConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hsmConfigurationIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hsmIpAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hsmPartitionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags