{-# 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.AppIntegrationS.Types.ScheduleConfiguration
-- 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.AppIntegrationS.Types.ScheduleConfiguration where

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

-- | The name of the data and how often it should be pulled from the source.
--
-- /See:/ 'newScheduleConfiguration' smart constructor.
data ScheduleConfiguration = ScheduleConfiguration'
  { -- | How often the data should be pulled from data source.
    ScheduleConfiguration -> Maybe Text
scheduleExpression :: Prelude.Maybe Prelude.Text,
    -- | The name of the object to pull from the data source.
    ScheduleConfiguration -> Maybe Text
object' :: Prelude.Maybe Prelude.Text,
    -- | The start date for objects to import in the first flow run.
    ScheduleConfiguration -> Maybe Text
firstExecutionFrom :: Prelude.Maybe Prelude.Text
  }
  deriving (ScheduleConfiguration -> ScheduleConfiguration -> Bool
(ScheduleConfiguration -> ScheduleConfiguration -> Bool)
-> (ScheduleConfiguration -> ScheduleConfiguration -> Bool)
-> Eq ScheduleConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
$c/= :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
== :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
$c== :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
Prelude.Eq, ReadPrec [ScheduleConfiguration]
ReadPrec ScheduleConfiguration
Int -> ReadS ScheduleConfiguration
ReadS [ScheduleConfiguration]
(Int -> ReadS ScheduleConfiguration)
-> ReadS [ScheduleConfiguration]
-> ReadPrec ScheduleConfiguration
-> ReadPrec [ScheduleConfiguration]
-> Read ScheduleConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduleConfiguration]
$creadListPrec :: ReadPrec [ScheduleConfiguration]
readPrec :: ReadPrec ScheduleConfiguration
$creadPrec :: ReadPrec ScheduleConfiguration
readList :: ReadS [ScheduleConfiguration]
$creadList :: ReadS [ScheduleConfiguration]
readsPrec :: Int -> ReadS ScheduleConfiguration
$creadsPrec :: Int -> ReadS ScheduleConfiguration
Prelude.Read, Int -> ScheduleConfiguration -> ShowS
[ScheduleConfiguration] -> ShowS
ScheduleConfiguration -> String
(Int -> ScheduleConfiguration -> ShowS)
-> (ScheduleConfiguration -> String)
-> ([ScheduleConfiguration] -> ShowS)
-> Show ScheduleConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduleConfiguration] -> ShowS
$cshowList :: [ScheduleConfiguration] -> ShowS
show :: ScheduleConfiguration -> String
$cshow :: ScheduleConfiguration -> String
showsPrec :: Int -> ScheduleConfiguration -> ShowS
$cshowsPrec :: Int -> ScheduleConfiguration -> ShowS
Prelude.Show, (forall x. ScheduleConfiguration -> Rep ScheduleConfiguration x)
-> (forall x. Rep ScheduleConfiguration x -> ScheduleConfiguration)
-> Generic ScheduleConfiguration
forall x. Rep ScheduleConfiguration x -> ScheduleConfiguration
forall x. ScheduleConfiguration -> Rep ScheduleConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduleConfiguration x -> ScheduleConfiguration
$cfrom :: forall x. ScheduleConfiguration -> Rep ScheduleConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ScheduleConfiguration' 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:
--
-- 'scheduleExpression', 'scheduleConfiguration_scheduleExpression' - How often the data should be pulled from data source.
--
-- 'object'', 'scheduleConfiguration_object' - The name of the object to pull from the data source.
--
-- 'firstExecutionFrom', 'scheduleConfiguration_firstExecutionFrom' - The start date for objects to import in the first flow run.
newScheduleConfiguration ::
  ScheduleConfiguration
newScheduleConfiguration :: ScheduleConfiguration
newScheduleConfiguration =
  ScheduleConfiguration' :: Maybe Text -> Maybe Text -> Maybe Text -> ScheduleConfiguration
ScheduleConfiguration'
    { $sel:scheduleExpression:ScheduleConfiguration' :: Maybe Text
scheduleExpression =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:object':ScheduleConfiguration' :: Maybe Text
object' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firstExecutionFrom:ScheduleConfiguration' :: Maybe Text
firstExecutionFrom = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | How often the data should be pulled from data source.
scheduleConfiguration_scheduleExpression :: Lens.Lens' ScheduleConfiguration (Prelude.Maybe Prelude.Text)
scheduleConfiguration_scheduleExpression :: (Maybe Text -> f (Maybe Text))
-> ScheduleConfiguration -> f ScheduleConfiguration
scheduleConfiguration_scheduleExpression = (ScheduleConfiguration -> Maybe Text)
-> (ScheduleConfiguration -> Maybe Text -> ScheduleConfiguration)
-> Lens
     ScheduleConfiguration
     ScheduleConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleConfiguration' {Maybe Text
scheduleExpression :: Maybe Text
$sel:scheduleExpression:ScheduleConfiguration' :: ScheduleConfiguration -> Maybe Text
scheduleExpression} -> Maybe Text
scheduleExpression) (\s :: ScheduleConfiguration
s@ScheduleConfiguration' {} Maybe Text
a -> ScheduleConfiguration
s {$sel:scheduleExpression:ScheduleConfiguration' :: Maybe Text
scheduleExpression = Maybe Text
a} :: ScheduleConfiguration)

-- | The name of the object to pull from the data source.
scheduleConfiguration_object :: Lens.Lens' ScheduleConfiguration (Prelude.Maybe Prelude.Text)
scheduleConfiguration_object :: (Maybe Text -> f (Maybe Text))
-> ScheduleConfiguration -> f ScheduleConfiguration
scheduleConfiguration_object = (ScheduleConfiguration -> Maybe Text)
-> (ScheduleConfiguration -> Maybe Text -> ScheduleConfiguration)
-> Lens
     ScheduleConfiguration
     ScheduleConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleConfiguration' {Maybe Text
object' :: Maybe Text
$sel:object':ScheduleConfiguration' :: ScheduleConfiguration -> Maybe Text
object'} -> Maybe Text
object') (\s :: ScheduleConfiguration
s@ScheduleConfiguration' {} Maybe Text
a -> ScheduleConfiguration
s {$sel:object':ScheduleConfiguration' :: Maybe Text
object' = Maybe Text
a} :: ScheduleConfiguration)

-- | The start date for objects to import in the first flow run.
scheduleConfiguration_firstExecutionFrom :: Lens.Lens' ScheduleConfiguration (Prelude.Maybe Prelude.Text)
scheduleConfiguration_firstExecutionFrom :: (Maybe Text -> f (Maybe Text))
-> ScheduleConfiguration -> f ScheduleConfiguration
scheduleConfiguration_firstExecutionFrom = (ScheduleConfiguration -> Maybe Text)
-> (ScheduleConfiguration -> Maybe Text -> ScheduleConfiguration)
-> Lens
     ScheduleConfiguration
     ScheduleConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleConfiguration' {Maybe Text
firstExecutionFrom :: Maybe Text
$sel:firstExecutionFrom:ScheduleConfiguration' :: ScheduleConfiguration -> Maybe Text
firstExecutionFrom} -> Maybe Text
firstExecutionFrom) (\s :: ScheduleConfiguration
s@ScheduleConfiguration' {} Maybe Text
a -> ScheduleConfiguration
s {$sel:firstExecutionFrom:ScheduleConfiguration' :: Maybe Text
firstExecutionFrom = Maybe Text
a} :: ScheduleConfiguration)

instance Core.FromJSON ScheduleConfiguration where
  parseJSON :: Value -> Parser ScheduleConfiguration
parseJSON =
    String
-> (Object -> Parser ScheduleConfiguration)
-> Value
-> Parser ScheduleConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ScheduleConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> ScheduleConfiguration
ScheduleConfiguration'
            (Maybe Text -> Maybe Text -> Maybe Text -> ScheduleConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> ScheduleConfiguration)
forall (f :: * -> *) a b. Functor 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
"ScheduleExpression")
            Parser (Maybe Text -> Maybe Text -> ScheduleConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> ScheduleConfiguration)
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
"Object")
            Parser (Maybe Text -> ScheduleConfiguration)
-> Parser (Maybe Text) -> Parser ScheduleConfiguration
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
"FirstExecutionFrom")
      )

instance Prelude.Hashable ScheduleConfiguration

instance Prelude.NFData ScheduleConfiguration

instance Core.ToJSON ScheduleConfiguration where
  toJSON :: ScheduleConfiguration -> Value
toJSON ScheduleConfiguration' {Maybe Text
firstExecutionFrom :: Maybe Text
object' :: Maybe Text
scheduleExpression :: Maybe Text
$sel:firstExecutionFrom:ScheduleConfiguration' :: ScheduleConfiguration -> Maybe Text
$sel:object':ScheduleConfiguration' :: ScheduleConfiguration -> Maybe Text
$sel:scheduleExpression:ScheduleConfiguration' :: ScheduleConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ScheduleExpression" 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
scheduleExpression,
            (Text
"Object" 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
object',
            (Text
"FirstExecutionFrom" 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
firstExecutionFrom
          ]
      )