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

import Amazonka.CloudFront.Types.KeyPairIds
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:/ 'newSigner' smart constructor.
data Signer = Signer'
  { -- | An Amazon Web Services account number that contains active CloudFront
    -- key pairs that CloudFront can use to verify the signatures of signed
    -- URLs and signed cookies. If the Amazon Web Services account that owns
    -- the key pairs is the same account that owns the CloudFront distribution,
    -- the value of this field is @self@.
    Signer -> Maybe Text
awsAccountNumber :: Prelude.Maybe Prelude.Text,
    -- | A list of CloudFront key pair identifiers.
    Signer -> Maybe KeyPairIds
keyPairIds :: Prelude.Maybe KeyPairIds
  }
  deriving (Signer -> Signer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Signer -> Signer -> Bool
$c/= :: Signer -> Signer -> Bool
== :: Signer -> Signer -> Bool
$c== :: Signer -> Signer -> Bool
Prelude.Eq, ReadPrec [Signer]
ReadPrec Signer
Int -> ReadS Signer
ReadS [Signer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Signer]
$creadListPrec :: ReadPrec [Signer]
readPrec :: ReadPrec Signer
$creadPrec :: ReadPrec Signer
readList :: ReadS [Signer]
$creadList :: ReadS [Signer]
readsPrec :: Int -> ReadS Signer
$creadsPrec :: Int -> ReadS Signer
Prelude.Read, Int -> Signer -> ShowS
[Signer] -> ShowS
Signer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Signer] -> ShowS
$cshowList :: [Signer] -> ShowS
show :: Signer -> String
$cshow :: Signer -> String
showsPrec :: Int -> Signer -> ShowS
$cshowsPrec :: Int -> Signer -> ShowS
Prelude.Show, forall x. Rep Signer x -> Signer
forall x. Signer -> Rep Signer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Signer x -> Signer
$cfrom :: forall x. Signer -> Rep Signer x
Prelude.Generic)

-- |
-- Create a value of 'Signer' 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:
--
-- 'awsAccountNumber', 'signer_awsAccountNumber' - An Amazon Web Services account number that contains active CloudFront
-- key pairs that CloudFront can use to verify the signatures of signed
-- URLs and signed cookies. If the Amazon Web Services account that owns
-- the key pairs is the same account that owns the CloudFront distribution,
-- the value of this field is @self@.
--
-- 'keyPairIds', 'signer_keyPairIds' - A list of CloudFront key pair identifiers.
newSigner ::
  Signer
newSigner :: Signer
newSigner =
  Signer'
    { $sel:awsAccountNumber:Signer' :: Maybe Text
awsAccountNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:keyPairIds:Signer' :: Maybe KeyPairIds
keyPairIds = forall a. Maybe a
Prelude.Nothing
    }

-- | An Amazon Web Services account number that contains active CloudFront
-- key pairs that CloudFront can use to verify the signatures of signed
-- URLs and signed cookies. If the Amazon Web Services account that owns
-- the key pairs is the same account that owns the CloudFront distribution,
-- the value of this field is @self@.
signer_awsAccountNumber :: Lens.Lens' Signer (Prelude.Maybe Prelude.Text)
signer_awsAccountNumber :: Lens' Signer (Maybe Text)
signer_awsAccountNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Signer' {Maybe Text
awsAccountNumber :: Maybe Text
$sel:awsAccountNumber:Signer' :: Signer -> Maybe Text
awsAccountNumber} -> Maybe Text
awsAccountNumber) (\s :: Signer
s@Signer' {} Maybe Text
a -> Signer
s {$sel:awsAccountNumber:Signer' :: Maybe Text
awsAccountNumber = Maybe Text
a} :: Signer)

-- | A list of CloudFront key pair identifiers.
signer_keyPairIds :: Lens.Lens' Signer (Prelude.Maybe KeyPairIds)
signer_keyPairIds :: Lens' Signer (Maybe KeyPairIds)
signer_keyPairIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Signer' {Maybe KeyPairIds
keyPairIds :: Maybe KeyPairIds
$sel:keyPairIds:Signer' :: Signer -> Maybe KeyPairIds
keyPairIds} -> Maybe KeyPairIds
keyPairIds) (\s :: Signer
s@Signer' {} Maybe KeyPairIds
a -> Signer
s {$sel:keyPairIds:Signer' :: Maybe KeyPairIds
keyPairIds = Maybe KeyPairIds
a} :: Signer)

instance Data.FromXML Signer where
  parseXML :: [Node] -> Either String Signer
parseXML [Node]
x =
    Maybe Text -> Maybe KeyPairIds -> Signer
Signer'
      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
"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 (Maybe a)
Data..@? Text
"KeyPairIds")

instance Prelude.Hashable Signer where
  hashWithSalt :: Int -> Signer -> Int
hashWithSalt Int
_salt Signer' {Maybe Text
Maybe KeyPairIds
keyPairIds :: Maybe KeyPairIds
awsAccountNumber :: Maybe Text
$sel:keyPairIds:Signer' :: Signer -> Maybe KeyPairIds
$sel:awsAccountNumber:Signer' :: Signer -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
awsAccountNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KeyPairIds
keyPairIds

instance Prelude.NFData Signer where
  rnf :: Signer -> ()
rnf Signer' {Maybe Text
Maybe KeyPairIds
keyPairIds :: Maybe KeyPairIds
awsAccountNumber :: Maybe Text
$sel:keyPairIds:Signer' :: Signer -> Maybe KeyPairIds
$sel:awsAccountNumber:Signer' :: Signer -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
awsAccountNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KeyPairIds
keyPairIds