{-# 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-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)
--
-- 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.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

-- | /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
(DisassociateFileSystem -> DisassociateFileSystem -> Bool)
-> (DisassociateFileSystem -> DisassociateFileSystem -> Bool)
-> Eq DisassociateFileSystem
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]
(Int -> ReadS DisassociateFileSystem)
-> ReadS [DisassociateFileSystem]
-> ReadPrec DisassociateFileSystem
-> ReadPrec [DisassociateFileSystem]
-> Read 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
(Int -> DisassociateFileSystem -> ShowS)
-> (DisassociateFileSystem -> String)
-> ([DisassociateFileSystem] -> ShowS)
-> Show DisassociateFileSystem
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. DisassociateFileSystem -> Rep DisassociateFileSystem x)
-> (forall x.
    Rep DisassociateFileSystem x -> DisassociateFileSystem)
-> Generic DisassociateFileSystem
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' :: Maybe Bool -> Text -> DisassociateFileSystem
DisassociateFileSystem'
    { $sel:forceDelete:DisassociateFileSystem' :: Maybe Bool
forceDelete =
        Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> DisassociateFileSystem -> f DisassociateFileSystem
disassociateFileSystem_forceDelete = (DisassociateFileSystem -> Maybe Bool)
-> (DisassociateFileSystem -> Maybe Bool -> DisassociateFileSystem)
-> Lens
     DisassociateFileSystem
     DisassociateFileSystem
     (Maybe Bool)
     (Maybe Bool)
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 :: (Text -> f Text)
-> DisassociateFileSystem -> f DisassociateFileSystem
disassociateFileSystem_fileSystemAssociationARN = (DisassociateFileSystem -> Text)
-> (DisassociateFileSystem -> Text -> DisassociateFileSystem)
-> Lens DisassociateFileSystem DisassociateFileSystem Text Text
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 :: DisassociateFileSystem -> Request DisassociateFileSystem
request = Service -> DisassociateFileSystem -> Request DisassociateFileSystem
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateFileSystem
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateFileSystem)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisassociateFileSystem))
-> Logger
-> Service
-> Proxy DisassociateFileSystem
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateFileSystem)))
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 -> DisassociateFileSystemResponse
DisassociateFileSystemResponse'
            (Maybe Text -> Int -> DisassociateFileSystemResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DisassociateFileSystemResponse)
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
"FileSystemAssociationARN")
            Either String (Int -> DisassociateFileSystemResponse)
-> Either String Int
-> Either String DisassociateFileSystemResponse
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 DisassociateFileSystem

instance Prelude.NFData DisassociateFileSystem

instance Core.ToHeaders DisassociateFileSystem where
  toHeaders :: DisassociateFileSystem -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateFileSystem -> 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.DisassociateFileSystem" ::
                          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 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
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
"FileSystemAssociationARN"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fileSystemAssociationARN
              )
          ]
      )

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

instance Core.ToQuery DisassociateFileSystem where
  toQuery :: DisassociateFileSystem -> QueryString
toQuery = QueryString -> DisassociateFileSystem -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DisassociateFileSystemResponse
 -> DisassociateFileSystemResponse -> Bool)
-> (DisassociateFileSystemResponse
    -> DisassociateFileSystemResponse -> Bool)
-> Eq DisassociateFileSystemResponse
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]
(Int -> ReadS DisassociateFileSystemResponse)
-> ReadS [DisassociateFileSystemResponse]
-> ReadPrec DisassociateFileSystemResponse
-> ReadPrec [DisassociateFileSystemResponse]
-> Read 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
(Int -> DisassociateFileSystemResponse -> ShowS)
-> (DisassociateFileSystemResponse -> String)
-> ([DisassociateFileSystemResponse] -> ShowS)
-> Show DisassociateFileSystemResponse
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.
 DisassociateFileSystemResponse
 -> Rep DisassociateFileSystemResponse x)
-> (forall x.
    Rep DisassociateFileSystemResponse x
    -> DisassociateFileSystemResponse)
-> Generic DisassociateFileSystemResponse
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' :: Maybe Text -> Int -> DisassociateFileSystemResponse
DisassociateFileSystemResponse'
    { $sel:fileSystemAssociationARN:DisassociateFileSystemResponse' :: Maybe Text
fileSystemAssociationARN =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DisassociateFileSystemResponse
-> f DisassociateFileSystemResponse
disassociateFileSystemResponse_fileSystemAssociationARN = (DisassociateFileSystemResponse -> Maybe Text)
-> (DisassociateFileSystemResponse
    -> Maybe Text -> DisassociateFileSystemResponse)
-> Lens
     DisassociateFileSystemResponse
     DisassociateFileSystemResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> DisassociateFileSystemResponse
-> f DisassociateFileSystemResponse
disassociateFileSystemResponse_httpStatus = (DisassociateFileSystemResponse -> Int)
-> (DisassociateFileSystemResponse
    -> Int -> DisassociateFileSystemResponse)
-> Lens
     DisassociateFileSystemResponse
     DisassociateFileSystemResponse
     Int
     Int
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