{-# 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.SSMIncidents.UpdateDeletionProtection
-- 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 deletion protection to either allow or deny deletion of the final
-- Region in a replication set.
module Amazonka.SSMIncidents.UpdateDeletionProtection
  ( -- * Creating a Request
    UpdateDeletionProtection (..),
    newUpdateDeletionProtection,

    -- * Request Lenses
    updateDeletionProtection_clientToken,
    updateDeletionProtection_arn,
    updateDeletionProtection_deletionProtected,

    -- * Destructuring the Response
    UpdateDeletionProtectionResponse (..),
    newUpdateDeletionProtectionResponse,

    -- * Response Lenses
    updateDeletionProtectionResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSMIncidents.Types

-- | /See:/ 'newUpdateDeletionProtection' smart constructor.
data UpdateDeletionProtection = UpdateDeletionProtection'
  { -- | A token that ensures that the operation is called only once with the
    -- specified details.
    UpdateDeletionProtection -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the replication set to update.
    UpdateDeletionProtection -> Text
arn :: Prelude.Text,
    -- | Specifies if deletion protection is turned on or off in your account.
    UpdateDeletionProtection -> Bool
deletionProtected :: Prelude.Bool
  }
  deriving (UpdateDeletionProtection -> UpdateDeletionProtection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDeletionProtection -> UpdateDeletionProtection -> Bool
$c/= :: UpdateDeletionProtection -> UpdateDeletionProtection -> Bool
== :: UpdateDeletionProtection -> UpdateDeletionProtection -> Bool
$c== :: UpdateDeletionProtection -> UpdateDeletionProtection -> Bool
Prelude.Eq, ReadPrec [UpdateDeletionProtection]
ReadPrec UpdateDeletionProtection
Int -> ReadS UpdateDeletionProtection
ReadS [UpdateDeletionProtection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDeletionProtection]
$creadListPrec :: ReadPrec [UpdateDeletionProtection]
readPrec :: ReadPrec UpdateDeletionProtection
$creadPrec :: ReadPrec UpdateDeletionProtection
readList :: ReadS [UpdateDeletionProtection]
$creadList :: ReadS [UpdateDeletionProtection]
readsPrec :: Int -> ReadS UpdateDeletionProtection
$creadsPrec :: Int -> ReadS UpdateDeletionProtection
Prelude.Read, Int -> UpdateDeletionProtection -> ShowS
[UpdateDeletionProtection] -> ShowS
UpdateDeletionProtection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDeletionProtection] -> ShowS
$cshowList :: [UpdateDeletionProtection] -> ShowS
show :: UpdateDeletionProtection -> String
$cshow :: UpdateDeletionProtection -> String
showsPrec :: Int -> UpdateDeletionProtection -> ShowS
$cshowsPrec :: Int -> UpdateDeletionProtection -> ShowS
Prelude.Show, forall x.
Rep UpdateDeletionProtection x -> UpdateDeletionProtection
forall x.
UpdateDeletionProtection -> Rep UpdateDeletionProtection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDeletionProtection x -> UpdateDeletionProtection
$cfrom :: forall x.
UpdateDeletionProtection -> Rep UpdateDeletionProtection x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDeletionProtection' 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:
--
-- 'clientToken', 'updateDeletionProtection_clientToken' - A token that ensures that the operation is called only once with the
-- specified details.
--
-- 'arn', 'updateDeletionProtection_arn' - The Amazon Resource Name (ARN) of the replication set to update.
--
-- 'deletionProtected', 'updateDeletionProtection_deletionProtected' - Specifies if deletion protection is turned on or off in your account.
newUpdateDeletionProtection ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'deletionProtected'
  Prelude.Bool ->
  UpdateDeletionProtection
newUpdateDeletionProtection :: Text -> Bool -> UpdateDeletionProtection
newUpdateDeletionProtection Text
pArn_ Bool
pDeletionProtected_ =
  UpdateDeletionProtection'
    { $sel:clientToken:UpdateDeletionProtection' :: Maybe Text
clientToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UpdateDeletionProtection' :: Text
arn = Text
pArn_,
      $sel:deletionProtected:UpdateDeletionProtection' :: Bool
deletionProtected = Bool
pDeletionProtected_
    }

-- | A token that ensures that the operation is called only once with the
-- specified details.
updateDeletionProtection_clientToken :: Lens.Lens' UpdateDeletionProtection (Prelude.Maybe Prelude.Text)
updateDeletionProtection_clientToken :: Lens' UpdateDeletionProtection (Maybe Text)
updateDeletionProtection_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeletionProtection' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateDeletionProtection' :: UpdateDeletionProtection -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateDeletionProtection
s@UpdateDeletionProtection' {} Maybe Text
a -> UpdateDeletionProtection
s {$sel:clientToken:UpdateDeletionProtection' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateDeletionProtection)

-- | The Amazon Resource Name (ARN) of the replication set to update.
updateDeletionProtection_arn :: Lens.Lens' UpdateDeletionProtection Prelude.Text
updateDeletionProtection_arn :: Lens' UpdateDeletionProtection Text
updateDeletionProtection_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeletionProtection' {Text
arn :: Text
$sel:arn:UpdateDeletionProtection' :: UpdateDeletionProtection -> Text
arn} -> Text
arn) (\s :: UpdateDeletionProtection
s@UpdateDeletionProtection' {} Text
a -> UpdateDeletionProtection
s {$sel:arn:UpdateDeletionProtection' :: Text
arn = Text
a} :: UpdateDeletionProtection)

-- | Specifies if deletion protection is turned on or off in your account.
updateDeletionProtection_deletionProtected :: Lens.Lens' UpdateDeletionProtection Prelude.Bool
updateDeletionProtection_deletionProtected :: Lens' UpdateDeletionProtection Bool
updateDeletionProtection_deletionProtected = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeletionProtection' {Bool
deletionProtected :: Bool
$sel:deletionProtected:UpdateDeletionProtection' :: UpdateDeletionProtection -> Bool
deletionProtected} -> Bool
deletionProtected) (\s :: UpdateDeletionProtection
s@UpdateDeletionProtection' {} Bool
a -> UpdateDeletionProtection
s {$sel:deletionProtected:UpdateDeletionProtection' :: Bool
deletionProtected = Bool
a} :: UpdateDeletionProtection)

