{-# 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.FSx.DeleteFileCache
-- 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 Amazon File Cache resource. After deletion, the cache no
-- longer exists, and its data is gone.
--
-- The @DeleteFileCache@ operation returns while the cache has the
-- @DELETING@ status. You can check the cache deletion status by calling
-- the
-- <https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileCaches.html DescribeFileCaches>
-- operation, which returns a list of caches in your account. If you pass
-- the cache ID for a deleted cache, the @DescribeFileCaches@ operation
-- returns a @FileCacheNotFound@ error.
--
-- The data in a deleted cache is also deleted and can\'t be recovered by
-- any means.
module Amazonka.FSx.DeleteFileCache
  ( -- * Creating a Request
    DeleteFileCache (..),
    newDeleteFileCache,

    -- * Request Lenses
    deleteFileCache_clientRequestToken,
    deleteFileCache_fileCacheId,

    -- * Destructuring the Response
    DeleteFileCacheResponse (..),
    newDeleteFileCacheResponse,

    -- * Response Lenses
    deleteFileCacheResponse_fileCacheId,
    deleteFileCacheResponse_lifecycle,
    deleteFileCacheResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteFileCache' smart constructor.
data DeleteFileCache = DeleteFileCache'
  { DeleteFileCache -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the cache that\'s being deleted.
    DeleteFileCache -> Text
fileCacheId :: Prelude.Text
  }
  deriving (DeleteFileCache -> DeleteFileCache -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFileCache -> DeleteFileCache -> Bool
$c/= :: DeleteFileCache -> DeleteFileCache -> Bool
== :: DeleteFileCache -> DeleteFileCache -> Bool
$c== :: DeleteFileCache -> DeleteFileCache -> Bool
Prelude.Eq, ReadPrec [DeleteFileCache]
ReadPrec DeleteFileCache
Int -> ReadS DeleteFileCache
ReadS [DeleteFileCache]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFileCache]
$creadListPrec :: ReadPrec [DeleteFileCache]
readPrec :: ReadPrec DeleteFileCache
$creadPrec :: ReadPrec DeleteFileCache
readList :: ReadS [DeleteFileCache]
$creadList :: ReadS [DeleteFileCache]
readsPrec :: Int -> ReadS DeleteFileCache
$creadsPrec :: Int -> ReadS DeleteFileCache
Prelude.Read, Int -> DeleteFileCache -> ShowS
[DeleteFileCache] -> ShowS
DeleteFileCache -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFileCache] -> ShowS
$cshowList :: [DeleteFileCache] -> ShowS
show :: DeleteFileCache -> String
$cshow :: DeleteFileCache -> String
showsPrec :: Int -> DeleteFileCache -> ShowS
$cshowsPrec :: Int -> DeleteFileCache -> ShowS
Prelude.Show, forall x. Rep DeleteFileCache x -> DeleteFileCache
forall x. DeleteFileCache -> Rep DeleteFileCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFileCache x -> DeleteFileCache
$cfrom :: forall x. DeleteFileCache -> Rep DeleteFileCache x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFileCache' 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:
--
-- 'clientRequestToken', 'deleteFileCache_clientRequestToken' - Undocumented member.
--
-- 'fileCacheId', 'deleteFileCache_fileCacheId' - The ID of the cache that\'s being deleted.
newDeleteFileCache ::
  -- | 'fileCacheId'
  Prelude.Text ->
  DeleteFileCache
newDeleteFileCache :: Text -> DeleteFileCache
newDeleteFileCache Text
pFileCacheId_ =
  DeleteFileCache'
    { $sel:clientRequestToken:DeleteFileCache' :: Maybe Text
clientRequestToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fileCacheId:DeleteFileCache' :: Text
fileCacheId = Text
pFileCacheId_
    }

-- | Undocumented member.
deleteFileCache_clientRequestToken :: Lens.Lens' DeleteFileCache (Prelude.Maybe Prelude.Text)
deleteFileCache_clientRequestToken :: Lens' DeleteFileCache (Maybe Text)
deleteFileCache_clientRequestToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileCache' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:DeleteFileCache' :: DeleteFileCache -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: DeleteFileCache
s@DeleteFileCache' {} Maybe Text
a -> DeleteFileCache
s {$sel:clientRequestToken:DeleteFileCache' :: Maybe Text
clientRequestToken = Maybe Text
a} :: DeleteFileCache)

-- | The ID of the cache that\'s being deleted.
deleteFileCache_fileCacheId :: Lens.Lens' DeleteFileCache Prelude.Text
deleteFileCache_fileCacheId :: Lens' DeleteFileCache Text
deleteFileCache_fileCacheId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileCache' {Text
fileCacheId :: Text
$sel:fileCacheId:DeleteFileCache' :: DeleteFileCache -> Text
fileCacheId} -> Text
fileCacheId) (\s :: DeleteFileCache
s@DeleteFileCache' {} Text
a -> DeleteFileCache
s {$sel:fileCacheId:DeleteFileCache' :: Text
fileCacheId = Text
a} :: DeleteFileCache)

instance Core.AWSRequest DeleteFileCache where
  type
    AWSResponse DeleteFileCache =
      DeleteFileCacheResponse
  request :: (Service -> Service) -> DeleteFileCache -> Request DeleteFileCache
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 DeleteFileCache
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFileCache)))
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 Text
-> Maybe FileCacheLifecycle -> Int -> DeleteFileCacheResponse
DeleteFileCacheResponse'
            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
"FileCacheId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Lifecycle")
            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 DeleteFileCache where
  hashWithSalt :: Int -> DeleteFileCache -> Int
hashWithSalt Int
_salt DeleteFileCache' {Maybe Text
Text
fileCacheId :: Text
clientRequestToken :: Maybe Text
$sel:fileCacheId:DeleteFileCache' :: DeleteFileCache -> Text
$sel:clientRequestToken:DeleteFileCache' :: DeleteFileCache -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientRequestToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fileCacheId

instance Prelude.NFData DeleteFileCache where
  rnf :: DeleteFileCache -> ()
rnf DeleteFileCache' {Maybe Text
Text
fileCacheId :: Text
clientRequestToken :: Maybe Text
$sel:fileCacheId:DeleteFileCache' :: DeleteFileCache -> Text
$sel:clientRequestToken:DeleteFileCache' :: DeleteFileCache -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientRequestToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fileCacheId

instance Data.ToHeaders DeleteFileCache where
  toHeaders :: DeleteFileCache -> 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
"AWSSimbaAPIService_v20180301.DeleteFileCache" ::
                          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 DeleteFileCache where
  toJSON :: DeleteFileCache -> Value
toJSON DeleteFileCache' {Maybe Text
Text
fileCacheId :: Text
clientRequestToken :: Maybe Text
$sel:fileCacheId:DeleteFileCache' :: DeleteFileCache -> Text
$sel:clientRequestToken:DeleteFileCache' :: DeleteFileCache -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientRequestToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"FileCacheId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fileCacheId)
          ]
      )

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

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

-- | /See:/ 'newDeleteFileCacheResponse' smart constructor.
data DeleteFileCacheResponse = DeleteFileCacheResponse'
  { -- | The ID of the cache that\'s being deleted.
    DeleteFileCacheResponse -> Maybe Text
fileCacheId :: Prelude.Maybe Prelude.Text,
    -- | The cache lifecycle for the deletion request. If the @DeleteFileCache@
    -- operation is successful, this status is @DELETING@.
    DeleteFileCacheResponse -> Maybe FileCacheLifecycle
lifecycle :: Prelude.Maybe FileCacheLifecycle,
    -- | The response's http status code.
    DeleteFileCacheResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFileCacheResponse -> DeleteFileCacheResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFileCacheResponse -> DeleteFileCacheResponse -> Bool
$c/= :: DeleteFileCacheResponse -> DeleteFileCacheResponse -> Bool
== :: DeleteFileCacheResponse -> DeleteFileCacheResponse -> Bool
$c== :: DeleteFileCacheResponse -> DeleteFileCacheResponse -> Bool
Prelude.Eq, ReadPrec [DeleteFileCacheResponse]
ReadPrec DeleteFileCacheResponse
Int -> ReadS DeleteFileCacheResponse
ReadS [DeleteFileCacheResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFileCacheResponse]
$creadListPrec :: ReadPrec [DeleteFileCacheResponse]
readPrec :: ReadPrec DeleteFileCacheResponse
$creadPrec :: ReadPrec DeleteFileCacheResponse
readList :: ReadS [DeleteFileCacheResponse]
$creadList :: ReadS [DeleteFileCacheResponse]
readsPrec :: Int -> ReadS DeleteFileCacheResponse
$creadsPrec :: Int -> ReadS DeleteFileCacheResponse
Prelude.Read, Int -> DeleteFileCacheResponse -> ShowS
[DeleteFileCacheResponse] -> ShowS
DeleteFileCacheResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFileCacheResponse] -> ShowS
$cshowList :: [DeleteFileCacheResponse] -> ShowS
show :: DeleteFileCacheResponse -> String
$cshow :: DeleteFileCacheResponse -> String
showsPrec :: Int -> DeleteFileCacheResponse -> ShowS
$cshowsPrec :: Int -> DeleteFileCacheResponse -> ShowS
Prelude.Show, forall x. Rep DeleteFileCacheResponse x -> DeleteFileCacheResponse
forall x. DeleteFileCacheResponse -> Rep DeleteFileCacheResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFileCacheResponse x -> DeleteFileCacheResponse
$cfrom :: forall x. DeleteFileCacheResponse -> Rep DeleteFileCacheResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFileCacheResponse' 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:
--
-- 'fileCacheId', 'deleteFileCacheResponse_fileCacheId' - The ID of the cache that\'s being deleted.
--
-- 'lifecycle', 'deleteFileCacheResponse_lifecycle' - The cache lifecycle for the deletion request. If the @DeleteFileCache@
-- operation is successful, this status is @DELETING@.
--
-- 'httpStatus', 'deleteFileCacheResponse_httpStatus' - The response's http status code.
newDeleteFileCacheResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFileCacheResponse
newDeleteFileCacheResponse :: Int -> DeleteFileCacheResponse
newDeleteFileCacheResponse Int
pHttpStatus_ =
  DeleteFileCacheResponse'
    { $sel:fileCacheId:DeleteFileCacheResponse' :: Maybe Text
fileCacheId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycle:DeleteFileCacheResponse' :: Maybe FileCacheLifecycle
lifecycle = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFileCacheResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the cache that\'s being deleted.
deleteFileCacheResponse_fileCacheId :: Lens.Lens' DeleteFileCacheResponse (Prelude.Maybe Prelude.Text)
deleteFileCacheResponse_fileCacheId :: Lens' DeleteFileCacheResponse (Maybe Text)
deleteFileCacheResponse_fileCacheId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileCacheResponse' {Maybe Text
fileCacheId :: Maybe Text
$sel:fileCacheId:DeleteFileCacheResponse' :: DeleteFileCacheResponse -> Maybe Text
fileCacheId} -> Maybe Text
fileCacheId) (\s :: DeleteFileCacheResponse
s@DeleteFileCacheResponse' {} Maybe Text
a -> DeleteFileCacheResponse
s {$sel:fileCacheId:DeleteFileCacheResponse' :: Maybe Text
fileCacheId = Maybe Text
a} :: DeleteFileCacheResponse)

-- | The cache lifecycle for the deletion request. If the @DeleteFileCache@
-- operation is successful, this status is @DELETING@.
deleteFileCacheResponse_lifecycle :: Lens.Lens' DeleteFileCacheResponse (Prelude.Maybe FileCacheLifecycle)
deleteFileCacheResponse_lifecycle :: Lens' DeleteFileCacheResponse (Maybe FileCacheLifecycle)
deleteFileCacheResponse_lifecycle = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileCacheResponse' {Maybe FileCacheLifecycle
lifecycle :: Maybe FileCacheLifecycle
$sel:lifecycle:DeleteFileCacheResponse' :: DeleteFileCacheResponse -> Maybe FileCacheLifecycle
lifecycle} -> Maybe FileCacheLifecycle
lifecycle) (\s :: DeleteFileCacheResponse
s@DeleteFileCacheResponse' {} Maybe FileCacheLifecycle
a -> DeleteFileCacheResponse
s {$sel:lifecycle:DeleteFileCacheResponse' :: Maybe FileCacheLifecycle
lifecycle = Maybe FileCacheLifecycle
a} :: DeleteFileCacheResponse)

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

instance Prelude.NFData DeleteFileCacheResponse where
  rnf :: DeleteFileCacheResponse -> ()
rnf DeleteFileCacheResponse' {Int
Maybe Text
Maybe FileCacheLifecycle
httpStatus :: Int
lifecycle :: Maybe FileCacheLifecycle
fileCacheId :: Maybe Text
$sel:httpStatus:DeleteFileCacheResponse' :: DeleteFileCacheResponse -> Int
$sel:lifecycle:DeleteFileCacheResponse' :: DeleteFileCacheResponse -> Maybe FileCacheLifecycle
$sel:fileCacheId:DeleteFileCacheResponse' :: DeleteFileCacheResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fileCacheId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FileCacheLifecycle
lifecycle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus