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

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

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

-- |
-- Create a value of 'CategoricalParameterRangeSpecification' 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:
--
-- 'values', 'categoricalParameterRangeSpecification_values' - The allowed categories for the hyperparameter.
newCategoricalParameterRangeSpecification ::
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  CategoricalParameterRangeSpecification
newCategoricalParameterRangeSpecification :: NonEmpty Text -> CategoricalParameterRangeSpecification
newCategoricalParameterRangeSpecification NonEmpty Text
pValues_ =
  CategoricalParameterRangeSpecification' :: NonEmpty Text -> CategoricalParameterRangeSpecification
CategoricalParameterRangeSpecification'
    { $sel:values:CategoricalParameterRangeSpecification' :: 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 allowed categories for the hyperparameter.
categoricalParameterRangeSpecification_values :: Lens.Lens' CategoricalParameterRangeSpecification (Prelude.NonEmpty Prelude.Text)
categoricalParameterRangeSpecification_values :: (NonEmpty Text -> f (NonEmpty Text))
-> CategoricalParameterRangeSpecification
-> f CategoricalParameterRangeSpecification
categoricalParameterRangeSpecification_values = (CategoricalParameterRangeSpecification -> NonEmpty Text)
-> (CategoricalParameterRangeSpecification
    -> NonEmpty Text -> CategoricalParameterRangeSpecification)
-> Lens
     CategoricalParameterRangeSpecification
     CategoricalParameterRangeSpecification
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CategoricalParameterRangeSpecification' {NonEmpty Text
values :: NonEmpty Text
$sel:values:CategoricalParameterRangeSpecification' :: CategoricalParameterRangeSpecification -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: CategoricalParameterRangeSpecification
s@CategoricalParameterRangeSpecification' {} NonEmpty Text
a -> CategoricalParameterRangeSpecification
s {$sel:values:CategoricalParameterRangeSpecification' :: NonEmpty Text
values = NonEmpty Text
a} :: CategoricalParameterRangeSpecification) ((NonEmpty Text -> f (NonEmpty Text))
 -> CategoricalParameterRangeSpecification
 -> f CategoricalParameterRangeSpecification)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> CategoricalParameterRangeSpecification
-> f CategoricalParameterRangeSpecification
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
    CategoricalParameterRangeSpecification
  where
  parseJSON :: Value -> Parser CategoricalParameterRangeSpecification
parseJSON =
    String
-> (Object -> Parser CategoricalParameterRangeSpecification)
-> Value
-> Parser CategoricalParameterRangeSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CategoricalParameterRangeSpecification"
      ( \Object
x ->
          NonEmpty Text -> CategoricalParameterRangeSpecification
CategoricalParameterRangeSpecification'
            (NonEmpty Text -> CategoricalParameterRangeSpecification)
-> Parser (NonEmpty Text)
-> Parser CategoricalParameterRangeSpecification
forall (f :: * -> *) a b. Functor 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
    CategoricalParameterRangeSpecification

instance
  Prelude.NFData
    CategoricalParameterRangeSpecification

instance
  Core.ToJSON
    CategoricalParameterRangeSpecification
  where
  toJSON :: CategoricalParameterRangeSpecification -> Value
toJSON CategoricalParameterRangeSpecification' {NonEmpty Text
values :: NonEmpty Text
$sel:values:CategoricalParameterRangeSpecification' :: CategoricalParameterRangeSpecification -> NonEmpty 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
"Values" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
values)]
      )