{-# 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.DisassociateFileSystem
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates an Amazon FSx file system from the specified gateway.
-- After the disassociation process finishes, the gateway can no longer
-- access the Amazon FSx file system. This operation is only supported in
-- the FSx File Gateway type.
module Amazonka.StorageGateway.DisassociateFileSystem
  ( -- * Creating a Request
    DisassociateFileSystem (..),
    newDisassociateFileSystem,

    -- * Request Lenses
    disassociateFileSystem_forceDelete,
    disassociateFileSystem_fileSystemAssociationARN,

    -- * Destructuring the Response
    DisassociateFileSystemResponse (..),
    newDisassociateFileSystemResponse,

    -- * Response Lenses
    disassociateFileSystemResponse_fileSystemAssociationARN,
    disassociateFileSystemResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDisassociateFileSystem' smart constructor.
data DisassociateFileSystem = DisassociateFileSystem'
  { -- | If this value is set to true, the operation disassociates an Amazon FSx
    -- file system immediately. It ends all data uploads to the file system,
    -- and the file system association enters the @FORCE_DELETING@ status. If
    -- this value is set to false, the Amazon FSx file system does not
    -- disassociate until all data is uploaded.
    DisassociateFileSystem -> Maybe Bool
forceDelete :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the file system association to be
    -- deleted.
    DisassociateFileSystem -> Text
fileSystemAssociationARN :: Prelude.Text
  }
  deriving (DisassociateFileSystem -> DisassociateFileSystem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateFileSystem -> DisassociateFileSystem -> Bool
$c/= :: DisassociateFileSystem -> DisassociateFileSystem -> Bool
== :: DisassociateFileSystem -> DisassociateFileSystem -> Bool
$c== :: DisassociateFileSystem -> DisassociateFileSystem -> Bool
Prelude.Eq, ReadPrec [DisassociateFileSystem]
ReadPrec DisassociateFileSystem
Int -> ReadS DisassociateFileSystem
ReadS [DisassociateFileSystem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateFileSystem]
$creadListPrec :: ReadPrec [DisassociateFileSystem]
readPrec :: ReadPrec DisassociateFileSystem
$creadPrec :: ReadPrec DisassociateFileSystem
readList :: ReadS [DisassociateFileSystem]
$creadList :: ReadS [DisassociateFileSystem]
readsPrec :: Int -> ReadS DisassociateFileSystem
$creadsPrec :: Int -> ReadS DisassociateFileSystem
Prelude.Read, Int -> DisassociateFileSystem -> ShowS
[DisassociateFileSystem] -> ShowS
DisassociateFileSystem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateFileSystem] -> ShowS
$cshowList :: [DisassociateFileSystem] -> ShowS
show :: DisassociateFileSystem -> String
$cshow :: DisassociateFileSystem -> String
showsPrec :: Int -> DisassociateFileSystem -> ShowS
$cshowsPrec :: Int -> DisassociateFileSystem -> ShowS
Prelude.Show, forall x. Rep DisassociateFileSystem x -> DisassociateFileSystem
forall x. DisassociateFileSystem -> Rep DisassociateFileSystem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateFileSystem x -> DisassociateFileSystem
$cfrom :: forall x. DisassociateFileSystem -> Rep DisassociateFileSystem x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateFileSystem' 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', 'disassociateFileSystem_forceDelete' - If this value is set to true, the operation disassociates an Amazon FSx
-- file system immediately. It ends all data uploads to the file system,
-- and the file system association enters the @FORCE_DELETING@ status. If
-- this value is set to false, the Amazon FSx file system does not
-- disassociate until all data is uploaded.
--
-- 'fileSystemAssociationARN', 'disassociateFileSystem_fileSystemAssociationARN' - The Amazon Resource Name (ARN) of the file system association to be
-- deleted.
newDisassociateFileSystem ::
  -- | 'fileSystemAssociationARN'
  Prelude.Text ->
  DisassociateFileSystem
newDisassociateFileSystem :: Text -> DisassociateFileSystem
newDisassociateFileSystem Text
pFileSystemAssociationARN_ =
  DisassociateFileSystem'
    { $sel:forceDelete:DisassociateFileSystem' :: Maybe Bool
forceDelete =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fileSystemAssociationARN:DisassociateFileSystem' :: Text
fileSystemAssociationARN =
        Text
pFileSystemAssociationARN_
    }

-- | If this value is set to true, the operation disassociates an Amazon FSx
-- file system immediately. It ends all data uploads to the file system,
-- and the file system association enters the @FORCE_DELETING@ status. If
-- this value is set to false, the Amazon FSx file system does not
-- disassociate until all data is uploaded.
disassociateFileSystem_forceDelete :: Lens.Lens' DisassociateFileSystem (Prelude.Maybe Prelude.Bool)
disassociateFileSystem_forceDelete :: Lens' DisassociateFileSystem (Maybe Bool)
disassociateFileSystem_forceDelete = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateFileSystem' {Maybe Bool
forceDelete :: Maybe Bool
$sel:forceDelete:DisassociateFileSystem' :: DisassociateFileSystem -> Maybe Bool
forceDelete} -> Maybe Bool
forceDelete) (\s :: DisassociateFileSystem
s@DisassociateFileSystem' {} Maybe Bool
a -> DisassociateFileSystem
s {$sel:forceDelete:DisassociateFileSystem' :: Maybe Bool
forceDelete = Maybe Bool
a} :: DisassociateFileSystem)

