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

import Amazonka.CloudFront.Types.OriginAccessControlSummary
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 origin access controls.
--
-- /See:/ 'newOriginAccessControlList' smart constructor.
data OriginAccessControlList = OriginAccessControlList'
  { -- | Contains the origin access controls in the list.
    OriginAccessControlList -> Maybe [OriginAccessControlSummary]
items :: Prelude.Maybe [OriginAccessControlSummary],
    -- | If there are more items in the list than are in this response, this
    -- element is present. It contains the value to use in the @Marker@ field
    -- of another request to continue listing origin access controls.
    OriginAccessControlList -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The value of the @Marker@ field that was provided in the request.
    OriginAccessControlList -> Text
marker :: Prelude.Text,
    -- | The maximum number of origin access controls requested.
    OriginAccessControlList -> Int
maxItems :: Prelude.Int,
    -- | If there are more items in the list than are in this response, this
    -- value is @true@.
    OriginAccessControlList -> Bool
isTruncated :: Prelude.Bool,
    -- | The number of origin access controls returned in the response.
    OriginAccessControlList -> Int
quantity :: Prelude.Int
  }
  deriving (OriginAccessControlList -> OriginAccessControlList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginAccessControlList -> OriginAccessControlList -> Bool
$c/= :: OriginAccessControlList -> OriginAccessControlList -> Bool
== :: OriginAccessControlList -> OriginAccessControlList -> Bool
$c== :: OriginAccessControlList -> OriginAccessControlList -> Bool
Prelude.Eq, ReadPrec [OriginAccessControlList]
ReadPrec OriginAccessControlList
Int -> ReadS OriginAccessControlList
ReadS [OriginAccessControlList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginAccessControlList]
$creadListPrec :: ReadPrec [OriginAccessControlList]
readPrec :: ReadPrec OriginAccessControlList
$creadPrec :: ReadPrec OriginAccessControlList
readList :: ReadS [OriginAccessControlList]
$creadList :: ReadS [OriginAccessControlList]
readsPrec :: Int -> ReadS OriginAccessControlList
$creadsPrec :: Int -> ReadS OriginAccessControlList
Prelude.Read, Int -> OriginAccessControlList -> ShowS
[OriginAccessControlList] -> ShowS
OriginAccessControlList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginAccessControlList] -> ShowS
$cshowList :: [OriginAccessControlList] -> ShowS
show :: OriginAccessControlList -> String
$cshow :: OriginAccessControlList -> String
showsPrec :: Int -> OriginAccessControlList -> ShowS
$cshowsPrec :: Int -> OriginAccessControlList -> ShowS
Prelude.Show, forall x. Rep OriginAccessControlList x -> OriginAccessControlList
forall x. OriginAccessControlList -> Rep OriginAccessControlList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OriginAccessControlList x -> OriginAccessControlList
$cfrom :: forall x. OriginAccessControlList -> Rep OriginAccessControlList x
Prelude.Generic)

-- |
-- Create a value of 'OriginAccessControlList' 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', 'originAccessControlList_items' - Contains the origin access controls in the list.
--
-- 'nextMarker', 'originAccessControlList_nextMarker' - If there are more items in the list than are in this response, this
-- element is present. It contains the value to use in the @Marker@ field
-- of another request to continue listing origin access controls.
--
-- 'marker', 'originAccessControlList_marker' - The value of the @Marker@ field that was provided in the request.
--
-- 'maxItems', 'originAccessControlList_maxItems' - The maximum number of origin access controls requested.
--
-- 'isTruncated', 'originAccessControlList_isTruncated' - If there are more items in the list than are in this response, this
-- value is @true@.
--
-- 'quantity', 'originAccessControlList_quantity' - The number of origin access controls returned in the response.
newOriginAccessControlList ::
  -- | 'marker'
  Prelude.Text ->
  -- | 'maxItems'
  Prelude.Int ->
  -- | 'isTruncated'
  Prelude.Bool ->
  -- | 'quantity'
  Prelude.Int ->
  OriginAccessControlList
