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

-- | Describes Challenge-Handshake Authentication Protocol (CHAP) information
-- that supports authentication between your gateway and iSCSI initiators.
--
-- /See:/ 'newChapInfo' smart constructor.
data ChapInfo = ChapInfo'
  { -- | The iSCSI initiator that connects to the target.
    ChapInfo -> Maybe Text
initiatorName :: 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 (Data.Sensitive 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 (Data.Sensitive Prelude.Text),
    -- | 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
  }
  deriving (ChapInfo -> ChapInfo -> Bool
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
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. 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:
--
-- 'initiatorName', 'chapInfo_initiatorName' - The iSCSI initiator that connects to the target.
--
-- 'secretToAuthenticateInitiator', 'chapInfo_secretToAuthenticateInitiator' - The secret key that the initiator (for example, the Windows client) must
-- provide to participate in mutual CHAP with 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).
--
-- 'targetARN', 'chapInfo_targetARN' - The Amazon Resource Name (ARN) of the volume.
--
-- Valid Values: 50 to 500 lowercase letters, numbers, periods (.), and
-- hyphens (-).
newChapInfo ::
  ChapInfo
newChapInfo :: ChapInfo
newChapInfo =
  ChapInfo'
    { $sel:initiatorName:ChapInfo' :: Maybe Text
initiatorName = forall a. Maybe a
Prelude.Nothing,
      $sel:secretToAuthenticateInitiator:ChapInfo' :: Maybe (Sensitive Text)
secretToAuthenticateInitiator = forall a. Maybe a
Prelude.Nothing,
      $sel:secretToAuthenticateTarget:ChapInfo' :: Maybe (Sensitive Text)
secretToAuthenticateTarget = forall a. Maybe a
Prelude.Nothing,
      $sel:targetARN:ChapInfo' :: Maybe Text
targetARN = forall a. Maybe a
Prelude.Nothing
    }

-- | The iSCSI initiator that connects to the target.
chapInfo_initiatorName :: Lens.Lens' ChapInfo (Prelude.Maybe Prelude.Text)
chapInfo_initiatorName :: Lens' ChapInfo (Maybe Text)
chapInfo_initiatorName = 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 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 :: Lens' ChapInfo (Maybe Text)
chapInfo_secretToAuthenticateInitiator = 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) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | 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 :: Lens' ChapInfo (Maybe Text)
chapInfo_secretToAuthenticateTarget = 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) 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 a. Iso' (Sensitive a) a
Data._Sensitive

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

instance Data.FromJSON ChapInfo where
  parseJSON :: Value -> Parser ChapInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChapInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> Maybe Text
-> ChapInfo
ChapInfo'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"InitiatorName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SecretToAuthenticateInitiator")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SecretToAuthenticateTarget")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TargetARN")
      )

instance Prelude.Hashable ChapInfo where
  hashWithSalt :: Int -> ChapInfo -> Int
hashWithSalt Int
_salt ChapInfo' {Maybe Text
Maybe (Sensitive Text)
targetARN :: Maybe Text
secretToAuthenticateTarget :: Maybe (Sensitive Text)
secretToAuthenticateInitiator :: Maybe (Sensitive Text)
initiatorName :: Maybe Text
$sel:targetARN:ChapInfo' :: ChapInfo -> Maybe Text
$sel:secretToAuthenticateTarget:ChapInfo' :: ChapInfo -> Maybe (Sensitive Text)
$sel:secretToAuthenticateInitiator:ChapInfo' :: ChapInfo -> Maybe (Sensitive Text)
$sel:initiatorName:ChapInfo' :: ChapInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
initiatorName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
secretToAuthenticateInitiator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
secretToAuthenticateTarget
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetARN

instance Prelude.NFData ChapInfo where
  rnf :: ChapInfo -> ()
rnf ChapInfo' {Maybe Text
Maybe (Sensitive Text)
targetARN :: Maybe Text
secretToAuthenticateTarget :: Maybe (Sensitive Text)
secretToAuthenticateInitiator :: Maybe (Sensitive Text)
initiatorName :: Maybe Text
$sel:targetARN:ChapInfo' :: ChapInfo -> Maybe Text
$sel:secretToAuthenticateTarget:ChapInfo' :: ChapInfo -> Maybe (Sensitive Text)
$sel:secretToAuthenticateInitiator:ChapInfo' :: ChapInfo -> Maybe (Sensitive Text)
$sel:initiatorName:ChapInfo' :: ChapInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
initiatorName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
secretToAuthenticateInitiator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
secretToAuthenticateTarget
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetARN