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

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

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

-- |
-- Create a value of 'ActiveTrustedSigners' 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', 'activeTrustedSigners_items' - A list of accounts and the identifiers of active CloudFront key pairs in
-- each account that CloudFront can use to verify the signatures of signed
-- URLs and signed cookies.
--
-- 'enabled', 'activeTrustedSigners_enabled' - This field is @true@ if any of the accounts in the list have active
-- CloudFront key pairs that CloudFront can use to verify the signatures of
-- signed URLs and signed cookies. If not, this field is @false@.
--
-- 'quantity', 'activeTrustedSigners_quantity' - The number of accounts in the list.
newActiveTrustedSigners ::
  -- | 'enabled'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  ActiveTrustedSigners
newActiveTrustedSigners :: Bool -> Int -> ActiveTrustedSigners
newActiveTrustedSigners Bool
pEnabled_ Int
pQuantity_ =
  ActiveTrustedSigners' :: Maybe [Signer] -> Bool -> Int -> ActiveTrustedSigners
ActiveTrustedSigners'
    { $sel:items:ActiveTrustedSigners' :: Maybe [Signer]
items = Maybe [Signer]
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:ActiveTrustedSigners' :: Bool
enabled = Bool
pEnabled_,
      $sel:quantity:ActiveTrustedSigners' :: Int
quantity = Int
pQuantity_
    }

-- | A list of accounts and the identifiers of active CloudFront key pairs in
-- each account that CloudFront can use to verify the signatures of signed
-- URLs and signed cookies.
activeTrustedSigners_items :: Lens.Lens' ActiveTrustedSigners (Prelude.Maybe [Signer])
activeTrustedSigners_items :: (Maybe [Signer] -> f (Maybe [Signer]))
-> ActiveTrustedSigners -> f ActiveTrustedSigners
activeTrustedSigners_items = (ActiveTrustedSigners -> Maybe [Signer])
-> (ActiveTrustedSigners -> Maybe [Signer] -> ActiveTrustedSigners)
-> Lens
     ActiveTrustedSigners
     ActiveTrustedSigners
     (Maybe [Signer])
     (Maybe [Signer])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveTrustedSigners' {Maybe [Signer]
items :: Maybe [Signer]
$sel:items:ActiveTrustedSigners' :: ActiveTrustedSigners -> Maybe [Signer]
items} -> Maybe [Signer]
items) (\s :: ActiveTrustedSigners
s@ActiveTrustedSigners' {} Maybe [Signer]
a -> ActiveTrustedSigners
s {$sel:items:ActiveTrustedSigners' :: Maybe [Signer]
items = Maybe [Signer]
a} :: ActiveTrustedSigners) ((Maybe [Signer] -> f (Maybe [Signer]))
 -> ActiveTrustedSigners -> f ActiveTrustedSigners)
-> ((Maybe [Signer] -> f (Maybe [Signer]))
    -> Maybe [Signer] -> f (Maybe [Signer]))
-> (Maybe [Signer] -> f (Maybe [Signer]))
-> ActiveTrustedSigners
-> f ActiveTrustedSigners
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Signer] [Signer] [Signer] [Signer]
-> Iso
     (Maybe [Signer]) (Maybe [Signer]) (Maybe [Signer]) (Maybe [Signer])
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 [Signer] [Signer] [Signer] [Signer]
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 accounts in the list have active
-- CloudFront key pairs that CloudFront can use to verify the signatures of
-- signed URLs and signed cookies. If not, this field is @false@.
activeTrustedSigners_enabled :: Lens.Lens' ActiveTrustedSigners Prelude.Bool
activeTrustedSigners_enabled :: (Bool -> f Bool) -> ActiveTrustedSigners -> f ActiveTrustedSigners
activeTrustedSigners_enabled = (ActiveTrustedSigners -> Bool)
-> (ActiveTrustedSigners -> Bool -> ActiveTrustedSigners)
-> Lens ActiveTrustedSigners ActiveTrustedSigners Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveTrustedSigners' {Bool
enabled :: Bool
$sel:enabled:ActiveTrustedSigners' :: ActiveTrustedSigners -> Bool
enabled} -> Bool
enabled) (\s :: ActiveTrustedSigners
s@ActiveTrustedSigners' {} Bool
a -> ActiveTrustedSigners
s {$sel:enabled:ActiveTrustedSigners' :: Bool
enabled = Bool
a} :: ActiveTrustedSigners)

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

instance Core.FromXML ActiveTrustedSigners where
  parseXML :: [Node] -> Either String ActiveTrustedSigners
parseXML [Node]
x =
    Maybe [Signer] -> Bool -> Int -> ActiveTrustedSigners
ActiveTrustedSigners'
      (Maybe [Signer] -> Bool -> Int -> ActiveTrustedSigners)
-> Either String (Maybe [Signer])
-> Either String (Bool -> Int -> ActiveTrustedSigners)
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 [Signer]))
-> Either String (Maybe [Signer])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Signer])
-> [Node] -> Either String (Maybe [Signer])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Signer]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Signer")
                  )
      Either String (Bool -> Int -> ActiveTrustedSigners)
-> Either String Bool
-> Either String (Int -> ActiveTrustedSigners)
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 -> ActiveTrustedSigners)
-> Either String Int -> Either String ActiveTrustedSigners
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 ActiveTrustedSigners

instance Prelude.NFData ActiveTrustedSigners