{-# 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.Redshift.Types.ScheduledActionType
-- 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.Redshift.Types.ScheduledActionType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.PauseClusterMessage
import Amazonka.Redshift.Types.ResizeClusterMessage
import Amazonka.Redshift.Types.ResumeClusterMessage

-- | The action type that specifies an Amazon Redshift API operation that is
-- supported by the Amazon Redshift scheduler.
--
-- /See:/ 'newScheduledActionType' smart constructor.
data ScheduledActionType = ScheduledActionType'
  { -- | An action that runs a @ResizeCluster@ API operation.
    ScheduledActionType -> Maybe ResizeClusterMessage
resizeCluster :: Prelude.Maybe ResizeClusterMessage,
    -- | An action that runs a @ResumeCluster@ API operation.
    ScheduledActionType -> Maybe ResumeClusterMessage
resumeCluster :: Prelude.Maybe ResumeClusterMessage,
    -- | An action that runs a @PauseCluster@ API operation.
    ScheduledActionType -> Maybe PauseClusterMessage
pauseCluster :: Prelude.Maybe PauseClusterMessage
  }
  deriving (ScheduledActionType -> ScheduledActionType -> Bool
(ScheduledActionType -> ScheduledActionType -> Bool)
-> (ScheduledActionType -> ScheduledActionType -> Bool)
-> Eq ScheduledActionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduledActionType -> ScheduledActionType -> Bool
$c/= :: ScheduledActionType -> ScheduledActionType -> Bool
== :: ScheduledActionType -> ScheduledActionType -> Bool
$c== :: ScheduledActionType -> ScheduledActionType -> Bool
Prelude.Eq, ReadPrec [ScheduledActionType]
ReadPrec ScheduledActionType
Int -> ReadS ScheduledActionType
ReadS [ScheduledActionType]
(Int -> ReadS ScheduledActionType)
-> ReadS [ScheduledActionType]
-> ReadPrec ScheduledActionType
-> ReadPrec [ScheduledActionType]
-> Read ScheduledActionType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduledActionType]
$creadListPrec :: ReadPrec [ScheduledActionType]
readPrec :: ReadPrec ScheduledActionType
$creadPrec :: ReadPrec ScheduledActionType
readList :: ReadS [ScheduledActionType]
$creadList :: ReadS [ScheduledActionType]
readsPrec :: Int -> ReadS ScheduledActionType
$creadsPrec :: Int -> ReadS ScheduledActionType
Prelude.Read, Int -> ScheduledActionType -> ShowS
[ScheduledActionType] -> ShowS
ScheduledActionType -> String
(Int -> ScheduledActionType -> ShowS)
-> (ScheduledActionType -> String)
-> ([ScheduledActionType] -> ShowS)
-> Show ScheduledActionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduledActionType] -> ShowS
$cshowList :: [ScheduledActionType] -> ShowS
show :: ScheduledActionType -> String
$cshow :: ScheduledActionType -> String
showsPrec :: Int -> ScheduledActionType -> ShowS
$cshowsPrec :: Int -> ScheduledActionType -> ShowS
Prelude.Show, (forall x. ScheduledActionType -> Rep ScheduledActionType x)
-> (forall x. Rep ScheduledActionType x -> ScheduledActionType)
-> Generic ScheduledActionType
forall x. Rep ScheduledActionType x -> ScheduledActionType
forall x. ScheduledActionType -> Rep ScheduledActionType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduledActionType x -> ScheduledActionType
$cfrom :: forall x. ScheduledActionType -> Rep ScheduledActionType x
Prelude.Generic)

-- |
-- Create a value of 'ScheduledActionType' 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:
--
-- 'resizeCluster', 'scheduledActionType_resizeCluster' - An action that runs a @ResizeCluster@ API operation.
--
-- 'resumeCluster', 'scheduledActionType_resumeCluster' - An action that runs a @ResumeCluster@ API operation.
--
-- 'pauseCluster', 'scheduledActionType_pauseCluster' - An action that runs a @PauseCluster@ API operation.
newScheduledActionType ::
  ScheduledActionType
newScheduledActionType :: ScheduledActionType
newScheduledActionType =
  ScheduledActionType' :: Maybe ResizeClusterMessage
-> Maybe ResumeClusterMessage
-> Maybe PauseClusterMessage
-> ScheduledActionType
ScheduledActionType'
    { $sel:resizeCluster:ScheduledActionType' :: Maybe ResizeClusterMessage
resizeCluster =
        Maybe ResizeClusterMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:resumeCluster:ScheduledActionType' :: Maybe ResumeClusterMessage
resumeCluster = Maybe ResumeClusterMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:pauseCluster:ScheduledActionType' :: Maybe PauseClusterMessage
pauseCluster = Maybe PauseClusterMessage
forall a. Maybe a
Prelude.Nothing
    }

-- | An action that runs a @ResizeCluster@ API operation.
scheduledActionType_resizeCluster :: Lens.Lens' ScheduledActionType (Prelude.Maybe ResizeClusterMessage)
scheduledActionType_resizeCluster :: (Maybe ResizeClusterMessage -> f (Maybe ResizeClusterMessage))
-> ScheduledActionType -> f ScheduledActionType
scheduledActionType_resizeCluster = (ScheduledActionType -> Maybe ResizeClusterMessage)
-> (ScheduledActionType
    -> Maybe ResizeClusterMessage -> ScheduledActionType)