instance Core.AWSRequest UpdateDeletionProtection where
  type
    AWSResponse UpdateDeletionProtection =
      UpdateDeletionProtectionResponse
  request :: (Service -> Service)
-> UpdateDeletionProtection -> Request UpdateDeletionProtection
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateDeletionProtection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDeletionProtection)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateDeletionProtectionResponse
UpdateDeletionProtectionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateDeletionProtection where
  hashWithSalt :: Int -> UpdateDeletionProtection -> Int
hashWithSalt Int
_salt UpdateDeletionProtection' {Bool
Maybe Text
Text
deletionProtected :: Bool
arn :: Text
clientToken :: Maybe Text
$sel:deletionProtected:UpdateDeletionProtection' :: UpdateDeletionProtection -> Bool
$sel:arn:UpdateDeletionProtection' :: UpdateDeletionProtection -> Text
$sel:clientToken:UpdateDeletionProtection' :: UpdateDeletionProtection -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
deletionProtected

instance Prelude.NFData UpdateDeletionProtection where
  rnf :: UpdateDeletionProtection -> ()
rnf UpdateDeletionProtection' {Bool
Maybe Text
Text
deletionProtected :: Bool
arn :: Text
clientToken :: Maybe Text
$sel:deletionProtected:UpdateDeletionProtection' :: UpdateDeletionProtection -> Bool
$sel:arn:UpdateDeletionProtection' :: UpdateDeletionProtection -> Text
$sel:clientToken:UpdateDeletionProtection' :: UpdateDeletionProtection -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
deletionProtected

instance Data.ToHeaders UpdateDeletionProtection where
  toHeaders :: UpdateDeletionProtection -> 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 UpdateDeletionProtection where
  toJSON :: UpdateDeletionProtection -> Value
toJSON UpdateDeletionProtection' {Bool
Maybe Text
Text
deletionProtected :: Bool
arn :: Text
clientToken :: Maybe Text
$sel:deletionProtected:UpdateDeletionProtection' :: UpdateDeletionProtection -> Bool
$sel:arn:UpdateDeletionProtection' :: UpdateDeletionProtection -> Text
$sel:clientToken:UpdateDeletionProtection' :: UpdateDeletionProtection -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" 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
clientToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"deletionProtected" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
deletionProtected)
          ]
      )

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

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

-- | /See:/ 'newUpdateDeletionProtectionResponse' smart constructor.
data UpdateDeletionProtectionResponse = UpdateDeletionProtectionResponse'
  { -- | The response's http status code.
    UpdateDeletionProtectionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateDeletionProtectionResponse
-> UpdateDeletionProtectionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDeletionProtectionResponse
-> UpdateDeletionProtectionResponse -> Bool
$c/= :: UpdateDeletionProtectionResponse
-> UpdateDeletionProtectionResponse -> Bool
== :: UpdateDeletionProtectionResponse
-> UpdateDeletionProtectionResponse -> Bool
$c== :: UpdateDeletionProtectionResponse
-> UpdateDeletionProtectionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDeletionProtectionResponse]
ReadPrec UpdateDeletionProtectionResponse
Int -> ReadS UpdateDeletionProtectionResponse
ReadS [UpdateDeletionProtectionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDeletionProtectionResponse]
$creadListPrec :: ReadPrec [UpdateDeletionProtectionResponse]
readPrec :: ReadPrec UpdateDeletionProtectionResponse
$creadPrec :: ReadPrec UpdateDeletionProtectionResponse
readList :: ReadS [UpdateDeletionProtectionResponse]
$creadList :: ReadS [UpdateDeletionProtectionResponse]
readsPrec :: Int -> ReadS UpdateDeletionProtectionResponse
$creadsPrec :: Int -> ReadS UpdateDeletionProtectionResponse
Prelude.Read, Int -> UpdateDeletionProtectionResponse -> ShowS
[UpdateDeletionProtectionResponse] -> ShowS
UpdateDeletionProtectionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDeletionProtectionResponse] -> ShowS
$cshowList :: [UpdateDeletionProtectionResponse] -> ShowS
show :: UpdateDeletionProtectionResponse -> String
$cshow :: UpdateDeletionProtectionResponse -> String
showsPrec :: Int -> UpdateDeletionProtectionResponse -> ShowS
$cshowsPrec :: Int -> UpdateDeletionProtectionResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateDeletionProtectionResponse x
-> UpdateDeletionProtectionResponse
forall x.
UpdateDeletionProtectionResponse
-> Rep UpdateDeletionProtectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDeletionProtectionResponse x
-> UpdateDeletionProtectionResponse
$cfrom :: forall x.
UpdateDeletionProtectionResponse
-> Rep UpdateDeletionProtectionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDeletionProtectionResponse' 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:
--
-- 'httpStatus', 'updateDeletionProtectionResponse_httpStatus' - The response's http status code.
newUpdateDeletionProtectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateDeletionProtectionResponse
newUpdateDeletionProtectionResponse :: Int -> UpdateDeletionProtectionResponse
newUpdateDeletionProtectionResponse Int
pHttpStatus_ =
  UpdateDeletionProtectionResponse'
    { $sel:httpStatus:UpdateDeletionProtectionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateDeletionProtectionResponse_httpStatus :: Lens.Lens' UpdateDeletionProtectionResponse Prelude.Int
updateDeletionProtectionResponse_httpStatus :: Lens' UpdateDeletionProtectionResponse Int
updateDeletionProtectionResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeletionProtectionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateDeletionProtectionResponse' :: UpdateDeletionProtectionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateDeletionProtectionResponse
s@UpdateDeletionProtectionResponse' {} Int
a -> UpdateDeletionProtectionResponse
s {$sel:httpStatus:UpdateDeletionProtectionResponse' :: Int
httpStatus = Int
a} :: UpdateDeletionProtectionResponse)

instance
  Prelude.NFData
    UpdateDeletionProtectionResponse
  where
  rnf :: UpdateDeletionProtectionResponse -> ()
rnf UpdateDeletionProtectionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateDeletionProtectionResponse' :: UpdateDeletionProtectionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus