{-# 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.Forecast.Types.DataConfig
-- 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.Forecast.Types.DataConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Forecast.Types.AdditionalDataset
import Amazonka.Forecast.Types.AttributeConfig
import qualified Amazonka.Prelude as Prelude

-- | The data configuration for your dataset group and any additional
-- datasets.
--
-- /See:/ 'newDataConfig' smart constructor.
data DataConfig = DataConfig'
  { -- | Additional built-in datasets like Holidays and the Weather Index.
    DataConfig -> Maybe (NonEmpty AdditionalDataset)
additionalDatasets :: Prelude.Maybe (Prelude.NonEmpty AdditionalDataset),
    -- | Aggregation and filling options for attributes in your dataset group.
    DataConfig -> Maybe (NonEmpty AttributeConfig)
attributeConfigs :: Prelude.Maybe (Prelude.NonEmpty AttributeConfig),
    -- | The ARN of the dataset group used to train the predictor.
    DataConfig -> Text
datasetGroupArn :: Prelude.Text
  }
  deriving (DataConfig -> DataConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataConfig -> DataConfig -> Bool
$c/= :: DataConfig -> DataConfig -> Bool
== :: DataConfig -> DataConfig -> Bool
$c== :: DataConfig -> DataConfig -> Bool
Prelude.Eq, ReadPrec [DataConfig]
ReadPrec DataConfig
Int -> ReadS DataConfig
ReadS [DataConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataConfig]
$creadListPrec :: ReadPrec [DataConfig]
readPrec :: ReadPrec DataConfig
$creadPrec :: ReadPrec DataConfig
readList :: ReadS [DataConfig]
$creadList :: ReadS [DataConfig]
readsPrec :: Int -> ReadS DataConfig
$creadsPrec :: Int -> ReadS DataConfig
Prelude.Read, Int -> DataConfig -> ShowS
[DataConfig] -> ShowS
DataConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataConfig] -> ShowS
$cshowList :: [DataConfig] -> ShowS
show :: DataConfig -> String
$cshow :: DataConfig -> String
showsPrec :: Int -> DataConfig -> ShowS
$cshowsPrec :: Int -> DataConfig -> ShowS
Prelude.Show, forall x. Rep DataConfig x -> DataConfig
forall x. DataConfig -> Rep DataConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataConfig x -> DataConfig
$cfrom :: forall x. DataConfig -> Rep DataConfig x
Prelude.Generic)

-- |
-- Create a value of 'DataConfig' 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:
--
-- 'additionalDatasets', 'dataConfig_additionalDatasets' - Additional built-in datasets like Holidays and the Weather Index.
--
-- 'attributeConfigs', 'dataConfig_attributeConfigs' - Aggregation and filling options for attributes in your dataset group.
--
-- 'datasetGroupArn', 'dataConfig_datasetGroupArn' - The ARN of the dataset group used to train the predictor.
newDataConfig ::
  -- | 'datasetGroupArn'
  Prelude.Text ->
  DataConfig
newDataConfig :: Text -> DataConfig
newDataConfig Text
pDatasetGroupArn_ =
  DataConfig'
    { $sel:additionalDatasets:DataConfig' :: Maybe (NonEmpty AdditionalDataset)
additionalDatasets = forall a. Maybe a
Prelude.Nothing,
      $sel:attributeConfigs:DataConfig' :: Maybe (NonEmpty AttributeConfig)
attributeConfigs = forall a. Maybe a
Prelude.Nothing,
      $sel:datasetGroupArn:DataConfig' :: Text
datasetGroupArn = Text
pDatasetGroupArn_
    }

-- | Additional built-in datasets like Holidays and the Weather Index.
dataConfig_additionalDatasets :: Lens.Lens' DataConfig (Prelude.Maybe (Prelude.NonEmpty AdditionalDataset))
dataConfig_additionalDatasets :: Lens' DataConfig (Maybe (NonEmpty AdditionalDataset))
dataConfig_additionalDatasets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataConfig' {Maybe (NonEmpty AdditionalDataset)
additionalDatasets :: Maybe (NonEmpty AdditionalDataset)
$sel:additionalDatasets:DataConfig' :: DataConfig -> Maybe (NonEmpty AdditionalDataset)
additionalDatasets} -> Maybe (NonEmpty AdditionalDataset)
additionalDatasets) (\s :: DataConfig
s@DataConfig' {} Maybe (NonEmpty AdditionalDataset)
a -> DataConfig
s {$sel:additionalDatasets:DataConfig' :: Maybe (NonEmpty AdditionalDataset)
additionalDatasets = Maybe (NonEmpty AdditionalDataset)
a} :: DataConfig) 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

-- | Aggregation and filling options for attributes in your dataset group.
dataConfig_attributeConfigs :: Lens.Lens' DataConfig (Prelude.Maybe (Prelude.NonEmpty AttributeConfig))
dataConfig_attributeConfigs :: Lens' DataConfig (Maybe (NonEmpty AttributeConfig))
dataConfig_attributeConfigs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataConfig' {Maybe (NonEmpty AttributeConfig)
attributeConfigs :: Maybe (NonEmpty AttributeConfig)
$sel:attributeConfigs:DataConfig' :: DataConfig -> Maybe (NonEmpty AttributeConfig)
attributeConfigs} -> Maybe (NonEmpty AttributeConfig)
attributeConfigs) (\s :: DataConfig
s@DataConfig' {} Maybe (NonEmpty AttributeConfig)
a -> DataConfig
s {$sel:attributeConfigs:DataConfig' :: Maybe (NonEmpty AttributeConfig)
attributeConfigs = Maybe (NonEmpty AttributeConfig)
a} :: DataConfig) 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

-- | The ARN of the dataset group used to train the predictor.
dataConfig_datasetGroupArn :: Lens.Lens' DataConfig Prelude.Text
dataConfig_datasetGroupArn :: Lens' DataConfig Text
dataConfig_datasetGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataConfig' {Text
datasetGroupArn :: Text
$sel:datasetGroupArn:DataConfig' :: DataConfig -> Text
datasetGroupArn} -> Text
datasetGroupArn) (\s :: DataConfig
s@DataConfig' {} Text
a -> DataConfig
s {$sel:datasetGroupArn:DataConfig' :: Text
datasetGroupArn = Text
a} :: DataConfig)

instance Data.FromJSON DataConfig where
  parseJSON :: Value -> Parser DataConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataConfig"
      ( \Object
x ->
          Maybe (NonEmpty AdditionalDataset)
-> Maybe (NonEmpty AttributeConfig) -> Text -> DataConfig
DataConfig'
            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
"AdditionalDatasets")
            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
"AttributeConfigs")
            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
"DatasetGroupArn")
      )

instance Prelude.Hashable DataConfig where
  hashWithSalt :: Int -> DataConfig -> Int
hashWithSalt Int
_salt DataConfig' {Maybe (NonEmpty AdditionalDataset)
Maybe (NonEmpty AttributeConfig)
Text
datasetGroupArn :: Text
attributeConfigs :: Maybe (NonEmpty AttributeConfig)
additionalDatasets :: Maybe (NonEmpty AdditionalDataset)
$sel:datasetGroupArn:DataConfig' :: DataConfig -> Text
$sel:attributeConfigs:DataConfig' :: DataConfig -> Maybe (NonEmpty AttributeConfig)
$sel:additionalDatasets:DataConfig' :: DataConfig -> Maybe (NonEmpty AdditionalDataset)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty AdditionalDataset)
additionalDatasets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty AttributeConfig)
attributeConfigs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
datasetGroupArn

instance Prelude.NFData DataConfig where
  rnf :: DataConfig -> ()
rnf DataConfig' {Maybe (NonEmpty AdditionalDataset)
Maybe (NonEmpty AttributeConfig)
Text
datasetGroupArn :: Text
attributeConfigs :: Maybe (NonEmpty AttributeConfig)
additionalDatasets :: Maybe (NonEmpty AdditionalDataset)
$sel:datasetGroupArn:DataConfig' :: DataConfig -> Text
$sel:attributeConfigs:DataConfig' :: DataConfig -> Maybe (NonEmpty AttributeConfig)
$sel:additionalDatasets:DataConfig' :: DataConfig -> Maybe (NonEmpty AdditionalDataset)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty AdditionalDataset)
additionalDatasets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty AttributeConfig)
attributeConfigs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
datasetGroupArn

instance Data.ToJSON DataConfig where
  toJSON :: DataConfig -> Value
toJSON DataConfig' {Maybe (NonEmpty AdditionalDataset)
Maybe (NonEmpty AttributeConfig)
Text
datasetGroupArn :: Text
attributeConfigs :: Maybe (NonEmpty AttributeConfig)
additionalDatasets :: Maybe (NonEmpty AdditionalDataset)
$sel:datasetGroupArn:DataConfig' :: DataConfig -> Text
$sel:attributeConfigs:DataConfig' :: DataConfig -> Maybe (NonEmpty AttributeConfig)
$sel:additionalDatasets:DataConfig' :: DataConfig -> Maybe (NonEmpty AdditionalDataset)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdditionalDatasets" 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 (NonEmpty AdditionalDataset)
additionalDatasets,
            (Key
"AttributeConfigs" 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 (NonEmpty AttributeConfig)
attributeConfigs,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"DatasetGroupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
datasetGroupArn)
          ]
      )