newOriginAccessControlList :: Text -> Int -> Bool -> Int -> OriginAccessControlList
newOriginAccessControlList
  Text
pMarker_
  Int
pMaxItems_
  Bool
pIsTruncated_
  Int
pQuantity_ =
    OriginAccessControlList'
      { $sel:items:OriginAccessControlList' :: Maybe [OriginAccessControlSummary]
items = forall a. Maybe a
Prelude.Nothing,
        $sel:nextMarker:OriginAccessControlList' :: Maybe Text
nextMarker = forall a. Maybe a
Prelude.Nothing,
        $sel:marker:OriginAccessControlList' :: Text
marker = Text
pMarker_,
        $sel:maxItems:OriginAccessControlList' :: Int
maxItems = Int
pMaxItems_,
        $sel:isTruncated:OriginAccessControlList' :: Bool
isTruncated = Bool
pIsTruncated_,
        $sel:quantity:OriginAccessControlList' :: Int
quantity = Int
pQuantity_
      }

-- | Contains the origin access controls in the list.
originAccessControlList_items :: Lens.Lens' OriginAccessControlList (Prelude.Maybe [OriginAccessControlSummary])
originAccessControlList_items :: Lens' OriginAccessControlList (Maybe [OriginAccessControlSummary])
originAccessControlList_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginAccessControlList' {Maybe [OriginAccessControlSummary]
items :: Maybe [OriginAccessControlSummary]
$sel:items:OriginAccessControlList' :: OriginAccessControlList -> Maybe [OriginAccessControlSummary]
items} -> Maybe [OriginAccessControlSummary]
items) (\s :: OriginAccessControlList
s@OriginAccessControlList' {} Maybe [OriginAccessControlSummary]
a -> OriginAccessControlList
s {$sel:items:OriginAccessControlList' :: Maybe [OriginAccessControlSummary]
items = Maybe [OriginAccessControlSummary]
a} :: OriginAccessControlList) 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

-- | If there are more items in the list than are in this response, this
-- element is present. It contains the value to use in the @Marker@ field
-- of another request to continue listing origin access controls.
originAccessControlList_nextMarker :: Lens.Lens' OriginAccessControlList (Prelude.Maybe Prelude.Text)
originAccessControlList_nextMarker :: Lens' OriginAccessControlList (Maybe Text)
originAccessControlList_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginAccessControlList' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:OriginAccessControlList' :: OriginAccessControlList -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: OriginAccessControlList
s@OriginAccessControlList' {} Maybe Text
a -> OriginAccessControlList
s {$sel:nextMarker:OriginAccessControlList' :: Maybe Text
nextMarker = Maybe Text
a} :: OriginAccessControlList)

-- | The value of the @Marker@ field that was provided in the request.
originAccessControlList_marker :: Lens.Lens' OriginAccessControlList Prelude.Text
originAccessControlList_marker :: Lens' OriginAccessControlList Text
originAccessControlList_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginAccessControlList' {Text
marker :: Text
$sel:marker:OriginAccessControlList' :: OriginAccessControlList -> Text
marker} -> Text
marker) (\s :: OriginAccessControlList
s@OriginAccessControlList' {} Text
a -> OriginAccessControlList
s {$sel:marker:OriginAccessControlList' :: Text
marker = Text
a} :: OriginAccessControlList)

-- | The maximum number of origin access controls requested.
originAccessControlList_maxItems :: Lens.Lens' OriginAccessControlList Prelude.Int
originAccessControlList_maxItems :: Lens' OriginAccessControlList Int
originAccessControlList_maxItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginAccessControlList' {Int
maxItems :: Int
$sel:maxItems:OriginAccessControlList' :: OriginAccessControlList -> Int
maxItems} -> Int
maxItems) (\s :: OriginAccessControlList
s@OriginAccessControlList' {} Int
a -> OriginAccessControlList
s {$sel:maxItems:OriginAccessControlList' :: Int
maxItems = Int
a} :: OriginAccessControlList)

