{-# 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.ArcZonalShift.UpdateZonalShift
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update an active zonal shift in Amazon Route 53 Application Recovery
-- Controller in your AWS account. You can update a zonal shift to set a
-- new expiration, or edit or replace the comment for the zonal shift.
module Amazonka.ArcZonalShift.UpdateZonalShift
  ( -- * Creating a Request
    UpdateZonalShift (..),
    newUpdateZonalShift,

    -- * Request Lenses
    updateZonalShift_comment,
    updateZonalShift_expiresIn,
    updateZonalShift_zonalShiftId,

    -- * Destructuring the Response
    ZonalShift (..),
    newZonalShift,

    -- * Response Lenses
    zonalShift_awayFrom,
    zonalShift_comment,
    zonalShift_expiryTime,
    zonalShift_resourceIdentifier,
    zonalShift_startTime,
    zonalShift_status,
    zonalShift_zonalShiftId,
  )
where

import Amazonka.ArcZonalShift.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateZonalShift' smart constructor.
data UpdateZonalShift = UpdateZonalShift'
  { -- | A comment that you enter about the zonal shift. Only the latest comment
    -- is retained; no comment history is maintained. A new comment overwrites
    -- any existing comment string.
    UpdateZonalShift -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The length of time that you want a zonal shift to be active, which Route
    -- 53 ARC converts to an expiry time (expiration time). Zonal shifts are
    -- temporary. You can set a zonal shift to be active initially for up to
    -- three days (72 hours).
    --
    -- If you want to still keep traffic away from an Availability Zone, you
    -- can update the zonal shift and set a new expiration. You can also cancel
    -- a zonal shift, before it expires, for example, if you\'re ready to
    -- restore traffic to the Availability Zone.
    --
    -- To set a length of time for a zonal shift to be active, specify a whole
    -- number, and then one of the following, with no space:
    --
    -- -   __A lowercase letter m:__ To specify that the value is in minutes.
    --
    -- -   __A lowercase letter h:__ To specify that the value is in hours.
    --
    -- For example: @20h@ means the zonal shift expires in 20 hours. @120m@
    -- means the zonal shift expires in 120 minutes (2 hours).
    UpdateZonalShift -> Maybe Text
expiresIn :: Prelude.Maybe Prelude.Text,
    -- | The identifier of a zonal shift.
    UpdateZonalShift -> Text
zonalShiftId :: Prelude.Text
  }
  deriving (UpdateZonalShift -> UpdateZonalShift -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateZonalShift -> UpdateZonalShift -> Bool
$c/= :: UpdateZonalShift -> UpdateZonalShift -> Bool
== :: UpdateZonalShift -> UpdateZonalShift -> Bool
$c== :: UpdateZonalShift -> UpdateZonalShift -> Bool
Prelude.Eq, ReadPrec [UpdateZonalShift]
ReadPrec UpdateZonalShift
Int -> ReadS UpdateZonalShift
ReadS [UpdateZonalShift]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateZonalShift]
$creadListPrec :: ReadPrec [UpdateZonalShift]
readPrec :: ReadPrec UpdateZonalShift
$creadPrec :: ReadPrec UpdateZonalShift
readList :: ReadS [UpdateZonalShift]
$creadList :: ReadS [UpdateZonalShift]
readsPrec :: Int -> ReadS UpdateZonalShift
$creadsPrec :: Int -> ReadS UpdateZonalShift
Prelude.Read, Int -> UpdateZonalShift -> ShowS
[UpdateZonalShift] -> ShowS
UpdateZonalShift -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateZonalShift] -> ShowS
$cshowList :: [UpdateZonalShift] -> ShowS
show :: UpdateZonalShift -> String
$cshow :: UpdateZonalShift -> String
showsPrec :: Int -> UpdateZonalShift -> ShowS
$cshowsPrec :: Int -> UpdateZonalShift -> ShowS
Prelude.Show, forall x. Rep UpdateZonalShift x -> UpdateZonalShift
forall x. UpdateZonalShift -> Rep UpdateZonalShift x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateZonalShift x -> UpdateZonalShift
$cfrom :: forall x. UpdateZonalShift -> Rep UpdateZonalShift x
Prelude.Generic)

-- |
-- Create a value of 'UpdateZonalShift' 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:
--
-- 'comment', 'updateZonalShift_comment' - A comment that you enter about the zonal shift. Only the latest comment
-- is retained; no comment history is maintained. A new comment overwrites
-- any existing comment string.
--
-- 'expiresIn', 'updateZonalShift_expiresIn' - The length of time that you want a zonal shift to be active, which Route
-- 53 ARC converts to an expiry time (expiration time). Zonal shifts are
-- temporary. You can set a zonal shift to be active initially for up to
-- three days (72 hours).
--
-- If you want to still keep traffic away from an Availability Zone, you
-- can update the zonal shift and set a new expiration. You can also cancel
-- a zonal shift, before it expires, for example, if you\'re ready to
-- restore traffic to the Availability Zone.
--
-- To set a length of time for a zonal shift to be active, specify a whole
-- number, and then one of the following, with no space:
--
-- -   __A lowercase letter m:__ To specify that the value is in minutes.
--
-- -   __A lowercase letter h:__ To specify that the value is in hours.
--
-- For example: @20h@ means the zonal shift expires in 20 hours. @120m@
-- means the zonal shift expires in 120 minutes (2 hours).
--
-- 'zonalShiftId', 'updateZonalShift_zonalShiftId' - The identifier of a zonal shift.
newUpdateZonalShift ::
  -- | 'zonalShiftId'
  Prelude.Text ->
  UpdateZonalShift
newUpdateZonalShift :: Text -> UpdateZonalShift
newUpdateZonalShift Text
pZonalShiftId_ =
  UpdateZonalShift'
    { $sel:comment:UpdateZonalShift' :: Maybe Text
comment = forall a. Maybe a
Prelude.Nothing,
      $sel:expiresIn:UpdateZonalShift' :: Maybe Text
expiresIn = forall a. Maybe a
Prelude.Nothing,
      $sel:zonalShiftId:UpdateZonalShift' :: Text
zonalShiftId = Text
pZonalShiftId_
    }

-- | A comment that you enter about the zonal shift. Only the latest comment
-- is retained; no comment history is maintained. A new comment overwrites
-- any existing comment string.
updateZonalShift_comment :: Lens.Lens' UpdateZonalShift (Prelude.Maybe Prelude.Text)
updateZonalShift_comment :: Lens' UpdateZonalShift (Maybe Text)
updateZonalShift_comment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateZonalShift' {Maybe Text
comment :: Maybe Text
$sel:comment:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
comment} -> Maybe Text
comment) (\s :: UpdateZonalShift
s@UpdateZonalShift' {} Maybe Text
a -> UpdateZonalShift
s {$sel:comment:UpdateZonalShift' :: Maybe Text
comment = Maybe Text
a} :: UpdateZonalShift)

-- | The length of time that you want a zonal shift to be active, which Route
-- 53 ARC converts to an expiry time (expiration time). Zonal shifts are
-- temporary. You can set a zonal shift to be active initially for up to
-- three days (72 hours).
--
-- If you want to still keep traffic away from an Availability Zone, you
-- can update the zonal shift and set a new expiration. You can also cancel
-- a zonal shift, before it expires, for example, if you\'re ready to
-- restore traffic to the Availability Zone.
--
-- To set a length of time for a zonal shift to be active, specify a whole
-- number, and then one of the following, with no space:
--
-- -   __A lowercase letter m:__ To specify that the value is in minutes.
--
-- -   __A lowercase letter h:__ To specify that the value is in hours.
--
-- For example: @20h@ means the zonal shift expires in 20 hours. @120m@
-- means the zonal shift expires in 120 minutes (2 hours).
updateZonalShift_expiresIn :: Lens.Lens' UpdateZonalShift (Prelude.Maybe Prelude.Text)
updateZonalShift_expiresIn :: Lens' UpdateZonalShift (Maybe Text)
updateZonalShift_expiresIn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateZonalShift' {Maybe Text
expiresIn :: Maybe Text
$sel:expiresIn:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
expiresIn} -> Maybe Text
expiresIn) (\s :: UpdateZonalShift
s@UpdateZonalShift' {} Maybe Text
a -> UpdateZonalShift
s {$sel:expiresIn:UpdateZonalShift' :: Maybe Text
expiresIn = Maybe Text
a} :: UpdateZonalShift)

-- | The identifier of a zonal shift.
updateZonalShift_zonalShiftId :: Lens.Lens' UpdateZonalShift Prelude.Text
updateZonalShift_zonalShiftId :: Lens' UpdateZonalShift Text
updateZonalShift_zonalShiftId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateZonalShift' {Text
zonalShiftId :: Text
$sel:zonalShiftId:UpdateZonalShift' :: UpdateZonalShift -> Text
zonalShiftId} -> Text
zonalShiftId) (\s :: UpdateZonalShift
s@UpdateZonalShift' {} Text
a -> UpdateZonalShift
s {$sel:zonalShiftId:UpdateZonalShift' :: Text
zonalShiftId = Text
a} :: UpdateZonalShift)

instance Core.AWSRequest UpdateZonalShift where
  type AWSResponse UpdateZonalShift = ZonalShift
  request :: (Service -> Service)
-> UpdateZonalShift -> Request UpdateZonalShift
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateZonalShift
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateZonalShift)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateZonalShift where
  hashWithSalt :: Int -> UpdateZonalShift -> Int
hashWithSalt Int
_salt UpdateZonalShift' {Maybe Text
Text
zonalShiftId :: Text
expiresIn :: Maybe Text
comment :: Maybe Text
$sel:zonalShiftId:UpdateZonalShift' :: UpdateZonalShift -> Text
$sel:expiresIn:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
$sel:comment:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
comment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expiresIn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
zonalShiftId

instance Prelude.NFData UpdateZonalShift where
  rnf :: UpdateZonalShift -> ()
rnf UpdateZonalShift' {Maybe Text
Text
zonalShiftId :: Text
expiresIn :: Maybe Text
comment :: Maybe Text
$sel:zonalShiftId:UpdateZonalShift' :: UpdateZonalShift -> Text
$sel:expiresIn:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
$sel:comment:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expiresIn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
zonalShiftId

instance Data.ToHeaders UpdateZonalShift where
  toHeaders :: UpdateZonalShift -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateZonalShift where
  toJSON :: UpdateZonalShift -> Value
toJSON UpdateZonalShift' {Maybe Text
Text
zonalShiftId :: Text
expiresIn :: Maybe Text
comment :: Maybe Text
$sel:zonalShiftId:UpdateZonalShift' :: UpdateZonalShift -> Text
$sel:expiresIn:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
$sel:comment:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"comment" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
comment,
            (Key
"expiresIn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
expiresIn
          ]
      )

instance Data.ToPath UpdateZonalShift where
  toPath :: UpdateZonalShift -> ByteString
toPath UpdateZonalShift' {Maybe Text
Text
zonalShiftId :: Text
expiresIn :: Maybe Text
comment :: Maybe Text
$sel:zonalShiftId:UpdateZonalShift' :: UpdateZonalShift -> Text
$sel:expiresIn:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
$sel:comment:UpdateZonalShift' :: UpdateZonalShift -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/zonalshifts/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
zonalShiftId]

instance Data.ToQuery UpdateZonalShift where
  toQuery :: UpdateZonalShift -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty