{-# 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.IAM.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.IAM.Types.SSHPublicKey where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types.StatusType
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an SSH public key.
--
-- This data type is used as a response element in the GetSSHPublicKey and
-- UploadSSHPublicKey operations.
--
-- /See:/ 'newSSHPublicKey' smart constructor.
data SSHPublicKey = SSHPublicKey'
  { -- | The date and time, in
    -- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the SSH
    -- public key was uploaded.
    SSHPublicKey -> Maybe ISO8601
uploadDate :: Prelude.Maybe Data.ISO8601,
    -- | The name of the IAM user associated with the SSH public key.
    SSHPublicKey -> Text
userName :: Prelude.Text,
    -- | The unique identifier for the SSH public key.
    SSHPublicKey -> Text
sSHPublicKeyId :: Prelude.Text,
    -- | The MD5 message digest of the SSH public key.
    SSHPublicKey -> Text
fingerprint :: Prelude.Text,
    -- | The SSH public key.
    SSHPublicKey -> Text
sSHPublicKeyBody :: Prelude.Text,
    -- | The status of the SSH public key. @Active@ means that the key can be
    -- used for authentication with an CodeCommit repository. @Inactive@ means
    -- that the key cannot be used.
    SSHPublicKey -> StatusType
status :: StatusType
  }
  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:
--
-- 'uploadDate', 'sSHPublicKey_uploadDate' - The date and time, in
-- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the SSH
-- public key was uploaded.
--
-- 'userName', 'sSHPublicKey_userName' - The name of the IAM user associated with the SSH public key.
--
-- 'sSHPublicKeyId', 'sSHPublicKey_sSHPublicKeyId' - The unique identifier for the SSH public key.
--
-- 'fingerprint', 'sSHPublicKey_fingerprint' - The MD5 message digest of the SSH public key.
--
-- 'sSHPublicKeyBody', 'sSHPublicKey_sSHPublicKeyBody' - The SSH public key.
--
-- 'status', 'sSHPublicKey_status' - The status of the SSH public key. @Active@ means that the key can be
-- used for authentication with an CodeCommit repository. @Inactive@ means
-- that the key cannot be used.
newSSHPublicKey ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'sSHPublicKeyId'
  Prelude.Text ->
  -- | 'fingerprint'
  Prelude.Text ->
  -- | 'sSHPublicKeyBody'
  Prelude.Text ->
  -- | 'status'
  StatusType ->
  SSHPublicKey
newSSHPublicKey :: Text -> Text -> Text -> Text -> StatusType -> SSHPublicKey
newSSHPublicKey
  Text
pUserName_
  Text
pSSHPublicKeyId_
  Text
pFingerprint_
  Text
pSSHPublicKeyBody_
  StatusType
pStatus_ =
    SSHPublicKey'
      { $sel:uploadDate:SSHPublicKey' :: Maybe ISO8601
uploadDate = forall a. Maybe a
Prelude.Nothing,
        $sel:userName:SSHPublicKey' :: Text
userName = Text
pUserName_,
        $sel:sSHPublicKeyId:SSHPublicKey' :: Text
sSHPublicKeyId = Text
pSSHPublicKeyId_,
        $sel:fingerprint:SSHPublicKey' :: Text
fingerprint = Text
pFingerprint_,
        $sel:sSHPublicKeyBody:SSHPublicKey' :: Text
sSHPublicKeyBody = Text
pSSHPublicKeyBody_,
        $sel:status:SSHPublicKey' :: StatusType
status = StatusType
pStatus_
      }

-- | The date and time, in
-- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the SSH
-- public key was uploaded.
sSHPublicKey_uploadDate :: Lens.Lens' SSHPublicKey (Prelude.Maybe Prelude.UTCTime)
sSHPublicKey_uploadDate :: Lens' SSHPublicKey (Maybe UTCTime)
sSHPublicKey_uploadDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKey' {Maybe ISO8601
uploadDate :: Maybe ISO8601
$sel:uploadDate:SSHPublicKey' :: SSHPublicKey -> Maybe ISO8601
uploadDate} -> Maybe ISO8601
uploadDate) (\s :: SSHPublicKey
s@SSHPublicKey' {} Maybe ISO8601
a -> SSHPublicKey
s {$sel:uploadDate:SSHPublicKey' :: Maybe ISO8601
uploadDate = Maybe ISO8601
a} :: SSHPublicKey) 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 name of the IAM user associated with the SSH public key.
sSHPublicKey_userName :: Lens.Lens' SSHPublicKey Prelude.Text
sSHPublicKey_userName :: Lens' SSHPublicKey Text
sSHPublicKey_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKey' {Text
userName :: Text
$sel:userName:SSHPublicKey' :: SSHPublicKey -> Text
userName} -> Text
userName) (\s :: SSHPublicKey
s@SSHPublicKey' {} Text
a -> SSHPublicKey
s {$sel:userName:SSHPublicKey' :: Text
userName = Text
a} :: SSHPublicKey)

