{-# 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.Personalize.Types.CampaignSummary
-- 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.Personalize.Types.CampaignSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides a summary of the properties of a campaign. For a complete
-- listing, call the DescribeCampaign API.
--
-- /See:/ 'newCampaignSummary' smart constructor.
data CampaignSummary = CampaignSummary'
  { -- | If a campaign fails, the reason behind the failure.
    CampaignSummary -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | The status of the campaign.
    --
    -- A campaign can be in one of the following states:
    --
    -- -   CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED
    --
    -- -   DELETE PENDING > DELETE IN_PROGRESS
    CampaignSummary -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The date and time (in Unix time) that the campaign was last updated.
    CampaignSummary -> Maybe POSIX
lastUpdatedDateTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the campaign.
    CampaignSummary -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The date and time (in Unix time) that the campaign was created.
    CampaignSummary -> Maybe POSIX
creationDateTime :: Prelude.Maybe Core.POSIX,
    -- | The Amazon Resource Name (ARN) of the campaign.
    CampaignSummary -> Maybe Text
campaignArn :: Prelude.Maybe Prelude.Text
  }
  deriving (CampaignSummary -> CampaignSummary -> Bool
(CampaignSummary -> CampaignSummary -> Bool)
-> (CampaignSummary -> CampaignSummary -> Bool)
-> Eq CampaignSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CampaignSummary -> CampaignSummary -> Bool
$c/= :: CampaignSummary -> CampaignSummary -> Bool
== :: CampaignSummary -> CampaignSummary -> Bool
$c== :: CampaignSummary -> CampaignSummary -> Bool
Prelude.Eq, ReadPrec [CampaignSummary]
ReadPrec CampaignSummary
Int -> ReadS CampaignSummary
ReadS [CampaignSummary]
(Int -> ReadS CampaignSummary)
-> ReadS [CampaignSummary]
-> ReadPrec CampaignSummary
-> ReadPrec [CampaignSummary]
-> Read CampaignSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CampaignSummary]
$creadListPrec :: ReadPrec [CampaignSummary]
readPrec :: ReadPrec CampaignSummary
$creadPrec :: ReadPrec CampaignSummary
readList :: ReadS [CampaignSummary]
$creadList :: ReadS [CampaignSummary]
readsPrec :: Int -> ReadS CampaignSummary
$creadsPrec :: Int -> ReadS CampaignSummary
Prelude.Read, Int -> CampaignSummary -> ShowS
[CampaignSummary] -> ShowS
CampaignSummary -> String
(Int -> CampaignSummary -> ShowS)
-> (CampaignSummary -> String)
-> ([CampaignSummary] -> ShowS)
-> Show CampaignSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CampaignSummary] -> ShowS
$cshowList :: [CampaignSummary] -> ShowS
show :: CampaignSummary -> String
$cshow :: CampaignSummary -> String
showsPrec :: Int -> CampaignSummary -> ShowS
$cshowsPrec :: Int -> CampaignSummary -> ShowS
Prelude.Show, (forall x. CampaignSummary -> Rep CampaignSummary x)
-> (forall x. Rep CampaignSummary x -> CampaignSummary)
-> Generic CampaignSummary
forall x. Rep CampaignSummary x -> CampaignSummary
forall x. CampaignSummary -> Rep CampaignSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CampaignSummary x -> CampaignSummary
$cfrom :: forall x. CampaignSummary -> Rep CampaignSummary x
Prelude.Generic)

-- |
-- Create a value of 'CampaignSummary' 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:
--
-- 'failureReason', 'campaignSummary_failureReason' - If a campaign fails, the reason behind the failure.
--
-- 'status', 'campaignSummary_status' - The status of the campaign.
--
-- A campaign can be in one of the following states:
--
-- -   CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED
--
-- -   DELETE PENDING > DELETE IN_PROGRESS
--
-- 'lastUpdatedDateTime', 'campaignSummary_lastUpdatedDateTime' - The date and time (in Unix time) that the campaign was last updated.
--
-- 'name', 'campaignSummary_name' - The name of the campaign.
--
-- 'creationDateTime', 'campaignSummary_creationDateTime' - The date and time (in Unix time) that the campaign was created.
--
-- 'campaignArn', 'campaignSummary_campaignArn' - The Amazon Resource Name (ARN) of the campaign.
newCampaignSummary ::
  CampaignSummary
newCampaignSummary :: CampaignSummary
newCampaignSummary =
  CampaignSummary' :: Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> CampaignSummary
CampaignSummary'
    { $sel:failureReason:CampaignSummary' :: Maybe Text
failureReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:CampaignSummary' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedDateTime:CampaignSummary' :: Maybe POSIX
lastUpdatedDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CampaignSummary' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDateTime:CampaignSummary' :: Maybe POSIX
creationDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:campaignArn:CampaignSummary' :: Maybe Text
campaignArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | If a campaign fails, the reason behind the failure.
campaignSummary_failureReason :: Lens.Lens' CampaignSummary (Prelude.Maybe Prelude.Text)
campaignSummary_failureReason :: (Maybe Text -> f (Maybe Text))
-> CampaignSummary -> f CampaignSummary
campaignSummary_failureReason = (CampaignSummary -> Maybe Text)
-> (CampaignSummary -> Maybe Text -> CampaignSummary)
-> Lens CampaignSummary CampaignSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignSummary' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:CampaignSummary' :: CampaignSummary -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: CampaignSummary
s@CampaignSummary' {} Maybe Text
a -> CampaignSummary
s {$sel:failureReason:CampaignSummary' :: Maybe Text
failureReason = Maybe Text
a} :: CampaignSummary)

-- | The status of the campaign.
--
-- A campaign can be in one of the following states:
--
-- -   CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED
--
-- -   DELETE PENDING > DELETE IN_PROGRESS
campaignSummary_status :: Lens.Lens' CampaignSummary (Prelude.Maybe Prelude.Text)
campaignSummary_status :: (Maybe Text -> f (Maybe Text))
-> CampaignSummary -> f CampaignSummary
campaignSummary_status = (CampaignSummary -> Maybe Text)
-> (CampaignSummary -> Maybe Text -> CampaignSummary)
-> Lens CampaignSummary CampaignSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignSummary' {Maybe Text
status :: Maybe Text
$sel:status:CampaignSummary' :: CampaignSummary -> Maybe Text
status} -> Maybe Text
status) (\s :: CampaignSummary
s@CampaignSummary' {} Maybe Text
a -> CampaignSummary
s {$sel:status:CampaignSummary' :: Maybe Text
status = Maybe Text
a} :: CampaignSummary)

-- | The date and time (in Unix time) that the campaign was last updated.
campaignSummary_lastUpdatedDateTime :: Lens.Lens' CampaignSummary (Prelude.Maybe Prelude.UTCTime)
campaignSummary_lastUpdatedDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CampaignSummary -> f CampaignSummary
campaignSummary_lastUpdatedDateTime = (CampaignSummary -> Maybe POSIX)
-> (CampaignSummary -> Maybe POSIX -> CampaignSummary)
-> Lens CampaignSummary CampaignSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignSummary' {Maybe POSIX
lastUpdatedDateTime :: Maybe POSIX
$sel:lastUpdatedDateTime:CampaignSummary' :: CampaignSummary -> Maybe POSIX
lastUpdatedDateTime} -> Maybe POSIX
lastUpdatedDateTime) (\s :: CampaignSummary
s@CampaignSummary' {} Maybe POSIX
a -> CampaignSummary
s {$sel:lastUpdatedDateTime:CampaignSummary' :: Maybe POSIX
lastUpdatedDateTime = Maybe POSIX
a} :: CampaignSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> CampaignSummary -> f CampaignSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CampaignSummary
-> f CampaignSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the campaign.
campaignSummary_name :: Lens.Lens' CampaignSummary (Prelude.Maybe Prelude.Text)
campaignSummary_name :: (Maybe Text -> f (Maybe Text))
-> CampaignSummary -> f CampaignSummary
campaignSummary_name = (CampaignSummary -> Maybe Text)
-> (CampaignSummary -> Maybe Text -> CampaignSummary)
-> Lens CampaignSummary CampaignSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignSummary' {Maybe Text
name :: Maybe Text
$sel:name:CampaignSummary' :: CampaignSummary -> Maybe Text
name} -> Maybe Text
name) (\s :: CampaignSummary
s@CampaignSummary' {} Maybe Text
a -> CampaignSummary
s {$sel:name:CampaignSummary' :: Maybe Text
name = Maybe Text
a} :: CampaignSummary)

-- | The date and time (in Unix time) that the campaign was created.
campaignSummary_creationDateTime :: Lens.Lens' CampaignSummary (Prelude.Maybe Prelude.UTCTime)
campaignSummary_creationDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CampaignSummary -> f CampaignSummary
campaignSummary_creationDateTime = (CampaignSummary -> Maybe POSIX)
-> (CampaignSummary -> Maybe POSIX -> CampaignSummary)
-> Lens CampaignSummary CampaignSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignSummary' {Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:creationDateTime:CampaignSummary' :: CampaignSummary -> Maybe POSIX
creationDateTime} -> Maybe POSIX
creationDateTime) (\s :: CampaignSummary
s@CampaignSummary' {} Maybe POSIX
a -> CampaignSummary
s {$sel:creationDateTime:CampaignSummary' :: Maybe POSIX
creationDateTime = Maybe POSIX
a} :: CampaignSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> CampaignSummary -> f CampaignSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CampaignSummary
-> f CampaignSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The Amazon Resource Name (ARN) of the campaign.
campaignSummary_campaignArn :: Lens.Lens' CampaignSummary (Prelude.Maybe Prelude.Text)
campaignSummary_campaignArn :: (Maybe Text -> f (Maybe Text))
-> CampaignSummary -> f CampaignSummary
campaignSummary_campaignArn = (CampaignSummary -> Maybe Text)
-> (CampaignSummary -> Maybe Text -> CampaignSummary)
-> Lens CampaignSummary CampaignSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignSummary' {Maybe Text
campaignArn :: Maybe Text
$sel:campaignArn:CampaignSummary' :: CampaignSummary -> Maybe Text
campaignArn} -> Maybe Text
campaignArn) (\s :: CampaignSummary
s@CampaignSummary' {} Maybe Text
a -> CampaignSummary
s {$sel:campaignArn:CampaignSummary' :: Maybe Text
campaignArn = Maybe Text
a} :: CampaignSummary)

instance Core.FromJSON CampaignSummary where
  parseJSON :: Value -> Parser CampaignSummary
parseJSON =
    String
-> (Object -> Parser CampaignSummary)
-> Value
-> Parser CampaignSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CampaignSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> CampaignSummary
CampaignSummary'
            (Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> CampaignSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> CampaignSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failureReason")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> CampaignSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe POSIX -> Maybe Text -> CampaignSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe POSIX -> Maybe Text -> CampaignSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> CampaignSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdatedDateTime")
            Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> CampaignSummary)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> CampaignSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
            Parser (Maybe POSIX -> Maybe Text -> CampaignSummary)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> CampaignSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationDateTime")
            Parser (Maybe Text -> CampaignSummary)
-> Parser (Maybe Text) -> Parser CampaignSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"campaignArn")
      )

instance Prelude.Hashable CampaignSummary

instance Prelude.NFData CampaignSummary