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

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

-- | Configuration information of the security key.
--
-- /See:/ 'newSecurityKey' smart constructor.
data SecurityKey = SecurityKey'
  { -- | When the security key was created.
    SecurityKey -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | 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,
    -- | The key of the security key.
    SecurityKey -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (SecurityKey -> SecurityKey -> Bool
(SecurityKey -> SecurityKey -> Bool)
-> (SecurityKey -> SecurityKey -> Bool) -> Eq SecurityKey
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]
(Int -> ReadS SecurityKey)
-> ReadS [SecurityKey]
-> ReadPrec SecurityKey
-> ReadPrec [SecurityKey]
-> Read 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
(Int -> SecurityKey -> ShowS)
-> (SecurityKey -> String)
-> ([SecurityKey] -> ShowS)
-> Show SecurityKey
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. SecurityKey -> Rep SecurityKey x)
-> (forall x. Rep SecurityKey x -> SecurityKey)
-> Generic SecurityKey
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:
--
-- 'creationTime', 'securityKey_creationTime' - When the security key was created.
--
-- 'associationId', 'securityKey_associationId' - The existing association identifier that uniquely identifies the
-- resource type and storage config for the given instance ID.
--
-- 'key', 'securityKey_key' - The key of the security key.
newSecurityKey ::
  SecurityKey
newSecurityKey :: SecurityKey
newSecurityKey =
  SecurityKey' :: Maybe POSIX -> Maybe Text -> Maybe Text -> SecurityKey
SecurityKey'
    { $sel:creationTime:SecurityKey' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:associationId:SecurityKey' :: Maybe Text
associationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:SecurityKey' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | When the security key was created.
securityKey_creationTime :: Lens.Lens' SecurityKey (Prelude.Maybe Prelude.UTCTime)
securityKey_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SecurityKey -> f SecurityKey
securityKey_creationTime = (SecurityKey -> Maybe POSIX)
-> (SecurityKey -> Maybe POSIX -> SecurityKey)
-> Lens SecurityKey SecurityKey (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> SecurityKey -> f SecurityKey)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SecurityKey
-> f SecurityKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> SecurityKey -> f SecurityKey
securityKey_associationId = (SecurityKey -> Maybe Text)
-> (SecurityKey -> Maybe Text -> SecurityKey)
-> Lens SecurityKey SecurityKey (Maybe Text) (Maybe Text)
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)

-- | The key of the security key.
securityKey_key :: Lens.Lens' SecurityKey (Prelude.Maybe Prelude.Text)
securityKey_key :: (Maybe Text -> f (Maybe Text)) -> SecurityKey -> f SecurityKey
securityKey_key = (SecurityKey -> Maybe Text)
-> (SecurityKey -> Maybe Text -> SecurityKey)
-> Lens SecurityKey SecurityKey (Maybe Text) (Maybe Text)
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 Core.FromJSON SecurityKey where
  parseJSON :: Value -> Parser SecurityKey
parseJSON =
    String
-> (Object -> Parser SecurityKey) -> Value -> Parser SecurityKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecurityKey"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> Maybe Text -> SecurityKey
SecurityKey'
            (Maybe POSIX -> Maybe Text -> Maybe Text -> SecurityKey)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> SecurityKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationTime")
            Parser (Maybe Text -> Maybe Text -> SecurityKey)
-> Parser (Maybe Text) -> Parser (Maybe Text -> SecurityKey)
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
"AssociationId")
            Parser (Maybe Text -> SecurityKey)
-> Parser (Maybe Text) -> Parser SecurityKey
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
"Key")
      )

instance Prelude.Hashable SecurityKey

instance Prelude.NFData SecurityKey