{-# 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-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.KeyPairIds 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 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
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]
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
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. 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'
    { $sel:items:KeyPairIds' :: Maybe [Text]
items = 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 :: Lens' KeyPairIds (Maybe [Text])
keyPairIds_items = 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) 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

-- | The number of key pair identifiers in the list.
keyPairIds_quantity :: Lens.Lens' KeyPairIds Prelude.Int
keyPairIds_quantity :: Lens' KeyPairIds Int
keyPairIds_quantity = 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 Data.FromXML KeyPairIds where
  parseXML :: [Node] -> Either String KeyPairIds
parseXML [Node]
x =
    Maybe [Text] -> Int -> KeyPairIds
KeyPairIds'
      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
"KeyPairId")
                  )
      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 KeyPairIds where
  hashWithSalt :: Int -> KeyPairIds -> Int
hashWithSalt Int
_salt KeyPairIds' {Int
Maybe [Text]
quantity :: Int
items :: Maybe [Text]
$sel:quantity:KeyPairIds' :: KeyPairIds -> Int
$sel:items:KeyPairIds' :: KeyPairIds -> 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` Int
quantity

instance Prelude.NFData KeyPairIds where
  rnf :: KeyPairIds -> ()
rnf KeyPairIds' {Int
Maybe [Text]
quantity :: Int
items :: Maybe [Text]
$sel:quantity:KeyPairIds' :: KeyPairIds -> Int
$sel:items:KeyPairIds' :: KeyPairIds -> 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 Int
quantity