{-# 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.MediaLive.Types.ScheduleAction
-- 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.MediaLive.Types.ScheduleAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaLive.Types.ScheduleActionSettings
import Amazonka.MediaLive.Types.ScheduleActionStartSettings
import qualified Amazonka.Prelude as Prelude

-- | Contains information on a single schedule action.
--
-- /See:/ 'newScheduleAction' smart constructor.
data ScheduleAction = ScheduleAction'
  { -- | The name of the action, must be unique within the schedule. This name
    -- provides the main reference to an action once it is added to the
    -- schedule. A name is unique if it is no longer in the schedule. The
    -- schedule is automatically cleaned up to remove actions with a start time
    -- of more than 1 hour ago (approximately) so at that point a name can be
    -- reused.
    ScheduleAction -> Text
actionName :: Prelude.Text,
    -- | The time for the action to start in the channel.
    ScheduleAction -> ScheduleActionStartSettings
scheduleActionStartSettings :: ScheduleActionStartSettings,
    -- | Settings for this schedule action.
    ScheduleAction -> ScheduleActionSettings
scheduleActionSettings :: ScheduleActionSettings
  }
  deriving (ScheduleAction -> ScheduleAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduleAction -> ScheduleAction -> Bool
$c/= :: ScheduleAction -> ScheduleAction -> Bool
== :: ScheduleAction -> ScheduleAction -> Bool
$c== :: ScheduleAction -> ScheduleAction -> Bool
Prelude.Eq, ReadPrec [ScheduleAction]
ReadPrec ScheduleAction
Int -> ReadS ScheduleAction
ReadS [ScheduleAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduleAction]
$creadListPrec :: ReadPrec [ScheduleAction]
readPrec :: ReadPrec ScheduleAction
$creadPrec :: ReadPrec ScheduleAction
readList :: ReadS [ScheduleAction]
$creadList :: ReadS [ScheduleAction]
readsPrec :: Int -> ReadS ScheduleAction
$creadsPrec :: Int -> ReadS ScheduleAction
Prelude.Read, Int -> ScheduleAction -> ShowS
[ScheduleAction] -> ShowS
ScheduleAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduleAction] -> ShowS
$cshowList :: [ScheduleAction] -> ShowS
show :: ScheduleAction -> String
$cshow :: ScheduleAction -> String
showsPrec :: Int -> ScheduleAction -> ShowS
$cshowsPrec :: Int -> ScheduleAction -> ShowS
Prelude.Show, forall x. Rep ScheduleAction x -> ScheduleAction
forall x. ScheduleAction -> Rep ScheduleAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduleAction x -> ScheduleAction
$cfrom :: forall x. ScheduleAction -> Rep ScheduleAction x
Prelude.Generic)

-- |
-- Create a value of 'ScheduleAction' 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:
--
-- 'actionName', 'scheduleAction_actionName' - The name of the action, must be unique within the schedule. This name
-- provides the main reference to an action once it is added to the
-- schedule. A name is unique if it is no longer in the schedule. The
-- schedule is automatically cleaned up to remove actions with a start time
-- of more than 1 hour ago (approximately) so at that point a name can be
-- reused.
--
-- 'scheduleActionStartSettings', 'scheduleAction_scheduleActionStartSettings' - The time for the action to start in the channel.
--
-- 'scheduleActionSettings', 'scheduleAction_scheduleActionSettings' - Settings for this schedule action.
newScheduleAction ::
  -- | 'actionName'
  Prelude.Text ->
  -- | 'scheduleActionStartSettings'
  ScheduleActionStartSettings ->
  -- | 'scheduleActionSettings'
  ScheduleActionSettings ->
  ScheduleAction
newScheduleAction :: Text
-> ScheduleActionStartSettings
-> ScheduleActionSettings
-> ScheduleAction
newScheduleAction
  Text
pActionName_
  ScheduleActionStartSettings
pScheduleActionStartSettings_
  ScheduleActionSettings
pScheduleActionSettings_ =
    ScheduleAction'
      { $sel:actionName:ScheduleAction' :: Text
actionName = Text
pActionName_,
        $sel:scheduleActionStartSettings:ScheduleAction' :: ScheduleActionStartSettings
scheduleActionStartSettings =
          ScheduleActionStartSettings
pScheduleActionStartSettings_,
        $sel:scheduleActionSettings:ScheduleAction' :: ScheduleActionSettings
scheduleActionSettings = ScheduleActionSettings
pScheduleActionSettings_
      }

