{-# 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.CloudFront.Types.PublicKeySummary
-- 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.CloudFront.Types.PublicKeySummary where

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

-- | Contains information about a public key.
--
-- /See:/ 'newPublicKeySummary' smart constructor.
data PublicKeySummary = PublicKeySummary'
  { -- | A comment to describe the public key. The comment cannot be longer than
    -- 128 characters.
    PublicKeySummary -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the public key.
    PublicKeySummary -> Text
id :: Prelude.Text,
    -- | A name to help identify the public key.
    PublicKeySummary -> Text
name :: Prelude.Text,
    -- | The date and time when the public key was uploaded.
    PublicKeySummary -> ISO8601
createdTime :: Core.ISO8601,
    -- | The public key.
    PublicKeySummary -> Text
encodedKey :: Prelude.Text
  }
  deriving (PublicKeySummary -> PublicKeySummary -> Bool
(PublicKeySummary -> PublicKeySummary -> Bool)
-> (PublicKeySummary -> PublicKeySummary -> Bool)
-> Eq PublicKeySummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublicKeySummary -> PublicKeySummary -> Bool
$c/= :: PublicKeySummary -> PublicKeySummary -> Bool
== :: PublicKeySummary -> PublicKeySummary -> Bool
$c== :: PublicKeySummary -> PublicKeySummary -> Bool
Prelude.Eq, ReadPrec [PublicKeySummary]
ReadPrec PublicKeySummary
Int -> ReadS PublicKeySummary
ReadS [PublicKeySummary]
(Int -> ReadS PublicKeySummary)
-> ReadS [PublicKeySummary]
-> ReadPrec PublicKeySummary
-> ReadPrec [PublicKeySummary]
-> Read PublicKeySummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublicKeySummary]
$creadListPrec :: ReadPrec [PublicKeySummary]
readPrec :: ReadPrec PublicKeySummary
$creadPrec :: ReadPrec PublicKeySummary
readList :: ReadS [PublicKeySummary]
$creadList :: ReadS [PublicKeySummary]
readsPrec :: Int -> ReadS PublicKeySummary
$creadsPrec :: Int -> ReadS PublicKeySummary
Prelude.Read, Int -> PublicKeySummary -> ShowS
[PublicKeySummary] -> ShowS
PublicKeySummary -> String
(Int -> PublicKeySummary -> ShowS)
-> (PublicKeySummary -> String)
-> ([PublicKeySummary] -> ShowS)
-> Show PublicKeySummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublicKeySummary] -> ShowS
$cshowList :: [PublicKeySummary] -> ShowS
show :: PublicKeySummary -> String
$cshow :: PublicKeySummary -> String
showsPrec :: Int -> PublicKeySummary -> ShowS
$cshowsPrec :: Int -> PublicKeySummary -> ShowS
Prelude.Show, (forall x. PublicKeySummary -> Rep PublicKeySummary x)
-> (forall x. Rep PublicKeySummary x -> PublicKeySummary)
-> Generic PublicKeySummary
forall x. Rep PublicKeySummary x -> PublicKeySummary
forall x. PublicKeySummary -> Rep PublicKeySummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublicKeySummary x -> PublicKeySummary
$cfrom :: forall x. PublicKeySummary -> Rep PublicKeySummary x
Prelude.Generic)

-- |
-- Create a value of 'PublicKeySummary' 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:
--
-- 'comment', 'publicKeySummary_comment' - A comment to describe the public key. The comment cannot be longer than
-- 128 characters.
--
-- 'id', 'publicKeySummary_id' - The identifier of the public key.
--
-- 'name', 'publicKeySummary_name' - A name to help identify the public key.
--
-- 'createdTime', 'publicKeySummary_createdTime' - The date and time when the public key was uploaded.
--
-- 'encodedKey', 'publicKeySummary_encodedKey' - The public key.
newPublicKeySummary ::
  -- | 'id'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'createdTime'
  Prelude.UTCTime ->
  -- | 'encodedKey'
  Prelude.Text ->
  PublicKeySummary
newPublicKeySummary :: Text -> Text -> UTCTime -> Text -> PublicKeySummary
newPublicKeySummary
  Text
pId_
  Text
pName_
  UTCTime
pCreatedTime_
  Text
pEncodedKey_ =
    PublicKeySummary' :: Maybe Text -> Text -> Text -> ISO8601 -> Text -> PublicKeySummary
PublicKeySummary'
      { $sel:comment:PublicKeySummary' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:id:PublicKeySummary' :: Text
id = Text
pId_,
        $sel:name:PublicKeySummary' :: Text
name = Text
pName_,
        $sel:createdTime:PublicKeySummary' :: ISO8601
createdTime = 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
pCreatedTime_,
        $sel:encodedKey:PublicKeySummary' :: Text
encodedKey = Text
pEncodedKey_
      }

-- | A comment to describe the public key. The comment cannot be longer than
-- 128 characters.
publicKeySummary_comment :: Lens.Lens' PublicKeySummary (Prelude.Maybe Prelude.Text)
publicKeySummary_comment :: (Maybe Text -> f (Maybe Text))
-> PublicKeySummary -> f PublicKeySummary
publicKeySummary_comment = (PublicKeySummary -> Maybe Text)
-> (PublicKeySummary -> Maybe Text -> PublicKeySummary)
-> Lens PublicKeySummary PublicKeySummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeySummary' {Maybe Text
comment :: Maybe Text
$sel:comment:PublicKeySummary' :: PublicKeySummary -> Maybe Text
comment} -> Maybe Text
comment) (\s :: PublicKeySummary
s@PublicKeySummary' {} Maybe Text
a -> PublicKeySummary
s {$sel:comment:PublicKeySummary' :: Maybe Text
comment = Maybe Text
a} :: PublicKeySummary)

-- | The identifier of the public key.
publicKeySummary_id :: Lens.Lens' PublicKeySummary Prelude.Text
publicKeySummary_id :: (Text -> f Text) -> PublicKeySummary -> f PublicKeySummary
publicKeySummary_id = (PublicKeySummary -> Text)
-> (PublicKeySummary -> Text -> PublicKeySummary)
-> Lens PublicKeySummary PublicKeySummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeySummary' {Text
id :: Text
$sel:id:PublicKeySummary' :: PublicKeySummary -> Text
id} -> Text
id) (\s :: PublicKeySummary
s@PublicKeySummary' {} Text
a -> PublicKeySummary
s {$sel:id:PublicKeySummary' :: Text
id = Text
a} :: PublicKeySummary)

-- | A name to help identify the public key.
publicKeySummary_name :: Lens.Lens' PublicKeySummary Prelude.Text
publicKeySummary_name :: (Text -> f Text) -> PublicKeySummary -> f PublicKeySummary
publicKeySummary_name = (PublicKeySummary -> Text)
-> (PublicKeySummary -> Text -> PublicKeySummary)
-> Lens PublicKeySummary PublicKeySummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeySummary' {Text
name :: Text
$sel:name:PublicKeySummary' :: PublicKeySummary -> Text
name} -> Text
name) (\s :: PublicKeySummary
s@PublicKeySummary' {} Text
a -> PublicKeySummary
s {$sel:name:PublicKeySummary' :: Text
name = Text
a} :: PublicKeySummary)

-- | The date and time when the public key was uploaded.
publicKeySummary_createdTime :: Lens.Lens' PublicKeySummary Prelude.UTCTime
publicKeySummary_createdTime :: (UTCTime -> f UTCTime) -> PublicKeySummary -> f PublicKeySummary
publicKeySummary_createdTime = (PublicKeySummary -> ISO8601)
-> (PublicKeySummary -> ISO8601 -> PublicKeySummary)
-> Lens PublicKeySummary PublicKeySummary ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeySummary' {ISO8601
createdTime :: ISO8601
$sel:createdTime:PublicKeySummary' :: PublicKeySummary -> ISO8601
createdTime} -> ISO8601
createdTime) (\s :: PublicKeySummary
s@PublicKeySummary' {} ISO8601
a -> PublicKeySummary
s {$sel:createdTime:PublicKeySummary' :: ISO8601
createdTime = ISO8601
a} :: PublicKeySummary) ((ISO8601 -> f ISO8601) -> PublicKeySummary -> f PublicKeySummary)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> PublicKeySummary
-> f PublicKeySummary
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

-- | The public key.
publicKeySummary_encodedKey :: Lens.Lens' PublicKeySummary Prelude.Text
publicKeySummary_encodedKey :: (Text -> f Text) -> PublicKeySummary -> f PublicKeySummary
publicKeySummary_encodedKey = (PublicKeySummary -> Text)
-> (PublicKeySummary -> Text -> PublicKeySummary)
-> Lens PublicKeySummary PublicKeySummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeySummary' {Text
encodedKey :: Text
$sel:encodedKey:PublicKeySummary' :: PublicKeySummary -> Text
encodedKey} -> Text
encodedKey) (\s :: PublicKeySummary
s@PublicKeySummary' {} Text
a -> PublicKeySummary
s {$sel:encodedKey:PublicKeySummary' :: Text
encodedKey = Text
a} :: PublicKeySummary)

instance Core.FromXML PublicKeySummary where
  parseXML :: [Node] -> Either String PublicKeySummary
parseXML [Node]
x =
    Maybe Text -> Text -> Text -> ISO8601 -> Text -> PublicKeySummary
PublicKeySummary'
      (Maybe Text -> Text -> Text -> ISO8601 -> Text -> PublicKeySummary)
-> Either String (Maybe Text)
-> Either
     String (Text -> Text -> ISO8601 -> Text -> PublicKeySummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Comment")
      Either String (Text -> Text -> ISO8601 -> Text -> PublicKeySummary)
-> Either String Text
-> Either String (Text -> ISO8601 -> Text -> PublicKeySummary)
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
"Id")
      Either String (Text -> ISO8601 -> Text -> PublicKeySummary)
-> Either String Text
-> Either String (ISO8601 -> Text -> PublicKeySummary)
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
"Name")
      Either String (ISO8601 -> Text -> PublicKeySummary)
-> Either String ISO8601
-> Either String (Text -> PublicKeySummary)
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
"CreatedTime")
      Either String (Text -> PublicKeySummary)
-> Either String Text -> Either String PublicKeySummary
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
"EncodedKey")

instance Prelude.Hashable PublicKeySummary

instance Prelude.NFData PublicKeySummary