{-# 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.CategoricalParameter
-- 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.CategoricalParameter 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

-- | Environment parameters you want to benchmark your load test against.
--
-- /See:/ 'newCategoricalParameter' smart constructor.
data CategoricalParameter = CategoricalParameter'
  { -- | The Name of the environment variable.
    CategoricalParameter -> Text
name :: Prelude.Text,
    -- | The list of values you can pass.
    CategoricalParameter -> NonEmpty Text
value :: Prelude.NonEmpty Prelude.Text
  }
  deriving (CategoricalParameter -> CategoricalParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CategoricalParameter -> CategoricalParameter -> Bool
$c/= :: CategoricalParameter -> CategoricalParameter -> Bool
== :: CategoricalParameter -> CategoricalParameter -> Bool
$c== :: CategoricalParameter -> CategoricalParameter -> Bool
Prelude.Eq, ReadPrec [CategoricalParameter]
ReadPrec CategoricalParameter
Int -> ReadS CategoricalParameter
ReadS [CategoricalParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CategoricalParameter]
$creadListPrec :: ReadPrec [CategoricalParameter]
readPrec :: ReadPrec CategoricalParameter
$creadPrec :: ReadPrec CategoricalParameter
readList :: ReadS [CategoricalParameter]
$creadList :: ReadS [CategoricalParameter]
readsPrec :: Int -> ReadS CategoricalParameter
$creadsPrec :: Int -> ReadS CategoricalParameter
Prelude.Read, Int -> CategoricalParameter -> ShowS
[CategoricalParameter] -> ShowS
CategoricalParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CategoricalParameter] -> ShowS
$cshowList :: [CategoricalParameter] -> ShowS
show :: CategoricalParameter -> String
$cshow :: CategoricalParameter -> String
showsPrec :: Int -> CategoricalParameter -> ShowS
$cshowsPrec :: Int -> CategoricalParameter -> ShowS
Prelude.Show, forall x. Rep CategoricalParameter x -> CategoricalParameter
forall x. CategoricalParameter -> Rep CategoricalParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CategoricalParameter x -> CategoricalParameter
$cfrom :: forall x. CategoricalParameter -> Rep CategoricalParameter x
Prelude.Generic)

-- |
-- Create a value of 'CategoricalParameter' 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', 'categoricalParameter_name' - The Name of the environment variable.
--
-- 'value', 'categoricalParameter_value' - The list of values you can pass.
newCategoricalParameter ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.NonEmpty Prelude.Text ->
  CategoricalParameter
newCategoricalParameter :: Text -> NonEmpty Text -> CategoricalParameter
newCategoricalParameter Text
pName_ NonEmpty Text
pValue_ =
  CategoricalParameter'
    { $sel:name:CategoricalParameter' :: Text
name = Text
pName_,
      $sel:value:CategoricalParameter' :: NonEmpty Text
value = 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
pValue_
    }

-- | The Name of the environment variable.
categoricalParameter_name :: Lens.Lens' CategoricalParameter Prelude.Text
categoricalParameter_name :: Lens' CategoricalParameter Text
categoricalParameter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CategoricalParameter' {Text
name :: Text
$sel:name:CategoricalParameter' :: CategoricalParameter -> Text
name} -> Text
name) (\s :: CategoricalParameter
s@CategoricalParameter' {} Text
a -> CategoricalParameter
s {$sel:name:CategoricalParameter' :: Text
name = Text
a} :: CategoricalParameter)

-- | The list of values you can pass.
categoricalParameter_value :: Lens.Lens' CategoricalParameter (Prelude.NonEmpty Prelude.Text)
categoricalParameter_value :: Lens' CategoricalParameter (NonEmpty Text)
categoricalParameter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CategoricalParameter' {NonEmpty Text
value :: NonEmpty Text
$sel:value:CategoricalParameter' :: CategoricalParameter -> NonEmpty Text
value} -> NonEmpty Text
value) (\s :: CategoricalParameter
s@CategoricalParameter' {} NonEmpty Text
a -> CategoricalParameter
s {$sel:value:CategoricalParameter' :: NonEmpty Text
value = NonEmpty Text
a} :: CategoricalParameter) 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 CategoricalParameter where
  parseJSON :: Value -> Parser CategoricalParameter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CategoricalParameter"
      ( \Object
x ->
          Text -> NonEmpty Text -> CategoricalParameter
CategoricalParameter'
            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
"Value")
      )

instance Prelude.Hashable CategoricalParameter where
  hashWithSalt :: Int -> CategoricalParameter -> Int
hashWithSalt Int
_salt CategoricalParameter' {NonEmpty Text
Text
value :: NonEmpty Text
name :: Text
$sel:value:CategoricalParameter' :: CategoricalParameter -> NonEmpty Text
$sel:name:CategoricalParameter' :: CategoricalParameter -> 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
value

instance Prelude.NFData CategoricalParameter where
  rnf :: CategoricalParameter -> ()
rnf CategoricalParameter' {NonEmpty Text
Text
value :: NonEmpty Text
name :: Text
$sel:value:CategoricalParameter' :: CategoricalParameter -> NonEmpty Text
$sel:name:CategoricalParameter' :: CategoricalParameter -> 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
value

instance Data.ToJSON CategoricalParameter where
  toJSON :: CategoricalParameter -> Value
toJSON CategoricalParameter' {NonEmpty Text
Text
value :: NonEmpty Text
name :: Text
$sel:value:CategoricalParameter' :: CategoricalParameter -> NonEmpty Text
$sel:name:CategoricalParameter' :: CategoricalParameter -> 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
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
value)
          ]
      )