-> Lens
     ScheduledActionType
     ScheduledActionType
     (Maybe ResizeClusterMessage)
     (Maybe ResizeClusterMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledActionType' {Maybe ResizeClusterMessage
resizeCluster :: Maybe ResizeClusterMessage
$sel:resizeCluster:ScheduledActionType' :: ScheduledActionType -> Maybe ResizeClusterMessage
resizeCluster} -> Maybe ResizeClusterMessage
resizeCluster) (\s :: ScheduledActionType
s@ScheduledActionType' {} Maybe ResizeClusterMessage
a -> ScheduledActionType
s {$sel:resizeCluster:ScheduledActionType' :: Maybe ResizeClusterMessage
resizeCluster = Maybe ResizeClusterMessage
a} :: ScheduledActionType)

-- | An action that runs a @ResumeCluster@ API operation.
scheduledActionType_resumeCluster :: Lens.Lens' ScheduledActionType (Prelude.Maybe ResumeClusterMessage)
scheduledActionType_resumeCluster :: (Maybe ResumeClusterMessage -> f (Maybe ResumeClusterMessage))
-> ScheduledActionType -> f ScheduledActionType
scheduledActionType_resumeCluster = (ScheduledActionType -> Maybe ResumeClusterMessage)
-> (ScheduledActionType
    -> Maybe ResumeClusterMessage -> ScheduledActionType)
-> Lens
     ScheduledActionType
     ScheduledActionType
     (Maybe ResumeClusterMessage)
     (Maybe ResumeClusterMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledActionType' {Maybe ResumeClusterMessage
resumeCluster :: Maybe ResumeClusterMessage
$sel:resumeCluster:ScheduledActionType' :: ScheduledActionType -> Maybe ResumeClusterMessage
resumeCluster} -> Maybe ResumeClusterMessage
resumeCluster) (\s :: ScheduledActionType
s@ScheduledActionType' {} Maybe ResumeClusterMessage
a -> ScheduledActionType
s {$sel:resumeCluster:ScheduledActionType' :: Maybe ResumeClusterMessage
resumeCluster = Maybe ResumeClusterMessage
a} :: ScheduledActionType)

-- | An action that runs a @PauseCluster@ API operation.
scheduledActionType_pauseCluster :: Lens.Lens' ScheduledActionType (Prelude.Maybe PauseClusterMessage)
scheduledActionType_pauseCluster :: (Maybe PauseClusterMessage -> f (Maybe PauseClusterMessage))
-> ScheduledActionType -> f ScheduledActionType
scheduledActionType_pauseCluster = (ScheduledActionType -> Maybe PauseClusterMessage)
-> (ScheduledActionType
    -> Maybe PauseClusterMessage -> ScheduledActionType)
-> Lens
     ScheduledActionType
     ScheduledActionType
     (Maybe PauseClusterMessage)
     (Maybe PauseClusterMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledActionType' {Maybe PauseClusterMessage
pauseCluster :: Maybe PauseClusterMessage
$sel:pauseCluster:ScheduledActionType' :: ScheduledActionType -> Maybe PauseClusterMessage
pauseCluster} -> Maybe PauseClusterMessage
pauseCluster) (\s :: ScheduledActionType
s@ScheduledActionType' {} Maybe PauseClusterMessage
a -> ScheduledActionType
s {$sel:pauseCluster:ScheduledActionType' :: Maybe PauseClusterMessage
pauseCluster = Maybe PauseClusterMessage
a} :: ScheduledActionType)

instance Core.FromXML ScheduledActionType where
  parseXML :: [Node] -> Either String ScheduledActionType
parseXML [Node]
x =
    Maybe ResizeClusterMessage
-> Maybe ResumeClusterMessage
-> Maybe PauseClusterMessage
-> ScheduledActionType
ScheduledActionType'
      (Maybe ResizeClusterMessage
 -> Maybe ResumeClusterMessage
 -> Maybe PauseClusterMessage
 -> ScheduledActionType)
-> Either String (Maybe ResizeClusterMessage)
-> Either
     String
     (Maybe ResumeClusterMessage
      -> Maybe PauseClusterMessage -> ScheduledActionType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ResizeClusterMessage)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResizeCluster")
      Either
  String
  (Maybe ResumeClusterMessage
   -> Maybe PauseClusterMessage -> ScheduledActionType)
-> Either String (Maybe ResumeClusterMessage)
-> Either String (Maybe PauseClusterMessage -> ScheduledActionType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ResumeClusterMessage)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResumeCluster")
      Either String (Maybe PauseClusterMessage -> ScheduledActionType)
-> Either String (Maybe PauseClusterMessage)
-> Either String ScheduledActionType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe PauseClusterMessage)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PauseCluster")

instance Prelude.Hashable ScheduledActionType

instance Prelude.NFData ScheduledActionType

instance Core.ToQuery ScheduledActionType where
  toQuery :: ScheduledActionType -> QueryString
toQuery ScheduledActionType' {Maybe PauseClusterMessage
Maybe ResizeClusterMessage
Maybe ResumeClusterMessage
pauseCluster :: Maybe PauseClusterMessage
resumeCluster :: Maybe ResumeClusterMessage
resizeCluster :: Maybe ResizeClusterMessage
$sel:pauseCluster:ScheduledActionType' :: ScheduledActionType -> Maybe PauseClusterMessage
$sel:resumeCluster:ScheduledActionType' :: ScheduledActionType -> Maybe ResumeClusterMessage
$sel:resizeCluster:ScheduledActionType' :: ScheduledActionType -> Maybe ResizeClusterMessage
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ResizeCluster" ByteString -> Maybe ResizeClusterMessage -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ResizeClusterMessage
resizeCluster,
        ByteString
"ResumeCluster" ByteString -> Maybe ResumeClusterMessage -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ResumeClusterMessage
resumeCluster,
        ByteString
"PauseCluster" ByteString -> Maybe PauseClusterMessage -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PauseClusterMessage
pauseCluster
      ]