{-# 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.BackupGateway.DisassociateGatewayFromServer
-- 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 a backup gateway from the specified server. After the
-- disassociation process finishes, the gateway can no longer access the
-- virtual machines on the server.
module Amazonka.BackupGateway.DisassociateGatewayFromServer
  ( -- * Creating a Request
    DisassociateGatewayFromServer (..),
    newDisassociateGatewayFromServer,

    -- * Request Lenses
    disassociateGatewayFromServer_gatewayArn,

    -- * Destructuring the Response
    DisassociateGatewayFromServerResponse (..),
    newDisassociateGatewayFromServerResponse,

    -- * Response Lenses
    disassociateGatewayFromServerResponse_gatewayArn,
    disassociateGatewayFromServerResponse_httpStatus,
  )
where

import Amazonka.BackupGateway.Types
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

-- | /See:/ 'newDisassociateGatewayFromServer' smart constructor.
data DisassociateGatewayFromServer = DisassociateGatewayFromServer'
  { -- | The Amazon Resource Name (ARN) of the gateway to disassociate.
    DisassociateGatewayFromServer -> Text
gatewayArn :: Prelude.Text
  }
  deriving (DisassociateGatewayFromServer
-> DisassociateGatewayFromServer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateGatewayFromServer
-> DisassociateGatewayFromServer -> Bool
$c/= :: DisassociateGatewayFromServer
-> DisassociateGatewayFromServer -> Bool
== :: DisassociateGatewayFromServer
-> DisassociateGatewayFromServer -> Bool
$c== :: DisassociateGatewayFromServer
-> DisassociateGatewayFromServer -> Bool
Prelude.Eq, ReadPrec [DisassociateGatewayFromServer]
ReadPrec DisassociateGatewayFromServer
Int -> ReadS DisassociateGatewayFromServer
ReadS [DisassociateGatewayFromServer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateGatewayFromServer]
$creadListPrec :: ReadPrec [DisassociateGatewayFromServer]
readPrec :: ReadPrec DisassociateGatewayFromServer
$creadPrec :: ReadPrec DisassociateGatewayFromServer
readList :: ReadS [DisassociateGatewayFromServer]
$creadList :: ReadS [DisassociateGatewayFromServer]
readsPrec :: Int -> ReadS DisassociateGatewayFromServer
$creadsPrec :: Int -> ReadS DisassociateGatewayFromServer
Prelude.Read, Int -> DisassociateGatewayFromServer -> ShowS
[DisassociateGatewayFromServer] -> ShowS
DisassociateGatewayFromServer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateGatewayFromServer] -> ShowS
$cshowList :: [DisassociateGatewayFromServer] -> ShowS
show :: DisassociateGatewayFromServer -> String
$cshow :: DisassociateGatewayFromServer -> String
showsPrec :: Int -> DisassociateGatewayFromServer -> ShowS
$cshowsPrec :: Int -> DisassociateGatewayFromServer -> ShowS
Prelude.Show, forall x.
Rep DisassociateGatewayFromServer x
-> DisassociateGatewayFromServer
forall x.
DisassociateGatewayFromServer
-> Rep DisassociateGatewayFromServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateGatewayFromServer x
-> DisassociateGatewayFromServer
$cfrom :: forall x.
DisassociateGatewayFromServer
-> Rep DisassociateGatewayFromServer x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateGatewayFromServer' 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:
--
-- 'gatewayArn', 'disassociateGatewayFromServer_gatewayArn' - The Amazon Resource Name (ARN) of the gateway to disassociate.
newDisassociateGatewayFromServer ::
  -- | 'gatewayArn'
  Prelude.Text ->
  DisassociateGatewayFromServer
newDisassociateGatewayFromServer :: Text -> DisassociateGatewayFromServer
newDisassociateGatewayFromServer Text
pGatewayArn_ =
  DisassociateGatewayFromServer'
    { $sel:gatewayArn:DisassociateGatewayFromServer' :: Text
gatewayArn =
        Text
pGatewayArn_
    }

-- | The Amazon Resource Name (ARN) of the gateway to disassociate.
disassociateGatewayFromServer_gatewayArn :: Lens.Lens' DisassociateGatewayFromServer Prelude.Text
disassociateGatewayFromServer_gatewayArn :: Lens' DisassociateGatewayFromServer Text
disassociateGatewayFromServer_gatewayArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateGatewayFromServer' {Text
gatewayArn :: Text
$sel:gatewayArn:DisassociateGatewayFromServer' :: DisassociateGatewayFromServer -> Text
gatewayArn} -> Text
gatewayArn) (\s :: DisassociateGatewayFromServer
s@DisassociateGatewayFromServer' {} Text
a -> DisassociateGatewayFromServer
s {$sel:gatewayArn:DisassociateGatewayFromServer' :: Text
gatewayArn = Text
a} :: DisassociateGatewayFromServer)

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

instance Prelude.NFData DisassociateGatewayFromServer where
  rnf :: DisassociateGatewayFromServer -> ()
rnf DisassociateGatewayFromServer' {Text
gatewayArn :: Text
$sel:gatewayArn:DisassociateGatewayFromServer' :: DisassociateGatewayFromServer -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
gatewayArn

instance Data.ToHeaders DisassociateGatewayFromServer where
  toHeaders :: DisassociateGatewayFromServer -> 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
"BackupOnPremises_v20210101.DisassociateGatewayFromServer" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DisassociateGatewayFromServer where
  toJSON :: DisassociateGatewayFromServer -> Value
toJSON DisassociateGatewayFromServer' {Text
gatewayArn :: Text
$sel:gatewayArn:DisassociateGatewayFromServer' :: DisassociateGatewayFromServer -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"GatewayArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
gatewayArn)]
      )

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

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

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

-- |
-- Create a value of 'DisassociateGatewayFromServerResponse' 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:
--
-- 'gatewayArn', 'disassociateGatewayFromServerResponse_gatewayArn' - The Amazon Resource Name (ARN) of the gateway you disassociated.
--
-- 'httpStatus', 'disassociateGatewayFromServerResponse_httpStatus' - The response's http status code.
newDisassociateGatewayFromServerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateGatewayFromServerResponse
newDisassociateGatewayFromServerResponse :: Int -> DisassociateGatewayFromServerResponse
newDisassociateGatewayFromServerResponse Int
pHttpStatus_ =
  DisassociateGatewayFromServerResponse'
    { $sel:gatewayArn:DisassociateGatewayFromServerResponse' :: Maybe Text
gatewayArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateGatewayFromServerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the gateway you disassociated.
disassociateGatewayFromServerResponse_gatewayArn :: Lens.Lens' DisassociateGatewayFromServerResponse (Prelude.Maybe Prelude.Text)
disassociateGatewayFromServerResponse_gatewayArn :: Lens' DisassociateGatewayFromServerResponse (Maybe Text)
disassociateGatewayFromServerResponse_gatewayArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateGatewayFromServerResponse' {Maybe Text
gatewayArn :: Maybe Text
$sel:gatewayArn:DisassociateGatewayFromServerResponse' :: DisassociateGatewayFromServerResponse -> Maybe Text
gatewayArn} -> Maybe Text
gatewayArn) (\s :: DisassociateGatewayFromServerResponse
s@DisassociateGatewayFromServerResponse' {} Maybe Text
a -> DisassociateGatewayFromServerResponse
s {$sel:gatewayArn:DisassociateGatewayFromServerResponse' :: Maybe Text
gatewayArn = Maybe Text
a} :: DisassociateGatewayFromServerResponse)

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

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