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

-- | 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 :: Data.POSIX,
    -- | Specifies the content of the SSH public key as specified by the
    -- @PublicKeyId@.
    --
    -- Transfer Family accepts RSA, ECDSA, and ED25519 keys.
    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
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]
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
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. 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@.
--
-- Transfer Family accepts RSA, ECDSA, and ED25519 keys.
--
-- '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'
      { $sel:dateImported:SshPublicKey' :: POSIX
dateImported =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' SshPublicKey UTCTime
sshPublicKey_dateImported = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Specifies the content of the SSH public key as specified by the
-- @PublicKeyId@.
--
-- Transfer Family accepts RSA, ECDSA, and ED25519 keys.
sshPublicKey_sshPublicKeyBody :: Lens.Lens' SshPublicKey Prelude.Text
sshPublicKey_sshPublicKeyBody :: Lens' SshPublicKey Text
sshPublicKey_sshPublicKeyBody = 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 :: Lens' SshPublicKey Text
sshPublicKey_sshPublicKeyId = 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 Data.FromJSON SshPublicKey where
  parseJSON :: Value -> Parser SshPublicKey
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SshPublicKey"
      ( \Object
x ->
          POSIX -> Text -> Text -> SshPublicKey
SshPublicKey'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DateImported")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SshPublicKeyBody")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SshPublicKeyId")
      )

instance Prelude.Hashable SshPublicKey where
  hashWithSalt :: Int -> SshPublicKey -> Int
hashWithSalt Int
_salt SshPublicKey' {Text
POSIX
sshPublicKeyId :: Text
sshPublicKeyBody :: Text
dateImported :: POSIX
$sel:sshPublicKeyId:SshPublicKey' :: SshPublicKey -> Text
$sel:sshPublicKeyBody:SshPublicKey' :: SshPublicKey -> Text
$sel:dateImported:SshPublicKey' :: SshPublicKey -> POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
dateImported
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sshPublicKeyBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sshPublicKeyId

instance Prelude.NFData SshPublicKey where
  rnf :: SshPublicKey -> ()
rnf SshPublicKey' {Text
POSIX
sshPublicKeyId :: Text
sshPublicKeyBody :: Text
dateImported :: POSIX
$sel:sshPublicKeyId:SshPublicKey' :: SshPublicKey -> Text
$sel:sshPublicKeyBody:SshPublicKey' :: SshPublicKey -> Text
$sel:dateImported:SshPublicKey' :: SshPublicKey -> POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf POSIX
dateImported
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sshPublicKeyBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sshPublicKeyId