{-# 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.StorageGateway.DeleteFileShare
-- 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 file share from an S3 File Gateway. This operation is only
-- supported for S3 File Gateways.
module Amazonka.StorageGateway.DeleteFileShare
  ( -- * Creating a Request
    DeleteFileShare (..),
    newDeleteFileShare,

    -- * Request Lenses
    deleteFileShare_forceDelete,
    deleteFileShare_fileShareARN,

    -- * Destructuring the Response
    DeleteFileShareResponse (..),
    newDeleteFileShareResponse,

    -- * Response Lenses
    deleteFileShareResponse_fileShareARN,
    deleteFileShareResponse_httpStatus,
  )
where

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

-- | DeleteFileShareInput
--
-- /See:/ 'newDeleteFileShare' smart constructor.
data DeleteFileShare = DeleteFileShare'
  { -- | If this value is set to @true@, the operation deletes a file share
    -- immediately and aborts all data uploads to Amazon Web Services.
    -- Otherwise, the file share is not deleted until all data is uploaded to
    -- Amazon Web Services. This process aborts the data upload process, and
    -- the file share enters the @FORCE_DELETING@ status.
    --
    -- Valid Values: @true@ | @false@
    DeleteFileShare -> Maybe Bool
forceDelete :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the file share to be deleted.
    DeleteFileShare -> Text
fileShareARN :: Prelude.Text
  }
  deriving (DeleteFileShare -> DeleteFileShare -> Bool
(DeleteFileShare -> DeleteFileShare -> Bool)
-> (DeleteFileShare -> DeleteFileShare -> Bool)
-> Eq DeleteFileShare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFileShare -> DeleteFileShare -> Bool
$c/= :: DeleteFileShare -> DeleteFileShare -> Bool
== :: DeleteFileShare -> DeleteFileShare -> Bool
$c== :: DeleteFileShare -> DeleteFileShare -> Bool
Prelude.Eq, ReadPrec [DeleteFileShare]
ReadPrec DeleteFileShare
Int -> ReadS DeleteFileShare
ReadS [DeleteFileShare]
(Int -> ReadS DeleteFileShare)
-> ReadS [DeleteFileShare]
-> ReadPrec DeleteFileShare
-> ReadPrec [DeleteFileShare]
-> Read DeleteFileShare
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFileShare]
$creadListPrec :: ReadPrec [DeleteFileShare]
readPrec :: ReadPrec DeleteFileShare
$creadPrec :: ReadPrec DeleteFileShare
readList :: ReadS [DeleteFileShare]
$creadList :: ReadS [DeleteFileShare]
readsPrec :: Int -> ReadS DeleteFileShare
$creadsPrec :: Int -> ReadS DeleteFileShare
Prelude.Read, Int -> DeleteFileShare -> ShowS
[DeleteFileShare] -> ShowS
DeleteFileShare -> String
(Int -> DeleteFileShare -> ShowS)
-> (DeleteFileShare -> String)
-> ([DeleteFileShare] -> ShowS)
-> Show DeleteFileShare
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFileShare] -> ShowS
$cshowList :: [DeleteFileShare] -> ShowS
show :: DeleteFileShare -> String
$cshow :: DeleteFileShare -> String
showsPrec :: Int -> DeleteFileShare -> ShowS
$cshowsPrec :: Int -> DeleteFileShare -> ShowS
Prelude.Show, (forall x. DeleteFileShare -> Rep DeleteFileShare x)
-> (forall x. Rep DeleteFileShare x -> DeleteFileShare)
-> Generic DeleteFileShare
forall x. Rep DeleteFileShare x -> DeleteFileShare
forall x. DeleteFileShare -> Rep DeleteFileShare x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFileShare x -> DeleteFileShare
$cfrom :: forall x. DeleteFileShare -> Rep DeleteFileShare x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFileShare' 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:
--
-- 'forceDelete', 'deleteFileShare_forceDelete' - If this value is set to @true@, the operation deletes a file share
-- immediately and aborts all data uploads to Amazon Web Services.
-- Otherwise, the file share is not deleted until all data is uploaded to
-- Amazon Web Services. This process aborts the data upload process, and
-- the file share enters the @FORCE_DELETING@ status.
--
-- Valid Values: @true@ | @false@
--
-- 'fileShareARN', 'deleteFileShare_fileShareARN' - The Amazon Resource Name (ARN) of the file share to be deleted.
newDeleteFileShare ::
  -- | 'fileShareARN'
  Prelude.Text ->
  DeleteFileShare
