{-# 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.DeleteAutoSnapshot
-- 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 an automatic snapshot of an instance or disk. For more
-- information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.DeleteAutoSnapshot
  ( -- * Creating a Request
    DeleteAutoSnapshot (..),
    newDeleteAutoSnapshot,

    -- * Request Lenses
    deleteAutoSnapshot_resourceName,
    deleteAutoSnapshot_date,

    -- * Destructuring the Response
    DeleteAutoSnapshotResponse (..),
    newDeleteAutoSnapshotResponse,

    -- * Response Lenses
    deleteAutoSnapshotResponse_operations,
    deleteAutoSnapshotResponse_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:/ 'newDeleteAutoSnapshot' smart constructor.
data DeleteAutoSnapshot = DeleteAutoSnapshot'
  { -- | The name of the source instance or disk from which to delete the
    -- automatic snapshot.
    DeleteAutoSnapshot -> Text
resourceName :: Prelude.Text,
    -- | The date of the automatic snapshot to delete in @YYYY-MM-DD@ format. Use
    -- the @get auto snapshots@ operation to get the available automatic
    -- snapshots for a resource.
    DeleteAutoSnapshot -> Text
date :: Prelude.Text
  }
  deriving (DeleteAutoSnapshot -> DeleteAutoSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAutoSnapshot -> DeleteAutoSnapshot -> Bool
$c/= :: DeleteAutoSnapshot -> DeleteAutoSnapshot -> Bool
== :: DeleteAutoSnapshot -> DeleteAutoSnapshot -> Bool
$c== :: DeleteAutoSnapshot -> DeleteAutoSnapshot -> Bool
Prelude.Eq, ReadPrec [DeleteAutoSnapshot]
ReadPrec DeleteAutoSnapshot
Int -> ReadS DeleteAutoSnapshot
ReadS [DeleteAutoSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAutoSnapshot]
$creadListPrec :: ReadPrec [DeleteAutoSnapshot]
readPrec :: ReadPrec DeleteAutoSnapshot
$creadPrec :: ReadPrec DeleteAutoSnapshot
readList :: ReadS [DeleteAutoSnapshot]
$creadList :: ReadS [DeleteAutoSnapshot]
readsPrec :: Int -> ReadS DeleteAutoSnapshot
$creadsPrec :: Int -> ReadS DeleteAutoSnapshot
Prelude.Read, Int -> DeleteAutoSnapshot -> ShowS
[DeleteAutoSnapshot] -> ShowS
DeleteAutoSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAutoSnapshot] -> ShowS
$cshowList :: [DeleteAutoSnapshot] -> ShowS
show :: DeleteAutoSnapshot -> String
$cshow :: DeleteAutoSnapshot -> String
showsPrec :: Int -> DeleteAutoSnapshot -> ShowS
$cshowsPrec :: Int -> DeleteAutoSnapshot -> ShowS
Prelude.Show, forall x. Rep DeleteAutoSnapshot x -> DeleteAutoSnapshot
forall x. DeleteAutoSnapshot -> Rep DeleteAutoSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAutoSnapshot x -> DeleteAutoSnapshot
$cfrom :: forall x. DeleteAutoSnapshot -> Rep DeleteAutoSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAutoSnapshot' 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:
--
-- 'resourceName', 'deleteAutoSnapshot_resourceName' - The name of the source instance or disk from which to delete the
-- automatic snapshot.
--
-- 'date', 'deleteAutoSnapshot_date' - The date of the automatic snapshot to delete in @YYYY-MM-DD@ format. Use
-- the @get auto snapshots@ operation to get the available automatic
-- snapshots for a resource.
newDeleteAutoSnapshot ::
  -- | 'resourceName'
  Prelude.Text ->
  -- | 'date'
  Prelude.Text ->
  DeleteAutoSnapshot
newDeleteAutoSnapshot :: Text -> Text -> DeleteAutoSnapshot
newDeleteAutoSnapshot Text
pResourceName_ Text
pDate_ =
  DeleteAutoSnapshot'
    { $sel:resourceName:DeleteAutoSnapshot' :: Text
resourceName = Text
pResourceName_,
      $sel:date:DeleteAutoSnapshot' :: Text
date = Text
pDate_
    }

-- | The name of the source instance or disk from which to delete the
-- automatic snapshot.
deleteAutoSnapshot_resourceName :: Lens.Lens' DeleteAutoSnapshot Prelude.Text
deleteAutoSnapshot_resourceName :: Lens' DeleteAutoSnapshot Text
deleteAutoSnapshot_resourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAutoSnapshot' {Text
resourceName :: Text
$sel:resourceName:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
resourceName} -> Text
resourceName) (\s :: DeleteAutoSnapshot
s@DeleteAutoSnapshot' {} Text
a -> DeleteAutoSnapshot
s {$sel:resourceName:DeleteAutoSnapshot' :: Text
resourceName = Text
a} :: DeleteAutoSnapshot)

-- | The date of the automatic snapshot to delete in @YYYY-MM-DD@ format. Use
-- the @get auto snapshots@ operation to get the available automatic
-- snapshots for a resource.
deleteAutoSnapshot_date :: Lens.Lens' DeleteAutoSnapshot Prelude.Text
deleteAutoSnapshot_date :: Lens' DeleteAutoSnapshot Text
deleteAutoSnapshot_date = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAutoSnapshot' {Text
date :: Text
$sel:date:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
date} -> Text
date) (\s :: DeleteAutoSnapshot
s@DeleteAutoSnapshot' {} Text
a -> DeleteAutoSnapshot
s {$sel:date:DeleteAutoSnapshot' :: Text
date = Text
a} :: DeleteAutoSnapshot)

instance Core.AWSRequest DeleteAutoSnapshot where
  type
    AWSResponse DeleteAutoSnapshot =
      DeleteAutoSnapshotResponse
  request :: (Service -> Service)
-> DeleteAutoSnapshot -> Request DeleteAutoSnapshot
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 DeleteAutoSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAutoSnapshot)))
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 -> DeleteAutoSnapshotResponse
DeleteAutoSnapshotResponse'
            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 DeleteAutoSnapshot where
  hashWithSalt :: Int -> DeleteAutoSnapshot -> Int
hashWithSalt Int
_salt DeleteAutoSnapshot' {Text
date :: Text
resourceName :: Text
$sel:date:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
$sel:resourceName:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
date

instance Prelude.NFData DeleteAutoSnapshot where
  rnf :: DeleteAutoSnapshot -> ()
rnf DeleteAutoSnapshot' {Text
date :: Text
resourceName :: Text
$sel:date:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
$sel:resourceName:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
date

instance Data.ToHeaders DeleteAutoSnapshot where
  toHeaders :: DeleteAutoSnapshot -> 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.DeleteAutoSnapshot" ::
                          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 DeleteAutoSnapshot where
  toJSON :: DeleteAutoSnapshot -> Value
toJSON DeleteAutoSnapshot' {Text
date :: Text
resourceName :: Text
$sel:date:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
$sel:resourceName:DeleteAutoSnapshot' :: DeleteAutoSnapshot -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"resourceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceName),
            forall a. a -> Maybe a
Prelude.Just (Key
"date" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
date)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteAutoSnapshotResponse' 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', 'deleteAutoSnapshotResponse_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', 'deleteAutoSnapshotResponse_httpStatus' - The response's http status code.
newDeleteAutoSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteAutoSnapshotResponse
newDeleteAutoSnapshotResponse :: Int -> DeleteAutoSnapshotResponse
newDeleteAutoSnapshotResponse Int
pHttpStatus_ =
  DeleteAutoSnapshotResponse'
    { $sel:operations:DeleteAutoSnapshotResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteAutoSnapshotResponse' :: 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.
deleteAutoSnapshotResponse_operations :: Lens.Lens' DeleteAutoSnapshotResponse (Prelude.Maybe [Operation])
deleteAutoSnapshotResponse_operations :: Lens' DeleteAutoSnapshotResponse (Maybe [Operation])
deleteAutoSnapshotResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAutoSnapshotResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteAutoSnapshotResponse' :: DeleteAutoSnapshotResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteAutoSnapshotResponse
s@DeleteAutoSnapshotResponse' {} Maybe [Operation]
a -> DeleteAutoSnapshotResponse
s {$sel:operations:DeleteAutoSnapshotResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteAutoSnapshotResponse) 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.
deleteAutoSnapshotResponse_httpStatus :: Lens.Lens' DeleteAutoSnapshotResponse Prelude.Int
deleteAutoSnapshotResponse_httpStatus :: Lens' DeleteAutoSnapshotResponse Int
deleteAutoSnapshotResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAutoSnapshotResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteAutoSnapshotResponse' :: DeleteAutoSnapshotResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteAutoSnapshotResponse
s@DeleteAutoSnapshotResponse' {} Int
a -> DeleteAutoSnapshotResponse
s {$sel:httpStatus:DeleteAutoSnapshotResponse' :: Int
httpStatus = Int
a} :: DeleteAutoSnapshotResponse)

instance Prelude.NFData DeleteAutoSnapshotResponse where
  rnf :: DeleteAutoSnapshotResponse -> ()
rnf DeleteAutoSnapshotResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:DeleteAutoSnapshotResponse' :: DeleteAutoSnapshotResponse -> Int
$sel:operations:DeleteAutoSnapshotResponse' :: DeleteAutoSnapshotResponse -> 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