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

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

-- | The configuration details of a campaign.
--
-- /See:/ 'newCampaignConfig' smart constructor.
data CampaignConfig = CampaignConfig'
  { -- | A string to string map specifying the exploration configuration
    -- hyperparameters, including @explorationWeight@ and
    -- @explorationItemAgeCutOff@, you want to use to configure the amount of
    -- item exploration Amazon Personalize uses when recommending items.
    -- Provide @itemExplorationConfig@ data only if your solution uses the
    -- <https://docs.aws.amazon.com/personalize/latest/dg/native-recipe-new-item-USER_PERSONALIZATION.html User-Personalization>
    -- recipe.
    CampaignConfig -> Maybe (HashMap Text Text)
itemExplorationConfig :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (CampaignConfig -> CampaignConfig -> Bool
(CampaignConfig -> CampaignConfig -> Bool)
-> (CampaignConfig -> CampaignConfig -> Bool) -> Eq CampaignConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CampaignConfig -> CampaignConfig -> Bool
$c/= :: CampaignConfig -> CampaignConfig -> Bool
== :: CampaignConfig -> CampaignConfig -> Bool
$c== :: CampaignConfig -> CampaignConfig -> Bool
Prelude.Eq, ReadPrec [CampaignConfig]
ReadPrec CampaignConfig
Int -> ReadS CampaignConfig
ReadS [CampaignConfig]
(Int -> ReadS CampaignConfig)
-> ReadS [CampaignConfig]
-> ReadPrec CampaignConfig
-> ReadPrec [CampaignConfig]
-> Read CampaignConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CampaignConfig]
$creadListPrec :: ReadPrec [CampaignConfig]
readPrec :: ReadPrec CampaignConfig
$creadPrec :: ReadPrec CampaignConfig
readList :: ReadS [CampaignConfig]
$creadList :: ReadS [CampaignConfig]
readsPrec :: Int -> ReadS CampaignConfig
$creadsPrec :: Int -> ReadS CampaignConfig
Prelude.Read, Int -> CampaignConfig -> ShowS
[CampaignConfig] -> ShowS
CampaignConfig -> String
(Int -> CampaignConfig -> ShowS)
-> (CampaignConfig -> String)
-> ([CampaignConfig] -> ShowS)
-> Show CampaignConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CampaignConfig] -> ShowS
$cshowList :: [CampaignConfig] -> ShowS
show :: CampaignConfig -> String
$cshow :: CampaignConfig -> String
showsPrec :: Int -> CampaignConfig -> ShowS
$cshowsPrec :: Int -> CampaignConfig -> ShowS
Prelude.Show, (forall x. CampaignConfig -> Rep CampaignConfig x)
-> (forall x. Rep CampaignConfig x -> CampaignConfig)
-> Generic CampaignConfig
forall x. Rep CampaignConfig x -> CampaignConfig
forall x. CampaignConfig -> Rep CampaignConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CampaignConfig x -> CampaignConfig
$cfrom :: forall x. CampaignConfig -> Rep CampaignConfig x
Prelude.Generic)

-- |
-- Create a value of 'CampaignConfig' 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:
--
-- 'itemExplorationConfig', 'campaignConfig_itemExplorationConfig' - A string to string map specifying the exploration configuration
-- hyperparameters, including @explorationWeight@ and
-- @explorationItemAgeCutOff@, you want to use to configure the amount of
-- item exploration Amazon Personalize uses when recommending items.
-- Provide @itemExplorationConfig@ data only if your solution uses the
-- <https://docs.aws.amazon.com/personalize/latest/dg/native-recipe-new-item-USER_PERSONALIZATION.html User-Personalization>
-- recipe.
newCampaignConfig ::
  CampaignConfig
newCampaignConfig :: CampaignConfig
newCampaignConfig =
  CampaignConfig' :: Maybe (HashMap Text Text) -> CampaignConfig
CampaignConfig'
    { $sel:itemExplorationConfig:CampaignConfig' :: Maybe (HashMap Text Text)
itemExplorationConfig =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | A string to string map specifying the exploration configuration
-- hyperparameters, including @explorationWeight@ and
-- @explorationItemAgeCutOff@, you want to use to configure the amount of
-- item exploration Amazon Personalize uses when recommending items.
-- Provide @itemExplorationConfig@ data only if your solution uses the
-- <https://docs.aws.amazon.com/personalize/latest/dg/native-recipe-new-item-USER_PERSONALIZATION.html User-Personalization>
-- recipe.
campaignConfig_itemExplorationConfig :: Lens.Lens' CampaignConfig (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
campaignConfig_itemExplorationConfig :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CampaignConfig -> f CampaignConfig
campaignConfig_itemExplorationConfig = (CampaignConfig -> Maybe (HashMap Text Text))
-> (CampaignConfig -> Maybe (HashMap Text Text) -> CampaignConfig)
-> Lens
     CampaignConfig
     CampaignConfig
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignConfig' {Maybe (HashMap Text Text)
itemExplorationConfig :: Maybe (HashMap Text Text)
$sel:itemExplorationConfig:CampaignConfig' :: CampaignConfig -> Maybe (HashMap Text Text)
itemExplorationConfig} -> Maybe (HashMap Text Text)
itemExplorationConfig) (\s :: CampaignConfig
s@CampaignConfig' {} Maybe (HashMap Text Text)
a -> CampaignConfig
s {$sel:itemExplorationConfig:CampaignConfig' :: Maybe (HashMap Text Text)
itemExplorationConfig = Maybe (HashMap Text Text)
a} :: CampaignConfig) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CampaignConfig -> f CampaignConfig)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CampaignConfig
-> f CampaignConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable CampaignConfig

instance Prelude.NFData CampaignConfig

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