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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.FeatureType

-- | A list of features. You must include @FeatureName@ and @FeatureType@.
-- Valid feature @FeatureType@s are @Integral@, @Fractional@ and @String@.
--
-- /See:/ 'newFeatureDefinition' smart constructor.
data FeatureDefinition = FeatureDefinition'
  { -- | The value type of a feature. Valid values are Integral, Fractional, or
    -- String.
    FeatureDefinition -> Maybe FeatureType
featureType :: Prelude.Maybe FeatureType,
    -- | The name of a feature. The type must be a string. @FeatureName@ cannot
    -- be any of the following: @is_deleted@, @write_time@,
    -- @api_invocation_time@.
    FeatureDefinition -> Maybe Text
featureName :: Prelude.Maybe Prelude.Text
  }
  deriving (FeatureDefinition -> FeatureDefinition -> Bool
(FeatureDefinition -> FeatureDefinition -> Bool)
-> (FeatureDefinition -> FeatureDefinition -> Bool)
-> Eq FeatureDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FeatureDefinition -> FeatureDefinition -> Bool
$c/= :: FeatureDefinition -> FeatureDefinition -> Bool
== :: FeatureDefinition -> FeatureDefinition -> Bool
$c== :: FeatureDefinition -> FeatureDefinition -> Bool
Prelude.Eq, ReadPrec [FeatureDefinition]
ReadPrec FeatureDefinition
Int -> ReadS FeatureDefinition
ReadS [FeatureDefinition]
(Int -> ReadS FeatureDefinition)
-> ReadS [FeatureDefinition]
-> ReadPrec FeatureDefinition
-> ReadPrec [FeatureDefinition]
-> Read FeatureDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FeatureDefinition]
$creadListPrec :: ReadPrec [FeatureDefinition]
readPrec :: ReadPrec FeatureDefinition
$creadPrec :: ReadPrec FeatureDefinition
readList :: ReadS [FeatureDefinition]
$creadList :: ReadS [FeatureDefinition]
readsPrec :: Int -> ReadS FeatureDefinition
$creadsPrec :: Int -> ReadS FeatureDefinition
Prelude.Read, Int -> FeatureDefinition -> ShowS
[FeatureDefinition] -> ShowS
FeatureDefinition -> String
(Int -> FeatureDefinition -> ShowS)
-> (FeatureDefinition -> String)
-> ([FeatureDefinition] -> ShowS)
-> Show FeatureDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FeatureDefinition] -> ShowS
$cshowList :: [FeatureDefinition] -> ShowS
show :: FeatureDefinition -> String
$cshow :: FeatureDefinition -> String
showsPrec :: Int -> FeatureDefinition -> ShowS
$cshowsPrec :: Int -> FeatureDefinition -> ShowS
Prelude.Show, (forall x. FeatureDefinition -> Rep FeatureDefinition x)
-> (forall x. Rep FeatureDefinition x -> FeatureDefinition)
-> Generic FeatureDefinition
forall x. Rep FeatureDefinition x -> FeatureDefinition
forall x. FeatureDefinition -> Rep FeatureDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FeatureDefinition x -> FeatureDefinition
$cfrom :: forall x. FeatureDefinition -> Rep FeatureDefinition x
Prelude.Generic)

-- |
-- Create a value of 'FeatureDefinition' 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:
--
-- 'featureType', 'featureDefinition_featureType' - The value type of a feature. Valid values are Integral, Fractional, or
-- String.
--
-- 'featureName', 'featureDefinition_featureName' - The name of a feature. The type must be a string. @FeatureName@ cannot
-- be any of the following: @is_deleted@, @write_time@,
-- @api_invocation_time@.
newFeatureDefinition ::
  FeatureDefinition
newFeatureDefinition :: FeatureDefinition
newFeatureDefinition =
  FeatureDefinition' :: Maybe FeatureType -> Maybe Text -> FeatureDefinition
