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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Personalize.Types.ObjectiveSensitivity
import qualified Amazonka.Prelude as Prelude

-- | Describes the additional objective for the solution, such as maximizing
-- streaming minutes or increasing revenue. For more information see
-- <https://docs.aws.amazon.com/personalize/latest/dg/optimizing-solution-for-objective.html Optimizing a solution>.
--
-- /See:/ 'newOptimizationObjective' smart constructor.
data OptimizationObjective = OptimizationObjective'
  { -- | The numerical metadata column in an Items dataset related to the
    -- optimization objective. For example, VIDEO_LENGTH (to maximize streaming
    -- minutes), or PRICE (to maximize revenue).
    OptimizationObjective -> Maybe Text
itemAttribute :: Prelude.Maybe Prelude.Text,
    -- | Specifies how Amazon Personalize balances the importance of your
    -- optimization objective versus relevance.
    OptimizationObjective -> Maybe ObjectiveSensitivity
objectiveSensitivity :: Prelude.Maybe ObjectiveSensitivity
  }
  deriving (OptimizationObjective -> OptimizationObjective -> Bool
(OptimizationObjective -> OptimizationObjective -> Bool)
-> (OptimizationObjective -> OptimizationObjective -> Bool)
-> Eq OptimizationObjective
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptimizationObjective -> OptimizationObjective -> Bool
$c/= :: OptimizationObjective -> OptimizationObjective -> Bool
== :: OptimizationObjective -> OptimizationObjective -> Bool
$c== :: OptimizationObjective -> OptimizationObjective -> Bool
Prelude.Eq, ReadPrec [OptimizationObjective]
ReadPrec OptimizationObjective
Int -> ReadS OptimizationObjective
ReadS [OptimizationObjective]
(Int -> ReadS OptimizationObjective)
-> ReadS [OptimizationObjective]
-> ReadPrec OptimizationObjective
-> ReadPrec [OptimizationObjective]
-> Read OptimizationObjective
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptimizationObjective]
$creadListPrec :: ReadPrec [OptimizationObjective]
readPrec :: ReadPrec OptimizationObjective
$creadPrec :: ReadPrec OptimizationObjective
readList :: ReadS [OptimizationObjective]
$creadList :: ReadS [OptimizationObjective]
readsPrec :: Int -> ReadS OptimizationObjective
$creadsPrec :: Int -> ReadS OptimizationObjective
Prelude.Read, Int -> OptimizationObjective -> ShowS
[OptimizationObjective] -> ShowS
OptimizationObjective -> String
(Int -> OptimizationObjective -> ShowS)
-> (OptimizationObjective -> String)
-> ([OptimizationObjective] -> ShowS)
-> Show OptimizationObjective
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptimizationObjective] -> ShowS
$cshowList :: [OptimizationObjective] -> ShowS
show :: OptimizationObjective -> String
$cshow :: OptimizationObjective -> String
showsPrec :: Int -> OptimizationObjective -> ShowS
$cshowsPrec :: Int -> OptimizationObjective -> ShowS
Prelude.Show, (forall x. OptimizationObjective -> Rep OptimizationObjective x)
-> (forall x. Rep OptimizationObjective x -> OptimizationObjective)
-> Generic OptimizationObjective
forall x. Rep OptimizationObjective x -> OptimizationObjective
forall x. OptimizationObjective -> Rep OptimizationObjective x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptimizationObjective x -> OptimizationObjective
$cfrom :: forall x. OptimizationObjective -> Rep OptimizationObjective x
Prelude.Generic)

-- |
-- Create a value of 'OptimizationObjective' 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:
--
-- 'itemAttribute', 'optimizationObjective_itemAttribute' - The numerical metadata column in an Items dataset related to the
-- optimization objective. For example, VIDEO_LENGTH (to maximize streaming
-- minutes), or PRICE (to maximize revenue).
--
-- 'objectiveSensitivity', 'optimizationObjective_objectiveSensitivity' - Specifies how Amazon Personalize balances the importance of your
-- optimization objective versus relevance.
newOptimizationObjective ::
  OptimizationObjective
newOptimizationObjective :: OptimizationObjective
newOptimizationObjective =
  OptimizationObjective' :: Maybe Text -> Maybe ObjectiveSensitivity -> OptimizationObjective
OptimizationObjective'
    { $sel:itemAttribute:OptimizationObjective' :: Maybe Text
itemAttribute =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:objectiveSensitivity:OptimizationObjective' :: Maybe ObjectiveSensitivity
objectiveSensitivity = Maybe ObjectiveSensitivity
forall a. Maybe a
Prelude.Nothing
    }

-- | The numerical metadata column in an Items dataset related to the
-- optimization objective. For example, VIDEO_LENGTH (to maximize streaming
-- minutes), or PRICE (to maximize revenue).
optimizationObjective_itemAttribute :: Lens.Lens' OptimizationObjective (Prelude.Maybe Prelude.Text)
optimizationObjective_itemAttribute :: (Maybe Text -> f (Maybe Text))
-> OptimizationObjective -> f OptimizationObjective
optimizationObjective_itemAttribute = (OptimizationObjective -> Maybe Text)
-> (OptimizationObjective -> Maybe Text -> OptimizationObjective)
-> Lens
     OptimizationObjective
     OptimizationObjective
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptimizationObjective' {Maybe Text
itemAttribute :: Maybe Text
$sel:itemAttribute:OptimizationObjective' :: OptimizationObjective -> Maybe Text
itemAttribute} -> Maybe Text
itemAttribute) (\s :: OptimizationObjective
s@OptimizationObjective' {} Maybe Text
a -> OptimizationObjective
s {$sel:itemAttribute:OptimizationObjective' :: Maybe Text
itemAttribute = Maybe Text
a} :: OptimizationObjective)

-- | Specifies how Amazon Personalize balances the importance of your
-- optimization objective versus relevance.
optimizationObjective_objectiveSensitivity :: Lens.Lens' OptimizationObjective (Prelude.Maybe ObjectiveSensitivity)
optimizationObjective_objectiveSensitivity :: (Maybe ObjectiveSensitivity -> f (Maybe ObjectiveSensitivity))
-> OptimizationObjective -> f OptimizationObjective
optimizationObjective_objectiveSensitivity = (OptimizationObjective -> Maybe ObjectiveSensitivity)
-> (OptimizationObjective
    -> Maybe ObjectiveSensitivity -> OptimizationObjective)
-> Lens
     OptimizationObjective
     OptimizationObjective
     (Maybe ObjectiveSensitivity)
     (Maybe ObjectiveSensitivity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptimizationObjective' {Maybe ObjectiveSensitivity
objectiveSensitivity :: Maybe ObjectiveSensitivity
$sel:objectiveSensitivity:OptimizationObjective' :: OptimizationObjective -> Maybe ObjectiveSensitivity
objectiveSensitivity} -> Maybe ObjectiveSensitivity
objectiveSensitivity) (\s :: OptimizationObjective
s@OptimizationObjective' {} Maybe ObjectiveSensitivity
a -> OptimizationObjective
s {$sel:objectiveSensitivity:OptimizationObjective' :: Maybe ObjectiveSensitivity
objectiveSensitivity = Maybe ObjectiveSensitivity
a} :: OptimizationObjective)

instance Core.FromJSON OptimizationObjective where
  parseJSON :: Value -> Parser OptimizationObjective
parseJSON =
    String
-> (Object -> Parser OptimizationObjective)
-> Value
-> Parser OptimizationObjective
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OptimizationObjective"
      ( \Object
x ->
          Maybe Text -> Maybe ObjectiveSensitivity -> OptimizationObjective
OptimizationObjective'
            (Maybe Text -> Maybe ObjectiveSensitivity -> OptimizationObjective)
-> Parser (Maybe Text)
-> Parser (Maybe ObjectiveSensitivity -> OptimizationObjective)
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
"itemAttribute")
            Parser (Maybe ObjectiveSensitivity -> OptimizationObjective)
-> Parser (Maybe ObjectiveSensitivity)
-> Parser OptimizationObjective
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ObjectiveSensitivity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"objectiveSensitivity")
      )

instance Prelude.Hashable OptimizationObjective

instance Prelude.NFData OptimizationObjective

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