{-# 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.StorageGateway.Types.ChapInfo
-- 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.StorageGateway.Types.ChapInfo where

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

-- | Describes Challenge-Handshake Authentication Protocol (CHAP) information
-- that supports authentication between your gateway and iSCSI initiators.
--
-- /See:/ 'newChapInfo' smart constructor.
data ChapInfo = ChapInfo'
  { -- | The Amazon Resource Name (ARN) of the volume.
    --
    -- Valid Values: 50 to 500 lowercase letters, numbers, periods (.), and
    -- hyphens (-).
    ChapInfo -> Maybe Text
targetARN :: Prelude.Maybe Prelude.Text,
    -- | The secret key that the initiator (for example, the Windows client) must
    -- provide to participate in mutual CHAP with the target.
    ChapInfo -> Maybe (Sensitive Text)
secretToAuthenticateInitiator :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The iSCSI initiator that connects to the target.
    ChapInfo -> Maybe Text
initiatorName :: Prelude.Maybe Prelude.Text,
    -- | The secret key that the target must provide to participate in mutual
    -- CHAP with the initiator (e.g., Windows client).
    ChapInfo -> Maybe (Sensitive Text)
secretToAuthenticateTarget :: Prelude.Maybe (Core.Sensitive Prelude.Text)
  }
  deriving (ChapInfo -> ChapInfo -> Bool
(ChapInfo -> ChapInfo -> Bool)
-> (ChapInfo -> ChapInfo -> Bool) -> Eq ChapInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChapInfo -> ChapInfo -> Bool
$c/= :: ChapInfo -> ChapInfo -> Bool
== :: ChapInfo -> ChapInfo -> Bool
$c== :: ChapInfo -> ChapInfo -> Bool
Prelude.Eq, Int -> ChapInfo -> ShowS
[ChapInfo] -> ShowS
ChapInfo -> String
(Int -> ChapInfo -> ShowS)
-> (ChapInfo -> String) -> ([ChapInfo] -> ShowS) -> Show ChapInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChapInfo] -> ShowS
$cshowList :: [ChapInfo] -> ShowS
show :: ChapInfo -> String
$cshow :: ChapInfo -> String
showsPrec :: Int -> ChapInfo -> ShowS
$cshowsPrec :: Int -> ChapInfo -> ShowS
Prelude.Show, (forall x. ChapInfo -> Rep ChapInfo x)
-> (forall x. Rep ChapInfo x -> ChapInfo) -> Generic ChapInfo
forall x. Rep ChapInfo x -> ChapInfo
forall x. ChapInfo -> Rep ChapInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChapInfo x -> ChapInfo
$cfrom :: forall x. ChapInfo -> Rep ChapInfo x
Prelude.Generic)

-- |
-- Create a value of 'ChapInfo' 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:
--
-- 'targetARN', 'chapInfo_targetARN' - The Amazon Resource Name (ARN) of the volume.
--
-- Valid Values: 50 to 500 lowercase letters, numbers, periods (.), and
-- hyphens (-).
--
-- 'secretToAuthenticateInitiator', 'chapInfo_secretToAuthenticateInitiator' - The secret key that the initiator (for example, the Windows client) must
-- provide to participate in mutual CHAP with the target.
--
-- 'initiatorName', 'chapInfo_initiatorName' - The iSCSI initiator that connects to the target.
--
-- 'secretToAuthenticateTarget', 'chapInfo_secretToAuthenticateTarget' - The secret key that the target must provide to participate in mutual
-- CHAP with the initiator (e.g., Windows client).
newChapInfo ::
  ChapInfo
newChapInfo :: ChapInfo
newChapInfo =
  ChapInfo' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe (Sensitive Text)
-> ChapInfo
ChapInfo'
    { $sel:targetARN:ChapInfo' :: Maybe Text
targetARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretToAuthenticateInitiator:ChapInfo' :: Maybe (Sensitive Text)
secretToAuthenticateInitiator = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:initiatorName:ChapInfo' :: Maybe Text
initiatorName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretToAuthenticateTarget:ChapInfo' :: Maybe (Sensitive Text)
secretToAuthenticateTarget = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the volume.
--
-- Valid Values: 50 to 500 lowercase letters, numbers, periods (.), and
-- hyphens (-).
chapInfo_targetARN :: Lens.Lens' ChapInfo (Prelude.Maybe Prelude.Text)
chapInfo_targetARN :: (Maybe Text -> f (Maybe Text)) -> ChapInfo -> f ChapInfo
chapInfo_targetARN = (ChapInfo -> Maybe Text)
-> (ChapInfo -> Maybe Text -> ChapInfo)
-> Lens ChapInfo ChapInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChapInfo' {Maybe Text
targetARN :: Maybe Text
$sel:targetARN:ChapInfo' :: ChapInfo -> Maybe Text
targetARN} -> Maybe Text
targetARN) (\s :: ChapInfo
s@ChapInfo' {} Maybe Text
a -> ChapInfo
s {$sel:targetARN:ChapInfo' :: Maybe Text
targetARN = Maybe Text
a} :: ChapInfo)

