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

import Amazonka.CloudFront.Types.KeyPairIds
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:/ 'newSigner' smart constructor.
data Signer = Signer'
  { -- | An account number that contains active CloudFront key pairs that
    -- CloudFront can use to verify the signatures of signed URLs and signed
    -- cookies. If the 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
(Signer -> Signer -> Bool)
-> (Signer -> Signer -> Bool) -> Eq Signer
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]
(Int -> ReadS Signer)
-> ReadS [Signer]
-> ReadPrec Signer
-> ReadPrec [Signer]
-> Read 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
(Int -> Signer -> ShowS)
-> (Signer -> String) -> ([Signer] -> ShowS) -> Show Signer
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. Signer -> Rep Signer x)
-> (forall x. Rep Signer x -> Signer) -> Generic Signer
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 account number that contains active CloudFront key pairs that
-- CloudFront can use to verify the signatures of signed URLs and signed
-- cookies. If the 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' :: Maybe Text -> Maybe KeyPairIds -> Signer
Signer'
    { $sel:awsAccountNumber:Signer' :: Maybe Text
awsAccountNumber = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyPairIds:Signer' :: Maybe KeyPairIds
keyPairIds = Maybe KeyPairIds
forall a. Maybe a
Prelude.Nothing
    }

-- | An account number that contains active CloudFront key pairs that
-- CloudFront can use to verify the signatures of signed URLs and signed
-- cookies. If the 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 :: (Maybe Text -> f (Maybe Text)) -> Signer -> f Signer
signer_awsAccountNumber = (Signer -> Maybe Text)
-> (Signer -> Maybe Text -> Signer)
-> Lens Signer Signer (Maybe Text) (Maybe Text)
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 :: (Maybe KeyPairIds -> f (Maybe KeyPairIds)) -> Signer -> f Signer
signer_keyPairIds = (Signer -> Maybe KeyPairIds)
-> (Signer -> Maybe KeyPairIds -> Signer)
-> Lens Signer Signer (Maybe KeyPairIds) (Maybe 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 Core.FromXML Signer where
  parseXML :: [Node] -> Either String Signer
parseXML [Node]
x =
    Maybe Text -> Maybe KeyPairIds -> Signer
Signer'
      (Maybe Text -> Maybe KeyPairIds -> Signer)
-> Either String (Maybe Text)
-> Either String (Maybe KeyPairIds -> Signer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AwsAccountNumber")
      Either String (Maybe KeyPairIds -> Signer)
-> Either String (Maybe KeyPairIds) -> Either String Signer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe KeyPairIds)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"KeyPairIds")

instance Prelude.Hashable Signer

instance Prelude.NFData Signer