{-# 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.Connect.Types.SecurityKey
-- 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.Connect.Types.SecurityKey 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

-- | Configuration information of the security key.
--
-- /See:/ 'newSecurityKey' smart constructor.
data SecurityKey = SecurityKey'
  { -- | The existing association identifier that uniquely identifies the
    -- resource type and storage config for the given instance ID.
    SecurityKey -> Maybe Text
associationId :: Prelude.Maybe Prelude.Text,
    -- | When the security key was created.
    SecurityKey -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The key of the security key.
    SecurityKey -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (SecurityKey -> SecurityKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityKey -> SecurityKey -> Bool
$c/= :: SecurityKey -> SecurityKey -> Bool
== :: SecurityKey -> SecurityKey -> Bool
$c== :: SecurityKey -> SecurityKey -> Bool
Prelude.Eq, ReadPrec [SecurityKey]
ReadPrec SecurityKey
Int -> ReadS SecurityKey
ReadS [SecurityKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecurityKey]
$creadListPrec :: ReadPrec [SecurityKey]
readPrec :: ReadPrec SecurityKey
$creadPrec :: ReadPrec SecurityKey
readList :: ReadS [SecurityKey]
$creadList :: ReadS [SecurityKey]
readsPrec :: Int -> ReadS SecurityKey
$creadsPrec :: Int -> ReadS SecurityKey
Prelude.Read, Int -> SecurityKey -> ShowS
[SecurityKey] -> ShowS
SecurityKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityKey] -> ShowS
$cshowList :: [SecurityKey] -> ShowS
show :: SecurityKey -> String
$cshow :: SecurityKey -> String
showsPrec :: Int -> SecurityKey -> ShowS
$cshowsPrec :: Int -> SecurityKey -> ShowS
Prelude.Show, forall x. Rep SecurityKey x -> SecurityKey
forall x. SecurityKey -> Rep SecurityKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SecurityKey x -> SecurityKey
$cfrom :: forall x. SecurityKey -> Rep SecurityKey x
Prelude.Generic)

-- |
-- Create a value of 'SecurityKey' 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:
--
-- 'associationId', 'securityKey_associationId' - The existing association identifier that uniquely identifies the
-- resource type and storage config for the given instance ID.
--
-- 'creationTime', 'securityKey_creationTime' - When the security key was created.
--
-- 'key', 'securityKey_key' - The key of the security key.
newSecurityKey ::
  SecurityKey
newSecurityKey :: SecurityKey
newSecurityKey =
  SecurityKey'
    { $sel:associationId:SecurityKey' :: Maybe Text
associationId = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:SecurityKey' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:key:SecurityKey' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing
    }

-- | The existing association identifier that uniquely identifies the
-- resource type and storage config for the given instance ID.
securityKey_associationId :: Lens.Lens' SecurityKey (Prelude.Maybe Prelude.Text)
securityKey_associationId :: Lens' SecurityKey (Maybe Text)
securityKey_associationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityKey' {Maybe Text
associationId :: Maybe Text
$sel:associationId:SecurityKey' :: SecurityKey -> Maybe Text
associationId} -> Maybe Text
associationId) (\s :: SecurityKey
s@SecurityKey' {} Maybe Text
a -> SecurityKey
s {$sel:associationId:SecurityKey' :: Maybe Text
associationId = Maybe Text
a} :: SecurityKey)

-- | When the security key was created.
securityKey_creationTime :: Lens.Lens' SecurityKey (Prelude.Maybe Prelude.UTCTime)
securityKey_creationTime :: Lens' SecurityKey (Maybe UTCTime)
securityKey_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityKey' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:SecurityKey' :: SecurityKey -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: SecurityKey
s@SecurityKey' {} Maybe POSIX
a -> SecurityKey
s {$sel:creationTime:SecurityKey' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: SecurityKey) 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 :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The key of the security key.
securityKey_key :: Lens.Lens' SecurityKey (Prelude.Maybe Prelude.Text)
securityKey_key :: Lens' SecurityKey (Maybe Text)
securityKey_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityKey' {Maybe Text
key :: Maybe Text
$sel:key:SecurityKey' :: SecurityKey -> Maybe Text
key} -> Maybe Text
key) (\s :: SecurityKey
s@SecurityKey' {} Maybe Text
a -> SecurityKey
s {$sel:key:SecurityKey' :: Maybe Text
key = Maybe Text
a} :: SecurityKey)

instance Data.FromJSON SecurityKey where
  parseJSON :: Value -> Parser SecurityKey
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SecurityKey"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe Text -> SecurityKey
SecurityKey'
            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
"AssociationId")
            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
"CreationTime")
            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
"Key")
      )

instance Prelude.Hashable SecurityKey where
  hashWithSalt :: Int -> SecurityKey -> Int
hashWithSalt Int
_salt SecurityKey' {Maybe Text
Maybe POSIX
key :: Maybe Text
creationTime :: Maybe POSIX
associationId :: Maybe Text
$sel:key:SecurityKey' :: SecurityKey -> Maybe Text
$sel:creationTime:SecurityKey' :: SecurityKey -> Maybe POSIX
$sel:associationId:SecurityKey' :: SecurityKey -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
associationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key

instance Prelude.NFData SecurityKey where
  rnf :: SecurityKey -> ()
rnf SecurityKey' {Maybe Text
Maybe POSIX
key :: Maybe Text
creationTime :: Maybe POSIX
associationId :: Maybe Text
$sel:key:SecurityKey' :: SecurityKey -> Maybe Text
$sel:creationTime:SecurityKey' :: SecurityKey -> Maybe POSIX
$sel:associationId:SecurityKey' :: SecurityKey -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
associationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key