{-# 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-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)
--
-- 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 Amazonka.ElastiCache.Types
import qualified Amazonka.Lens as Lens
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
(DeleteCacheCluster -> DeleteCacheCluster -> Bool)
-> (DeleteCacheCluster -> DeleteCacheCluster -> Bool)
-> Eq DeleteCacheCluster
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]
(Int -> ReadS DeleteCacheCluster)
-> ReadS [DeleteCacheCluster]
-> ReadPrec DeleteCacheCluster
-> ReadPrec [DeleteCacheCluster]
-> Read 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
(Int -> DeleteCacheCluster -> ShowS)
-> (DeleteCacheCluster -> String)
-> ([DeleteCacheCluster] -> ShowS)
-> Show DeleteCacheCluster
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. DeleteCacheCluster -> Rep DeleteCacheCluster x)
-> (forall x. Rep DeleteCacheCluster x -> DeleteCacheCluster)
-> Generic DeleteCacheCluster
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' :: Maybe Text -> Text -> DeleteCacheCluster
DeleteCacheCluster'
    { $sel:finalSnapshotIdentifier:DeleteCacheCluster' :: Maybe Text
finalSnapshotIdentifier =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteCacheCluster -> f DeleteCacheCluster
deleteCacheCluster_finalSnapshotIdentifier = (DeleteCacheCluster -> Maybe Text)
-> (DeleteCacheCluster -> Maybe Text -> DeleteCacheCluster)
-> Lens
     DeleteCacheCluster DeleteCacheCluster (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeleteCacheCluster -> f DeleteCacheCluster
deleteCacheCluster_cacheClusterId = (DeleteCacheCluster -> Text)
-> (DeleteCacheCluster -> Text -> DeleteCacheCluster)
-> Lens DeleteCacheCluster DeleteCacheCluster Text Text
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 :: DeleteCacheCluster -> Request DeleteCacheCluster
request = Service -> DeleteCacheCluster -> Request DeleteCacheCluster
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteCacheCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCacheCluster)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteCacheCluster))
-> Logger
-> Service
-> Proxy DeleteCacheCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCacheCluster)))
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
"DeleteCacheClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe CacheCluster -> Int -> DeleteCacheClusterResponse
DeleteCacheClusterResponse'
            (Maybe CacheCluster -> Int -> DeleteCacheClusterResponse)
-> Either String (Maybe CacheCluster)
-> Either String (Int -> DeleteCacheClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe CacheCluster)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CacheCluster")
            Either String (Int -> DeleteCacheClusterResponse)
-> Either String Int -> Either String DeleteCacheClusterResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteCacheCluster

instance Prelude.NFData DeleteCacheCluster

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteCacheCluster" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"FinalSnapshotIdentifier"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
finalSnapshotIdentifier,
        ByteString
"CacheClusterId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DeleteCacheClusterResponse -> DeleteCacheClusterResponse -> Bool)
-> (DeleteCacheClusterResponse
    -> DeleteCacheClusterResponse -> Bool)
-> Eq DeleteCacheClusterResponse
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]
(Int -> ReadS DeleteCacheClusterResponse)
-> ReadS [DeleteCacheClusterResponse]
-> ReadPrec DeleteCacheClusterResponse
-> ReadPrec [DeleteCacheClusterResponse]
-> Read 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
(Int -> DeleteCacheClusterResponse -> ShowS)
-> (DeleteCacheClusterResponse -> String)
-> ([DeleteCacheClusterResponse] -> ShowS)
-> Show DeleteCacheClusterResponse
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.
 DeleteCacheClusterResponse -> Rep DeleteCacheClusterResponse x)
-> (forall x.
    Rep DeleteCacheClusterResponse x -> DeleteCacheClusterResponse)
-> Generic DeleteCacheClusterResponse
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' :: Maybe CacheCluster -> Int -> DeleteCacheClusterResponse
DeleteCacheClusterResponse'
    { $sel:cacheCluster:DeleteCacheClusterResponse' :: Maybe CacheCluster
cacheCluster =
        Maybe 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 :: (Maybe CacheCluster -> f (Maybe CacheCluster))
-> DeleteCacheClusterResponse -> f DeleteCacheClusterResponse
deleteCacheClusterResponse_cacheCluster = (DeleteCacheClusterResponse -> Maybe CacheCluster)
-> (DeleteCacheClusterResponse
    -> Maybe CacheCluster -> DeleteCacheClusterResponse)
-> Lens
     DeleteCacheClusterResponse
     DeleteCacheClusterResponse
     (Maybe CacheCluster)
     (Maybe 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 :: (Int -> f Int)
-> DeleteCacheClusterResponse -> f DeleteCacheClusterResponse
deleteCacheClusterResponse_httpStatus = (DeleteCacheClusterResponse -> Int)
-> (DeleteCacheClusterResponse
    -> Int -> DeleteCacheClusterResponse)
-> Lens
     DeleteCacheClusterResponse DeleteCacheClusterResponse Int Int
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