-- | If there are more items in the list than are in this response, this
-- value is @true@.
originAccessControlList_isTruncated :: Lens.Lens' OriginAccessControlList Prelude.Bool
originAccessControlList_isTruncated :: Lens' OriginAccessControlList Bool
originAccessControlList_isTruncated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginAccessControlList' {Bool
isTruncated :: Bool
$sel:isTruncated:OriginAccessControlList' :: OriginAccessControlList -> Bool
isTruncated} -> Bool
isTruncated) (\s :: OriginAccessControlList
s@OriginAccessControlList' {} Bool
a -> OriginAccessControlList
s {$sel:isTruncated:OriginAccessControlList' :: Bool
isTruncated = Bool
a} :: OriginAccessControlList)

-- | The number of origin access controls returned in the response.
originAccessControlList_quantity :: Lens.Lens' OriginAccessControlList Prelude.Int
originAccessControlList_quantity :: Lens' OriginAccessControlList Int
originAccessControlList_quantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginAccessControlList' {Int
quantity :: Int
$sel:quantity:OriginAccessControlList' :: OriginAccessControlList -> Int
quantity} -> Int
quantity) (\s :: OriginAccessControlList
s@OriginAccessControlList' {} Int
a -> OriginAccessControlList
s {$sel:quantity:OriginAccessControlList' :: Int
quantity = Int
a} :: OriginAccessControlList)

instance Data.FromXML OriginAccessControlList where
  parseXML :: [Node] -> Either String OriginAccessControlList
parseXML [Node]
x =
    Maybe [OriginAccessControlSummary]
-> Maybe Text
-> Text
-> Int
-> Bool
-> Int
-> OriginAccessControlList
OriginAccessControlList'
      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
"OriginAccessControlSummary")
                  )
      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
"NextMarker")
      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
"Marker")
      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
"MaxItems")
      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
"IsTruncated")
      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 OriginAccessControlList where
  hashWithSalt :: Int -> OriginAccessControlList -> Int
hashWithSalt Int
_salt OriginAccessControlList' {Bool
Int
Maybe [OriginAccessControlSummary]
Maybe Text
Text
quantity :: Int
isTruncated :: Bool
maxItems :: Int
marker :: Text
nextMarker :: Maybe Text
items :: Maybe [OriginAccessControlSummary]
$sel:quantity:OriginAccessControlList' :: OriginAccessControlList -> Int
$sel:isTruncated:OriginAccessControlList' :: OriginAccessControlList -> Bool
$sel:maxItems:OriginAccessControlList' :: OriginAccessControlList -> Int
$sel:marker:OriginAccessControlList' :: OriginAccessControlList -> Text
$sel:nextMarker:OriginAccessControlList' :: OriginAccessControlList -> Maybe Text
$sel:items:OriginAccessControlList' :: OriginAccessControlList -> Maybe [OriginAccessControlSummary]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [OriginAccessControlSummary]
items
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextMarker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
marker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
maxItems
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
isTruncated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

instance Prelude.NFData OriginAccessControlList where
  rnf :: OriginAccessControlList -> ()
rnf OriginAccessControlList' {Bool
Int
Maybe [OriginAccessControlSummary]
Maybe Text
Text
quantity :: Int
isTruncated :: Bool
maxItems :: Int
marker :: Text
nextMarker :: Maybe Text
items :: Maybe [OriginAccessControlSummary]
$sel:quantity:OriginAccessControlList' :: OriginAccessControlList -> Int
$sel:isTruncated:OriginAccessControlList' :: OriginAccessControlList -> Bool
$sel:maxItems:OriginAccessControlList' :: OriginAccessControlList -> Int
$sel:marker:OriginAccessControlList' :: OriginAccessControlList -> Text
$sel:nextMarker:OriginAccessControlList' :: OriginAccessControlList -> Maybe Text
$sel:items:OriginAccessControlList' :: OriginAccessControlList -> Maybe [OriginAccessControlSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [OriginAccessControlSummary]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
marker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
maxItems
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
isTruncated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity