{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.CategoricalParameterRange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:name:CategoricalParameterRange' :: Text
name = Text
pName_,
      $sel:values:CategoricalParameterRange' :: NonEmpty Text
values = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 :: Lens' CategoricalParameterRange Text
categoricalParameterRange_name = 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 :: Lens' CategoricalParameterRange (NonEmpty Text)
categoricalParameterRange_values = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable CategoricalParameterRange where
  hashWithSalt :: Int -> CategoricalParameterRange -> Int
hashWithSalt Int
_salt CategoricalParameterRange' {NonEmpty Text
Text
values :: NonEmpty Text
name :: Text
$sel:values:CategoricalParameterRange' :: CategoricalParameterRange -> NonEmpty Text
$sel:name:CategoricalParameterRange' :: CategoricalParameterRange -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
values

instance Prelude.NFData CategoricalParameterRange where
  rnf :: CategoricalParameterRange -> ()
rnf CategoricalParameterRange' {NonEmpty Text
Text
values :: NonEmpty Text
name :: Text
$sel:values:CategoricalParameterRange' :: CategoricalParameterRange -> NonEmpty Text
$sel:name:CategoricalParameterRange' :: CategoricalParameterRange -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
values

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
values)
          ]
      )