{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A list of Amazon Web Services 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 Amazon Web Services 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 Amazon Web Services 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 Amazon Web Services accounts in the list.
    ActiveTrustedSigners -> Int
quantity :: Prelude.Int
  }
  deriving (ActiveTrustedSigners -> ActiveTrustedSigners -> Bool
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]
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
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. 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 Amazon Web Services 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 Amazon Web Services 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 Amazon Web Services accounts in the list.
newActiveTrustedSigners ::
  -- | 'enabled'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  ActiveTrustedSigners
newActiveTrustedSigners :: Bool -> Int -> ActiveTrustedSigners
newActiveTrustedSigners Bool
pEnabled_ Int
pQuantity_ =
  ActiveTrustedSigners'
    { $sel:items:ActiveTrustedSigners' :: Maybe [Signer]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:ActiveTrustedSigners' :: Bool
enabled = Bool
pEnabled_,
      $sel:quantity:ActiveTrustedSigners' :: Int
quantity = Int
pQuantity_
    }

-- | A list of Amazon Web Services 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 :: Lens' ActiveTrustedSigners (Maybe [Signer])
activeTrustedSigners_items = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 Amazon Web Services 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 :: Lens' ActiveTrustedSigners Bool
activeTrustedSigners_enabled = 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 Amazon Web Services accounts in the list.
activeTrustedSigners_quantity :: Lens.Lens' ActiveTrustedSigners Prelude.Int
activeTrustedSigners_quantity :: Lens' ActiveTrustedSigners Int
activeTrustedSigners_quantity = 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 Data.FromXML ActiveTrustedSigners where
  parseXML :: [Node] -> Either String ActiveTrustedSigners
parseXML [Node]
x =
    Maybe [Signer] -> Bool -> Int -> ActiveTrustedSigners
ActiveTrustedSigners'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Items"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"Signer")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Enabled")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Quantity")

instance Prelude.Hashable ActiveTrustedSigners where
  hashWithSalt :: Int -> ActiveTrustedSigners -> Int
hashWithSalt Int
_salt ActiveTrustedSigners' {Bool
Int
Maybe [Signer]
quantity :: Int
enabled :: Bool
items :: Maybe [Signer]
$sel:quantity:ActiveTrustedSigners' :: ActiveTrustedSigners -> Int
$sel:enabled:ActiveTrustedSigners' :: ActiveTrustedSigners -> Bool
$sel:items:ActiveTrustedSigners' :: ActiveTrustedSigners -> Maybe [Signer]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Signer]
items
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

instance Prelude.NFData ActiveTrustedSigners where
  rnf :: ActiveTrustedSigners -> ()
rnf ActiveTrustedSigners' {Bool
Int
Maybe [Signer]
quantity :: Int
enabled :: Bool
items :: Maybe [Signer]
$sel:quantity:ActiveTrustedSigners' :: ActiveTrustedSigners -> Int
$sel:enabled:ActiveTrustedSigners' :: ActiveTrustedSigners -> Bool
$sel:items:ActiveTrustedSigners' :: ActiveTrustedSigners -> Maybe [Signer]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Signer]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity