{-# 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.DeleteInstanceSnapshot
-- 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 specific snapshot of a virtual private server (or /instance/).
--
-- The @delete instance snapshot@ operation supports tag-based access
-- control via resource tags applied to the resource identified by
-- @instance 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.DeleteInstanceSnapshot
  ( -- * Creating a Request
    DeleteInstanceSnapshot (..),
    newDeleteInstanceSnapshot,

    -- * Request Lenses
    deleteInstanceSnapshot_instanceSnapshotName,

    -- * Destructuring the Response
    DeleteInstanceSnapshotResponse (..),
    newDeleteInstanceSnapshotResponse,

    -- * Response Lenses
    deleteInstanceSnapshotResponse_operations,
    deleteInstanceSnapshotResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DeleteInstanceSnapshot' 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:
--
-- 'instanceSnapshotName', 'deleteInstanceSnapshot_instanceSnapshotName' - The name of the snapshot to delete.
newDeleteInstanceSnapshot ::
  -- | 'instanceSnapshotName'
  Prelude.Text ->
  DeleteInstanceSnapshot
newDeleteInstanceSnapshot :: Text -> DeleteInstanceSnapshot
newDeleteInstanceSnapshot Text
pInstanceSnapshotName_ =
  DeleteInstanceSnapshot'
    { $sel:instanceSnapshotName:DeleteInstanceSnapshot' :: Text
instanceSnapshotName =
        Text
pInstanceSnapshotName_
    }

-- | The name of the snapshot to delete.
deleteInstanceSnapshot_instanceSnapshotName :: Lens.Lens' DeleteInstanceSnapshot Prelude.Text
deleteInstanceSnapshot_instanceSnapshotName :: Lens' DeleteInstanceSnapshot Text
deleteInstanceSnapshot_instanceSnapshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInstanceSnapshot' {Text
instanceSnapshotName :: Text
$sel:instanceSnapshotName:DeleteInstanceSnapshot' :: DeleteInstanceSnapshot -> Text
instanceSnapshotName} -> Text
instanceSnapshotName) (\s :: DeleteInstanceSnapshot
s@DeleteInstanceSnapshot' {} Text
a -> DeleteInstanceSnapshot
s {$sel:instanceSnapshotName:DeleteInstanceSnapshot' :: Text
instanceSnapshotName = Text
a} :: DeleteInstanceSnapshot)

instance Core.AWSRequest DeleteInstanceSnapshot where
  type
    AWSResponse DeleteInstanceSnapshot =
      DeleteInstanceSnapshotResponse
  request :: (Service -> Service)
-> DeleteInstanceSnapshot -> Request DeleteInstanceSnapshot
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteInstanceSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInstanceSnapshot)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> DeleteInstanceSnapshotResponse
DeleteInstanceSnapshotResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 DeleteInstanceSnapshot where
  hashWithSalt :: Int -> DeleteInstanceSnapshot -> Int
hashWithSalt Int
_salt DeleteInstanceSnapshot' {Text
instanceSnapshotName :: Text
$sel:instanceSnapshotName:DeleteInstanceSnapshot' :: DeleteInstanceSnapshot -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceSnapshotName

instance Prelude.NFData DeleteInstanceSnapshot where
  rnf :: DeleteInstanceSnapshot -> ()
rnf DeleteInstanceSnapshot' {Text
instanceSnapshotName :: Text
$sel:instanceSnapshotName:DeleteInstanceSnapshot' :: DeleteInstanceSnapshot -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceSnapshotName

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

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

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

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

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

-- |
-- Create a value of 'DeleteInstanceSnapshotResponse' 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', 'deleteInstanceSnapshotResponse_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', 'deleteInstanceSnapshotResponse_httpStatus' - The response's http status code.
newDeleteInstanceSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteInstanceSnapshotResponse
newDeleteInstanceSnapshotResponse :: Int -> DeleteInstanceSnapshotResponse
newDeleteInstanceSnapshotResponse Int
pHttpStatus_ =
  DeleteInstanceSnapshotResponse'
    { $sel:operations:DeleteInstanceSnapshotResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteInstanceSnapshotResponse' :: 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.
deleteInstanceSnapshotResponse_operations :: Lens.Lens' DeleteInstanceSnapshotResponse (Prelude.Maybe [Operation])
deleteInstanceSnapshotResponse_operations :: Lens' DeleteInstanceSnapshotResponse (Maybe [Operation])
deleteInstanceSnapshotResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInstanceSnapshotResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteInstanceSnapshotResponse' :: DeleteInstanceSnapshotResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteInstanceSnapshotResponse
s@DeleteInstanceSnapshotResponse' {} Maybe [Operation]
a -> DeleteInstanceSnapshotResponse
s {$sel:operations:DeleteInstanceSnapshotResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteInstanceSnapshotResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DeleteInstanceSnapshotResponse
  where
  rnf :: DeleteInstanceSnapshotResponse -> ()
rnf DeleteInstanceSnapshotResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:DeleteInstanceSnapshotResponse' :: DeleteInstanceSnapshotResponse -> Int
$sel:operations:DeleteInstanceSnapshotResponse' :: DeleteInstanceSnapshotResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus