{-# 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.SageMaker.Types.CategoricalParameterRange
-- 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.SageMaker.Types.CategoricalParameterRange where

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

-- | A list of categorical hyperparameters to tune.
--
-- /See:/ 'newCategoricalParameterRange' smart constructor.
data CategoricalParameterRange = CategoricalParameterRange'
  { -- | The name of the categorical hyperparameter to tune.
    CategoricalParameterRange -> Text
name :: Prelude.Text,
    -- | A list of the categories for the hyperparameter.
    CategoricalParameterRange -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text
  }
  deriving (CategoricalParameterRange -> CategoricalParameterRange -> Bool
(CategoricalParameterRange -> CategoricalParameterRange -> Bool)
-> (CategoricalParameterRange -> CategoricalParameterRange -> Bool)
-> Eq CategoricalParameterRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CategoricalParameterRange -> CategoricalParameterRange -> Bool
$c/= :: CategoricalParameterRange -> CategoricalParameterRange -> Bool
== :: CategoricalParameterRange -> CategoricalParameterRange -> Bool
$c== :: CategoricalParameterRange -> CategoricalParameterRange -> Bool
Prelude.Eq, ReadPrec [CategoricalParameterRange]
ReadPrec CategoricalParameterRange
Int -> ReadS CategoricalParameterRange
ReadS [CategoricalParameterRange]
(Int -> ReadS CategoricalParameterRange)
-> ReadS [CategoricalParameterRange]
-> ReadPrec CategoricalParameterRange
-> ReadPrec [CategoricalParameterRange]
-> Read CategoricalParameterRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CategoricalParameterRange]
$creadListPrec :: ReadPrec [CategoricalParameterRange]
readPrec :: ReadPrec CategoricalParameterRange
$creadPrec :: ReadPrec CategoricalParameterRange
readList :: ReadS [CategoricalParameterRange]
$creadList :: ReadS [CategoricalParameterRange]
readsPrec :: Int -> ReadS CategoricalParameterRange
$creadsPrec :: Int -> ReadS CategoricalParameterRange
Prelude.Read, Int -> CategoricalParameterRange -> ShowS
[CategoricalParameterRange] -> ShowS
CategoricalParameterRange -> String
(Int -> CategoricalParameterRange -> ShowS)
-> (CategoricalParameterRange -> String)
-> ([CategoricalParameterRange] -> ShowS)
-> Show CategoricalParameterRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CategoricalParameterRange] -> ShowS
$cshowList :: [CategoricalParameterRange] -> ShowS
show :: CategoricalParameterRange -> String
$cshow :: CategoricalParameterRange -> String
showsPrec :: Int -> CategoricalParameterRange -> ShowS
$cshowsPrec :: Int -> CategoricalParameterRange -> ShowS
Prelude.Show, (forall x.
 CategoricalParameterRange -> Rep CategoricalParameterRange x)
-> (forall x.
    Rep CategoricalParameterRange x -> CategoricalParameterRange)
-> Generic CategoricalParameterRange
forall x.
Rep CategoricalParameterRange x -> CategoricalParameterRange
forall x.
CategoricalParameterRange -> Rep CategoricalParameterRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CategoricalParameterRange x -> CategoricalParameterRange
$cfrom :: forall x.
CategoricalParameterRange -> Rep CategoricalParameterRange x
Prelude.Generic)

-- |
-- Create a value of 'CategoricalParameterRange' 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:
--
-- 'name', 'categoricalParameterRange_name' - The name of the categorical hyperparameter to tune.
--
-- 'values', 'categoricalParameterRange_values' - A list of the categories for the hyperparameter.
newCategoricalParameterRange ::
  -- | 'name'
  Prelude.Text ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  CategoricalParameterRange
newCategoricalParameterRange :: Text -> NonEmpty Text -> CategoricalParameterRange
newCategoricalParameterRange Text
pName_ NonEmpty Text
pValues_ =
  CategoricalParameterRange' :: Text -> NonEmpty Text -> CategoricalParameterRange
CategoricalParameterRange'
    { $sel:name:CategoricalParameterRange' :: Text
name = Text
pName_,
      $sel:values:CategoricalParameterRange' :: NonEmpty Text
values = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pValues_
    }

-- | The name of the categorical hyperparameter to tune.
categoricalParameterRange_name :: Lens.Lens' CategoricalParameterRange Prelude.Text
categoricalParameterRange_name :: (Text -> f Text)
-> CategoricalParameterRange -> f CategoricalParameterRange
categoricalParameterRange_name = (CategoricalParameterRange -> Text)
-> (CategoricalParameterRange -> Text -> CategoricalParameterRange)
-> Lens
     CategoricalParameterRange CategoricalParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CategoricalParameterRange' {Text
name :: Text
$sel:name:CategoricalParameterRange' :: CategoricalParameterRange -> Text
name} -> Text
name) (\s :: CategoricalParameterRange
s@CategoricalParameterRange' {} Text
a -> CategoricalParameterRange
s {$sel:name:CategoricalParameterRange' :: Text
name = Text
a} :: CategoricalParameterRange)

-- | A list of the categories for the hyperparameter.
categoricalParameterRange_values :: Lens.Lens' CategoricalParameterRange (Prelude.NonEmpty Prelude.Text)
categoricalParameterRange_values :: (NonEmpty Text -> f (NonEmpty Text))
-> CategoricalParameterRange -> f CategoricalParameterRange
categoricalParameterRange_values = (CategoricalParameterRange -> NonEmpty Text)
-> (CategoricalParameterRange
    -> NonEmpty Text -> CategoricalParameterRange)
-> Lens
     CategoricalParameterRange
     CategoricalParameterRange
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CategoricalParameterRange' {NonEmpty Text
values :: NonEmpty Text
$sel:values:CategoricalParameterRange' :: CategoricalParameterRange -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: CategoricalParameterRange
s@CategoricalParameterRange' {} NonEmpty Text
a -> CategoricalParameterRange
s {$sel:values:CategoricalParameterRange' :: NonEmpty Text
values = NonEmpty Text
a} :: CategoricalParameterRange) ((NonEmpty Text -> f (NonEmpty Text))
 -> CategoricalParameterRange -> f CategoricalParameterRange)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> CategoricalParameterRange
-> f CategoricalParameterRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON CategoricalParameterRange where
  parseJSON :: Value -> Parser CategoricalParameterRange
parseJSON =
    String
-> (Object -> Parser CategoricalParameterRange)
-> Value
-> Parser CategoricalParameterRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CategoricalParameterRange"
      ( \Object
x ->
          Text -> NonEmpty Text -> CategoricalParameterRange
CategoricalParameterRange'
            (Text -> NonEmpty Text -> CategoricalParameterRange)
-> Parser Text
-> Parser (NonEmpty Text -> CategoricalParameterRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name") Parser (NonEmpty Text -> CategoricalParameterRange)
-> Parser (NonEmpty Text) -> Parser CategoricalParameterRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Values")
      )

instance Prelude.Hashable CategoricalParameterRange

instance Prelude.NFData CategoricalParameterRange

instance Core.ToJSON CategoricalParameterRange where
  toJSON :: CategoricalParameterRange -> Value
toJSON CategoricalParameterRange' {NonEmpty Text
Text
values :: NonEmpty Text
name :: Text
$sel:values:CategoricalParameterRange' :: CategoricalParameterRange -> NonEmpty Text
$sel:name:CategoricalParameterRange' :: CategoricalParameterRange -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
values)
          ]
      )