{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_associatedClusterCount,
    snapshotSchedule_associatedClusters,
    snapshotSchedule_nextInvocations,
    snapshotSchedule_scheduleDefinitions,
    snapshotSchedule_scheduleDescription,
    snapshotSchedule_scheduleIdentifier,
    snapshotSchedule_tags,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:scheduleIdentifier:ModifySnapshotSchedule' :: Text
scheduleIdentifier =
        Text
pScheduleIdentifier_,
      $sel:scheduleDefinitions:ModifySnapshotSchedule' :: [Text]
scheduleDefinitions = 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 :: Lens' ModifySnapshotSchedule Text
modifySnapshotSchedule_scheduleIdentifier = 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 :: Lens' ModifySnapshotSchedule [Text]
modifySnapshotSchedule_scheduleDefinitions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: (Service -> Service)
-> ModifySnapshotSchedule -> Request ModifySnapshotSchedule
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ModifySnapshotSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifySnapshotSchedule)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifySnapshotScheduleResult"
      (\Int
s ResponseHeaders
h [Node]
x -> forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)

instance Prelude.Hashable ModifySnapshotSchedule where
  hashWithSalt :: Int -> ModifySnapshotSchedule -> Int
hashWithSalt Int
_salt ModifySnapshotSchedule' {[Text]
Text
scheduleDefinitions :: [Text]
scheduleIdentifier :: Text
$sel:scheduleDefinitions:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> [Text]
$sel:scheduleIdentifier:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
scheduleIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
scheduleDefinitions

instance Prelude.NFData ModifySnapshotSchedule where
  rnf :: ModifySnapshotSchedule -> ()
rnf ModifySnapshotSchedule' {[Text]
Text
scheduleDefinitions :: [Text]
scheduleIdentifier :: Text
$sel:scheduleDefinitions:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> [Text]
$sel:scheduleIdentifier:ModifySnapshotSchedule' :: ModifySnapshotSchedule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
scheduleIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
scheduleDefinitions

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

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

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