FeatureDefinition'
    { $sel:featureType:FeatureDefinition' :: Maybe FeatureType
featureType = Maybe FeatureType
forall a. Maybe a
Prelude.Nothing,
      $sel:featureName:FeatureDefinition' :: Maybe Text
featureName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value type of a feature. Valid values are Integral, Fractional, or
-- String.
featureDefinition_featureType :: Lens.Lens' FeatureDefinition (Prelude.Maybe FeatureType)
featureDefinition_featureType :: (Maybe FeatureType -> f (Maybe FeatureType))
-> FeatureDefinition -> f FeatureDefinition
featureDefinition_featureType = (FeatureDefinition -> Maybe FeatureType)
-> (FeatureDefinition -> Maybe FeatureType -> FeatureDefinition)
-> Lens
     FeatureDefinition
     FeatureDefinition
     (Maybe FeatureType)
     (Maybe FeatureType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FeatureDefinition' {Maybe FeatureType
featureType :: Maybe FeatureType
$sel:featureType:FeatureDefinition' :: FeatureDefinition -> Maybe FeatureType
featureType} -> Maybe FeatureType
featureType) (\s :: FeatureDefinition
s@FeatureDefinition' {} Maybe FeatureType
a -> FeatureDefinition
s {$sel:featureType:FeatureDefinition' :: Maybe FeatureType
featureType = Maybe FeatureType
a} :: FeatureDefinition)

-- | The name of a feature. The type must be a string. @FeatureName@ cannot
-- be any of the following: @is_deleted@, @write_time@,
-- @api_invocation_time@.
featureDefinition_featureName :: Lens.Lens' FeatureDefinition (Prelude.Maybe Prelude.Text)
featureDefinition_featureName :: (Maybe Text -> f (Maybe Text))
-> FeatureDefinition -> f FeatureDefinition
featureDefinition_featureName = (FeatureDefinition -> Maybe Text)
-> (FeatureDefinition -> Maybe Text -> FeatureDefinition)
-> Lens
     FeatureDefinition FeatureDefinition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FeatureDefinition' {Maybe Text
featureName :: Maybe Text
$sel:featureName:FeatureDefinition' :: FeatureDefinition -> Maybe Text
featureName} -> Maybe Text
featureName) (\s :: FeatureDefinition
s@FeatureDefinition' {} Maybe Text
a -> FeatureDefinition
s {$sel:featureName:FeatureDefinition' :: Maybe Text
featureName = Maybe Text
a} :: FeatureDefinition)

instance Core.FromJSON FeatureDefinition where
  parseJSON :: Value -> Parser FeatureDefinition
parseJSON =
    String
-> (Object -> Parser FeatureDefinition)
-> Value
-> Parser FeatureDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FeatureDefinition"
      ( \Object
x ->
          Maybe FeatureType -> Maybe Text -> FeatureDefinition
FeatureDefinition'
            (Maybe FeatureType -> Maybe Text -> FeatureDefinition)
-> Parser (Maybe FeatureType)
-> Parser (Maybe Text -> FeatureDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FeatureType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FeatureType")
            Parser (Maybe Text -> FeatureDefinition)
-> Parser (Maybe Text) -> Parser FeatureDefinition
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
"FeatureName")
      )

instance Prelude.Hashable FeatureDefinition

instance Prelude.NFData FeatureDefinition

instance Core.ToJSON FeatureDefinition where
  toJSON :: FeatureDefinition -> Value
toJSON FeatureDefinition' {Maybe Text
Maybe FeatureType
featureName :: Maybe Text
featureType :: Maybe FeatureType
$sel:featureName:FeatureDefinition' :: FeatureDefinition -> Maybe Text
$sel:featureType:FeatureDefinition' :: FeatureDefinition -> Maybe FeatureType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FeatureType" Text -> FeatureType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FeatureType -> Pair) -> Maybe FeatureType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FeatureType
featureType,
            (Text
"FeatureName" 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
featureName
          ]
      )