-- | The secret key that the initiator (for example, the Windows client) must
-- provide to participate in mutual CHAP with the target.
chapInfo_secretToAuthenticateInitiator :: Lens.Lens' ChapInfo (Prelude.Maybe Prelude.Text)
chapInfo_secretToAuthenticateInitiator :: (Maybe Text -> f (Maybe Text)) -> ChapInfo -> f ChapInfo
chapInfo_secretToAuthenticateInitiator = (ChapInfo -> Maybe (Sensitive Text))
-> (ChapInfo -> Maybe (Sensitive Text) -> ChapInfo)
-> Lens
     ChapInfo ChapInfo (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChapInfo' {Maybe (Sensitive Text)
secretToAuthenticateInitiator :: Maybe (Sensitive Text)
$sel:secretToAuthenticateInitiator:ChapInfo' :: ChapInfo -> Maybe (Sensitive Text)
secretToAuthenticateInitiator} -> Maybe (Sensitive Text)
secretToAuthenticateInitiator) (\s :: ChapInfo
s@ChapInfo' {} Maybe (Sensitive Text)
a -> ChapInfo
s {$sel:secretToAuthenticateInitiator:ChapInfo' :: Maybe (Sensitive Text)
secretToAuthenticateInitiator = Maybe (Sensitive Text)
a} :: ChapInfo) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ChapInfo -> f ChapInfo)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ChapInfo
-> f ChapInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The iSCSI initiator that connects to the target.
chapInfo_initiatorName :: Lens.Lens' ChapInfo (Prelude.Maybe Prelude.Text)
chapInfo_initiatorName :: (Maybe Text -> f (Maybe Text)) -> ChapInfo -> f ChapInfo
chapInfo_initiatorName = (ChapInfo -> Maybe Text)
-> (ChapInfo -> Maybe Text -> ChapInfo)
-> Lens ChapInfo ChapInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChapInfo' {Maybe Text
initiatorName :: Maybe Text
$sel:initiatorName:ChapInfo' :: ChapInfo -> Maybe Text
initiatorName} -> Maybe Text
initiatorName) (\s :: ChapInfo
s@ChapInfo' {} Maybe Text
a -> ChapInfo
s {$sel:initiatorName:ChapInfo' :: Maybe Text
initiatorName = Maybe Text
a} :: ChapInfo)

-- | The secret key that the target must provide to participate in mutual
-- CHAP with the initiator (e.g., Windows client).
chapInfo_secretToAuthenticateTarget :: Lens.Lens' ChapInfo (Prelude.Maybe Prelude.Text)
chapInfo_secretToAuthenticateTarget :: (Maybe Text -> f (Maybe Text)) -> ChapInfo -> f ChapInfo
chapInfo_secretToAuthenticateTarget = (ChapInfo -> Maybe (Sensitive Text))
-> (ChapInfo -> Maybe (Sensitive Text) -> ChapInfo)
-> Lens
     ChapInfo ChapInfo (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChapInfo' {Maybe (Sensitive Text)
secretToAuthenticateTarget :: Maybe (Sensitive Text)
$sel:secretToAuthenticateTarget:ChapInfo' :: ChapInfo -> Maybe (Sensitive Text)
secretToAuthenticateTarget} -> Maybe (Sensitive Text)
secretToAuthenticateTarget) (\s :: ChapInfo
s@ChapInfo' {} Maybe (Sensitive Text)
a -> ChapInfo
s {$sel:secretToAuthenticateTarget:ChapInfo' :: Maybe (Sensitive Text)
secretToAuthenticateTarget = Maybe (Sensitive Text)
a} :: ChapInfo) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ChapInfo -> f ChapInfo)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ChapInfo
-> f ChapInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.FromJSON ChapInfo where
  parseJSON :: Value -> Parser ChapInfo
parseJSON =
    String -> (Object -> Parser ChapInfo) -> Value -> Parser ChapInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChapInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe (Sensitive Text)
-> ChapInfo
ChapInfo'
            (Maybe Text
 -> Maybe (Sensitive Text)
 -> Maybe Text
 -> Maybe (Sensitive Text)
 -> ChapInfo)
-> Parser (Maybe Text)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe Text -> Maybe (Sensitive Text) -> ChapInfo)
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
"TargetARN")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe Text -> Maybe (Sensitive Text) -> ChapInfo)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> Maybe (Sensitive Text) -> ChapInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SecretToAuthenticateInitiator")
            Parser (Maybe Text -> Maybe (Sensitive Text) -> ChapInfo)
-> Parser (Maybe Text)
-> Parser (Maybe (Sensitive Text) -> ChapInfo)
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
"InitiatorName")
            Parser (Maybe (Sensitive Text) -> ChapInfo)
-> Parser (Maybe (Sensitive Text)) -> Parser ChapInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SecretToAuthenticateTarget")
      )

instance Prelude.Hashable ChapInfo

instance Prelude.NFData ChapInfo