newDeleteFileShare :: Text -> DeleteFileShare
newDeleteFileShare Text
pFileShareARN_ =
  DeleteFileShare' :: Maybe Bool -> Text -> DeleteFileShare
DeleteFileShare'
    { $sel:forceDelete:DeleteFileShare' :: Maybe Bool
forceDelete = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:fileShareARN:DeleteFileShare' :: Text
fileShareARN = Text
pFileShareARN_
    }

-- | If this value is set to @true@, the operation deletes a file share
-- immediately and aborts all data uploads to Amazon Web Services.
-- Otherwise, the file share is not deleted until all data is uploaded to
-- Amazon Web Services. This process aborts the data upload process, and
-- the file share enters the @FORCE_DELETING@ status.
--
-- Valid Values: @true@ | @false@
deleteFileShare_forceDelete :: Lens.Lens' DeleteFileShare (Prelude.Maybe Prelude.Bool)
deleteFileShare_forceDelete :: (Maybe Bool -> f (Maybe Bool))
-> DeleteFileShare -> f DeleteFileShare
deleteFileShare_forceDelete = (DeleteFileShare -> Maybe Bool)
-> (DeleteFileShare -> Maybe Bool -> DeleteFileShare)
-> Lens DeleteFileShare DeleteFileShare (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileShare' {Maybe Bool
forceDelete :: Maybe Bool
$sel:forceDelete:DeleteFileShare' :: DeleteFileShare -> Maybe Bool
forceDelete} -> Maybe Bool
forceDelete) (\s :: DeleteFileShare
s@DeleteFileShare' {} Maybe Bool
a -> DeleteFileShare
s {$sel:forceDelete:DeleteFileShare' :: Maybe Bool
forceDelete = Maybe Bool
a} :: DeleteFileShare)

-- | The Amazon Resource Name (ARN) of the file share to be deleted.
deleteFileShare_fileShareARN :: Lens.Lens' DeleteFileShare Prelude.Text
deleteFileShare_fileShareARN :: (Text -> f Text) -> DeleteFileShare -> f DeleteFileShare
deleteFileShare_fileShareARN = (DeleteFileShare -> Text)
-> (DeleteFileShare -> Text -> DeleteFileShare)
-> Lens DeleteFileShare DeleteFileShare Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileShare' {Text
fileShareARN :: Text
$sel:fileShareARN:DeleteFileShare' :: DeleteFileShare -> Text
fileShareARN} -> Text
fileShareARN) (\s :: DeleteFileShare
s@DeleteFileShare' {} Text
a -> DeleteFileShare
s {$sel:fileShareARN:DeleteFileShare' :: Text
fileShareARN = Text
a} :: DeleteFileShare)

instance Core.AWSRequest DeleteFileShare where
  type
    AWSResponse DeleteFileShare =
      DeleteFileShareResponse
  request :: DeleteFileShare -> Request DeleteFileShare
request = Service -> DeleteFileShare -> Request DeleteFileShare
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteFileShare
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFileShare)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteFileShare))
-> Logger
-> Service
-> Proxy DeleteFileShare
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFileShare)))
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 Text -> Int -> DeleteFileShareResponse
DeleteFileShareResponse'
            (Maybe Text -> Int -> DeleteFileShareResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteFileShareResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FileShareARN")
            Either String (Int -> DeleteFileShareResponse)
-> Either String Int -> Either String DeleteFileShareResponse
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 DeleteFileShare

instance Prelude.NFData DeleteFileShare

instance Core.ToHeaders DeleteFileShare where
  toHeaders :: DeleteFileShare -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteFileShare -> 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
"StorageGateway_20130630.DeleteFileShare" ::
                          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 DeleteFileShare where
  toJSON :: DeleteFileShare -> Value
toJSON DeleteFileShare' {Maybe Bool
Text
fileShareARN :: Text
forceDelete :: Maybe Bool
$sel:fileShareARN:DeleteFileShare' :: DeleteFileShare -> Text
$sel:forceDelete:DeleteFileShare' :: DeleteFileShare -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ForceDelete" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
forceDelete,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FileShareARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fileShareARN)
          ]
      )

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

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

