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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A list of CloudFront key pair identifiers.
--
-- /See:/ 'newKeyPairIds' smart constructor.
data KeyPairIds = KeyPairIds'
  { -- | A list of CloudFront key pair identifiers.
    KeyPairIds -> Maybe [Text]
items :: Prelude.Maybe [Prelude.Text],
    -- | The number of key pair identifiers in the list.
    KeyPairIds -> Int
quantity :: Prelude.Int
  }
  deriving (KeyPairIds -> KeyPairIds -> Bool
(KeyPairIds -> KeyPairIds -> Bool)
-> (KeyPairIds -> KeyPairIds -> Bool) -> Eq KeyPairIds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyPairIds -> KeyPairIds -> Bool
$c/= :: KeyPairIds -> KeyPairIds -> Bool
== :: KeyPairIds -> KeyPairIds -> Bool
$c== :: KeyPairIds -> KeyPairIds -> Bool
Prelude.Eq, ReadPrec [KeyPairIds]
ReadPrec KeyPairIds
Int -> ReadS KeyPairIds
ReadS [KeyPairIds]
(Int -> ReadS KeyPairIds)
-> ReadS [KeyPairIds]
-> ReadPrec KeyPairIds
-> ReadPrec [KeyPairIds]
-> Read KeyPairIds
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyPairIds]
$creadListPrec :: ReadPrec [KeyPairIds]
readPrec :: ReadPrec KeyPairIds
$creadPrec :: ReadPrec KeyPairIds
readList :: ReadS [KeyPairIds]
$creadList :: ReadS [KeyPairIds]
readsPrec :: Int -> ReadS KeyPairIds
$creadsPrec :: Int -> ReadS KeyPairIds
Prelude.Read, Int -> KeyPairIds -> ShowS
[KeyPairIds] -> ShowS
KeyPairIds -> String
(Int -> KeyPairIds -> ShowS)
-> (KeyPairIds -> String)
-> ([KeyPairIds] -> ShowS)
-> Show KeyPairIds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyPairIds] -> ShowS
$cshowList :: [KeyPairIds] -> ShowS
show :: KeyPairIds -> String
$cshow :: KeyPairIds -> String
showsPrec :: Int -> KeyPairIds -> ShowS
$cshowsPrec :: Int -> KeyPairIds -> ShowS
Prelude.Show, (forall x. KeyPairIds -> Rep KeyPairIds x)
-> (forall x. Rep KeyPairIds x -> KeyPairIds) -> Generic KeyPairIds
forall x. Rep KeyPairIds x -> KeyPairIds
forall x. KeyPairIds -> Rep KeyPairIds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyPairIds x -> KeyPairIds
$cfrom :: forall x. KeyPairIds -> Rep KeyPairIds x
Prelude.Generic)

-- |
-- Create a value of 'KeyPairIds' 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', 'keyPairIds_items' - A list of CloudFront key pair identifiers.
--
-- 'quantity', 'keyPairIds_quantity' - The number of key pair identifiers in the list.
newKeyPairIds ::
  -- | 'quantity'
  Prelude.Int ->
  KeyPairIds
newKeyPairIds :: Int -> KeyPairIds
newKeyPairIds Int
pQuantity_ =
  KeyPairIds' :: Maybe [Text] -> Int -> KeyPairIds
KeyPairIds'
    { $sel:items:KeyPairIds' :: Maybe [Text]
items = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:quantity:KeyPairIds' :: Int
quantity = Int
pQuantity_
    }

-- | A list of CloudFront key pair identifiers.
keyPairIds_items :: Lens.Lens' KeyPairIds (Prelude.Maybe [Prelude.Text])
keyPairIds_items :: (Maybe [Text] -> f (Maybe [Text])) -> KeyPairIds -> f KeyPairIds
keyPairIds_items = (KeyPairIds -> Maybe [Text])
-> (KeyPairIds -> Maybe [Text] -> KeyPairIds)
-> Lens KeyPairIds KeyPairIds (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyPairIds' {Maybe [Text]
items :: Maybe [Text]
$sel:items:KeyPairIds' :: KeyPairIds -> Maybe [Text]
items} -> Maybe [Text]
items) (\s :: KeyPairIds
s@KeyPairIds' {} Maybe [Text]
a -> KeyPairIds
s {$sel:items:KeyPairIds' :: Maybe [Text]
items = Maybe [Text]
a} :: KeyPairIds) ((Maybe [Text] -> f (Maybe [Text])) -> KeyPairIds -> f KeyPairIds)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> KeyPairIds
-> f KeyPairIds
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData KeyPairIds