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

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

-- | Configuration information for the Debugger output tensor collections.
--
-- /See:/ 'newCollectionConfiguration' smart constructor.
data CollectionConfiguration = CollectionConfiguration'
  { -- | 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),
    -- | 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
  }
  deriving (CollectionConfiguration -> CollectionConfiguration -> Bool
(CollectionConfiguration -> CollectionConfiguration -> Bool)
-> (CollectionConfiguration -> CollectionConfiguration -> Bool)
-> Eq CollectionConfiguration
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]
(Int -> ReadS CollectionConfiguration)
-> ReadS [CollectionConfiguration]
-> ReadPrec CollectionConfiguration
-> ReadPrec [CollectionConfiguration]
-> Read 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
(Int -> CollectionConfiguration -> ShowS)
-> (CollectionConfiguration -> String)
-> ([CollectionConfiguration] -> ShowS)
-> Show CollectionConfiguration
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.
 CollectionConfiguration -> Rep CollectionConfiguration x)
-> (forall x.
    Rep CollectionConfiguration x -> CollectionConfiguration)
-> Generic CollectionConfiguration
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:
--
-- '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\"@.
--
-- 'collectionName', 'collectionConfiguration_collectionName' - The name of the tensor collection. The name must be unique relative to
-- other rule configuration names.
newCollectionConfiguration ::
  CollectionConfiguration
newCollectionConfiguration :: CollectionConfiguration
newCollectionConfiguration =
  CollectionConfiguration' :: Maybe (HashMap Text Text) -> Maybe Text -> CollectionConfiguration
CollectionConfiguration'
    { $sel:collectionParameters:CollectionConfiguration' :: Maybe (HashMap Text Text)
collectionParameters =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:collectionName:CollectionConfiguration' :: Maybe Text
collectionName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CollectionConfiguration -> f CollectionConfiguration
collectionConfiguration_collectionParameters = (CollectionConfiguration -> Maybe (HashMap Text Text))
-> (CollectionConfiguration
    -> Maybe (HashMap Text Text) -> CollectionConfiguration)
-> Lens
     CollectionConfiguration
     CollectionConfiguration
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CollectionConfiguration -> f CollectionConfiguration)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CollectionConfiguration
-> f CollectionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> CollectionConfiguration -> f CollectionConfiguration
collectionConfiguration_collectionName = (CollectionConfiguration -> Maybe Text)
-> (CollectionConfiguration
    -> Maybe Text -> CollectionConfiguration)
-> Lens
     CollectionConfiguration
     CollectionConfiguration
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable CollectionConfiguration

instance Prelude.NFData CollectionConfiguration

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