{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ModifySnapshotSchedule
-- 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)
--
-- Modifies a snapshot schedule. Any schedule associated with a cluster is
-- modified asynchronously.
module Amazonka.Redshift.ModifySnapshotSchedule
  ( -- * Creating a Request
    ModifySnapshotSchedule (..),
    newModifySnapshotSchedule,

    -- * Request Lenses
    modifySnapshotSchedule_scheduleIdentifier,
    modifySnapshotSchedule_scheduleDefinitions,

    -- * Destructuring the Response
    SnapshotSchedule (..),
    newSnapshotSchedule,

    -- * Response Lenses
    snapshotSchedule_associatedClusters,
    snapshotSchedule_nextInvocations,
    snapshotSchedule_scheduleDefinitions,
    snapshotSchedule_scheduleDescription,
    snapshotSchedule_scheduleIdentifier,
    snapshotSchedule_associatedClusterCount,
    snapshotSchedule_tags,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newModifySnapshotSchedule' smart constructor.
data ModifySnapshotSchedule = ModifySnapshotSchedule'
  { -- | A unique alphanumeric identifier of the schedule to modify.
    ModifySnapshotSchedule -> Text
scheduleIdentifier :: Prelude.Text,
    -- | An updated list of schedule definitions. A schedule definition is made
    -- up of schedule expressions, for example, \"cron(30 12 *)\" or \"rate(12
    -- hours)\".
    ModifySnapshotSchedule -> [Text]
scheduleDefinitions :: [Prelude.Text]
  }
  deriving (ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool
(ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool)
-> (ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool)
-> Eq ModifySnapshotSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool
$c/= :: ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool
== :: ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool
$c== :: ModifySnapshotSchedule -> ModifySnapshotSchedule -> Bool
Prelude.Eq, ReadPrec [ModifySnapshotSchedule]
ReadPrec ModifySnapshotSchedule
Int -> ReadS ModifySnapshotSchedule
ReadS [ModifySnapshotSchedule]
(Int -> ReadS ModifySnapshotSchedule)
-> ReadS [ModifySnapshotSchedule]
-> ReadPrec ModifySnapshotSchedule
-> ReadPrec [ModifySnapshotSchedule]
-> Read ModifySnapshotSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifySnapshotSchedule]
$creadListPrec :: ReadPrec [ModifySnapshotSchedule]
readPrec :: ReadPrec ModifySnapshotSchedule
$creadPrec :: ReadPrec ModifySnapshotSchedule
readList :: ReadS [ModifySnapshotSchedule]
$creadList :: ReadS [ModifySnapshotSchedule]
readsPrec :: Int -> ReadS ModifySnapshotSchedule
$creadsPrec :: Int -> ReadS ModifySnapshotSchedule
Prelude.Read, Int -> ModifySnapshotSchedule -> ShowS
[ModifySnapshotSchedule] -> ShowS
ModifySnapshotSchedule -> String
(Int -> ModifySnapshotSchedule -> ShowS)
-> (ModifySnapshotSchedule -> String)
-> ([ModifySnapshotSchedule] -> ShowS)
-> Show ModifySnapshotSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifySnapshotSchedule] -> ShowS
$cshowList :: [ModifySnapshotSchedule] -> ShowS
show :: ModifySnapshotSchedule -> String
$cshow :: ModifySnapshotSchedule -> String
showsPrec :: Int -> ModifySnapshotSchedule -> ShowS
$cshowsPrec :: Int -> ModifySnapshotSchedule -> ShowS
Prelude.Show, (forall x. ModifySnapshotSchedule -> Rep ModifySnapshotSchedule x)
-> (forall x.
    Rep ModifySnapshotSchedule x -> ModifySnapshotSchedule)
-> Generic ModifySnapshotSchedule
forall x. Rep ModifySnapshotSchedule x -> ModifySnapshotSchedule
forall x. ModifySnapshotSchedule -> Rep ModifySnapshotSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifySnapshotSchedule x -> ModifySnapshotSchedule
$cfrom :: forall x. ModifySnapshotSchedule -> Rep ModifySnapshotSchedule x
Prelude.Generic)

-- |
-- Create a value of 'ModifySnapshotSchedule' 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:
--
-- 'scheduleIdentifier', 'modifySnapshotSchedule_scheduleIdentifier' - A unique alphanumeric identifier of the schedule to modify.
--
-- 'scheduleDefinitions', 'modifySnapshotSchedule_scheduleDefinitions' - An updated list of schedule definitions. A schedule definition is made
-- up of schedule expressions, for example, \"cron(30 12 *)\" or \"rate(12
-- hours)\".
newModifySnapshotSchedule ::
  -- | 'scheduleIdentifier'
  Prelude.Text ->
  ModifySnapshotSchedule
newModifySnapshotSchedule :: Text -> ModifySnapshotSchedule
newModifySnapshotSchedule Text
pScheduleIdentifier_ =
  ModifySnapshotSchedule' :: Text -> [Text] -> ModifySnapshotSchedule
ModifySnapshotSchedule'
    { $sel:scheduleIdentifier:ModifySnapshotSchedule' :: Text
scheduleIdentifier =
        Text
pScheduleIdentifier_,
      $sel:scheduleDefinitions:ModifySnapshotSchedule' :: [Text]
scheduleDefinitions = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A unique alphanumeric identifier of the schedule to modify.
modifySnapshotSchedule_scheduleIdentifier :: Lens.Lens' ModifySnapshotSchedule Prelude.Text
modifySnapshotSchedule_scheduleIdentifier :: (Text -> f Text)
-> ModifySnapshotSchedule -> f ModifySnapshotSchedule
modifySnapshotSchedule_scheduleIdentifier = (ModifySnapshotSchedule -> Text)
-> (ModifySnapshotSchedule -> Text -> ModifySnapshotSchedule)
-> Lens ModifySnapshotSchedule ModifySnapshotSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifySnapshotSchedule' {Text
scheduleIdentifier :: Text
$sel:scheduleIdentifier:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> Text
scheduleIdentifier} -> Text
scheduleIdentifier) (\s :: ModifySnapshotSchedule
s@ModifySnapshotSchedule' {} Text
a -> ModifySnapshotSchedule
s {$sel:scheduleIdentifier:ModifySnapshotSchedule' :: Text
scheduleIdentifier = Text
a} :: ModifySnapshotSchedule)

-- | An updated list of schedule definitions. A schedule definition is made
-- up of schedule expressions, for example, \"cron(30 12 *)\" or \"rate(12
-- hours)\".
modifySnapshotSchedule_scheduleDefinitions :: Lens.Lens' ModifySnapshotSchedule [Prelude.Text]
modifySnapshotSchedule_scheduleDefinitions :: ([Text] -> f [Text])
-> ModifySnapshotSchedule -> f ModifySnapshotSchedule
modifySnapshotSchedule_scheduleDefinitions = (ModifySnapshotSchedule -> [Text])
-> (ModifySnapshotSchedule -> [Text] -> ModifySnapshotSchedule)
-> Lens ModifySnapshotSchedule ModifySnapshotSchedule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifySnapshotSchedule' {[Text]
scheduleDefinitions :: [Text]
$sel:scheduleDefinitions:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> [Text]
scheduleDefinitions} -> [Text]
scheduleDefinitions) (\s :: ModifySnapshotSchedule
s@ModifySnapshotSchedule' {} [Text]
a -> ModifySnapshotSchedule
s {$sel:scheduleDefinitions:ModifySnapshotSchedule' :: [Text]
scheduleDefinitions = [Text]
a} :: ModifySnapshotSchedule) (([Text] -> f [Text])
 -> ModifySnapshotSchedule -> f ModifySnapshotSchedule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ModifySnapshotSchedule
-> f ModifySnapshotSchedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest ModifySnapshotSchedule where
  type
    AWSResponse ModifySnapshotSchedule =
      SnapshotSchedule
  request :: ModifySnapshotSchedule -> Request ModifySnapshotSchedule
request = Service -> ModifySnapshotSchedule -> Request ModifySnapshotSchedule
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifySnapshotSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifySnapshotSchedule)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ModifySnapshotSchedule))
-> Logger
-> Service
-> Proxy ModifySnapshotSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifySnapshotSchedule)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifySnapshotScheduleResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String SnapshotSchedule
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable ModifySnapshotSchedule

instance Prelude.NFData ModifySnapshotSchedule

instance Core.ToHeaders ModifySnapshotSchedule where
  toHeaders :: ModifySnapshotSchedule -> ResponseHeaders
toHeaders = ResponseHeaders -> ModifySnapshotSchedule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ModifySnapshotSchedule where
  toPath :: ModifySnapshotSchedule -> ByteString
toPath = ByteString -> ModifySnapshotSchedule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ModifySnapshotSchedule where
  toQuery :: ModifySnapshotSchedule -> QueryString
toQuery ModifySnapshotSchedule' {[Text]
Text
scheduleDefinitions :: [Text]
scheduleIdentifier :: Text
$sel:scheduleDefinitions:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> [Text]
$sel:scheduleIdentifier:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ModifySnapshotSchedule" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ScheduleIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
scheduleIdentifier,
        ByteString
"ScheduleDefinitions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList
            ByteString
"ScheduleDefinition"
            [Text]
scheduleDefinitions
      ]