{-# 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.Transfer.Types.SshPublicKey
-- 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.Transfer.Types.SshPublicKey where

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

-- | Provides information about the public Secure Shell (SSH) key that is
-- associated with a user account for the specific file transfer
-- protocol-enabled server (as identified by @ServerId@). The information
-- returned includes the date the key was imported, the public key
-- contents, and the public key ID. A user can store more than one SSH
-- public key associated with their user name on a specific server.
--
-- /See:/ 'newSshPublicKey' smart constructor.
data SshPublicKey = SshPublicKey'
  { -- | Specifies the date that the public key was added to the user account.
    SshPublicKey -> POSIX
dateImported :: Core.POSIX,
    -- | Specifies the content of the SSH public key as specified by the
    -- @PublicKeyId@.
    SshPublicKey -> Text
sshPublicKeyBody :: Prelude.Text,
    -- | Specifies the @SshPublicKeyId@ parameter contains the identifier of the
    -- public key.
    SshPublicKey -> Text
sshPublicKeyId :: Prelude.Text
  }
  deriving (SshPublicKey -> SshPublicKey -> Bool
(SshPublicKey -> SshPublicKey -> Bool)
-> (SshPublicKey -> SshPublicKey -> Bool) -> Eq SshPublicKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SshPublicKey -> SshPublicKey -> Bool
$c/= :: SshPublicKey -> SshPublicKey -> Bool
== :: SshPublicKey -> SshPublicKey -> Bool
$c== :: SshPublicKey -> SshPublicKey -> Bool
Prelude.Eq, ReadPrec [SshPublicKey]
ReadPrec SshPublicKey
Int -> ReadS SshPublicKey
ReadS [SshPublicKey]
(Int -> ReadS SshPublicKey)
-> ReadS [SshPublicKey]
-> ReadPrec SshPublicKey
-> ReadPrec [SshPublicKey]
-> Read SshPublicKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SshPublicKey]
$creadListPrec :: ReadPrec [SshPublicKey]
readPrec :: ReadPrec SshPublicKey
$creadPrec :: ReadPrec SshPublicKey
readList :: ReadS [SshPublicKey]
$creadList :: ReadS [SshPublicKey]
readsPrec :: Int -> ReadS SshPublicKey
$creadsPrec :: Int -> ReadS SshPublicKey
Prelude.Read, Int -> SshPublicKey -> ShowS
[SshPublicKey] -> ShowS
SshPublicKey -> String
(Int -> SshPublicKey -> ShowS)
-> (SshPublicKey -> String)
-> ([SshPublicKey] -> ShowS)
-> Show SshPublicKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SshPublicKey] -> ShowS
$cshowList :: [SshPublicKey] -> ShowS
show :: SshPublicKey -> String
$cshow :: SshPublicKey -> String
showsPrec :: Int -> SshPublicKey -> ShowS
$cshowsPrec :: Int -> SshPublicKey -> ShowS
Prelude.Show, (forall x. SshPublicKey -> Rep SshPublicKey x)
-> (forall x. Rep SshPublicKey x -> SshPublicKey)
-> Generic SshPublicKey
forall x. Rep SshPublicKey x -> SshPublicKey
forall x. SshPublicKey -> Rep SshPublicKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SshPublicKey x -> SshPublicKey
$cfrom :: forall x. SshPublicKey -> Rep SshPublicKey x
Prelude.Generic)

-- |
-- Create a value of 'SshPublicKey' 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:
--
-- 'dateImported', 'sshPublicKey_dateImported' - Specifies the date that the public key was added to the user account.
--
-- 'sshPublicKeyBody', 'sshPublicKey_sshPublicKeyBody' - Specifies the content of the SSH public key as specified by the
-- @PublicKeyId@.
--
-- 'sshPublicKeyId', 'sshPublicKey_sshPublicKeyId' - Specifies the @SshPublicKeyId@ parameter contains the identifier of the
-- public key.
newSshPublicKey ::
  -- | 'dateImported'
  Prelude.UTCTime ->
  -- | 'sshPublicKeyBody'
  Prelude.Text ->
  -- | 'sshPublicKeyId'
  Prelude.Text ->
  SshPublicKey
newSshPublicKey :: UTCTime -> Text -> Text -> SshPublicKey
newSshPublicKey
  UTCTime
pDateImported_
  Text
pSshPublicKeyBody_
  Text
pSshPublicKeyId_ =
    SshPublicKey' :: POSIX -> Text -> Text -> SshPublicKey
SshPublicKey'
      { $sel:dateImported:SshPublicKey' :: POSIX
dateImported =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pDateImported_,
        $sel:sshPublicKeyBody:SshPublicKey' :: Text
sshPublicKeyBody = Text
pSshPublicKeyBody_,
        $sel:sshPublicKeyId:SshPublicKey' :: Text
sshPublicKeyId = Text
pSshPublicKeyId_
      }

-- | Specifies the date that the public key was added to the user account.
sshPublicKey_dateImported :: Lens.Lens' SshPublicKey Prelude.UTCTime
sshPublicKey_dateImported :: (UTCTime -> f UTCTime) -> SshPublicKey -> f SshPublicKey
sshPublicKey_dateImported = (SshPublicKey -> POSIX)
-> (SshPublicKey -> POSIX -> SshPublicKey)
-> Lens SshPublicKey SshPublicKey POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SshPublicKey' {POSIX
dateImported :: POSIX
$sel:dateImported:SshPublicKey' :: SshPublicKey -> POSIX
dateImported} -> POSIX
dateImported) (\s :: SshPublicKey
s@SshPublicKey' {} POSIX
a -> SshPublicKey
s {$sel:dateImported:SshPublicKey' :: POSIX
dateImported = POSIX
a} :: SshPublicKey) ((POSIX -> f POSIX) -> SshPublicKey -> f SshPublicKey)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> SshPublicKey
-> f SshPublicKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Specifies the content of the SSH public key as specified by the
-- @PublicKeyId@.
sshPublicKey_sshPublicKeyBody :: Lens.Lens' SshPublicKey Prelude.Text
sshPublicKey_sshPublicKeyBody :: (Text -> f Text) -> SshPublicKey -> f SshPublicKey
sshPublicKey_sshPublicKeyBody = (SshPublicKey -> Text)
-> (SshPublicKey -> Text -> SshPublicKey)
-> Lens SshPublicKey SshPublicKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SshPublicKey' {Text
sshPublicKeyBody :: Text
$sel:sshPublicKeyBody:SshPublicKey' :: SshPublicKey -> Text
sshPublicKeyBody} -> Text
sshPublicKeyBody) (\s :: SshPublicKey
s@SshPublicKey' {} Text
a -> SshPublicKey
s {$sel:sshPublicKeyBody:SshPublicKey' :: Text
sshPublicKeyBody = Text
a} :: SshPublicKey)

-- | Specifies the @SshPublicKeyId@ parameter contains the identifier of the
-- public key.
sshPublicKey_sshPublicKeyId :: Lens.Lens' SshPublicKey Prelude.Text
sshPublicKey_sshPublicKeyId :: (Text -> f Text) -> SshPublicKey -> f SshPublicKey
sshPublicKey_sshPublicKeyId = (SshPublicKey -> Text)
-> (SshPublicKey -> Text -> SshPublicKey)
-> Lens SshPublicKey SshPublicKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SshPublicKey' {Text
sshPublicKeyId :: Text
$sel:sshPublicKeyId:SshPublicKey' :: SshPublicKey -> Text
sshPublicKeyId} -> Text
sshPublicKeyId) (\s :: SshPublicKey
s@SshPublicKey' {} Text
a -> SshPublicKey
s {$sel:sshPublicKeyId:SshPublicKey' :: Text
sshPublicKeyId = Text
a} :: SshPublicKey)

instance Core.FromJSON SshPublicKey where
  parseJSON :: Value -> Parser SshPublicKey
parseJSON =
    String
-> (Object -> Parser SshPublicKey) -> Value -> Parser SshPublicKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SshPublicKey"
      ( \Object
x ->
          POSIX -> Text -> Text -> SshPublicKey
SshPublicKey'
            (POSIX -> Text -> Text -> SshPublicKey)
-> Parser POSIX -> Parser (Text -> Text -> SshPublicKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DateImported")
            Parser (Text -> Text -> SshPublicKey)
-> Parser Text -> Parser (Text -> SshPublicKey)
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
"SshPublicKeyBody")
            Parser (Text -> SshPublicKey) -> Parser Text -> Parser SshPublicKey
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
"SshPublicKeyId")
      )

instance Prelude.Hashable SshPublicKey

instance Prelude.NFData SshPublicKey