{-# 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.DisableGateway
-- 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)
--
-- Disables a tape gateway when the gateway is no longer functioning. For
-- example, if your gateway VM is damaged, you can disable the gateway so
-- you can recover virtual tapes.
--
-- Use this operation for a tape gateway that is not reachable or not
-- functioning. This operation is only supported in the tape gateway type.
--
-- After a gateway is disabled, it cannot be enabled.
module Amazonka.StorageGateway.DisableGateway
  ( -- * Creating a Request
    DisableGateway (..),
    newDisableGateway,

    -- * Request Lenses
    disableGateway_gatewayARN,

    -- * Destructuring the Response
    DisableGatewayResponse (..),
    newDisableGatewayResponse,

    -- * Response Lenses
    disableGatewayResponse_gatewayARN,
    disableGatewayResponse_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

-- | DisableGatewayInput
--
-- /See:/ 'newDisableGateway' smart constructor.
data DisableGateway = DisableGateway'
  { DisableGateway -> Text
gatewayARN :: Prelude.Text
  }
  deriving (DisableGateway -> DisableGateway -> Bool
(DisableGateway -> DisableGateway -> Bool)
-> (DisableGateway -> DisableGateway -> Bool) -> Eq DisableGateway
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableGateway -> DisableGateway -> Bool
$c/= :: DisableGateway -> DisableGateway -> Bool
== :: DisableGateway -> DisableGateway -> Bool
$c== :: DisableGateway -> DisableGateway -> Bool
Prelude.Eq, ReadPrec [DisableGateway]
ReadPrec DisableGateway
Int -> ReadS DisableGateway
ReadS [DisableGateway]
(Int -> ReadS DisableGateway)
-> ReadS [DisableGateway]
-> ReadPrec DisableGateway
-> ReadPrec [DisableGateway]
-> Read DisableGateway
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableGateway]
$creadListPrec :: ReadPrec [DisableGateway]
readPrec :: ReadPrec DisableGateway
$creadPrec :: ReadPrec DisableGateway
readList :: ReadS [DisableGateway]
$creadList :: ReadS [DisableGateway]
readsPrec :: Int -> ReadS DisableGateway
$creadsPrec :: Int -> ReadS DisableGateway
Prelude.Read, Int -> DisableGateway -> ShowS
[DisableGateway] -> ShowS
DisableGateway -> String
(Int -> DisableGateway -> ShowS)
-> (DisableGateway -> String)
-> ([DisableGateway] -> ShowS)
-> Show DisableGateway
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableGateway] -> ShowS
$cshowList :: [DisableGateway] -> ShowS
show :: DisableGateway -> String
$cshow :: DisableGateway -> String
showsPrec :: Int -> DisableGateway -> ShowS
$cshowsPrec :: Int -> DisableGateway -> ShowS
Prelude.Show, (forall x. DisableGateway -> Rep DisableGateway x)
-> (forall x. Rep DisableGateway x -> DisableGateway)
-> Generic DisableGateway
forall x. Rep DisableGateway x -> DisableGateway
forall x. DisableGateway -> Rep DisableGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableGateway x -> DisableGateway
$cfrom :: forall x. DisableGateway -> Rep DisableGateway x
Prelude.Generic)

-- |
-- Create a value of 'DisableGateway' 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', 'disableGateway_gatewayARN' - Undocumented member.
newDisableGateway ::
  -- | 'gatewayARN'
  Prelude.Text ->
  DisableGateway
newDisableGateway :: Text -> DisableGateway
newDisableGateway Text
pGatewayARN_ =
  DisableGateway' :: Text -> DisableGateway
DisableGateway' {$sel:gatewayARN:DisableGateway' :: Text
gatewayARN = Text
pGatewayARN_}

-- | Undocumented member.
disableGateway_gatewayARN :: Lens.Lens' DisableGateway Prelude.Text
disableGateway_gatewayARN :: (Text -> f Text) -> DisableGateway -> f DisableGateway
disableGateway_gatewayARN = (DisableGateway -> Text)
-> (DisableGateway -> Text -> DisableGateway)
-> Lens DisableGateway DisableGateway Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableGateway' {Text
gatewayARN :: Text
$sel:gatewayARN:DisableGateway' :: DisableGateway -> Text
gatewayARN} -> Text
gatewayARN) (\s :: DisableGateway
s@DisableGateway' {} Text
a -> DisableGateway
s {$sel:gatewayARN:DisableGateway' :: Text
gatewayARN = Text
a} :: DisableGateway)

instance Core.AWSRequest DisableGateway where
  type
    AWSResponse DisableGateway =
      DisableGatewayResponse
  request :: DisableGateway -> Request DisableGateway
request = Service -> DisableGateway -> Request DisableGateway
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableGateway)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisableGateway))
-> Logger
-> Service
-> Proxy DisableGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableGateway)))
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 -> DisableGatewayResponse
DisableGatewayResponse'
            (Maybe Text -> Int -> DisableGatewayResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DisableGatewayResponse)
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
"GatewayARN")
            Either String (Int -> DisableGatewayResponse)
-> Either String Int -> Either String DisableGatewayResponse
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 DisableGateway

instance Prelude.NFData DisableGateway

instance Core.ToHeaders DisableGateway where
  toHeaders :: DisableGateway -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisableGateway -> 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.DisableGateway" ::
                          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 DisableGateway where
  toJSON :: DisableGateway -> Value
toJSON DisableGateway' {Text
gatewayARN :: Text
$sel:gatewayARN:DisableGateway' :: DisableGateway -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GatewayARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayARN)]
      )

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

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

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

-- |
-- Create a value of 'DisableGatewayResponse' 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', 'disableGatewayResponse_gatewayARN' - The unique Amazon Resource Name (ARN) of the disabled gateway.
--
-- 'httpStatus', 'disableGatewayResponse_httpStatus' - The response's http status code.
newDisableGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisableGatewayResponse
newDisableGatewayResponse :: Int -> DisableGatewayResponse
newDisableGatewayResponse Int
pHttpStatus_ =
  DisableGatewayResponse' :: Maybe Text -> Int -> DisableGatewayResponse
DisableGatewayResponse'
    { $sel:gatewayARN:DisableGatewayResponse' :: Maybe Text
gatewayARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisableGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique Amazon Resource Name (ARN) of the disabled gateway.
disableGatewayResponse_gatewayARN :: Lens.Lens' DisableGatewayResponse (Prelude.Maybe Prelude.Text)
disableGatewayResponse_gatewayARN :: (Maybe Text -> f (Maybe Text))
-> DisableGatewayResponse -> f DisableGatewayResponse
disableGatewayResponse_gatewayARN = (DisableGatewayResponse -> Maybe Text)
-> (DisableGatewayResponse -> Maybe Text -> DisableGatewayResponse)
-> Lens
     DisableGatewayResponse
     DisableGatewayResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableGatewayResponse' {Maybe Text
gatewayARN :: Maybe Text
$sel:gatewayARN:DisableGatewayResponse' :: DisableGatewayResponse -> Maybe Text
gatewayARN} -> Maybe Text
gatewayARN) (\s :: DisableGatewayResponse
s@DisableGatewayResponse' {} Maybe Text
a -> DisableGatewayResponse
s {$sel:gatewayARN:DisableGatewayResponse' :: Maybe Text
gatewayARN = Maybe Text
a} :: DisableGatewayResponse)

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

instance Prelude.NFData DisableGatewayResponse