-- | The unique identifier for the SSH 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)

-- | The MD5 message digest of the SSH public key.
sSHPublicKey_fingerprint :: Lens.Lens' SSHPublicKey Prelude.Text
sSHPublicKey_fingerprint :: Lens' SSHPublicKey Text
sSHPublicKey_fingerprint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKey' {Text
fingerprint :: Text
$sel:fingerprint:SSHPublicKey' :: SSHPublicKey -> Text
fingerprint} -> Text
fingerprint) (\s :: SSHPublicKey
s@SSHPublicKey' {} Text
a -> SSHPublicKey
s {$sel:fingerprint:SSHPublicKey' :: Text
fingerprint = Text
a} :: SSHPublicKey)

-- | The SSH public key.
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)

-- | The status of the SSH public key. @Active@ means that the key can be
-- used for authentication with an CodeCommit repository. @Inactive@ means
-- that the key cannot be used.
sSHPublicKey_status :: Lens.Lens' SSHPublicKey StatusType
sSHPublicKey_status :: Lens' SSHPublicKey StatusType
sSHPublicKey_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKey' {StatusType
status :: StatusType
$sel:status:SSHPublicKey' :: SSHPublicKey -> StatusType
status} -> StatusType
status) (\s :: SSHPublicKey
s@SSHPublicKey' {} StatusType
a -> SSHPublicKey
s {$sel:status:SSHPublicKey' :: StatusType
status = StatusType
a} :: SSHPublicKey)

instance Data.FromXML SSHPublicKey where
  parseXML :: [Node] -> Either String SSHPublicKey
parseXML [Node]
x =
    Maybe ISO8601
-> Text -> Text -> Text -> Text -> StatusType -> SSHPublicKey
SSHPublicKey'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"UploadDate")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"UserName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SSHPublicKeyId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Fingerprint")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SSHPublicKeyBody")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Status")

instance Prelude.Hashable SSHPublicKey where
  hashWithSalt :: Int -> SSHPublicKey -> Int
hashWithSalt Int
_salt SSHPublicKey' {Maybe ISO8601
Text
StatusType
status :: StatusType
sSHPublicKeyBody :: Text
fingerprint :: Text
sSHPublicKeyId :: Text
userName :: Text
uploadDate :: Maybe ISO8601
$sel:status:SSHPublicKey' :: SSHPublicKey -> StatusType
$sel:sSHPublicKeyBody:SSHPublicKey' :: SSHPublicKey -> Text
$sel:fingerprint:SSHPublicKey' :: SSHPublicKey -> Text
$sel:sSHPublicKeyId:SSHPublicKey' :: SSHPublicKey -> Text
$sel:userName:SSHPublicKey' :: SSHPublicKey -> Text
$sel:uploadDate:SSHPublicKey' :: SSHPublicKey -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
uploadDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sSHPublicKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fingerprint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sSHPublicKeyBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StatusType
status

instance Prelude.NFData SSHPublicKey where
  rnf :: SSHPublicKey -> ()
rnf SSHPublicKey' {Maybe ISO8601
Text
StatusType
status :: StatusType
sSHPublicKeyBody :: Text
fingerprint :: Text
sSHPublicKeyId :: Text
userName :: Text
uploadDate :: Maybe ISO8601
$sel:status:SSHPublicKey' :: SSHPublicKey -> StatusType
$sel:sSHPublicKeyBody:SSHPublicKey' :: SSHPublicKey -> Text
$sel:fingerprint:SSHPublicKey' :: SSHPublicKey -> Text
$sel:sSHPublicKeyId:SSHPublicKey' :: SSHPublicKey -> Text
$sel:userName:SSHPublicKey' :: SSHPublicKey -> Text
$sel:uploadDate:SSHPublicKey' :: SSHPublicKey -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
uploadDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sSHPublicKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fingerprint
      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 StatusType
status