{-# 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.Lightsail.DeleteDiskSnapshot
-- 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 disk snapshot.
--
-- When you make periodic snapshots of a disk, the snapshots are
-- incremental, and only the blocks on the device that have changed since
-- your last snapshot are saved in the new snapshot. When you delete a
-- snapshot, only the data not needed for any other snapshot is removed. So
-- regardless of which prior snapshots have been deleted, all active
-- snapshots will have access to all the information needed to restore the
-- disk.
--
-- The @delete disk snapshot@ operation supports tag-based access control
-- via resource tags applied to the resource identified by
-- @disk snapshot name@. For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.DeleteDiskSnapshot
  ( -- * Creating a Request
    DeleteDiskSnapshot (..),
    newDeleteDiskSnapshot,

    -- * Request Lenses
    deleteDiskSnapshot_diskSnapshotName,

    -- * Destructuring the Response
    DeleteDiskSnapshotResponse (..),
    newDeleteDiskSnapshotResponse,

    -- * Response Lenses
    deleteDiskSnapshotResponse_operations,
    deleteDiskSnapshotResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteDiskSnapshot' smart constructor.
data DeleteDiskSnapshot = DeleteDiskSnapshot'
  { -- | The name of the disk snapshot you want to delete (e.g.,
    -- @my-disk-snapshot@).
    DeleteDiskSnapshot -> Text
diskSnapshotName :: Prelude.Text
  }
  deriving (DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool
(DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool)
-> (DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool)
-> Eq DeleteDiskSnapshot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool
$c/= :: DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool
== :: DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool
$c== :: DeleteDiskSnapshot -> DeleteDiskSnapshot -> Bool
Prelude.Eq, ReadPrec [DeleteDiskSnapshot]
ReadPrec DeleteDiskSnapshot
Int -> ReadS DeleteDiskSnapshot
ReadS [DeleteDiskSnapshot]
(Int -> ReadS DeleteDiskSnapshot)
-> ReadS [DeleteDiskSnapshot]
-> ReadPrec DeleteDiskSnapshot
-> ReadPrec [DeleteDiskSnapshot]
-> Read DeleteDiskSnapshot
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDiskSnapshot]
$creadListPrec :: ReadPrec [DeleteDiskSnapshot]
readPrec :: ReadPrec DeleteDiskSnapshot
$creadPrec :: ReadPrec DeleteDiskSnapshot
readList :: ReadS [DeleteDiskSnapshot]
$creadList :: ReadS [DeleteDiskSnapshot]
readsPrec :: Int -> ReadS DeleteDiskSnapshot
$creadsPrec :: Int -> ReadS DeleteDiskSnapshot
Prelude.Read, Int -> DeleteDiskSnapshot -> ShowS
[DeleteDiskSnapshot] -> ShowS
DeleteDiskSnapshot -> String
(Int -> DeleteDiskSnapshot -> ShowS)
-> (DeleteDiskSnapshot -> String)
-> ([DeleteDiskSnapshot] -> ShowS)
-> Show DeleteDiskSnapshot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDiskSnapshot] -> ShowS
$cshowList :: [DeleteDiskSnapshot] -> ShowS
show :: DeleteDiskSnapshot -> String
$cshow :: DeleteDiskSnapshot -> String
showsPrec :: Int -> DeleteDiskSnapshot -> ShowS
$cshowsPrec :: Int -> DeleteDiskSnapshot -> ShowS
Prelude.Show, (forall x. DeleteDiskSnapshot -> Rep DeleteDiskSnapshot x)
-> (forall x. Rep DeleteDiskSnapshot x -> DeleteDiskSnapshot)
-> Generic DeleteDiskSnapshot
forall x. Rep DeleteDiskSnapshot x -> DeleteDiskSnapshot
forall x. DeleteDiskSnapshot -> Rep DeleteDiskSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDiskSnapshot x -> DeleteDiskSnapshot
$cfrom :: forall x. DeleteDiskSnapshot -> Rep DeleteDiskSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDiskSnapshot' 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:
--
-- 'diskSnapshotName', 'deleteDiskSnapshot_diskSnapshotName' - The name of the disk snapshot you want to delete (e.g.,
-- @my-disk-snapshot@).
newDeleteDiskSnapshot ::
  -- | 'diskSnapshotName'
  Prelude.Text ->
  DeleteDiskSnapshot
newDeleteDiskSnapshot :: Text -> DeleteDiskSnapshot
newDeleteDiskSnapshot Text
pDiskSnapshotName_ =
  DeleteDiskSnapshot' :: Text -> DeleteDiskSnapshot
DeleteDiskSnapshot'
    { $sel:diskSnapshotName:DeleteDiskSnapshot' :: Text
diskSnapshotName =
        Text
pDiskSnapshotName_
    }

-- | The name of the disk snapshot you want to delete (e.g.,
-- @my-disk-snapshot@).
deleteDiskSnapshot_diskSnapshotName :: Lens.Lens' DeleteDiskSnapshot Prelude.Text
deleteDiskSnapshot_diskSnapshotName :: (Text -> f Text) -> DeleteDiskSnapshot -> f DeleteDiskSnapshot
deleteDiskSnapshot_diskSnapshotName = (DeleteDiskSnapshot -> Text)
-> (DeleteDiskSnapshot -> Text -> DeleteDiskSnapshot)
-> Lens DeleteDiskSnapshot DeleteDiskSnapshot Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDiskSnapshot' {Text
diskSnapshotName :: Text
$sel:diskSnapshotName:DeleteDiskSnapshot' :: DeleteDiskSnapshot -> Text
diskSnapshotName} -> Text
diskSnapshotName) (\s :: DeleteDiskSnapshot
s@DeleteDiskSnapshot' {} Text
a -> DeleteDiskSnapshot
s {$sel:diskSnapshotName:DeleteDiskSnapshot' :: Text
diskSnapshotName = Text
a} :: DeleteDiskSnapshot)

