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

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

-- |
-- Create a value of 'TrustedSigners' 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', 'trustedSigners_items' - A list of Amazon Web Services account identifiers.
--
-- 'enabled', 'trustedSigners_enabled' - This field is @true@ if any of the Amazon Web Services accounts have
-- public keys that CloudFront can use to verify the signatures of signed
-- URLs and signed cookies. If not, this field is @false@.
--
-- 'quantity', 'trustedSigners_quantity' - The number of Amazon Web Services accounts in the list.
newTrustedSigners ::
  -- | 'enabled'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  TrustedSigners
newTrustedSigners :: Bool -> Int -> TrustedSigners
newTrustedSigners Bool
pEnabled_ Int
pQuantity_ =
  TrustedSigners'
    { $sel:items:TrustedSigners' :: Maybe [Text]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:TrustedSigners' :: Bool
enabled = Bool
pEnabled_,
      $sel:quantity:TrustedSigners' :: Int
quantity = Int
pQuantity_
    }

-- | A list of Amazon Web Services account identifiers.
trustedSigners_items :: Lens.Lens' TrustedSigners (Prelude.Maybe [Prelude.Text])
trustedSigners_items :: Lens' TrustedSigners (Maybe [Text])
trustedSigners_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrustedSigners' {Maybe [Text]
items :: Maybe [Text]
$sel:items:TrustedSigners' :: TrustedSigners -> Maybe [Text]
items} -> Maybe [Text]
items) (\s :: TrustedSigners
s@TrustedSigners' {} Maybe [Text]
a -> TrustedSigners
s {$sel:items:TrustedSigners' :: Maybe [Text]
items = Maybe [Text]
a} :: TrustedSigners) 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 have
-- public keys that CloudFront can use to verify the signatures of signed
-- URLs and signed cookies. If not, this field is @false@.
trustedSigners_enabled :: Lens.Lens' TrustedSigners Prelude.Bool
trustedSigners_enabled :: Lens' TrustedSigners Bool
trustedSigners_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrustedSigners' {Bool
enabled :: Bool
$sel:enabled:TrustedSigners' :: TrustedSigners -> Bool
enabled} -> Bool
enabled) (\s :: TrustedSigners
s@TrustedSigners' {} Bool
a -> TrustedSigners
s {$sel:enabled:TrustedSigners' :: Bool
enabled = Bool
a} :: TrustedSigners)

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

instance Data.FromXML TrustedSigners where
  parseXML :: [Node] -> Either String TrustedSigners
parseXML [Node]
x =
    Maybe [Text] -> Bool -> Int -> TrustedSigners
TrustedSigners'
      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
"AwsAccountNumber")
                  )
      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 TrustedSigners where
  hashWithSalt :: Int -> TrustedSigners -> Int
hashWithSalt Int
_salt TrustedSigners' {Bool
Int
Maybe [Text]
quantity :: Int
enabled :: Bool
items :: Maybe [Text]
$sel:quantity:TrustedSigners' :: TrustedSigners -> Int
$sel:enabled:TrustedSigners' :: TrustedSigners -> Bool
$sel:items:TrustedSigners' :: TrustedSigners -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
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 TrustedSigners where
  rnf :: TrustedSigners -> ()
rnf TrustedSigners' {Bool
Int
Maybe [Text]
quantity :: Int
enabled :: Bool
items :: Maybe [Text]
$sel:quantity:TrustedSigners' :: TrustedSigners -> Int
$sel:enabled:TrustedSigners' :: TrustedSigners -> Bool
$sel:items:TrustedSigners' :: TrustedSigners -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
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

instance Data.ToXML TrustedSigners where
  toXML :: TrustedSigners -> XML
toXML TrustedSigners' {Bool
Int
Maybe [Text]
quantity :: Int
enabled :: Bool
items :: Maybe [Text]
$sel:quantity:TrustedSigners' :: TrustedSigners -> Int
$sel:enabled:TrustedSigners' :: TrustedSigners -> Bool
$sel:items:TrustedSigners' :: TrustedSigners -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          forall a. ToXML a => Name -> a -> XML
Data.@= forall a. ToXML a => a -> XML
Data.toXML
            ( forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"AwsAccountNumber"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
items
            ),
        Name
"Enabled" forall a. ToXML a => Name -> a -> XML
Data.@= Bool
enabled,
        Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity
      ]