{-# 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-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 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.Lens as Lens
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
(DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool)
-> (DeleteClusterSnapshot -> DeleteClusterSnapshot -> Bool)
-> Eq DeleteClusterSnapshot
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]
(Int -> ReadS DeleteClusterSnapshot)
-> ReadS [DeleteClusterSnapshot]
-> ReadPrec DeleteClusterSnapshot
-> ReadPrec [DeleteClusterSnapshot]
-> Read 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
(Int -> DeleteClusterSnapshot -> ShowS)
-> (DeleteClusterSnapshot -> String)
-> ([DeleteClusterSnapshot] -> ShowS)
-> Show DeleteClusterSnapshot
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. DeleteClusterSnapshot -> Rep DeleteClusterSnapshot x)
-> (forall x. Rep DeleteClusterSnapshot x -> DeleteClusterSnapshot)
-> Generic DeleteClusterSnapshot
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' :: Maybe Text -> Text -> DeleteClusterSnapshot
DeleteClusterSnapshot'
    { $sel:snapshotClusterIdentifier:DeleteClusterSnapshot' :: Maybe Text
snapshotClusterIdentifier =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteClusterSnapshot -> f DeleteClusterSnapshot
deleteClusterSnapshot_snapshotClusterIdentifier = (DeleteClusterSnapshot -> Maybe Text)
-> (DeleteClusterSnapshot -> Maybe Text -> DeleteClusterSnapshot)
-> Lens
     DeleteClusterSnapshot
     DeleteClusterSnapshot
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> DeleteClusterSnapshot -> f DeleteClusterSnapshot
deleteClusterSnapshot_snapshotIdentifier = (DeleteClusterSnapshot -> Text)
-> (DeleteClusterSnapshot -> Text -> DeleteClusterSnapshot)
-> Lens DeleteClusterSnapshot DeleteClusterSnapshot Text Text
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 :: DeleteClusterSnapshot -> Request DeleteClusterSnapshot
request = Service -> DeleteClusterSnapshot -> Request DeleteClusterSnapshot
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteClusterSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteClusterSnapshot)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteClusterSnapshot))
-> Logger
-> Service
-> Proxy DeleteClusterSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteClusterSnapshot)))
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
"DeleteClusterSnapshotResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Snapshot -> Int -> DeleteClusterSnapshotResponse
DeleteClusterSnapshotResponse'
            (Maybe Snapshot -> Int -> DeleteClusterSnapshotResponse)
-> Either String (Maybe Snapshot)
-> Either String (Int -> DeleteClusterSnapshotResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Snapshot)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Snapshot")
            Either String (Int -> DeleteClusterSnapshotResponse)
-> Either String Int -> Either String DeleteClusterSnapshotResponse
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 DeleteClusterSnapshot

instance Prelude.NFData DeleteClusterSnapshot

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteClusterSnapshot" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"SnapshotClusterIdentifier"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
snapshotClusterIdentifier,
        ByteString
"SnapshotIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DeleteClusterSnapshotResponse
 -> DeleteClusterSnapshotResponse -> Bool)
-> (DeleteClusterSnapshotResponse
    -> DeleteClusterSnapshotResponse -> Bool)
-> Eq DeleteClusterSnapshotResponse
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]
(Int -> ReadS DeleteClusterSnapshotResponse)
-> ReadS [DeleteClusterSnapshotResponse]
-> ReadPrec DeleteClusterSnapshotResponse
-> ReadPrec [DeleteClusterSnapshotResponse]
-> Read 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
(Int -> DeleteClusterSnapshotResponse -> ShowS)
-> (DeleteClusterSnapshotResponse -> String)
-> ([DeleteClusterSnapshotResponse] -> ShowS)
-> Show DeleteClusterSnapshotResponse
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.
 DeleteClusterSnapshotResponse
 -> Rep DeleteClusterSnapshotResponse x)
-> (forall x.
    Rep DeleteClusterSnapshotResponse x
    -> DeleteClusterSnapshotResponse)
-> Generic DeleteClusterSnapshotResponse
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' :: Maybe Snapshot -> Int -> DeleteClusterSnapshotResponse
DeleteClusterSnapshotResponse'
    { $sel:snapshot:DeleteClusterSnapshotResponse' :: Maybe Snapshot
snapshot =
        Maybe 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 :: (Maybe Snapshot -> f (Maybe Snapshot))
-> DeleteClusterSnapshotResponse -> f DeleteClusterSnapshotResponse
deleteClusterSnapshotResponse_snapshot = (DeleteClusterSnapshotResponse -> Maybe Snapshot)
-> (DeleteClusterSnapshotResponse
    -> Maybe Snapshot -> DeleteClusterSnapshotResponse)
-> Lens
     DeleteClusterSnapshotResponse
     DeleteClusterSnapshotResponse
     (Maybe Snapshot)
     (Maybe 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 :: (Int -> f Int)
-> DeleteClusterSnapshotResponse -> f DeleteClusterSnapshotResponse
deleteClusterSnapshotResponse_httpStatus = (DeleteClusterSnapshotResponse -> Int)
-> (DeleteClusterSnapshotResponse
    -> Int -> DeleteClusterSnapshotResponse)
-> Lens
     DeleteClusterSnapshotResponse DeleteClusterSnapshotResponse Int Int
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