-- | The name of the action, must be unique within the schedule. This name
-- provides the main reference to an action once it is added to the
-- schedule. A name is unique if it is no longer in the schedule. The
-- schedule is automatically cleaned up to remove actions with a start time
-- of more than 1 hour ago (approximately) so at that point a name can be
-- reused.
scheduleAction_actionName :: Lens.Lens' ScheduleAction Prelude.Text
scheduleAction_actionName :: Lens' ScheduleAction Text
scheduleAction_actionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleAction' {Text
actionName :: Text
$sel:actionName:ScheduleAction' :: ScheduleAction -> Text
actionName} -> Text
actionName) (\s :: ScheduleAction
s@ScheduleAction' {} Text
a -> ScheduleAction
s {$sel:actionName:ScheduleAction' :: Text
actionName = Text
a} :: ScheduleAction)

-- | The time for the action to start in the channel.
scheduleAction_scheduleActionStartSettings :: Lens.Lens' ScheduleAction ScheduleActionStartSettings
scheduleAction_scheduleActionStartSettings :: Lens' ScheduleAction ScheduleActionStartSettings
scheduleAction_scheduleActionStartSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleAction' {ScheduleActionStartSettings
scheduleActionStartSettings :: ScheduleActionStartSettings
$sel:scheduleActionStartSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionStartSettings
scheduleActionStartSettings} -> ScheduleActionStartSettings
scheduleActionStartSettings) (\s :: ScheduleAction
s@ScheduleAction' {} ScheduleActionStartSettings
a -> ScheduleAction
s {$sel:scheduleActionStartSettings:ScheduleAction' :: ScheduleActionStartSettings
scheduleActionStartSettings = ScheduleActionStartSettings
a} :: ScheduleAction)

-- | Settings for this schedule action.
scheduleAction_scheduleActionSettings :: Lens.Lens' ScheduleAction ScheduleActionSettings
scheduleAction_scheduleActionSettings :: Lens' ScheduleAction ScheduleActionSettings
scheduleAction_scheduleActionSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleAction' {ScheduleActionSettings
scheduleActionSettings :: ScheduleActionSettings
$sel:scheduleActionSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionSettings
scheduleActionSettings} -> ScheduleActionSettings
scheduleActionSettings) (\s :: ScheduleAction
s@ScheduleAction' {} ScheduleActionSettings
a -> ScheduleAction
s {$sel:scheduleActionSettings:ScheduleAction' :: ScheduleActionSettings
scheduleActionSettings = ScheduleActionSettings
a} :: ScheduleAction)

instance Data.FromJSON ScheduleAction where
  parseJSON :: Value -> Parser ScheduleAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScheduleAction"
      ( \Object
x ->
          Text
-> ScheduleActionStartSettings
-> ScheduleActionSettings
-> ScheduleAction
ScheduleAction'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"actionName")
            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
"scheduleActionStartSettings")
            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
"scheduleActionSettings")
      )

instance Prelude.Hashable ScheduleAction where
  hashWithSalt :: Int -> ScheduleAction -> Int
hashWithSalt Int
_salt ScheduleAction' {Text
ScheduleActionStartSettings
ScheduleActionSettings
scheduleActionSettings :: ScheduleActionSettings
scheduleActionStartSettings :: ScheduleActionStartSettings
actionName :: Text
$sel:scheduleActionSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionSettings
$sel:scheduleActionStartSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionStartSettings
$sel:actionName:ScheduleAction' :: ScheduleAction -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
actionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ScheduleActionStartSettings
scheduleActionStartSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ScheduleActionSettings
scheduleActionSettings

instance Prelude.NFData ScheduleAction where
  rnf :: ScheduleAction -> ()
rnf ScheduleAction' {Text
ScheduleActionStartSettings
ScheduleActionSettings
scheduleActionSettings :: ScheduleActionSettings
scheduleActionStartSettings :: ScheduleActionStartSettings
actionName :: Text
$sel:scheduleActionSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionSettings
$sel:scheduleActionStartSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionStartSettings
$sel:actionName:ScheduleAction' :: ScheduleAction -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
actionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScheduleActionStartSettings
scheduleActionStartSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScheduleActionSettings
scheduleActionSettings

instance Data.ToJSON ScheduleAction where
  toJSON :: ScheduleAction -> Value
toJSON ScheduleAction' {Text
ScheduleActionStartSettings
ScheduleActionSettings
scheduleActionSettings :: ScheduleActionSettings
scheduleActionStartSettings :: ScheduleActionStartSettings
actionName :: Text
$sel:scheduleActionSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionSettings
$sel:scheduleActionStartSettings:ScheduleAction' :: ScheduleAction -> ScheduleActionStartSettings
$sel:actionName:ScheduleAction' :: ScheduleAction -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"actionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
actionName),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"scheduleActionStartSettings"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ScheduleActionStartSettings
scheduleActionStartSettings
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"scheduleActionSettings"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ScheduleActionSettings
scheduleActionSettings
              )
          ]
      )