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

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

-- | Information about an origin group for the distribution.
--
-- /See:/ 'newAwsCloudFrontDistributionOriginGroup' smart constructor.
data AwsCloudFrontDistributionOriginGroup = AwsCloudFrontDistributionOriginGroup'
  { -- | Provides the criteria for an origin group to fail over.
    AwsCloudFrontDistributionOriginGroup
-> Maybe AwsCloudFrontDistributionOriginGroupFailover
failoverCriteria :: Prelude.Maybe AwsCloudFrontDistributionOriginGroupFailover
  }
  deriving (AwsCloudFrontDistributionOriginGroup
-> AwsCloudFrontDistributionOriginGroup -> Bool
(AwsCloudFrontDistributionOriginGroup
 -> AwsCloudFrontDistributionOriginGroup -> Bool)
-> (AwsCloudFrontDistributionOriginGroup
    -> AwsCloudFrontDistributionOriginGroup -> Bool)
-> Eq AwsCloudFrontDistributionOriginGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCloudFrontDistributionOriginGroup
-> AwsCloudFrontDistributionOriginGroup -> Bool
$c/= :: AwsCloudFrontDistributionOriginGroup
-> AwsCloudFrontDistributionOriginGroup -> Bool
== :: AwsCloudFrontDistributionOriginGroup
-> AwsCloudFrontDistributionOriginGroup -> Bool
$c== :: AwsCloudFrontDistributionOriginGroup
-> AwsCloudFrontDistributionOriginGroup -> Bool
Prelude.Eq, ReadPrec [AwsCloudFrontDistributionOriginGroup]
ReadPrec AwsCloudFrontDistributionOriginGroup
Int -> ReadS AwsCloudFrontDistributionOriginGroup
ReadS [AwsCloudFrontDistributionOriginGroup]
(Int -> ReadS AwsCloudFrontDistributionOriginGroup)
-> ReadS [AwsCloudFrontDistributionOriginGroup]
-> ReadPrec AwsCloudFrontDistributionOriginGroup
-> ReadPrec [AwsCloudFrontDistributionOriginGroup]
-> Read AwsCloudFrontDistributionOriginGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCloudFrontDistributionOriginGroup]
$creadListPrec :: ReadPrec [AwsCloudFrontDistributionOriginGroup]
readPrec :: ReadPrec AwsCloudFrontDistributionOriginGroup
$creadPrec :: ReadPrec AwsCloudFrontDistributionOriginGroup
readList :: ReadS [AwsCloudFrontDistributionOriginGroup]
$creadList :: ReadS [AwsCloudFrontDistributionOriginGroup]
readsPrec :: Int -> ReadS AwsCloudFrontDistributionOriginGroup
$creadsPrec :: Int -> ReadS AwsCloudFrontDistributionOriginGroup
Prelude.Read, Int -> AwsCloudFrontDistributionOriginGroup -> ShowS
[AwsCloudFrontDistributionOriginGroup] -> ShowS
AwsCloudFrontDistributionOriginGroup -> String
(Int -> AwsCloudFrontDistributionOriginGroup -> ShowS)
-> (AwsCloudFrontDistributionOriginGroup -> String)
-> ([AwsCloudFrontDistributionOriginGroup] -> ShowS)
-> Show AwsCloudFrontDistributionOriginGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCloudFrontDistributionOriginGroup] -> ShowS
$cshowList :: [AwsCloudFrontDistributionOriginGroup] -> ShowS
show :: AwsCloudFrontDistributionOriginGroup -> String
$cshow :: AwsCloudFrontDistributionOriginGroup -> String
showsPrec :: Int -> AwsCloudFrontDistributionOriginGroup -> ShowS
$cshowsPrec :: Int -> AwsCloudFrontDistributionOriginGroup -> ShowS
Prelude.Show, (forall x.
 AwsCloudFrontDistributionOriginGroup
 -> Rep AwsCloudFrontDistributionOriginGroup x)
-> (forall x.
    Rep AwsCloudFrontDistributionOriginGroup x
    -> AwsCloudFrontDistributionOriginGroup)
-> Generic AwsCloudFrontDistributionOriginGroup
forall x.
Rep AwsCloudFrontDistributionOriginGroup x
-> AwsCloudFrontDistributionOriginGroup
forall x.
AwsCloudFrontDistributionOriginGroup
-> Rep AwsCloudFrontDistributionOriginGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCloudFrontDistributionOriginGroup x
-> AwsCloudFrontDistributionOriginGroup
$cfrom :: forall x.
AwsCloudFrontDistributionOriginGroup
-> Rep AwsCloudFrontDistributionOriginGroup x
Prelude.Generic)

