{-# 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.SSHPublicKeyMetadata
-- 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.SSHPublicKeyMetadata 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, without the key\'s body or
-- fingerprint.
--
-- This data type is used as a response element in the ListSSHPublicKeys
-- operation.
--
-- /See:/ 'newSSHPublicKeyMetadata' smart constructor.
data SSHPublicKeyMetadata = SSHPublicKeyMetadata'
  { -- | The name of the IAM user associated with the SSH public key.
    SSHPublicKeyMetadata -> Text
userName :: Prelude.Text,
    -- | The unique identifier for the SSH public key.
    SSHPublicKeyMetadata -> Text
sSHPublicKeyId :: 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.
    SSHPublicKeyMetadata -> StatusType
status :: StatusType,
    -- | The date and time, in
    -- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the SSH
    -- public key was uploaded.
    SSHPublicKeyMetadata -> ISO8601
uploadDate :: Core.ISO8601
  }
  deriving (SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool
(SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool)
-> (SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool)
-> Eq SSHPublicKeyMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool
$c/= :: SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool
== :: SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool
$c== :: SSHPublicKeyMetadata -> SSHPublicKeyMetadata -> Bool
Prelude.Eq, ReadPrec [SSHPublicKeyMetadata]
ReadPrec SSHPublicKeyMetadata
Int -> ReadS SSHPublicKeyMetadata
ReadS [SSHPublicKeyMetadata]
(Int -> ReadS SSHPublicKeyMetadata)
-> ReadS [SSHPublicKeyMetadata]
-> ReadPrec SSHPublicKeyMetadata
-> ReadPrec [SSHPublicKeyMetadata]
-> Read SSHPublicKeyMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SSHPublicKeyMetadata]
$creadListPrec :: ReadPrec [SSHPublicKeyMetadata]
readPrec :: ReadPrec SSHPublicKeyMetadata
$creadPrec :: ReadPrec SSHPublicKeyMetadata
readList :: ReadS [SSHPublicKeyMetadata]
$creadList :: ReadS [SSHPublicKeyMetadata]
readsPrec :: Int -> ReadS SSHPublicKeyMetadata
$creadsPrec :: Int -> ReadS SSHPublicKeyMetadata
Prelude.Read, Int -> SSHPublicKeyMetadata -> ShowS
[SSHPublicKeyMetadata] -> ShowS
SSHPublicKeyMetadata -> String
(Int -> SSHPublicKeyMetadata -> ShowS)
-> (SSHPublicKeyMetadata -> String)
-> ([SSHPublicKeyMetadata] -> ShowS)
-> Show SSHPublicKeyMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SSHPublicKeyMetadata] -> ShowS
$cshowList :: [SSHPublicKeyMetadata] -> ShowS
show :: SSHPublicKeyMetadata -> String
$cshow :: SSHPublicKeyMetadata -> String
showsPrec :: Int -> SSHPublicKeyMetadata -> ShowS
$cshowsPrec :: Int -> SSHPublicKeyMetadata -> ShowS
Prelude.Show, (forall x. SSHPublicKeyMetadata -> Rep SSHPublicKeyMetadata x)
-> (forall x. Rep SSHPublicKeyMetadata x -> SSHPublicKeyMetadata)
-> Generic SSHPublicKeyMetadata
forall x. Rep SSHPublicKeyMetadata x -> SSHPublicKeyMetadata
forall x. SSHPublicKeyMetadata -> Rep SSHPublicKeyMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SSHPublicKeyMetadata x -> SSHPublicKeyMetadata
$cfrom :: forall x. SSHPublicKeyMetadata -> Rep SSHPublicKeyMetadata x
Prelude.Generic)

-- |
-- Create a value of 'SSHPublicKeyMetadata' 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:
--
-- 'userName', 'sSHPublicKeyMetadata_userName' - The name of the IAM user associated with the SSH public key.
--
-- 'sSHPublicKeyId', 'sSHPublicKeyMetadata_sSHPublicKeyId' - The unique identifier for the SSH public key.
--
-- 'status', 'sSHPublicKeyMetadata_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.
--
-- 'uploadDate', 'sSHPublicKeyMetadata_uploadDate' - The date and time, in
-- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the SSH
-- public key was uploaded.
newSSHPublicKeyMetadata ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'sSHPublicKeyId'
  Prelude.Text ->
  -- | 'status'
  StatusType ->
  -- | 'uploadDate'
  Prelude.UTCTime ->
  SSHPublicKeyMetadata
newSSHPublicKeyMetadata :: Text -> Text -> StatusType -> UTCTime -> SSHPublicKeyMetadata
newSSHPublicKeyMetadata
  Text
pUserName_
  Text
pSSHPublicKeyId_
  StatusType
pStatus_
  UTCTime
pUploadDate_ =
    SSHPublicKeyMetadata' :: Text -> Text -> StatusType -> ISO8601 -> SSHPublicKeyMetadata
SSHPublicKeyMetadata'
      { $sel:userName:SSHPublicKeyMetadata' :: Text
userName = Text
pUserName_,
        $sel:sSHPublicKeyId:SSHPublicKeyMetadata' :: Text
sSHPublicKeyId = Text
pSSHPublicKeyId_,
        $sel:status:SSHPublicKeyMetadata' :: StatusType
status = StatusType
pStatus_,
        $sel:uploadDate:SSHPublicKeyMetadata' :: ISO8601
uploadDate = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUploadDate_
      }

-- | The name of the IAM user associated with the SSH public key.
sSHPublicKeyMetadata_userName :: Lens.Lens' SSHPublicKeyMetadata Prelude.Text
sSHPublicKeyMetadata_userName :: (Text -> f Text) -> SSHPublicKeyMetadata -> f SSHPublicKeyMetadata
sSHPublicKeyMetadata_userName = (SSHPublicKeyMetadata -> Text)
-> (SSHPublicKeyMetadata -> Text -> SSHPublicKeyMetadata)
-> Lens SSHPublicKeyMetadata SSHPublicKeyMetadata Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKeyMetadata' {Text
userName :: Text
$sel:userName:SSHPublicKeyMetadata' :: SSHPublicKeyMetadata -> Text
userName} -> Text
userName) (\s :: SSHPublicKeyMetadata
s@SSHPublicKeyMetadata' {} Text
a -> SSHPublicKeyMetadata
s {$sel:userName:SSHPublicKeyMetadata' :: Text
userName = Text
a} :: SSHPublicKeyMetadata)

-- | The unique identifier for the SSH public key.
sSHPublicKeyMetadata_sSHPublicKeyId :: Lens.Lens' SSHPublicKeyMetadata Prelude.Text
sSHPublicKeyMetadata_sSHPublicKeyId :: (Text -> f Text) -> SSHPublicKeyMetadata -> f SSHPublicKeyMetadata
sSHPublicKeyMetadata_sSHPublicKeyId = (SSHPublicKeyMetadata -> Text)
-> (SSHPublicKeyMetadata -> Text -> SSHPublicKeyMetadata)
-> Lens SSHPublicKeyMetadata SSHPublicKeyMetadata Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKeyMetadata' {Text
sSHPublicKeyId :: Text
$sel:sSHPublicKeyId:SSHPublicKeyMetadata' :: SSHPublicKeyMetadata -> Text
sSHPublicKeyId} -> Text
sSHPublicKeyId) (\s :: SSHPublicKeyMetadata
s@SSHPublicKeyMetadata' {} Text
a -> SSHPublicKeyMetadata
s {$sel:sSHPublicKeyId:SSHPublicKeyMetadata' :: Text
sSHPublicKeyId = Text
a} :: SSHPublicKeyMetadata)

-- | 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.
sSHPublicKeyMetadata_status :: Lens.Lens' SSHPublicKeyMetadata StatusType
sSHPublicKeyMetadata_status :: (StatusType -> f StatusType)
-> SSHPublicKeyMetadata -> f SSHPublicKeyMetadata
sSHPublicKeyMetadata_status = (SSHPublicKeyMetadata -> StatusType)
-> (SSHPublicKeyMetadata -> StatusType -> SSHPublicKeyMetadata)
-> Lens
     SSHPublicKeyMetadata SSHPublicKeyMetadata StatusType StatusType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKeyMetadata' {StatusType
status :: StatusType
$sel:status:SSHPublicKeyMetadata' :: SSHPublicKeyMetadata -> StatusType
status} -> StatusType
status) (\s :: SSHPublicKeyMetadata
s@SSHPublicKeyMetadata' {} StatusType
a -> SSHPublicKeyMetadata
s {$sel:status:SSHPublicKeyMetadata' :: StatusType
status = StatusType
a} :: SSHPublicKeyMetadata)

-- | The date and time, in
-- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the SSH
-- public key was uploaded.
sSHPublicKeyMetadata_uploadDate :: Lens.Lens' SSHPublicKeyMetadata Prelude.UTCTime
sSHPublicKeyMetadata_uploadDate :: (UTCTime -> f UTCTime)
-> SSHPublicKeyMetadata -> f SSHPublicKeyMetadata
sSHPublicKeyMetadata_uploadDate = (SSHPublicKeyMetadata -> ISO8601)
-> (SSHPublicKeyMetadata -> ISO8601 -> SSHPublicKeyMetadata)
-> Lens SSHPublicKeyMetadata SSHPublicKeyMetadata ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SSHPublicKeyMetadata' {ISO8601
uploadDate :: ISO8601
$sel:uploadDate:SSHPublicKeyMetadata' :: SSHPublicKeyMetadata -> ISO8601
uploadDate} -> ISO8601
uploadDate) (\s :: SSHPublicKeyMetadata
s@SSHPublicKeyMetadata' {} ISO8601
a -> SSHPublicKeyMetadata
s {$sel:uploadDate:SSHPublicKeyMetadata' :: ISO8601
uploadDate = ISO8601
a} :: SSHPublicKeyMetadata) ((ISO8601 -> f ISO8601)
 -> SSHPublicKeyMetadata -> f SSHPublicKeyMetadata)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> SSHPublicKeyMetadata
-> f SSHPublicKeyMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML SSHPublicKeyMetadata where
  parseXML :: [Node] -> Either String SSHPublicKeyMetadata
parseXML [Node]
x =
    Text -> Text -> StatusType -> ISO8601 -> SSHPublicKeyMetadata
SSHPublicKeyMetadata'
      (Text -> Text -> StatusType -> ISO8601 -> SSHPublicKeyMetadata)
-> Either String Text
-> Either
     String (Text -> StatusType -> ISO8601 -> SSHPublicKeyMetadata)
forall (f :: * -> *) a b. Functor 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 -> StatusType -> ISO8601 -> SSHPublicKeyMetadata)
-> Either String Text
-> Either String (StatusType -> ISO8601 -> SSHPublicKeyMetadata)
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 (StatusType -> ISO8601 -> SSHPublicKeyMetadata)
-> Either String StatusType
-> Either String (ISO8601 -> SSHPublicKeyMetadata)
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")
      Either String (ISO8601 -> SSHPublicKeyMetadata)
-> Either String ISO8601 -> Either String SSHPublicKeyMetadata
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ISO8601
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"UploadDate")

instance Prelude.Hashable SSHPublicKeyMetadata

instance Prelude.NFData SSHPublicKeyMetadata