{-# 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.DeleteClusterSnapshot
-- 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 the specified manual snapshot. The snapshot must be in the
-- @available@ state, with no other users authorized to access the
-- snapshot.
--
-- Unlike automated snapshots, manual snapshots are retained even after you
-- delete your cluster. Amazon Redshift does not delete your manual
-- snapshots. You must delete manual snapshot explicitly to avoid getting
-- charged. If other accounts are authorized to access the snapshot, you
-- must revoke all of the authorizations before you can delete the
-- snapshot.
module Amazonka.Redshift.DeleteClusterSnapshot
  ( -- * Creating a Request
    DeleteClusterSnapshot (..),
    newDeleteClusterSnapshot,

    -- * Request Lenses
    deleteClusterSnapshot_snapshotClusterIdentifier,
    deleteClusterSnapshot_snapshotIdentifier,

    -- * Destructuring the Response
    DeleteClusterSnapshotResponse (..),
    newDeleteClusterSnapshotResponse,

    -- * Response Lenses
    deleteClusterSnapshotResponse_snapshot,
    deleteClusterSnapshotResponse_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 Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newDeleteClusterSnapshot' smart constructor.
data DeleteClusterSnapshot = DeleteClusterSnapshot'
  { -- | The unique identifier of the cluster the snapshot was created from. This
    -- parameter is required if your IAM user has a policy containing a
    -- snapshot resource element that specifies anything other than * for the
    -- cluster name.
    --
    -- Constraints: Must be the name of valid cluster.
    DeleteClusterSnapshot -> Maybe Text
snapshotClusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the manual snapshot to be deleted.
    --
    -- Constraints: Must be the name of an existing snapshot that is in the
    -- @available@, @failed@, or @cancelled@ state.
    DeleteClusterSnapshot -> Text
snapshotIdentifier :: Prelude.Text
  }
  deriving (DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool
$c/= :: DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool
== :: DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool
$c== :: DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool
Prelude.Eq, ReadPrec [DeleteClusterSnapshot]
ReadPrec DeleteClusterSnapshot
Int -> ReadS DeleteClusterSnapshot
ReadS [DeleteClusterSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteClusterSnapshot]
$creadListPrec :: ReadPrec [DeleteClusterSnapshot]
readPrec :: ReadPrec DeleteClusterSnapshot
$creadPrec :: ReadPrec DeleteClusterSnapshot
readList :: ReadS [DeleteClusterSnapshot]
$creadList :: ReadS [DeleteClusterSnapshot]
readsPrec :: Int -> ReadS DeleteClusterSnapshot
$creadsPrec :: Int -> ReadS DeleteClusterSnapshot
Prelude.Read, Int -> DeleteClusterSnapshot -> ShowS
[DeleteClusterSnapshot] -> ShowS
DeleteClusterSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteClusterSnapshot] -> ShowS
$cshowList :: [DeleteClusterSnapshot] -> ShowS
show :: DeleteClusterSnapshot -> String
$cshow :: DeleteClusterSnapshot -> String
showsPrec :: Int -> DeleteClusterSnapshot -> ShowS
$cshowsPrec :: Int -> DeleteClusterSnapshot -> ShowS
Prelude.Show, forall x. Rep DeleteClusterSnapshot x -> DeleteClusterSnapshot
forall x. DeleteClusterSnapshot -> Rep DeleteClusterSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteClusterSnapshot x -> DeleteClusterSnapshot
$cfrom :: forall x. DeleteClusterSnapshot -> Rep DeleteClusterSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'DeleteClusterSnapshot' 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:
--
-- 'snapshotClusterIdentifier', 'deleteClusterSnapshot_snapshotClusterIdentifier' - The unique identifier of the cluster the snapshot was created from. This
-- parameter is required if your IAM user has a policy containing a
-- snapshot resource element that specifies anything other than * for the
-- cluster name.
--
-- Constraints: Must be the name of valid cluster.
--
-- 'snapshotIdentifier', 'deleteClusterSnapshot_snapshotIdentifier' - The unique identifier of the manual snapshot to be deleted.
--
-- Constraints: Must be the name of an existing snapshot that is in the
-- @available@, @failed@, or @cancelled@ state.
newDeleteClusterSnapshot ::
  -- | 'snapshotIdentifier'
  Prelude.Text ->
  DeleteClusterSnapshot
newDeleteClusterSnapshot :: Text -> DeleteClusterSnapshot
newDeleteClusterSnapshot Text
pSnapshotIdentifier_ =
  DeleteClusterSnapshot'
    { $sel:snapshotClusterIdentifier:DeleteClusterSnapshot' :: Maybe Text
snapshotClusterIdentifier =
        forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotIdentifier:DeleteClusterSnapshot' :: Text
snapshotIdentifier = Text
pSnapshotIdentifier_
    }

-- | The unique identifier of the cluster the snapshot was created from. This
-- parameter is required if your IAM user has a policy containing a
-- snapshot resource element that specifies anything other than * for the
-- cluster name.
--
-- Constraints: Must be the name of valid cluster.
deleteClusterSnapshot_snapshotClusterIdentifier :: Lens.Lens' DeleteClusterSnapshot (Prelude.Maybe Prelude.Text)
deleteClusterSnapshot_snapshotClusterIdentifier :: Lens' DeleteClusterSnapshot (Maybe Text)
deleteClusterSnapshot_snapshotClusterIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteClusterSnapshot' {Maybe Text
snapshotClusterIdentifier :: Maybe Text
$sel:snapshotClusterIdentifier:DeleteClusterSnapshot' :: DeleteClusterSnapshot -> Maybe Text
snapshotClusterIdentifier} -> Maybe Text
snapshotClusterIdentifier) (\s :: DeleteClusterSnapshot
s@DeleteClusterSnapshot' {} Maybe Text
a -> DeleteClusterSnapshot
s {$sel:snapshotClusterIdentifier:DeleteClusterSnapshot' :: Maybe Text
snapshotClusterIdentifier = Maybe Text
a} :: DeleteClusterSnapshot)

-- | The unique identifier of the manual snapshot to be deleted.
--
-- Constraints: Must be the name of an existing snapshot that is in the
-- @available@, @failed@, or @cancelled@ state.
deleteClusterSnapshot_snapshotIdentifier :: Lens.Lens' DeleteClusterSnapshot Prelude.Text
deleteClusterSnapshot_snapshotIdentifier :: Lens' DeleteClusterSnapshot Text
deleteClusterSnapshot_snapshotIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteClusterSnapshot' {Text
snapshotIdentifier :: Text
$sel:snapshotIdentifier:DeleteClusterSnapshot' :: DeleteClusterSnapshot -> Text
snapshotIdentifier} -> Text
snapshotIdentifier) (\s :: DeleteClusterSnapshot
s@DeleteClusterSnapshot' {} Text
a -> DeleteClusterSnapshot
s {$sel:snapshotIdentifier:DeleteClusterSnapshot' :: Text
snapshotIdentifier = Text
a} :: DeleteClusterSnapshot)

instance Core.AWSRequest DeleteClusterSnapshot where
  type
    AWSResponse DeleteClusterSnapshot =
      DeleteClusterSnapshotResponse
  request :: (Service -> Service)
-> DeleteClusterSnapshot -> Request DeleteClusterSnapshot
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 DeleteClusterSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteClusterSnapshot)))
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
"DeleteClusterSnapshotResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Snapshot -> Int -> DeleteClusterSnapshotResponse
DeleteClusterSnapshotResponse'
            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
"Snapshot")
            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 DeleteClusterSnapshot where
  hashWithSalt :: Int -> DeleteClusterSnapshot -> Int
hashWithSalt Int
_salt DeleteClusterSnapshot' {Maybe Text
Text
snapshotIdentifier :: Text
snapshotClusterIdentifier :: Maybe Text
$sel:snapshotIdentifier:DeleteClusterSnapshot' :: DeleteClusterSnapshot -> Text
$sel:snapshotClusterIdentifier:DeleteClusterSnapshot' :: DeleteClusterSnapshot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snapshotClusterIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snapshotIdentifier

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

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

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

instance Data.ToQuery DeleteClusterSnapshot where
  toQuery :: DeleteClusterSnapshot -> QueryString
toQuery DeleteClusterSnapshot' {Maybe Text
Text
snapshotIdentifier :: Text
snapshotClusterIdentifier :: Maybe Text
$sel:snapshotIdentifier:DeleteClusterSnapshot' :: DeleteClusterSnapshot -> Text
$sel:snapshotClusterIdentifier:DeleteClusterSnapshot' :: DeleteClusterSnapshot -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteClusterSnapshot" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"SnapshotClusterIdentifier"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
snapshotClusterIdentifier,
        ByteString
"SnapshotIdentifier" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
snapshotIdentifier
      ]

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

-- |
-- Create a value of 'DeleteClusterSnapshotResponse' 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:
--
-- 'snapshot', 'deleteClusterSnapshotResponse_snapshot' - Undocumented member.
--
-- 'httpStatus', 'deleteClusterSnapshotResponse_httpStatus' - The response's http status code.
newDeleteClusterSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteClusterSnapshotResponse
newDeleteClusterSnapshotResponse :: Int -> DeleteClusterSnapshotResponse
newDeleteClusterSnapshotResponse Int
pHttpStatus_ =
  DeleteClusterSnapshotResponse'
    { $sel:snapshot:DeleteClusterSnapshotResponse' :: Maybe Snapshot
snapshot =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteClusterSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteClusterSnapshotResponse_snapshot :: Lens.Lens' DeleteClusterSnapshotResponse (Prelude.Maybe Snapshot)
deleteClusterSnapshotResponse_snapshot :: Lens' DeleteClusterSnapshotResponse (Maybe Snapshot)
deleteClusterSnapshotResponse_snapshot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteClusterSnapshotResponse' {Maybe Snapshot
snapshot :: Maybe Snapshot
$sel:snapshot:DeleteClusterSnapshotResponse' :: DeleteClusterSnapshotResponse -> Maybe Snapshot
snapshot} -> Maybe Snapshot
snapshot) (\s :: DeleteClusterSnapshotResponse
s@DeleteClusterSnapshotResponse' {} Maybe Snapshot
a -> DeleteClusterSnapshotResponse
s {$sel:snapshot:DeleteClusterSnapshotResponse' :: Maybe Snapshot
snapshot = Maybe Snapshot
a} :: DeleteClusterSnapshotResponse)

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

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