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

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.StatusType
import qualified Amazonka.Lens as Lens
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 Core.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
(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:
--
-- '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' :: Maybe ISO8601
-> Text -> Text -> Text -> Text -> StatusType -> SSHPublicKey
SSHPublicKey'
      { $sel:uploadDate:SSHPublicKey' :: Maybe ISO8601
uploadDate = Maybe ISO8601
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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SSHPublicKey -> f SSHPublicKey
sSHPublicKey_uploadDate = (SSHPublicKey -> Maybe ISO8601)
-> (SSHPublicKey -> Maybe ISO8601 -> SSHPublicKey)
-> Lens SSHPublicKey SSHPublicKey (Maybe ISO8601) (Maybe ISO8601)
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) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> SSHPublicKey -> f SSHPublicKey)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SSHPublicKey
-> f SSHPublicKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the IAM user associated with the SSH public key.
sSHPublicKey_userName :: Lens.Lens' SSHPublicKey Prelude.Text
sSHPublicKey_userName :: (Text -> f Text) -> SSHPublicKey -> f SSHPublicKey
sSHPublicKey_userName = (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
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 :: (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)

-- | The MD5 message digest of the SSH public key.
sSHPublicKey_fingerprint :: Lens.Lens' SSHPublicKey Prelude.Text
sSHPublicKey_fingerprint :: (Text -> f Text) -> SSHPublicKey -> f SSHPublicKey
sSHPublicKey_fingerprint = (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
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 :: (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)

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

instance Prelude.Hashable SSHPublicKey

instance Prelude.NFData SSHPublicKey