{-# 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-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 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.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:/ 'newDeleteInstanceSnapshot' smart constructor.
data DeleteInstanceSnapshot = DeleteInstanceSnapshot'
  { -- | The name of the snapshot to delete.
    DeleteInstanceSnapshot -> Text
instanceSnapshotName :: Prelude.Text
  }
  deriving (DeleteInstanceSnapshot -> DeleteInstanceSnapshot -> Bool
(DeleteInstanceSnapshot -> DeleteInstanceSnapshot -> Bool)
-> (DeleteInstanceSnapshot -> DeleteInstanceSnapshot -> Bool)
-> Eq DeleteInstanceSnapshot
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]
(Int -> ReadS DeleteInstanceSnapshot)
-> ReadS [DeleteInstanceSnapshot]
-> ReadPrec DeleteInstanceSnapshot
-> ReadPrec [DeleteInstanceSnapshot]
-> Read 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
(Int -> DeleteInstanceSnapshot -> ShowS)
-> (DeleteInstanceSnapshot -> String)
-> ([DeleteInstanceSnapshot] -> ShowS)
-> Show DeleteInstanceSnapshot
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. DeleteInstanceSnapshot -> Rep DeleteInstanceSnapshot x)
-> (forall x.
    Rep DeleteInstanceSnapshot x -> DeleteInstanceSnapshot)
-> Generic DeleteInstanceSnapshot
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' :: Text -> DeleteInstanceSnapshot
DeleteInstanceSnapshot'
    { $sel:instanceSnapshotName:DeleteInstanceSnapshot' :: Text
instanceSnapshotName =
        Text
pInstanceSnapshotName_
    }

-- | The name of the snapshot to delete.
deleteInstanceSnapshot_instanceSnapshotName :: Lens.Lens' DeleteInstanceSnapshot Prelude.Text
deleteInstanceSnapshot_instanceSnapshotName :: (Text -> f Text)
-> DeleteInstanceSnapshot -> f DeleteInstanceSnapshot
deleteInstanceSnapshot_instanceSnapshotName = (DeleteInstanceSnapshot -> Text)
-> (DeleteInstanceSnapshot -> Text -> DeleteInstanceSnapshot)
-> Lens DeleteInstanceSnapshot DeleteInstanceSnapshot Text Text
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 :: DeleteInstanceSnapshot -> Request DeleteInstanceSnapshot
request = Service -> DeleteInstanceSnapshot -> Request DeleteInstanceSnapshot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteInstanceSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInstanceSnapshot)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteInstanceSnapshot))
-> Logger
-> Service
-> Proxy DeleteInstanceSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInstanceSnapshot)))
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 -> DeleteInstanceSnapshotResponse
DeleteInstanceSnapshotResponse'
            (Maybe [Operation] -> Int -> DeleteInstanceSnapshotResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> DeleteInstanceSnapshotResponse)
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 -> DeleteInstanceSnapshotResponse)
-> Either String Int
-> Either String DeleteInstanceSnapshotResponse
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 DeleteInstanceSnapshot

instance Prelude.NFData DeleteInstanceSnapshot

instance Core.ToHeaders DeleteInstanceSnapshot where
  toHeaders :: DeleteInstanceSnapshot -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteInstanceSnapshot -> 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.DeleteInstanceSnapshot" ::
                          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 DeleteInstanceSnapshot where
  toJSON :: DeleteInstanceSnapshot -> Value
toJSON DeleteInstanceSnapshot' {Text
instanceSnapshotName :: Text
$sel:instanceSnapshotName:DeleteInstanceSnapshot' :: DeleteInstanceSnapshot -> 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
"instanceSnapshotName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceSnapshotName
              )
          ]
      )

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

instance Core.ToQuery DeleteInstanceSnapshot where
  toQuery :: DeleteInstanceSnapshot -> QueryString
toQuery = QueryString -> DeleteInstanceSnapshot -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteInstanceSnapshotResponse
 -> DeleteInstanceSnapshotResponse -> Bool)
-> (DeleteInstanceSnapshotResponse
    -> DeleteInstanceSnapshotResponse -> Bool)
-> Eq DeleteInstanceSnapshotResponse
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]
(Int -> ReadS DeleteInstanceSnapshotResponse)
-> ReadS [DeleteInstanceSnapshotResponse]
-> ReadPrec DeleteInstanceSnapshotResponse
-> ReadPrec [DeleteInstanceSnapshotResponse]
-> Read 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
(Int -> DeleteInstanceSnapshotResponse -> ShowS)
-> (DeleteInstanceSnapshotResponse -> String)
-> ([DeleteInstanceSnapshotResponse] -> ShowS)
-> Show DeleteInstanceSnapshotResponse
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.
 DeleteInstanceSnapshotResponse
 -> Rep DeleteInstanceSnapshotResponse x)
-> (forall x.
    Rep DeleteInstanceSnapshotResponse x
    -> DeleteInstanceSnapshotResponse)
-> Generic DeleteInstanceSnapshotResponse
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' :: Maybe [Operation] -> Int -> DeleteInstanceSnapshotResponse
DeleteInstanceSnapshotResponse'
    { $sel:operations:DeleteInstanceSnapshotResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
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 :: (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteInstanceSnapshotResponse
-> f DeleteInstanceSnapshotResponse
deleteInstanceSnapshotResponse_operations = (DeleteInstanceSnapshotResponse -> Maybe [Operation])
-> (DeleteInstanceSnapshotResponse
    -> Maybe [Operation] -> DeleteInstanceSnapshotResponse)
-> Lens
     DeleteInstanceSnapshotResponse
     DeleteInstanceSnapshotResponse
     (Maybe [Operation])
     (Maybe [Operation])
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) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> DeleteInstanceSnapshotResponse
 -> f DeleteInstanceSnapshotResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteInstanceSnapshotResponse
-> f DeleteInstanceSnapshotResponse
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.
deleteInstanceSnapshotResponse_httpStatus :: Lens.Lens' DeleteInstanceSnapshotResponse Prelude.Int
deleteInstanceSnapshotResponse_httpStatus :: (Int -> f Int)
-> DeleteInstanceSnapshotResponse
-> f DeleteInstanceSnapshotResponse
deleteInstanceSnapshotResponse_httpStatus = (DeleteInstanceSnapshotResponse -> Int)
-> (DeleteInstanceSnapshotResponse
    -> Int -> DeleteInstanceSnapshotResponse)
-> Lens
     DeleteInstanceSnapshotResponse
     DeleteInstanceSnapshotResponse
     Int
     Int
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