-- |
-- Create a value of 'AwsCloudFrontDistributionOriginGroup' 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:
--
-- 'failoverCriteria', 'awsCloudFrontDistributionOriginGroup_failoverCriteria' - Provides the criteria for an origin group to fail over.
newAwsCloudFrontDistributionOriginGroup ::
  AwsCloudFrontDistributionOriginGroup
newAwsCloudFrontDistributionOriginGroup :: AwsCloudFrontDistributionOriginGroup
newAwsCloudFrontDistributionOriginGroup =
  AwsCloudFrontDistributionOriginGroup' :: Maybe AwsCloudFrontDistributionOriginGroupFailover
-> AwsCloudFrontDistributionOriginGroup
AwsCloudFrontDistributionOriginGroup'
    { $sel:failoverCriteria:AwsCloudFrontDistributionOriginGroup' :: Maybe AwsCloudFrontDistributionOriginGroupFailover
failoverCriteria =
        Maybe AwsCloudFrontDistributionOriginGroupFailover
forall a. Maybe a
Prelude.Nothing
    }

-- | Provides the criteria for an origin group to fail over.
awsCloudFrontDistributionOriginGroup_failoverCriteria :: Lens.Lens' AwsCloudFrontDistributionOriginGroup (Prelude.Maybe AwsCloudFrontDistributionOriginGroupFailover)
awsCloudFrontDistributionOriginGroup_failoverCriteria :: (Maybe AwsCloudFrontDistributionOriginGroupFailover
 -> f (Maybe AwsCloudFrontDistributionOriginGroupFailover))
-> AwsCloudFrontDistributionOriginGroup
-> f AwsCloudFrontDistributionOriginGroup
awsCloudFrontDistributionOriginGroup_failoverCriteria = (AwsCloudFrontDistributionOriginGroup
 -> Maybe AwsCloudFrontDistributionOriginGroupFailover)
-> (AwsCloudFrontDistributionOriginGroup
    -> Maybe AwsCloudFrontDistributionOriginGroupFailover
    -> AwsCloudFrontDistributionOriginGroup)
-> Lens
     AwsCloudFrontDistributionOriginGroup
     AwsCloudFrontDistributionOriginGroup
     (Maybe AwsCloudFrontDistributionOriginGroupFailover)
     (Maybe AwsCloudFrontDistributionOriginGroupFailover)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionOriginGroup' {Maybe AwsCloudFrontDistributionOriginGroupFailover
failoverCriteria :: Maybe AwsCloudFrontDistributionOriginGroupFailover
$sel:failoverCriteria:AwsCloudFrontDistributionOriginGroup' :: AwsCloudFrontDistributionOriginGroup
-> Maybe AwsCloudFrontDistributionOriginGroupFailover
failoverCriteria} -> Maybe AwsCloudFrontDistributionOriginGroupFailover
failoverCriteria) (\s :: AwsCloudFrontDistributionOriginGroup
s@AwsCloudFrontDistributionOriginGroup' {} Maybe AwsCloudFrontDistributionOriginGroupFailover
a -> AwsCloudFrontDistributionOriginGroup
s {$sel:failoverCriteria:AwsCloudFrontDistributionOriginGroup' :: Maybe AwsCloudFrontDistributionOriginGroupFailover
failoverCriteria = Maybe AwsCloudFrontDistributionOriginGroupFailover
a} :: AwsCloudFrontDistributionOriginGroup)

instance
  Core.FromJSON
    AwsCloudFrontDistributionOriginGroup
  where
  parseJSON :: Value -> Parser AwsCloudFrontDistributionOriginGroup
parseJSON =
    String
-> (Object -> Parser AwsCloudFrontDistributionOriginGroup)
-> Value
-> Parser AwsCloudFrontDistributionOriginGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCloudFrontDistributionOriginGroup"
      ( \Object
x ->
          Maybe AwsCloudFrontDistributionOriginGroupFailover
-> AwsCloudFrontDistributionOriginGroup
AwsCloudFrontDistributionOriginGroup'
            (Maybe AwsCloudFrontDistributionOriginGroupFailover
 -> AwsCloudFrontDistributionOriginGroup)
-> Parser (Maybe AwsCloudFrontDistributionOriginGroupFailover)
-> Parser AwsCloudFrontDistributionOriginGroup
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe AwsCloudFrontDistributionOriginGroupFailover)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FailoverCriteria")
      )

instance
  Prelude.Hashable
    AwsCloudFrontDistributionOriginGroup

instance
  Prelude.NFData
    AwsCloudFrontDistributionOriginGroup

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