{-# 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.Hsm
-- 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.Hsm where

import Amazonka.CloudHSMV2.Types.HsmState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a hardware security module (HSM) in an AWS
-- CloudHSM cluster.
--
-- /See:/ 'newHsm' smart constructor.
data Hsm = Hsm'
  { -- | A description of the HSM\'s state.
    Hsm -> Maybe Text
stateMessage :: Prelude.Maybe Prelude.Text,
    -- | The HSM\'s state.
    Hsm -> Maybe HsmState
state :: Prelude.Maybe HsmState,
    -- | The identifier (ID) of the HSM\'s elastic network interface (ENI).
    Hsm -> Maybe Text
eniId :: Prelude.Maybe Prelude.Text,
    -- | The subnet that contains the HSM\'s elastic network interface (ENI).
    Hsm -> Maybe Text
subnetId :: Prelude.Maybe Prelude.Text,
    -- | The Availability Zone that contains the HSM.
    Hsm -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The identifier (ID) of the cluster that contains the HSM.
    Hsm -> Maybe Text
clusterId :: Prelude.Maybe Prelude.Text,
    -- | The IP address of the HSM\'s elastic network interface (ENI).
    Hsm -> Maybe Text
eniIp :: Prelude.Maybe Prelude.Text,
    -- | The HSM\'s identifier (ID).
    Hsm -> Text
hsmId :: Prelude.Text
  }
  deriving (Hsm -> Hsm -> Bool
(Hsm -> Hsm -> Bool) -> (Hsm -> Hsm -> Bool) -> Eq Hsm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hsm -> Hsm -> Bool
$c/= :: Hsm -> Hsm -> Bool
== :: Hsm -> Hsm -> Bool
$c== :: Hsm -> Hsm -> Bool
Prelude.Eq, ReadPrec [Hsm]
ReadPrec Hsm
Int -> ReadS Hsm
ReadS [Hsm]
(Int -> ReadS Hsm)
-> ReadS [Hsm] -> ReadPrec Hsm -> ReadPrec [Hsm] -> Read Hsm
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Hsm]
$creadListPrec :: ReadPrec [Hsm]
readPrec :: ReadPrec Hsm
$creadPrec :: ReadPrec Hsm
readList :: ReadS [Hsm]
$creadList :: ReadS [Hsm]
readsPrec :: Int -> ReadS Hsm
$creadsPrec :: Int -> ReadS Hsm
Prelude.Read, Int -> Hsm -> ShowS
[Hsm] -> ShowS
Hsm -> String
(Int -> Hsm -> ShowS)
-> (Hsm -> String) -> ([Hsm] -> ShowS) -> Show Hsm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hsm] -> ShowS
$cshowList :: [Hsm] -> ShowS
show :: Hsm -> String
$cshow :: Hsm -> String
showsPrec :: Int -> Hsm -> ShowS
$cshowsPrec :: Int -> Hsm -> ShowS
Prelude.Show, (forall x. Hsm -> Rep Hsm x)
-> (forall x. Rep Hsm x -> Hsm) -> Generic Hsm
forall x. Rep Hsm x -> Hsm
forall x. Hsm -> Rep Hsm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Hsm x -> Hsm
$cfrom :: forall x. Hsm -> Rep Hsm x
Prelude.Generic)

-- |
-- Create a value of 'Hsm' 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:
--
-- 'stateMessage', 'hsm_stateMessage' - A description of the HSM\'s state.
--
-- 'state', 'hsm_state' - The HSM\'s state.
--
-- 'eniId', 'hsm_eniId' - The identifier (ID) of the HSM\'s elastic network interface (ENI).
--
-- 'subnetId', 'hsm_subnetId' - The subnet that contains the HSM\'s elastic network interface (ENI).
--
-- 'availabilityZone', 'hsm_availabilityZone' - The Availability Zone that contains the HSM.
--
-- 'clusterId', 'hsm_clusterId' - The identifier (ID) of the cluster that contains the HSM.
--
-- 'eniIp', 'hsm_eniIp' - The IP address of the HSM\'s elastic network interface (ENI).
--
-- 'hsmId', 'hsm_hsmId' - The HSM\'s identifier (ID).
newHsm ::
  -- | 'hsmId'
  Prelude.Text ->
  Hsm
newHsm :: Text -> Hsm
newHsm Text
pHsmId_ =
  Hsm' :: Maybe Text
-> Maybe HsmState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Hsm
Hsm'
    { $sel:stateMessage:Hsm' :: Maybe Text
stateMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Hsm' :: Maybe HsmState
state = Maybe HsmState
forall a. Maybe a
Prelude.Nothing,
      $sel:eniId:Hsm' :: Maybe Text
eniId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnetId:Hsm' :: Maybe Text
subnetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZone:Hsm' :: Maybe Text
availabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterId:Hsm' :: Maybe Text
clusterId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eniIp:Hsm' :: Maybe Text
eniIp = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hsmId:Hsm' :: Text
hsmId = Text
pHsmId_
    }

-- | A description of the HSM\'s state.
hsm_stateMessage :: Lens.Lens' Hsm (Prelude.Maybe Prelude.Text)
hsm_stateMessage :: (Maybe Text -> f (Maybe Text)) -> Hsm -> f Hsm
hsm_stateMessage = (Hsm -> Maybe Text)
-> (Hsm -> Maybe Text -> Hsm)
-> Lens Hsm Hsm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe Text
stateMessage :: Maybe Text
$sel:stateMessage:Hsm' :: Hsm -> Maybe Text
stateMessage} -> Maybe Text
stateMessage) (\s :: Hsm
s@Hsm' {} Maybe Text
a -> Hsm
s {$sel:stateMessage:Hsm' :: Maybe Text
stateMessage = Maybe Text
a} :: Hsm)

-- | The HSM\'s state.
hsm_state :: Lens.Lens' Hsm (Prelude.Maybe HsmState)
hsm_state :: (Maybe HsmState -> f (Maybe HsmState)) -> Hsm -> f Hsm
hsm_state = (Hsm -> Maybe HsmState)
-> (Hsm -> Maybe HsmState -> Hsm)
-> Lens Hsm Hsm (Maybe HsmState) (Maybe HsmState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe HsmState
state :: Maybe HsmState
$sel:state:Hsm' :: Hsm -> Maybe HsmState
state} -> Maybe HsmState
state) (\s :: Hsm
s@Hsm' {} Maybe HsmState
a -> Hsm
s {$sel:state:Hsm' :: Maybe HsmState
state = Maybe HsmState
a} :: Hsm)

-- | The identifier (ID) of the HSM\'s elastic network interface (ENI).
hsm_eniId :: Lens.Lens' Hsm (Prelude.Maybe Prelude.Text)
hsm_eniId :: (Maybe Text -> f (Maybe Text)) -> Hsm -> f Hsm
hsm_eniId = (Hsm -> Maybe Text)
-> (Hsm -> Maybe Text -> Hsm)
-> Lens Hsm Hsm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe Text
eniId :: Maybe Text
$sel:eniId:Hsm' :: Hsm -> Maybe Text
eniId} -> Maybe Text
eniId) (\s :: Hsm
s@Hsm' {} Maybe Text
a -> Hsm
s {$sel:eniId:Hsm' :: Maybe Text
eniId = Maybe Text
a} :: Hsm)

-- | The subnet that contains the HSM\'s elastic network interface (ENI).
hsm_subnetId :: Lens.Lens' Hsm (Prelude.Maybe Prelude.Text)
hsm_subnetId :: (Maybe Text -> f (Maybe Text)) -> Hsm -> f Hsm
hsm_subnetId = (Hsm -> Maybe Text)
-> (Hsm -> Maybe Text -> Hsm)
-> Lens Hsm Hsm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe Text
subnetId :: Maybe Text
$sel:subnetId:Hsm' :: Hsm -> Maybe Text
subnetId} -> Maybe Text
subnetId) (\s :: Hsm
s@Hsm' {} Maybe Text
a -> Hsm
s {$sel:subnetId:Hsm' :: Maybe Text
subnetId = Maybe Text
a} :: Hsm)

