{-# 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.SecurityHub.Types.AwsCloudFrontDistributionOrigins
-- 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.SecurityHub.Types.AwsCloudFrontDistributionOrigins where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsCloudFrontDistributionOriginItem

-- | A complex type that contains information about origins and origin groups
-- for this distribution.
--
-- /See:/ 'newAwsCloudFrontDistributionOrigins' smart constructor.
data AwsCloudFrontDistributionOrigins = AwsCloudFrontDistributionOrigins'
  { -- | A complex type that contains origins or origin groups for this
    -- distribution.
    AwsCloudFrontDistributionOrigins
-> Maybe [AwsCloudFrontDistributionOriginItem]
items :: Prelude.Maybe [AwsCloudFrontDistributionOriginItem]
  }
  deriving (AwsCloudFrontDistributionOrigins
-> AwsCloudFrontDistributionOrigins -> Bool
(AwsCloudFrontDistributionOrigins
 -> AwsCloudFrontDistributionOrigins -> Bool)
-> (AwsCloudFrontDistributionOrigins
    -> AwsCloudFrontDistributionOrigins -> Bool)
-> Eq AwsCloudFrontDistributionOrigins
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCloudFrontDistributionOrigins
-> AwsCloudFrontDistributionOrigins -> Bool
$c/= :: AwsCloudFrontDistributionOrigins
-> AwsCloudFrontDistributionOrigins -> Bool
== :: AwsCloudFrontDistributionOrigins
-> AwsCloudFrontDistributionOrigins -> Bool
$c== :: AwsCloudFrontDistributionOrigins
-> AwsCloudFrontDistributionOrigins -> Bool
Prelude.Eq, ReadPrec [AwsCloudFrontDistributionOrigins]
ReadPrec AwsCloudFrontDistributionOrigins
Int -> ReadS AwsCloudFrontDistributionOrigins
ReadS [AwsCloudFrontDistributionOrigins]
(Int -> ReadS AwsCloudFrontDistributionOrigins)
-> ReadS [AwsCloudFrontDistributionOrigins]
-> ReadPrec AwsCloudFrontDistributionOrigins
-> ReadPrec [AwsCloudFrontDistributionOrigins]
-> Read AwsCloudFrontDistributionOrigins
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCloudFrontDistributionOrigins]
$creadListPrec :: ReadPrec [AwsCloudFrontDistributionOrigins]
readPrec :: ReadPrec AwsCloudFrontDistributionOrigins
$creadPrec :: ReadPrec AwsCloudFrontDistributionOrigins
readList :: ReadS [AwsCloudFrontDistributionOrigins]
$creadList :: ReadS [AwsCloudFrontDistributionOrigins]
readsPrec :: Int -> ReadS AwsCloudFrontDistributionOrigins
$creadsPrec :: Int -> ReadS AwsCloudFrontDistributionOrigins
Prelude.Read, Int -> AwsCloudFrontDistributionOrigins -> ShowS
[AwsCloudFrontDistributionOrigins] -> ShowS
AwsCloudFrontDistributionOrigins -> String
(Int -> AwsCloudFrontDistributionOrigins -> ShowS)
-> (AwsCloudFrontDistributionOrigins -> String)
-> ([AwsCloudFrontDistributionOrigins] -> ShowS)
-> Show AwsCloudFrontDistributionOrigins
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCloudFrontDistributionOrigins] -> ShowS
$cshowList :: [AwsCloudFrontDistributionOrigins] -> ShowS
show :: AwsCloudFrontDistributionOrigins -> String
$cshow :: AwsCloudFrontDistributionOrigins -> String
showsPrec :: Int -> AwsCloudFrontDistributionOrigins -> ShowS
$cshowsPrec :: Int -> AwsCloudFrontDistributionOrigins -> ShowS
Prelude.Show, (forall x.
 AwsCloudFrontDistributionOrigins
 -> Rep AwsCloudFrontDistributionOrigins x)
-> (forall x.
    Rep AwsCloudFrontDistributionOrigins x
    -> AwsCloudFrontDistributionOrigins)
-> Generic AwsCloudFrontDistributionOrigins
forall x.
Rep AwsCloudFrontDistributionOrigins x
-> AwsCloudFrontDistributionOrigins
forall x.
AwsCloudFrontDistributionOrigins
-> Rep AwsCloudFrontDistributionOrigins x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCloudFrontDistributionOrigins x
-> AwsCloudFrontDistributionOrigins
$cfrom :: forall x.
AwsCloudFrontDistributionOrigins
-> Rep AwsCloudFrontDistributionOrigins x
Prelude.Generic)

-- |
-- Create a value of 'AwsCloudFrontDistributionOrigins' 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', 'awsCloudFrontDistributionOrigins_items' - A complex type that contains origins or origin groups for this
-- distribution.
newAwsCloudFrontDistributionOrigins ::
  AwsCloudFrontDistributionOrigins
newAwsCloudFrontDistributionOrigins :: AwsCloudFrontDistributionOrigins
newAwsCloudFrontDistributionOrigins =
  AwsCloudFrontDistributionOrigins' :: Maybe [AwsCloudFrontDistributionOriginItem]
-> AwsCloudFrontDistributionOrigins
AwsCloudFrontDistributionOrigins'
    { $sel:items:AwsCloudFrontDistributionOrigins' :: Maybe [AwsCloudFrontDistributionOriginItem]
items =
        Maybe [AwsCloudFrontDistributionOriginItem]
forall a. Maybe a
Prelude.Nothing
    }

-- | A complex type that contains origins or origin groups for this
-- distribution.
awsCloudFrontDistributionOrigins_items :: Lens.Lens' AwsCloudFrontDistributionOrigins (Prelude.Maybe [AwsCloudFrontDistributionOriginItem])
awsCloudFrontDistributionOrigins_items :: (Maybe [AwsCloudFrontDistributionOriginItem]
 -> f (Maybe [AwsCloudFrontDistributionOriginItem]))
-> AwsCloudFrontDistributionOrigins
-> f AwsCloudFrontDistributionOrigins
awsCloudFrontDistributionOrigins_items = (AwsCloudFrontDistributionOrigins
 -> Maybe [AwsCloudFrontDistributionOriginItem])
-> (AwsCloudFrontDistributionOrigins
    -> Maybe [AwsCloudFrontDistributionOriginItem]
    -> AwsCloudFrontDistributionOrigins)
-> Lens
     AwsCloudFrontDistributionOrigins
     AwsCloudFrontDistributionOrigins
     (Maybe [AwsCloudFrontDistributionOriginItem])
     (Maybe [AwsCloudFrontDistributionOriginItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionOrigins' {Maybe [AwsCloudFrontDistributionOriginItem]
items :: Maybe [AwsCloudFrontDistributionOriginItem]
$sel:items:AwsCloudFrontDistributionOrigins' :: AwsCloudFrontDistributionOrigins
-> Maybe [AwsCloudFrontDistributionOriginItem]
items} -> Maybe [AwsCloudFrontDistributionOriginItem]
items) (\s :: AwsCloudFrontDistributionOrigins
s@AwsCloudFrontDistributionOrigins' {} Maybe [AwsCloudFrontDistributionOriginItem]
a -> AwsCloudFrontDistributionOrigins
s {$sel:items:AwsCloudFrontDistributionOrigins' :: Maybe [AwsCloudFrontDistributionOriginItem]
items = Maybe [AwsCloudFrontDistributionOriginItem]
a} :: AwsCloudFrontDistributionOrigins) ((Maybe [AwsCloudFrontDistributionOriginItem]
  -> f (Maybe [AwsCloudFrontDistributionOriginItem]))
 -> AwsCloudFrontDistributionOrigins
 -> f AwsCloudFrontDistributionOrigins)
-> ((Maybe [AwsCloudFrontDistributionOriginItem]
     -> f (Maybe [AwsCloudFrontDistributionOriginItem]))
    -> Maybe [AwsCloudFrontDistributionOriginItem]
    -> f (Maybe [AwsCloudFrontDistributionOriginItem]))
-> (Maybe [AwsCloudFrontDistributionOriginItem]
    -> f (Maybe [AwsCloudFrontDistributionOriginItem]))
-> AwsCloudFrontDistributionOrigins
-> f AwsCloudFrontDistributionOrigins
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsCloudFrontDistributionOriginItem]
  [AwsCloudFrontDistributionOriginItem]
  [AwsCloudFrontDistributionOriginItem]
  [AwsCloudFrontDistributionOriginItem]
-> Iso
     (Maybe [AwsCloudFrontDistributionOriginItem])
     (Maybe [AwsCloudFrontDistributionOriginItem])
     (Maybe [AwsCloudFrontDistributionOriginItem])
     (Maybe [AwsCloudFrontDistributionOriginItem])
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
  [AwsCloudFrontDistributionOriginItem]
  [AwsCloudFrontDistributionOriginItem]
  [AwsCloudFrontDistributionOriginItem]
  [AwsCloudFrontDistributionOriginItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromJSON
    AwsCloudFrontDistributionOrigins
  where
  parseJSON :: Value -> Parser AwsCloudFrontDistributionOrigins
parseJSON =
    String
-> (Object -> Parser AwsCloudFrontDistributionOrigins)
-> Value
-> Parser AwsCloudFrontDistributionOrigins
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCloudFrontDistributionOrigins"
      ( \Object
x ->
          Maybe [AwsCloudFrontDistributionOriginItem]
-> AwsCloudFrontDistributionOrigins
AwsCloudFrontDistributionOrigins'
            (Maybe [AwsCloudFrontDistributionOriginItem]
 -> AwsCloudFrontDistributionOrigins)
-> Parser (Maybe [AwsCloudFrontDistributionOriginItem])
-> Parser AwsCloudFrontDistributionOrigins
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe (Maybe [AwsCloudFrontDistributionOriginItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Items" Parser (Maybe (Maybe [AwsCloudFrontDistributionOriginItem]))
-> Maybe [AwsCloudFrontDistributionOriginItem]
-> Parser (Maybe [AwsCloudFrontDistributionOriginItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AwsCloudFrontDistributionOriginItem]
forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    AwsCloudFrontDistributionOrigins

instance
  Prelude.NFData
    AwsCloudFrontDistributionOrigins

instance Core.ToJSON AwsCloudFrontDistributionOrigins where
  toJSON :: AwsCloudFrontDistributionOrigins -> Value
toJSON AwsCloudFrontDistributionOrigins' {Maybe [AwsCloudFrontDistributionOriginItem]
items :: Maybe [AwsCloudFrontDistributionOriginItem]
$sel:items:AwsCloudFrontDistributionOrigins' :: AwsCloudFrontDistributionOrigins
-> Maybe [AwsCloudFrontDistributionOriginItem]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Items" Text -> [AwsCloudFrontDistributionOriginItem] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AwsCloudFrontDistributionOriginItem] -> Pair)
-> Maybe [AwsCloudFrontDistributionOriginItem] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AwsCloudFrontDistributionOriginItem]
items]
      )