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

import Amazonka.CloudFront.Types.StatusCodes
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A complex data type that includes information about the failover
-- criteria for an origin group, including the status codes for which
-- CloudFront will failover from the primary origin to the second origin.
--
-- /See:/ 'newOriginGroupFailoverCriteria' smart constructor.
data OriginGroupFailoverCriteria = OriginGroupFailoverCriteria'
  { -- | The status codes that, when returned from the primary origin, will
    -- trigger CloudFront to failover to the second origin.
    OriginGroupFailoverCriteria -> StatusCodes
statusCodes :: StatusCodes
  }
  deriving (OriginGroupFailoverCriteria -> OriginGroupFailoverCriteria -> Bool
(OriginGroupFailoverCriteria
 -> OriginGroupFailoverCriteria -> Bool)
-> (OriginGroupFailoverCriteria
    -> OriginGroupFailoverCriteria -> Bool)
-> Eq OriginGroupFailoverCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginGroupFailoverCriteria -> OriginGroupFailoverCriteria -> Bool
$c/= :: OriginGroupFailoverCriteria -> OriginGroupFailoverCriteria -> Bool
== :: OriginGroupFailoverCriteria -> OriginGroupFailoverCriteria -> Bool
$c== :: OriginGroupFailoverCriteria -> OriginGroupFailoverCriteria -> Bool
Prelude.Eq, ReadPrec [OriginGroupFailoverCriteria]
ReadPrec OriginGroupFailoverCriteria
Int -> ReadS OriginGroupFailoverCriteria
ReadS [OriginGroupFailoverCriteria]
(Int -> ReadS OriginGroupFailoverCriteria)
-> ReadS [OriginGroupFailoverCriteria]
-> ReadPrec OriginGroupFailoverCriteria
-> ReadPrec [OriginGroupFailoverCriteria]
-> Read OriginGroupFailoverCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginGroupFailoverCriteria]
$creadListPrec :: ReadPrec [OriginGroupFailoverCriteria]
readPrec :: ReadPrec OriginGroupFailoverCriteria
$creadPrec :: ReadPrec OriginGroupFailoverCriteria
readList :: ReadS [OriginGroupFailoverCriteria]
$creadList :: ReadS [OriginGroupFailoverCriteria]
readsPrec :: Int -> ReadS OriginGroupFailoverCriteria
$creadsPrec :: Int -> ReadS OriginGroupFailoverCriteria
Prelude.Read, Int -> OriginGroupFailoverCriteria -> ShowS
[OriginGroupFailoverCriteria] -> ShowS
OriginGroupFailoverCriteria -> String
(Int -> OriginGroupFailoverCriteria -> ShowS)
-> (OriginGroupFailoverCriteria -> String)
-> ([OriginGroupFailoverCriteria] -> ShowS)
-> Show OriginGroupFailoverCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginGroupFailoverCriteria] -> ShowS
$cshowList :: [OriginGroupFailoverCriteria] -> ShowS
show :: OriginGroupFailoverCriteria -> String
$cshow :: OriginGroupFailoverCriteria -> String
showsPrec :: Int -> OriginGroupFailoverCriteria -> ShowS
$cshowsPrec :: Int -> OriginGroupFailoverCriteria -> ShowS
Prelude.Show, (forall x.
 OriginGroupFailoverCriteria -> Rep OriginGroupFailoverCriteria x)
-> (forall x.
    Rep OriginGroupFailoverCriteria x -> OriginGroupFailoverCriteria)
-> Generic OriginGroupFailoverCriteria
forall x.
Rep OriginGroupFailoverCriteria x -> OriginGroupFailoverCriteria
forall x.
OriginGroupFailoverCriteria -> Rep OriginGroupFailoverCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OriginGroupFailoverCriteria x -> OriginGroupFailoverCriteria
$cfrom :: forall x.
OriginGroupFailoverCriteria -> Rep OriginGroupFailoverCriteria x
Prelude.Generic)

-- |
-- Create a value of 'OriginGroupFailoverCriteria' 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:
--
-- 'statusCodes', 'originGroupFailoverCriteria_statusCodes' - The status codes that, when returned from the primary origin, will
-- trigger CloudFront to failover to the second origin.
newOriginGroupFailoverCriteria ::
  -- | 'statusCodes'
  StatusCodes ->
  OriginGroupFailoverCriteria
newOriginGroupFailoverCriteria :: StatusCodes -> OriginGroupFailoverCriteria
newOriginGroupFailoverCriteria StatusCodes
pStatusCodes_ =
  OriginGroupFailoverCriteria' :: StatusCodes -> OriginGroupFailoverCriteria
OriginGroupFailoverCriteria'
    { $sel:statusCodes:OriginGroupFailoverCriteria' :: StatusCodes
statusCodes =
        StatusCodes
pStatusCodes_
    }

-- | The status codes that, when returned from the primary origin, will
-- trigger CloudFront to failover to the second origin.
originGroupFailoverCriteria_statusCodes :: Lens.Lens' OriginGroupFailoverCriteria StatusCodes
originGroupFailoverCriteria_statusCodes :: (StatusCodes -> f StatusCodes)
-> OriginGroupFailoverCriteria -> f OriginGroupFailoverCriteria
originGroupFailoverCriteria_statusCodes = (OriginGroupFailoverCriteria -> StatusCodes)
-> (OriginGroupFailoverCriteria
    -> StatusCodes -> OriginGroupFailoverCriteria)
-> Lens
     OriginGroupFailoverCriteria
     OriginGroupFailoverCriteria
     StatusCodes
     StatusCodes
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginGroupFailoverCriteria' {StatusCodes
statusCodes :: StatusCodes
$sel:statusCodes:OriginGroupFailoverCriteria' :: OriginGroupFailoverCriteria -> StatusCodes
statusCodes} -> StatusCodes
statusCodes) (\s :: OriginGroupFailoverCriteria
s@OriginGroupFailoverCriteria' {} StatusCodes
a -> OriginGroupFailoverCriteria
s {$sel:statusCodes:OriginGroupFailoverCriteria' :: StatusCodes
statusCodes = StatusCodes
a} :: OriginGroupFailoverCriteria)

instance Core.FromXML OriginGroupFailoverCriteria where
  parseXML :: [Node] -> Either String OriginGroupFailoverCriteria
parseXML [Node]
x =
    StatusCodes -> OriginGroupFailoverCriteria
OriginGroupFailoverCriteria'
      (StatusCodes -> OriginGroupFailoverCriteria)
-> Either String StatusCodes
-> Either String OriginGroupFailoverCriteria
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String StatusCodes
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"StatusCodes")

instance Prelude.Hashable OriginGroupFailoverCriteria

instance Prelude.NFData OriginGroupFailoverCriteria

instance Core.ToXML OriginGroupFailoverCriteria where
  toXML :: OriginGroupFailoverCriteria -> XML
toXML OriginGroupFailoverCriteria' {StatusCodes
statusCodes :: StatusCodes
$sel:statusCodes:OriginGroupFailoverCriteria' :: OriginGroupFailoverCriteria -> StatusCodes
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat [Name
"StatusCodes" Name -> StatusCodes -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= StatusCodes
statusCodes]