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

-- | Configuration information for the Amazon SageMaker Debugger output
-- tensor collections.
--
-- /See:/ 'newCollectionConfiguration' smart constructor.
data CollectionConfiguration = CollectionConfiguration'
  { -- | The name of the tensor collection. The name must be unique relative to
    -- other rule configuration names.
    CollectionConfiguration -> Maybe Text
collectionName :: Prelude.Maybe Prelude.Text,
    -- | Parameter values for the tensor collection. The allowed parameters are
    -- @\"name\"@, @\"include_regex\"@, @\"reduction_config\"@,
    -- @\"save_config\"@, @\"tensor_names\"@, and @\"save_histogram\"@.
    CollectionConfiguration -> Maybe (HashMap Text Text)
collectionParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (CollectionConfiguration -> CollectionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CollectionConfiguration -> CollectionConfiguration -> Bool
$c/= :: CollectionConfiguration -> CollectionConfiguration -> Bool
== :: CollectionConfiguration -> CollectionConfiguration -> Bool
$c== :: CollectionConfiguration -> CollectionConfiguration -> Bool
Prelude.Eq, ReadPrec [CollectionConfiguration]
ReadPrec CollectionConfiguration
Int -> ReadS CollectionConfiguration
ReadS [CollectionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CollectionConfiguration]
$creadListPrec :: ReadPrec [CollectionConfiguration]
readPrec :: ReadPrec CollectionConfiguration
$creadPrec :: ReadPrec CollectionConfiguration
readList :: ReadS [CollectionConfiguration]
$creadList :: ReadS [CollectionConfiguration]
readsPrec :: Int -> ReadS CollectionConfiguration
$creadsPrec :: Int -> ReadS CollectionConfiguration
Prelude.Read, Int -> CollectionConfiguration -> ShowS
[CollectionConfiguration] -> ShowS
CollectionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CollectionConfiguration] -> ShowS
$cshowList :: [CollectionConfiguration] -> ShowS
show :: CollectionConfiguration -> String
$cshow :: CollectionConfiguration -> String
showsPrec :: Int -> CollectionConfiguration -> ShowS
$cshowsPrec :: Int -> CollectionConfiguration -> ShowS
Prelude.Show, forall x. Rep CollectionConfiguration x -> CollectionConfiguration
forall x. CollectionConfiguration -> Rep CollectionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CollectionConfiguration x -> CollectionConfiguration
$cfrom :: forall x. CollectionConfiguration -> Rep CollectionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CollectionConfiguration' 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:
--
-- 'collectionName', 'collectionConfiguration_collectionName' - The name of the tensor collection. The name must be unique relative to
-- other rule configuration names.
--
-- 'collectionParameters', 'collectionConfiguration_collectionParameters' - Parameter values for the tensor collection. The allowed parameters are
-- @\"name\"@, @\"include_regex\"@, @\"reduction_config\"@,
-- @\"save_config\"@, @\"tensor_names\"@, and @\"save_histogram\"@.
newCollectionConfiguration ::
  CollectionConfiguration
newCollectionConfiguration :: CollectionConfiguration
newCollectionConfiguration =
  CollectionConfiguration'
    { $sel:collectionName:CollectionConfiguration' :: Maybe Text
collectionName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:collectionParameters:CollectionConfiguration' :: Maybe (HashMap Text Text)
collectionParameters = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the tensor collection. The name must be unique relative to
-- other rule configuration names.
collectionConfiguration_collectionName :: Lens.Lens' CollectionConfiguration (Prelude.Maybe Prelude.Text)
collectionConfiguration_collectionName :: Lens' CollectionConfiguration (Maybe Text)
collectionConfiguration_collectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CollectionConfiguration' {Maybe Text
collectionName :: Maybe Text
$sel:collectionName:CollectionConfiguration' :: CollectionConfiguration -> Maybe Text
collectionName} -> Maybe Text
collectionName) (\s :: CollectionConfiguration
s@CollectionConfiguration' {} Maybe Text
a -> CollectionConfiguration
s {$sel:collectionName:CollectionConfiguration' :: Maybe Text
collectionName = Maybe Text
a} :: CollectionConfiguration)

-- | Parameter values for the tensor collection. The allowed parameters are
-- @\"name\"@, @\"include_regex\"@, @\"reduction_config\"@,
-- @\"save_config\"@, @\"tensor_names\"@, and @\"save_histogram\"@.
collectionConfiguration_collectionParameters :: Lens.Lens' CollectionConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
collectionConfiguration_collectionParameters :: Lens' CollectionConfiguration (Maybe (HashMap Text Text))
collectionConfiguration_collectionParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CollectionConfiguration' {Maybe (HashMap Text Text)
collectionParameters :: Maybe (HashMap Text Text)
$sel:collectionParameters:CollectionConfiguration' :: CollectionConfiguration -> Maybe (HashMap Text Text)
collectionParameters} -> Maybe (HashMap Text Text)
collectionParameters) (\s :: CollectionConfiguration
s@CollectionConfiguration' {} Maybe (HashMap Text Text)
a -> CollectionConfiguration
s {$sel:collectionParameters:CollectionConfiguration' :: Maybe (HashMap Text Text)
collectionParameters = Maybe (HashMap Text Text)
a} :: CollectionConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON CollectionConfiguration where
  parseJSON :: Value -> Parser CollectionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CollectionConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe (HashMap Text Text) -> CollectionConfiguration
CollectionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CollectionName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CollectionParameters"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable CollectionConfiguration where
  hashWithSalt :: Int -> CollectionConfiguration -> Int
hashWithSalt Int
_salt CollectionConfiguration' {Maybe Text
Maybe (HashMap Text Text)
collectionParameters :: Maybe (HashMap Text Text)
collectionName :: Maybe Text
$sel:collectionParameters:CollectionConfiguration' :: CollectionConfiguration -> Maybe (HashMap Text Text)
$sel:collectionName:CollectionConfiguration' :: CollectionConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
collectionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
collectionParameters

instance Prelude.NFData CollectionConfiguration where
  rnf :: CollectionConfiguration -> ()
rnf CollectionConfiguration' {Maybe Text
Maybe (HashMap Text Text)
collectionParameters :: Maybe (HashMap Text Text)
collectionName :: Maybe Text
$sel:collectionParameters:CollectionConfiguration' :: CollectionConfiguration -> Maybe (HashMap Text Text)
$sel:collectionName:CollectionConfiguration' :: CollectionConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
collectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
collectionParameters

instance Data.ToJSON CollectionConfiguration where
  toJSON :: CollectionConfiguration -> Value
toJSON CollectionConfiguration' {Maybe Text
Maybe (HashMap Text Text)
collectionParameters :: Maybe (HashMap Text Text)
collectionName :: Maybe Text
$sel:collectionParameters:CollectionConfiguration' :: CollectionConfiguration -> Maybe (HashMap Text Text)
$sel:collectionName:CollectionConfiguration' :: CollectionConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CollectionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
collectionName,
            (Key
"CollectionParameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
collectionParameters
          ]
      )