instance Core.AWSRequest DeleteDiskSnapshot where
  type
    AWSResponse DeleteDiskSnapshot =
      DeleteDiskSnapshotResponse
  request :: DeleteDiskSnapshot -> Request DeleteDiskSnapshot
request = Service -> DeleteDiskSnapshot -> Request DeleteDiskSnapshot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDiskSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDiskSnapshot)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteDiskSnapshot))
-> Logger
-> Service
-> Proxy DeleteDiskSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDiskSnapshot)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> DeleteDiskSnapshotResponse
DeleteDiskSnapshotResponse'
            (Maybe [Operation] -> Int -> DeleteDiskSnapshotResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> DeleteDiskSnapshotResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DeleteDiskSnapshotResponse)
-> Either String Int -> Either String DeleteDiskSnapshotResponse
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 DeleteDiskSnapshot

instance Prelude.NFData DeleteDiskSnapshot

instance Core.ToHeaders DeleteDiskSnapshot where
  toHeaders :: DeleteDiskSnapshot -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDiskSnapshot -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.DeleteDiskSnapshot" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeleteDiskSnapshot where
  toJSON :: DeleteDiskSnapshot -> Value
toJSON DeleteDiskSnapshot' {Text
diskSnapshotName :: Text
$sel:diskSnapshotName:DeleteDiskSnapshot' :: DeleteDiskSnapshot -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"diskSnapshotName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
diskSnapshotName)
          ]
      )

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

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

-- | /See:/ 'newDeleteDiskSnapshotResponse' smart constructor.
data DeleteDiskSnapshotResponse = DeleteDiskSnapshotResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    DeleteDiskSnapshotResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    DeleteDiskSnapshotResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteDiskSnapshotResponse -> DeleteDiskSnapshotResponse -> Bool
(DeleteDiskSnapshotResponse -> DeleteDiskSnapshotResponse -> Bool)
-> (DeleteDiskSnapshotResponse
    -> DeleteDiskSnapshotResponse -> Bool)
-> Eq DeleteDiskSnapshotResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDiskSnapshotResponse -> DeleteDiskSnapshotResponse -> Bool
$c/= :: DeleteDiskSnapshotResponse -> DeleteDiskSnapshotResponse -> Bool
== :: DeleteDiskSnapshotResponse -> DeleteDiskSnapshotResponse -> Bool
$c== :: DeleteDiskSnapshotResponse -> DeleteDiskSnapshotResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDiskSnapshotResponse]
ReadPrec DeleteDiskSnapshotResponse
Int -> ReadS DeleteDiskSnapshotResponse
ReadS [DeleteDiskSnapshotResponse]
(Int -> ReadS DeleteDiskSnapshotResponse)
-> ReadS [DeleteDiskSnapshotResponse]
-> ReadPrec DeleteDiskSnapshotResponse
-> ReadPrec [DeleteDiskSnapshotResponse]
-> Read DeleteDiskSnapshotResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDiskSnapshotResponse]
$creadListPrec :: ReadPrec [DeleteDiskSnapshotResponse]
readPrec :: ReadPrec DeleteDiskSnapshotResponse
$creadPrec :: ReadPrec DeleteDiskSnapshotResponse
readList :: ReadS [DeleteDiskSnapshotResponse]
$creadList :: ReadS [DeleteDiskSnapshotResponse]
readsPrec :: Int -> ReadS DeleteDiskSnapshotResponse
$creadsPrec :: Int -> ReadS DeleteDiskSnapshotResponse
Prelude.Read, Int -> DeleteDiskSnapshotResponse -> ShowS
[DeleteDiskSnapshotResponse] -> ShowS
DeleteDiskSnapshotResponse -> String
(Int -> DeleteDiskSnapshotResponse -> ShowS)
-> (DeleteDiskSnapshotResponse -> String)
-> ([DeleteDiskSnapshotResponse] -> ShowS)
-> Show DeleteDiskSnapshotResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDiskSnapshotResponse] -> ShowS
$cshowList :: [DeleteDiskSnapshotResponse] -> ShowS
show :: DeleteDiskSnapshotResponse -> String
$cshow :: DeleteDiskSnapshotResponse -> String
showsPrec :: Int -> DeleteDiskSnapshotResponse -> ShowS
$cshowsPrec :: Int -> DeleteDiskSnapshotResponse -> ShowS
Prelude.Show, (forall x.
 DeleteDiskSnapshotResponse -> Rep DeleteDiskSnapshotResponse x)
-> (forall x.
    Rep DeleteDiskSnapshotResponse x -> DeleteDiskSnapshotResponse)
-> Generic DeleteDiskSnapshotResponse
forall x.
Rep DeleteDiskSnapshotResponse x -> DeleteDiskSnapshotResponse
forall x.
DeleteDiskSnapshotResponse -> Rep DeleteDiskSnapshotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDiskSnapshotResponse x -> DeleteDiskSnapshotResponse
$cfrom :: forall x.
DeleteDiskSnapshotResponse -> Rep DeleteDiskSnapshotResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDiskSnapshotResponse' 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:
--
-- 'operations', 'deleteDiskSnapshotResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'deleteDiskSnapshotResponse_httpStatus' - The response's http status code.
newDeleteDiskSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDiskSnapshotResponse
newDeleteDiskSnapshotResponse :: Int -> DeleteDiskSnapshotResponse
newDeleteDiskSnapshotResponse Int
pHttpStatus_ =
  DeleteDiskSnapshotResponse' :: Maybe [Operation] -> Int -> DeleteDiskSnapshotResponse
DeleteDiskSnapshotResponse'
    { $sel:operations:DeleteDiskSnapshotResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDiskSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
deleteDiskSnapshotResponse_operations :: Lens.Lens' DeleteDiskSnapshotResponse (Prelude.Maybe [Operation])
deleteDiskSnapshotResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteDiskSnapshotResponse -> f DeleteDiskSnapshotResponse
deleteDiskSnapshotResponse_operations = (DeleteDiskSnapshotResponse -> Maybe [Operation])
-> (DeleteDiskSnapshotResponse
    -> Maybe [Operation] -> DeleteDiskSnapshotResponse)
-> Lens
     DeleteDiskSnapshotResponse
     DeleteDiskSnapshotResponse
     (Maybe [Operation])
     (Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDiskSnapshotResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteDiskSnapshotResponse' :: DeleteDiskSnapshotResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteDiskSnapshotResponse
s@DeleteDiskSnapshotResponse' {} Maybe [Operation]
a -> DeleteDiskSnapshotResponse
s {$sel:operations:DeleteDiskSnapshotResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteDiskSnapshotResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> DeleteDiskSnapshotResponse -> f DeleteDiskSnapshotResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteDiskSnapshotResponse
-> f DeleteDiskSnapshotResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteDiskSnapshotResponse