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

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

-- | A list of key groups, and the public keys in each key group, that
-- CloudFront can use to verify the signatures of signed URLs and signed
-- cookies.
--
-- /See:/ 'newActiveTrustedKeyGroups' smart constructor.
data ActiveTrustedKeyGroups = ActiveTrustedKeyGroups'
  { -- | A list of key groups, including the identifiers of the public keys in
    -- each key group that CloudFront can use to verify the signatures of
    -- signed URLs and signed cookies.
    ActiveTrustedKeyGroups -> Maybe [KGKeyPairIds]
items :: Prelude.Maybe [KGKeyPairIds],
    -- | This field is @true@ if any of the key groups have public keys that
    -- CloudFront can use to verify the signatures of signed URLs and signed
    -- cookies. If not, this field is @false@.
    ActiveTrustedKeyGroups -> Bool
enabled :: Prelude.Bool,
    -- | The number of key groups in the list.
    ActiveTrustedKeyGroups -> Int
quantity :: Prelude.Int
  }
  deriving (ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool
(ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool)
-> (ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool)
-> Eq ActiveTrustedKeyGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool
$c/= :: ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool
== :: ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool
$c== :: ActiveTrustedKeyGroups -> ActiveTrustedKeyGroups -> Bool
Prelude.Eq, ReadPrec [ActiveTrustedKeyGroups]
ReadPrec ActiveTrustedKeyGroups
Int -> ReadS ActiveTrustedKeyGroups
ReadS [ActiveTrustedKeyGroups]
(Int -> ReadS ActiveTrustedKeyGroups)
-> ReadS [ActiveTrustedKeyGroups]
-> ReadPrec ActiveTrustedKeyGroups
-> ReadPrec [ActiveTrustedKeyGroups]
-> Read ActiveTrustedKeyGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActiveTrustedKeyGroups]
$creadListPrec :: ReadPrec [ActiveTrustedKeyGroups]
readPrec :: ReadPrec ActiveTrustedKeyGroups
$creadPrec :: ReadPrec ActiveTrustedKeyGroups
readList :: ReadS [ActiveTrustedKeyGroups]
$creadList :: ReadS [ActiveTrustedKeyGroups]
readsPrec :: Int -> ReadS ActiveTrustedKeyGroups
$creadsPrec :: Int -> ReadS ActiveTrustedKeyGroups
Prelude.Read, Int -> ActiveTrustedKeyGroups -> ShowS
[ActiveTrustedKeyGroups] -> ShowS
ActiveTrustedKeyGroups -> String
(Int -> ActiveTrustedKeyGroups -> ShowS)
-> (ActiveTrustedKeyGroups -> String)
-> ([ActiveTrustedKeyGroups] -> ShowS)
-> Show ActiveTrustedKeyGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActiveTrustedKeyGroups] -> ShowS
$cshowList :: [ActiveTrustedKeyGroups] -> ShowS
show :: ActiveTrustedKeyGroups -> String
$cshow :: ActiveTrustedKeyGroups -> String
showsPrec :: Int -> ActiveTrustedKeyGroups -> ShowS
$cshowsPrec :: Int -> ActiveTrustedKeyGroups -> ShowS
Prelude.Show, (forall x. ActiveTrustedKeyGroups -> Rep ActiveTrustedKeyGroups x)
-> (forall x.
    Rep ActiveTrustedKeyGroups x -> ActiveTrustedKeyGroups)
-> Generic ActiveTrustedKeyGroups
forall x. Rep ActiveTrustedKeyGroups x -> ActiveTrustedKeyGroups
forall x. ActiveTrustedKeyGroups -> Rep ActiveTrustedKeyGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActiveTrustedKeyGroups x -> ActiveTrustedKeyGroups
$cfrom :: forall x. ActiveTrustedKeyGroups -> Rep ActiveTrustedKeyGroups x
Prelude.Generic)

