{-# 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.Pinpoint.Types.CampaignState
-- 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.Pinpoint.Types.CampaignState where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.CampaignStatus
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the status of a campaign.
--
-- /See:/ 'newCampaignState' smart constructor.
data CampaignState = CampaignState'
  { -- | The current status of the campaign, or the current status of a treatment
    -- that belongs to an A\/B test campaign.
    --
    -- If a campaign uses A\/B testing, the campaign has a status of COMPLETED
    -- only if all campaign treatments have a status of COMPLETED. If you
    -- delete the segment that\'s associated with a campaign, the campaign
    -- fails and has a status of DELETED.
    CampaignState -> Maybe CampaignStatus
campaignStatus :: Prelude.Maybe CampaignStatus
  }
  deriving (CampaignState -> CampaignState -> Bool
(CampaignState -> CampaignState -> Bool)
-> (CampaignState -> CampaignState -> Bool) -> Eq CampaignState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CampaignState -> CampaignState -> Bool
$c/= :: CampaignState -> CampaignState -> Bool
== :: CampaignState -> CampaignState -> Bool
$c== :: CampaignState -> CampaignState -> Bool
Prelude.Eq, ReadPrec [CampaignState]
ReadPrec CampaignState
Int -> ReadS CampaignState
ReadS [CampaignState]
(Int -> ReadS CampaignState)
-> ReadS [CampaignState]
-> ReadPrec CampaignState
-> ReadPrec [CampaignState]
-> Read CampaignState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CampaignState]
$creadListPrec :: ReadPrec [CampaignState]
readPrec :: ReadPrec CampaignState
$creadPrec :: ReadPrec CampaignState
readList :: ReadS [CampaignState]
$creadList :: ReadS [CampaignState]
readsPrec :: Int -> ReadS CampaignState
$creadsPrec :: Int -> ReadS CampaignState
Prelude.Read, Int -> CampaignState -> ShowS
[CampaignState] -> ShowS
CampaignState -> String
(Int -> CampaignState -> ShowS)
-> (CampaignState -> String)
-> ([CampaignState] -> ShowS)
-> Show CampaignState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CampaignState] -> ShowS
$cshowList :: [CampaignState] -> ShowS
show :: CampaignState -> String
$cshow :: CampaignState -> String
showsPrec :: Int -> CampaignState -> ShowS
$cshowsPrec :: Int -> CampaignState -> ShowS
Prelude.Show, (forall x. CampaignState -> Rep CampaignState x)
-> (forall x. Rep CampaignState x -> CampaignState)
-> Generic CampaignState
forall x. Rep CampaignState x -> CampaignState
forall x. CampaignState -> Rep CampaignState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CampaignState x -> CampaignState
$cfrom :: forall x. CampaignState -> Rep CampaignState x
Prelude.Generic)

-- |
-- Create a value of 'CampaignState' 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:
--
-- 'campaignStatus', 'campaignState_campaignStatus' - The current status of the campaign, or the current status of a treatment
-- that belongs to an A\/B test campaign.
--
-- If a campaign uses A\/B testing, the campaign has a status of COMPLETED
-- only if all campaign treatments have a status of COMPLETED. If you
-- delete the segment that\'s associated with a campaign, the campaign
-- fails and has a status of DELETED.
newCampaignState ::
  CampaignState
newCampaignState :: CampaignState
newCampaignState =
  CampaignState' :: Maybe CampaignStatus -> CampaignState
CampaignState' {$sel:campaignStatus:CampaignState' :: Maybe CampaignStatus
campaignStatus = Maybe CampaignStatus
forall a. Maybe a
Prelude.Nothing}

-- | The current status of the campaign, or the current status of a treatment
-- that belongs to an A\/B test campaign.
--
-- If a campaign uses A\/B testing, the campaign has a status of COMPLETED
-- only if all campaign treatments have a status of COMPLETED. If you
-- delete the segment that\'s associated with a campaign, the campaign
-- fails and has a status of DELETED.
campaignState_campaignStatus :: Lens.Lens' CampaignState (Prelude.Maybe CampaignStatus)
campaignState_campaignStatus :: (Maybe CampaignStatus -> f (Maybe CampaignStatus))
-> CampaignState -> f CampaignState
campaignState_campaignStatus = (CampaignState -> Maybe CampaignStatus)
-> (CampaignState -> Maybe CampaignStatus -> CampaignState)
-> Lens
     CampaignState
     CampaignState
     (Maybe CampaignStatus)
     (Maybe CampaignStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignState' {Maybe CampaignStatus
campaignStatus :: Maybe CampaignStatus
$sel:campaignStatus:CampaignState' :: CampaignState -> Maybe CampaignStatus
campaignStatus} -> Maybe CampaignStatus
campaignStatus) (\s :: CampaignState
s@CampaignState' {} Maybe CampaignStatus
a -> CampaignState
s {$sel:campaignStatus:CampaignState' :: Maybe CampaignStatus
campaignStatus = Maybe CampaignStatus
a} :: CampaignState)

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

instance Prelude.Hashable CampaignState

instance Prelude.NFData CampaignState