{-# 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.ElastiCache.DeleteCacheCluster
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a previously provisioned cluster. @DeleteCacheCluster@ deletes
-- all associated cache nodes, node endpoints and the cluster itself. When
-- you receive a successful response from this operation, Amazon
-- ElastiCache immediately begins deleting the cluster; you cannot cancel
-- or revert this operation.
--
-- This operation is not valid for:
--
-- -   Redis (cluster mode enabled) clusters
--
-- -   Redis (cluster mode disabled) clusters
--
-- -   A cluster that is the last read replica of a replication group
--
-- -   A cluster that is the primary node of a replication group
--
-- -   A node group (shard) that has Multi-AZ mode enabled
--
-- -   A cluster from a Redis (cluster mode enabled) replication group
--
-- -   A cluster that is not in the @available@ state
module Amazonka.ElastiCache.DeleteCacheCluster
  ( -- * Creating a Request
    DeleteCacheCluster (..),
    newDeleteCacheCluster,

    -- * Request Lenses
    deleteCacheCluster_finalSnapshotIdentifier,
    deleteCacheCluster_cacheClusterId,

    -- * Destructuring the Response
    DeleteCacheClusterResponse (..),
    newDeleteCacheClusterResponse,

    -- * Response Lenses
    deleteCacheClusterResponse_cacheCluster,
    deleteCacheClusterResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElastiCache.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @DeleteCacheCluster@ operation.
--
-- /See:/ 'newDeleteCacheCluster' smart constructor.
data DeleteCacheCluster = DeleteCacheCluster'
  { -- | The user-supplied name of a final cluster snapshot. This is the unique
    -- name that identifies the snapshot. ElastiCache creates the snapshot, and
    -- then deletes the cluster immediately afterward.
    DeleteCacheCluster -> Maybe Text
finalSnapshotIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The cluster identifier for the cluster to be deleted. This parameter is
    -- not case sensitive.
    DeleteCacheCluster -> Text
cacheClusterId :: Prelude.Text
  }
  deriving (DeleteCacheCluster -> DeleteCacheCluster -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCacheCluster -> DeleteCacheCluster -> Bool
$c/= :: DeleteCacheCluster -> DeleteCacheCluster -> Bool
== :: DeleteCacheCluster -> DeleteCacheCluster -> Bool
$c== :: DeleteCacheCluster -> DeleteCacheCluster -> Bool
Prelude.Eq, ReadPrec [DeleteCacheCluster]
ReadPrec DeleteCacheCluster
Int -> ReadS DeleteCacheCluster
ReadS [DeleteCacheCluster]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCacheCluster]
$creadListPrec :: ReadPrec [DeleteCacheCluster]
readPrec :: ReadPrec DeleteCacheCluster
$creadPrec :: ReadPrec DeleteCacheCluster
readList :: ReadS [DeleteCacheCluster]
$creadList :: ReadS [DeleteCacheCluster]
readsPrec :: Int -> ReadS DeleteCacheCluster
$creadsPrec :: Int -> ReadS DeleteCacheCluster
Prelude.Read, Int -> DeleteCacheCluster -> ShowS
[DeleteCacheCluster] -> ShowS
DeleteCacheCluster -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCacheCluster] -> ShowS
$cshowList :: [DeleteCacheCluster] -> ShowS
show :: DeleteCacheCluster -> String
$cshow :: DeleteCacheCluster -> String
showsPrec :: Int -> DeleteCacheCluster -> ShowS
$cshowsPrec :: Int -> DeleteCacheCluster -> ShowS
Prelude.Show, forall x. Rep DeleteCacheCluster x -> DeleteCacheCluster
forall x. DeleteCacheCluster -> Rep DeleteCacheCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCacheCluster x -> DeleteCacheCluster
$cfrom :: forall x. DeleteCacheCluster -> Rep DeleteCacheCluster x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCacheCluster' 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:
--
-- 'finalSnapshotIdentifier', 'deleteCacheCluster_finalSnapshotIdentifier' - The user-supplied name of a final cluster snapshot. This is the unique
-- name that identifies the snapshot. ElastiCache creates the snapshot, and
-- then deletes the cluster immediately afterward.
--
-- 'cacheClusterId', 'deleteCacheCluster_cacheClusterId' - The cluster identifier for the cluster to be deleted. This parameter is
-- not case sensitive.
newDeleteCacheCluster ::
  -- | 'cacheClusterId'
  Prelude.Text ->
  DeleteCacheCluster
newDeleteCacheCluster :: Text -> DeleteCacheCluster
newDeleteCacheCluster Text
pCacheClusterId_ =
  DeleteCacheCluster'
    { $sel:finalSnapshotIdentifier:DeleteCacheCluster' :: Maybe Text
finalSnapshotIdentifier =
        forall a. Maybe a
Prelude.Nothing,
      $sel:cacheClusterId:DeleteCacheCluster' :: Text
cacheClusterId = Text
pCacheClusterId_
    }

-- | The user-supplied name of a final cluster snapshot. This is the unique
-- name that identifies the snapshot. ElastiCache creates the snapshot, and
-- then deletes the cluster immediately afterward.
deleteCacheCluster_finalSnapshotIdentifier :: Lens.Lens' DeleteCacheCluster (Prelude.Maybe Prelude.Text)
deleteCacheCluster_finalSnapshotIdentifier :: Lens' DeleteCacheCluster (Maybe Text)
deleteCacheCluster_finalSnapshotIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCacheCluster' {Maybe Text
finalSnapshotIdentifier :: Maybe Text
$sel:finalSnapshotIdentifier:DeleteCacheCluster' :: DeleteCacheCluster -> Maybe Text
finalSnapshotIdentifier} -> Maybe Text
finalSnapshotIdentifier) (\s :: DeleteCacheCluster
s@DeleteCacheCluster' {} Maybe Text
a -> DeleteCacheCluster
s {$sel:finalSnapshotIdentifier:DeleteCacheCluster' :: Maybe Text
finalSnapshotIdentifier = Maybe Text
a} :: DeleteCacheCluster)

-- | The cluster identifier for the cluster to be deleted. This parameter is
-- not case sensitive.
deleteCacheCluster_cacheClusterId :: Lens.Lens' DeleteCacheCluster Prelude.Text
deleteCacheCluster_cacheClusterId :: Lens' DeleteCacheCluster Text
deleteCacheCluster_cacheClusterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCacheCluster' {Text
cacheClusterId :: Text
$sel:cacheClusterId:DeleteCacheCluster' :: DeleteCacheCluster -> Text
cacheClusterId} -> Text
cacheClusterId) (\s :: DeleteCacheCluster
s@DeleteCacheCluster' {} Text
a -> DeleteCacheCluster
s {$sel:cacheClusterId:DeleteCacheCluster' :: Text
cacheClusterId = Text
a} :: DeleteCacheCluster)

instance Core.AWSRequest DeleteCacheCluster where
  type
    AWSResponse DeleteCacheCluster =
      DeleteCacheClusterResponse
  request :: (Service -> Service)
-> DeleteCacheCluster -> Request DeleteCacheCluster
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 DeleteCacheCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCacheCluster)))
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
"DeleteCacheClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe CacheCluster -> Int -> DeleteCacheClusterResponse
DeleteCacheClusterResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CacheCluster")
            forall (f :: * -> *) a b. Applicative f => 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 DeleteCacheCluster where
  hashWithSalt :: Int -> DeleteCacheCluster -> Int
hashWithSalt Int
_salt DeleteCacheCluster' {Maybe Text
Text
cacheClusterId :: Text
finalSnapshotIdentifier :: Maybe Text
$sel:cacheClusterId:DeleteCacheCluster' :: DeleteCacheCluster -> Text
$sel:finalSnapshotIdentifier:DeleteCacheCluster' :: DeleteCacheCluster -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
finalSnapshotIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
cacheClusterId

instance Prelude.NFData DeleteCacheCluster where
  rnf :: DeleteCacheCluster -> ()
rnf DeleteCacheCluster' {Maybe Text
Text
cacheClusterId :: Text
finalSnapshotIdentifier :: Maybe Text
$sel:cacheClusterId:DeleteCacheCluster' :: DeleteCacheCluster -> Text
$sel:finalSnapshotIdentifier:DeleteCacheCluster' :: DeleteCacheCluster -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
finalSnapshotIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
cacheClusterId

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

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

instance Data.ToQuery DeleteCacheCluster where
  toQuery :: DeleteCacheCluster -> QueryString
toQuery DeleteCacheCluster' {Maybe Text
Text
cacheClusterId :: Text
finalSnapshotIdentifier :: Maybe Text
$sel:cacheClusterId:DeleteCacheCluster' :: DeleteCacheCluster -> Text
$sel:finalSnapshotIdentifier:DeleteCacheCluster' :: DeleteCacheCluster -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteCacheCluster" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"FinalSnapshotIdentifier"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
finalSnapshotIdentifier,
        ByteString
"CacheClusterId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
cacheClusterId
      ]

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

-- |
-- Create a value of 'DeleteCacheClusterResponse' 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:
--
-- 'cacheCluster', 'deleteCacheClusterResponse_cacheCluster' - Undocumented member.
--
-- 'httpStatus', 'deleteCacheClusterResponse_httpStatus' - The response's http status code.
newDeleteCacheClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCacheClusterResponse
newDeleteCacheClusterResponse :: Int -> DeleteCacheClusterResponse
newDeleteCacheClusterResponse Int
pHttpStatus_ =
  DeleteCacheClusterResponse'
    { $sel:cacheCluster:DeleteCacheClusterResponse' :: Maybe CacheCluster
cacheCluster =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCacheClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteCacheClusterResponse_cacheCluster :: Lens.Lens' DeleteCacheClusterResponse (Prelude.Maybe CacheCluster)
deleteCacheClusterResponse_cacheCluster :: Lens' DeleteCacheClusterResponse (Maybe CacheCluster)
deleteCacheClusterResponse_cacheCluster = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCacheClusterResponse' {Maybe CacheCluster
cacheCluster :: Maybe CacheCluster
$sel:cacheCluster:DeleteCacheClusterResponse' :: DeleteCacheClusterResponse -> Maybe CacheCluster
cacheCluster} -> Maybe CacheCluster
cacheCluster) (\s :: DeleteCacheClusterResponse
s@DeleteCacheClusterResponse' {} Maybe CacheCluster
a -> DeleteCacheClusterResponse
s {$sel:cacheCluster:DeleteCacheClusterResponse' :: Maybe CacheCluster
cacheCluster = Maybe CacheCluster
a} :: DeleteCacheClusterResponse)

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

instance Prelude.NFData DeleteCacheClusterResponse where
  rnf :: DeleteCacheClusterResponse -> ()
rnf DeleteCacheClusterResponse' {Int
Maybe CacheCluster
httpStatus :: Int
cacheCluster :: Maybe CacheCluster
$sel:httpStatus:DeleteCacheClusterResponse' :: DeleteCacheClusterResponse -> Int
$sel:cacheCluster:DeleteCacheClusterResponse' :: DeleteCacheClusterResponse -> Maybe CacheCluster
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CacheCluster
cacheCluster
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus