{-# 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.KeyGroup
-- 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.KeyGroup where

import Amazonka.CloudFront.Types.KeyGroupConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A key group.
--
-- A key group contains a list of public keys that you can use with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html CloudFront signed URLs and signed cookies>.
--
-- /See:/ 'newKeyGroup' smart constructor.
data KeyGroup = KeyGroup'
  { -- | The identifier for the key group.
    KeyGroup -> Text
id :: Prelude.Text,
    -- | The date and time when the key group was last modified.
    KeyGroup -> ISO8601
lastModifiedTime :: Core.ISO8601,
    -- | The key group configuration.
    KeyGroup -> KeyGroupConfig
keyGroupConfig :: KeyGroupConfig
  }
  deriving (KeyGroup -> KeyGroup -> Bool
(KeyGroup -> KeyGroup -> Bool)
-> (KeyGroup -> KeyGroup -> Bool) -> Eq KeyGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyGroup -> KeyGroup -> Bool
$c/= :: KeyGroup -> KeyGroup -> Bool
== :: KeyGroup -> KeyGroup -> Bool
$c== :: KeyGroup -> KeyGroup -> Bool
Prelude.Eq, ReadPrec [KeyGroup]
ReadPrec KeyGroup
Int -> ReadS KeyGroup
ReadS [KeyGroup]
(Int -> ReadS KeyGroup)
-> ReadS [KeyGroup]
-> ReadPrec KeyGroup
-> ReadPrec [KeyGroup]
-> Read KeyGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyGroup]
$creadListPrec :: ReadPrec [KeyGroup]
readPrec :: ReadPrec KeyGroup
$creadPrec :: ReadPrec KeyGroup
readList :: ReadS [KeyGroup]
$creadList :: ReadS [KeyGroup]
readsPrec :: Int -> ReadS KeyGroup
$creadsPrec :: Int -> ReadS KeyGroup
Prelude.Read, Int -> KeyGroup -> ShowS
[KeyGroup] -> ShowS
KeyGroup -> String
(Int -> KeyGroup -> ShowS)
-> (KeyGroup -> String) -> ([KeyGroup] -> ShowS) -> Show KeyGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyGroup] -> ShowS
$cshowList :: [KeyGroup] -> ShowS
show :: KeyGroup -> String
$cshow :: KeyGroup -> String
showsPrec :: Int -> KeyGroup -> ShowS
$cshowsPrec :: Int -> KeyGroup -> ShowS
Prelude.Show, (forall x. KeyGroup -> Rep KeyGroup x)
-> (forall x. Rep KeyGroup x -> KeyGroup) -> Generic KeyGroup
forall x. Rep KeyGroup x -> KeyGroup
forall x. KeyGroup -> Rep KeyGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyGroup x -> KeyGroup
$cfrom :: forall x. KeyGroup -> Rep KeyGroup x
Prelude.Generic)

-- |
-- Create a value of 'KeyGroup' 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:
--
-- 'id', 'keyGroup_id' - The identifier for the key group.
--
-- 'lastModifiedTime', 'keyGroup_lastModifiedTime' - The date and time when the key group was last modified.
--
-- 'keyGroupConfig', 'keyGroup_keyGroupConfig' - The key group configuration.
newKeyGroup ::
  -- | 'id'
  Prelude.Text ->
  -- | 'lastModifiedTime'
  Prelude.UTCTime ->
  -- | 'keyGroupConfig'
  KeyGroupConfig ->
  KeyGroup
newKeyGroup :: Text -> UTCTime -> KeyGroupConfig -> KeyGroup
newKeyGroup Text
pId_ UTCTime
pLastModifiedTime_ KeyGroupConfig
pKeyGroupConfig_ =
  KeyGroup' :: Text -> ISO8601 -> KeyGroupConfig -> KeyGroup
KeyGroup'
    { $sel:id:KeyGroup' :: Text
id = Text
pId_,
      $sel:lastModifiedTime:KeyGroup' :: ISO8601
lastModifiedTime =
        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
pLastModifiedTime_,
      $sel:keyGroupConfig:KeyGroup' :: KeyGroupConfig
keyGroupConfig = KeyGroupConfig
pKeyGroupConfig_
    }

-- | The identifier for the key group.
keyGroup_id :: Lens.Lens' KeyGroup Prelude.Text
keyGroup_id :: (Text -> f Text) -> KeyGroup -> f KeyGroup
keyGroup_id = (KeyGroup -> Text)
-> (KeyGroup -> Text -> KeyGroup)
-> Lens KeyGroup KeyGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroup' {Text
id :: Text
$sel:id:KeyGroup' :: KeyGroup -> Text
id} -> Text
id) (\s :: KeyGroup
s@KeyGroup' {} Text
a -> KeyGroup
s {$sel:id:KeyGroup' :: Text
id = Text
a} :: KeyGroup)

-- | The date and time when the key group was last modified.
keyGroup_lastModifiedTime :: Lens.Lens' KeyGroup Prelude.UTCTime
keyGroup_lastModifiedTime :: (UTCTime -> f UTCTime) -> KeyGroup -> f KeyGroup
keyGroup_lastModifiedTime = (KeyGroup -> ISO8601)
-> (KeyGroup -> ISO8601 -> KeyGroup)
-> Lens KeyGroup KeyGroup ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroup' {ISO8601
lastModifiedTime :: ISO8601
$sel:lastModifiedTime:KeyGroup' :: KeyGroup -> ISO8601
lastModifiedTime} -> ISO8601
lastModifiedTime) (\s :: KeyGroup
s@KeyGroup' {} ISO8601
a -> KeyGroup
s {$sel:lastModifiedTime:KeyGroup' :: ISO8601
lastModifiedTime = ISO8601
a} :: KeyGroup) ((ISO8601 -> f ISO8601) -> KeyGroup -> f KeyGroup)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> KeyGroup
-> f KeyGroup
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 key group configuration.
keyGroup_keyGroupConfig :: Lens.Lens' KeyGroup KeyGroupConfig
keyGroup_keyGroupConfig :: (KeyGroupConfig -> f KeyGroupConfig) -> KeyGroup -> f KeyGroup
keyGroup_keyGroupConfig = (KeyGroup -> KeyGroupConfig)
-> (KeyGroup -> KeyGroupConfig -> KeyGroup)
-> Lens KeyGroup KeyGroup KeyGroupConfig KeyGroupConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyGroup' {KeyGroupConfig
keyGroupConfig :: KeyGroupConfig
$sel:keyGroupConfig:KeyGroup' :: KeyGroup -> KeyGroupConfig
keyGroupConfig} -> KeyGroupConfig
keyGroupConfig) (\s :: KeyGroup
s@KeyGroup' {} KeyGroupConfig
a -> KeyGroup
s {$sel:keyGroupConfig:KeyGroup' :: KeyGroupConfig
keyGroupConfig = KeyGroupConfig
a} :: KeyGroup)

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

instance Prelude.Hashable KeyGroup

instance Prelude.NFData KeyGroup