-- | The Availability Zone that contains the HSM.
hsm_availabilityZone :: Lens.Lens' Hsm (Prelude.Maybe Prelude.Text)
hsm_availabilityZone :: (Maybe Text -> f (Maybe Text)) -> Hsm -> f Hsm
hsm_availabilityZone = (Hsm -> Maybe Text)
-> (Hsm -> Maybe Text -> Hsm)
-> Lens Hsm Hsm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:Hsm' :: Hsm -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: Hsm
s@Hsm' {} Maybe Text
a -> Hsm
s {$sel:availabilityZone:Hsm' :: Maybe Text
availabilityZone = Maybe Text
a} :: Hsm)

-- | The identifier (ID) of the cluster that contains the HSM.
hsm_clusterId :: Lens.Lens' Hsm (Prelude.Maybe Prelude.Text)
hsm_clusterId :: (Maybe Text -> f (Maybe Text)) -> Hsm -> f Hsm
hsm_clusterId = (Hsm -> Maybe Text)
-> (Hsm -> Maybe Text -> Hsm)
-> Lens Hsm Hsm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe Text
clusterId :: Maybe Text
$sel:clusterId:Hsm' :: Hsm -> Maybe Text
clusterId} -> Maybe Text
clusterId) (\s :: Hsm
s@Hsm' {} Maybe Text
a -> Hsm
s {$sel:clusterId:Hsm' :: Maybe Text
clusterId = Maybe Text
a} :: Hsm)

-- | The IP address of the HSM\'s elastic network interface (ENI).
hsm_eniIp :: Lens.Lens' Hsm (Prelude.Maybe Prelude.Text)
hsm_eniIp :: (Maybe Text -> f (Maybe Text)) -> Hsm -> f Hsm
hsm_eniIp = (Hsm -> Maybe Text)
-> (Hsm -> Maybe Text -> Hsm)
-> Lens Hsm Hsm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Maybe Text
eniIp :: Maybe Text
$sel:eniIp:Hsm' :: Hsm -> Maybe Text
eniIp} -> Maybe Text
eniIp) (\s :: Hsm
s@Hsm' {} Maybe Text
a -> Hsm
s {$sel:eniIp:Hsm' :: Maybe Text
eniIp = Maybe Text
a} :: Hsm)

-- | The HSM\'s identifier (ID).
hsm_hsmId :: Lens.Lens' Hsm Prelude.Text
hsm_hsmId :: (Text -> f Text) -> Hsm -> f Hsm
hsm_hsmId = (Hsm -> Text) -> (Hsm -> Text -> Hsm) -> Lens Hsm Hsm Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Hsm' {Text
hsmId :: Text
$sel:hsmId:Hsm' :: Hsm -> Text
hsmId} -> Text
hsmId) (\s :: Hsm
s@Hsm' {} Text
a -> Hsm
s {$sel:hsmId:Hsm' :: Text
hsmId = Text
a} :: Hsm)

instance Core.FromJSON Hsm where
  parseJSON :: Value -> Parser Hsm
parseJSON =
    String -> (Object -> Parser Hsm) -> Value -> Parser Hsm
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Hsm"
      ( \Object
x ->
          Maybe Text
-> Maybe HsmState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Hsm
Hsm'
            (Maybe Text
 -> Maybe HsmState
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> Hsm)
-> Parser (Maybe Text)
-> Parser
     (Maybe HsmState
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Hsm)
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
"StateMessage")
            Parser
  (Maybe HsmState
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Hsm)
-> Parser (Maybe HsmState)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Hsm)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HsmState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Hsm)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> Text -> Hsm)
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
"EniId")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> Text -> Hsm)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Text -> Hsm)
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
"SubnetId")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Text -> Hsm)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Text -> Hsm)
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
"AvailabilityZone")
            Parser (Maybe Text -> Maybe Text -> Text -> Hsm)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Text -> Hsm)
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
"ClusterId")
            Parser (Maybe Text -> Text -> Hsm)
-> Parser (Maybe Text) -> Parser (Text -> Hsm)
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
"EniIp")
            Parser (Text -> Hsm) -> Parser Text -> Parser Hsm
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"HsmId")
      )

instance Prelude.Hashable Hsm

instance Prelude.NFData Hsm