-- | DeleteFileShareOutput
--
-- /See:/ 'newDeleteFileShareResponse' smart constructor.
data DeleteFileShareResponse = DeleteFileShareResponse'
  { -- | The Amazon Resource Name (ARN) of the deleted file share.
    DeleteFileShareResponse -> Maybe Text
fileShareARN :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteFileShareResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFileShareResponse -> DeleteFileShareResponse -> Bool
(DeleteFileShareResponse -> DeleteFileShareResponse -> Bool)
-> (DeleteFileShareResponse -> DeleteFileShareResponse -> Bool)
-> Eq DeleteFileShareResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFileShareResponse -> DeleteFileShareResponse -> Bool
$c/= :: DeleteFileShareResponse -> DeleteFileShareResponse -> Bool
== :: DeleteFileShareResponse -> DeleteFileShareResponse -> Bool
$c== :: DeleteFileShareResponse -> DeleteFileShareResponse -> Bool
Prelude.Eq, ReadPrec [DeleteFileShareResponse]
ReadPrec DeleteFileShareResponse
Int -> ReadS DeleteFileShareResponse
ReadS [DeleteFileShareResponse]
(Int -> ReadS DeleteFileShareResponse)
-> ReadS [DeleteFileShareResponse]
-> ReadPrec DeleteFileShareResponse
-> ReadPrec [DeleteFileShareResponse]
-> Read DeleteFileShareResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFileShareResponse]
$creadListPrec :: ReadPrec [DeleteFileShareResponse]
readPrec :: ReadPrec DeleteFileShareResponse
$creadPrec :: ReadPrec DeleteFileShareResponse
readList :: ReadS [DeleteFileShareResponse]
$creadList :: ReadS [DeleteFileShareResponse]
readsPrec :: Int -> ReadS DeleteFileShareResponse
$creadsPrec :: Int -> ReadS DeleteFileShareResponse
Prelude.Read, Int -> DeleteFileShareResponse -> ShowS
[DeleteFileShareResponse] -> ShowS
DeleteFileShareResponse -> String
(Int -> DeleteFileShareResponse -> ShowS)
-> (DeleteFileShareResponse -> String)
-> ([DeleteFileShareResponse] -> ShowS)
-> Show DeleteFileShareResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFileShareResponse] -> ShowS
$cshowList :: [DeleteFileShareResponse] -> ShowS
show :: DeleteFileShareResponse -> String
$cshow :: DeleteFileShareResponse -> String
showsPrec :: Int -> DeleteFileShareResponse -> ShowS
$cshowsPrec :: Int -> DeleteFileShareResponse -> ShowS
Prelude.Show, (forall x.
 DeleteFileShareResponse -> Rep DeleteFileShareResponse x)
-> (forall x.
    Rep DeleteFileShareResponse x -> DeleteFileShareResponse)
-> Generic DeleteFileShareResponse
forall x. Rep DeleteFileShareResponse x -> DeleteFileShareResponse
forall x. DeleteFileShareResponse -> Rep DeleteFileShareResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFileShareResponse x -> DeleteFileShareResponse
$cfrom :: forall x. DeleteFileShareResponse -> Rep DeleteFileShareResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFileShareResponse' 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:
--
-- 'fileShareARN', 'deleteFileShareResponse_fileShareARN' - The Amazon Resource Name (ARN) of the deleted file share.
--
-- 'httpStatus', 'deleteFileShareResponse_httpStatus' - The response's http status code.
newDeleteFileShareResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFileShareResponse
newDeleteFileShareResponse :: Int -> DeleteFileShareResponse
newDeleteFileShareResponse Int
pHttpStatus_ =
  DeleteFileShareResponse' :: Maybe Text -> Int -> DeleteFileShareResponse
DeleteFileShareResponse'
    { $sel:fileShareARN:DeleteFileShareResponse' :: Maybe Text
fileShareARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFileShareResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the deleted file share.
deleteFileShareResponse_fileShareARN :: Lens.Lens' DeleteFileShareResponse (Prelude.Maybe Prelude.Text)
deleteFileShareResponse_fileShareARN :: (Maybe Text -> f (Maybe Text))
-> DeleteFileShareResponse -> f DeleteFileShareResponse
deleteFileShareResponse_fileShareARN = (DeleteFileShareResponse -> Maybe Text)
-> (DeleteFileShareResponse
    -> Maybe Text -> DeleteFileShareResponse)
-> Lens
     DeleteFileShareResponse
     DeleteFileShareResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFileShareResponse' {Maybe Text
fileShareARN :: Maybe Text
$sel:fileShareARN:DeleteFileShareResponse' :: DeleteFileShareResponse -> Maybe Text
fileShareARN} -> Maybe Text
fileShareARN) (\s :: DeleteFileShareResponse
s@DeleteFileShareResponse' {} Maybe Text
a -> DeleteFileShareResponse
s {$sel:fileShareARN:DeleteFileShareResponse' :: Maybe Text
fileShareARN = Maybe Text
a} :: DeleteFileShareResponse)

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

instance Prelude.NFData DeleteFileShareResponse