-- | The Amazon Resource Name (ARN) of the file system association to be
-- deleted.
disassociateFileSystem_fileSystemAssociationARN :: Lens.Lens' DisassociateFileSystem Prelude.Text
disassociateFileSystem_fileSystemAssociationARN :: Lens' DisassociateFileSystem Text
disassociateFileSystem_fileSystemAssociationARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateFileSystem' {Text
fileSystemAssociationARN :: Text
$sel:fileSystemAssociationARN:DisassociateFileSystem' :: DisassociateFileSystem -> Text
fileSystemAssociationARN} -> Text
fileSystemAssociationARN) (\s :: DisassociateFileSystem
s@DisassociateFileSystem' {} Text
a -> DisassociateFileSystem
s {$sel:fileSystemAssociationARN:DisassociateFileSystem' :: Text
fileSystemAssociationARN = Text
a} :: DisassociateFileSystem)

instance Core.AWSRequest DisassociateFileSystem where
  type
    AWSResponse DisassociateFileSystem =
      DisassociateFileSystemResponse
  request :: (Service -> Service)
-> DisassociateFileSystem -> Request DisassociateFileSystem
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 DisassociateFileSystem
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateFileSystem)))
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 -> Int -> DisassociateFileSystemResponse
DisassociateFileSystemResponse'
            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
"FileSystemAssociationARN")
            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 DisassociateFileSystem where
  hashWithSalt :: Int -> DisassociateFileSystem -> Int
hashWithSalt Int
_salt DisassociateFileSystem' {Maybe Bool
Text
fileSystemAssociationARN :: Text
forceDelete :: Maybe Bool
$sel:fileSystemAssociationARN:DisassociateFileSystem' :: DisassociateFileSystem -> Text
$sel:forceDelete:DisassociateFileSystem' :: DisassociateFileSystem -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
forceDelete
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fileSystemAssociationARN

instance Prelude.NFData DisassociateFileSystem where
  rnf :: DisassociateFileSystem -> ()
rnf DisassociateFileSystem' {Maybe Bool
Text
fileSystemAssociationARN :: Text
forceDelete :: Maybe Bool
$sel:fileSystemAssociationARN:DisassociateFileSystem' :: DisassociateFileSystem -> Text
$sel:forceDelete:DisassociateFileSystem' :: DisassociateFileSystem -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
forceDelete
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fileSystemAssociationARN

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

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

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

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

-- |
-- Create a value of 'DisassociateFileSystemResponse' 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:
--
-- 'fileSystemAssociationARN', 'disassociateFileSystemResponse_fileSystemAssociationARN' - The Amazon Resource Name (ARN) of the deleted file system association.
--
-- 'httpStatus', 'disassociateFileSystemResponse_httpStatus' - The response's http status code.
newDisassociateFileSystemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateFileSystemResponse
newDisassociateFileSystemResponse :: Int -> DisassociateFileSystemResponse
newDisassociateFileSystemResponse Int
pHttpStatus_ =
  DisassociateFileSystemResponse'
    { $sel:fileSystemAssociationARN:DisassociateFileSystemResponse' :: Maybe Text
fileSystemAssociationARN =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateFileSystemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the deleted file system association.
disassociateFileSystemResponse_fileSystemAssociationARN :: Lens.Lens' DisassociateFileSystemResponse (Prelude.Maybe Prelude.Text)
disassociateFileSystemResponse_fileSystemAssociationARN :: Lens' DisassociateFileSystemResponse (Maybe Text)
disassociateFileSystemResponse_fileSystemAssociationARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateFileSystemResponse' {Maybe Text
fileSystemAssociationARN :: Maybe Text
$sel:fileSystemAssociationARN:DisassociateFileSystemResponse' :: DisassociateFileSystemResponse -> Maybe Text
fileSystemAssociationARN} -> Maybe Text
fileSystemAssociationARN) (\s :: DisassociateFileSystemResponse
s@DisassociateFileSystemResponse' {} Maybe Text
a -> DisassociateFileSystemResponse
s {$sel:fileSystemAssociationARN:DisassociateFileSystemResponse' :: Maybe Text
fileSystemAssociationARN = Maybe Text
a} :: DisassociateFileSystemResponse)

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

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