-- |
-- Create a value of 'ActiveTrustedKeyGroups' 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:
--
-- 'items', 'activeTrustedKeyGroups_items' - A list of key groups, including the identifiers of the public keys in
-- each key group that CloudFront can use to verify the signatures of
-- signed URLs and signed cookies.
--
-- 'enabled', 'activeTrustedKeyGroups_enabled' - This field is @true@ if any of the key groups have public keys that
-- CloudFront can use to verify the signatures of signed URLs and signed
-- cookies. If not, this field is @false@.
--
-- 'quantity', 'activeTrustedKeyGroups_quantity' - The number of key groups in the list.
newActiveTrustedKeyGroups ::
  -- | 'enabled'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  ActiveTrustedKeyGroups
newActiveTrustedKeyGroups :: Bool -> Int -> ActiveTrustedKeyGroups
newActiveTrustedKeyGroups Bool
pEnabled_ Int
pQuantity_ =
  ActiveTrustedKeyGroups' :: Maybe [KGKeyPairIds] -> Bool -> Int -> ActiveTrustedKeyGroups
ActiveTrustedKeyGroups'
    { $sel:items:ActiveTrustedKeyGroups' :: Maybe [KGKeyPairIds]
items = Maybe [KGKeyPairIds]
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:ActiveTrustedKeyGroups' :: Bool
enabled = Bool
pEnabled_,
      $sel:quantity:ActiveTrustedKeyGroups' :: Int
quantity = Int
pQuantity_
    }

-- | A list of key groups, including the identifiers of the public keys in
-- each key group that CloudFront can use to verify the signatures of
-- signed URLs and signed cookies.
activeTrustedKeyGroups_items :: Lens.Lens' ActiveTrustedKeyGroups (Prelude.Maybe [KGKeyPairIds])
activeTrustedKeyGroups_items :: (Maybe [KGKeyPairIds] -> f (Maybe [KGKeyPairIds]))
-> ActiveTrustedKeyGroups -> f ActiveTrustedKeyGroups
activeTrustedKeyGroups_items = (ActiveTrustedKeyGroups -> Maybe [KGKeyPairIds])
-> (ActiveTrustedKeyGroups
    -> Maybe [KGKeyPairIds] -> ActiveTrustedKeyGroups)
-> Lens
     ActiveTrustedKeyGroups
     ActiveTrustedKeyGroups
     (Maybe [KGKeyPairIds])
     (Maybe [KGKeyPairIds])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveTrustedKeyGroups' {Maybe [KGKeyPairIds]
items :: Maybe [KGKeyPairIds]
$sel:items:ActiveTrustedKeyGroups' :: ActiveTrustedKeyGroups -> Maybe [KGKeyPairIds]
items} -> Maybe [KGKeyPairIds]
items) (\s :: ActiveTrustedKeyGroups
s@ActiveTrustedKeyGroups' {} Maybe [KGKeyPairIds]
a -> ActiveTrustedKeyGroups
s {$sel:items:ActiveTrustedKeyGroups' :: Maybe [KGKeyPairIds]
items = Maybe [KGKeyPairIds]
a} :: ActiveTrustedKeyGroups) ((Maybe [KGKeyPairIds] -> f (Maybe [KGKeyPairIds]))
 -> ActiveTrustedKeyGroups -> f ActiveTrustedKeyGroups)
-> ((Maybe [KGKeyPairIds] -> f (Maybe [KGKeyPairIds]))
    -> Maybe [KGKeyPairIds] -> f (Maybe [KGKeyPairIds]))
-> (Maybe [KGKeyPairIds] -> f (Maybe [KGKeyPairIds]))
-> ActiveTrustedKeyGroups
-> f ActiveTrustedKeyGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [KGKeyPairIds] [KGKeyPairIds] [KGKeyPairIds] [KGKeyPairIds]
-> Iso
     (Maybe [KGKeyPairIds])
     (Maybe [KGKeyPairIds])
     (Maybe [KGKeyPairIds])
     (Maybe [KGKeyPairIds])
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 [KGKeyPairIds] [KGKeyPairIds] [KGKeyPairIds] [KGKeyPairIds]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This field is @true@ if any of the key groups have public keys that
-- CloudFront can use to verify the signatures of signed URLs and signed
-- cookies. If not, this field is @false@.
activeTrustedKeyGroups_enabled :: Lens.Lens' ActiveTrustedKeyGroups Prelude.Bool
activeTrustedKeyGroups_enabled :: (Bool -> f Bool)
-> ActiveTrustedKeyGroups -> f ActiveTrustedKeyGroups
activeTrustedKeyGroups_enabled = (ActiveTrustedKeyGroups -> Bool)
-> (ActiveTrustedKeyGroups -> Bool -> ActiveTrustedKeyGroups)
-> Lens ActiveTrustedKeyGroups ActiveTrustedKeyGroups Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveTrustedKeyGroups' {Bool
enabled :: Bool
$sel:enabled:ActiveTrustedKeyGroups' :: ActiveTrustedKeyGroups -> Bool
enabled} -> Bool
enabled) (\s :: ActiveTrustedKeyGroups
s@ActiveTrustedKeyGroups' {} Bool
a -> ActiveTrustedKeyGroups
s {$sel:enabled:ActiveTrustedKeyGroups' :: Bool
enabled = Bool
a} :: ActiveTrustedKeyGroups)

-- | The number of key groups in the list.
activeTrustedKeyGroups_quantity :: Lens.Lens' ActiveTrustedKeyGroups Prelude.Int
activeTrustedKeyGroups_quantity :: (Int -> f Int)
-> ActiveTrustedKeyGroups -> f ActiveTrustedKeyGroups
activeTrustedKeyGroups_quantity = (ActiveTrustedKeyGroups -> Int)
-> (ActiveTrustedKeyGroups -> Int -> ActiveTrustedKeyGroups)
-> Lens ActiveTrustedKeyGroups ActiveTrustedKeyGroups Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveTrustedKeyGroups' {Int
quantity :: Int
$sel:quantity:ActiveTrustedKeyGroups' :: ActiveTrustedKeyGroups -> Int
quantity} -> Int
quantity) (\s :: ActiveTrustedKeyGroups
s@ActiveTrustedKeyGroups' {} Int
a -> ActiveTrustedKeyGroups
s {$sel:quantity:ActiveTrustedKeyGroups' :: Int
quantity = Int
a} :: ActiveTrustedKeyGroups)

instance Core.FromXML ActiveTrustedKeyGroups where
  parseXML :: [Node] -> Either String ActiveTrustedKeyGroups
parseXML [Node]
x =
    Maybe [KGKeyPairIds] -> Bool -> Int -> ActiveTrustedKeyGroups
ActiveTrustedKeyGroups'
      (Maybe [KGKeyPairIds] -> Bool -> Int -> ActiveTrustedKeyGroups)
-> Either String (Maybe [KGKeyPairIds])
-> Either String (Bool -> Int -> ActiveTrustedKeyGroups)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Items" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [KGKeyPairIds]))
-> Either String (Maybe [KGKeyPairIds])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [KGKeyPairIds])
-> [Node] -> Either String (Maybe [KGKeyPairIds])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [KGKeyPairIds]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"KeyGroup")
                  )
      Either String (Bool -> Int -> ActiveTrustedKeyGroups)
-> Either String Bool
-> Either String (Int -> ActiveTrustedKeyGroups)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Bool
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Enabled")
      Either String (Int -> ActiveTrustedKeyGroups)
-> Either String Int -> Either String ActiveTrustedKeyGroups
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Int
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Quantity")

instance Prelude.Hashable ActiveTrustedKeyGroups

instance Prelude.NFData ActiveTrustedKeyGroups