{-# 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.ShutdownGateway
-- 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)
--
-- Shuts down a gateway. To specify which gateway to shut down, use the
-- Amazon Resource Name (ARN) of the gateway in the body of your request.
--
-- The operation shuts down the gateway service component running in the
-- gateway\'s virtual machine (VM) and not the host VM.
--
-- If you want to shut down the VM, it is recommended that you first shut
-- down the gateway component in the VM to avoid unpredictable conditions.
--
-- After the gateway is shutdown, you cannot call any other API except
-- StartGateway, DescribeGatewayInformation, and ListGateways. For more
-- information, see ActivateGateway. Your applications cannot read from or
-- write to the gateway\'s storage volumes, and there are no snapshots
-- taken.
--
-- When you make a shutdown request, you will get a @200 OK@ success
-- response immediately. However, it might take some time for the gateway
-- to shut down. You can call the DescribeGatewayInformation API to check
-- the status. For more information, see ActivateGateway.
--
-- If do not intend to use the gateway again, you must delete the gateway
-- (using DeleteGateway) to no longer pay software charges associated with
-- the gateway.
module Amazonka.StorageGateway.ShutdownGateway
  ( -- * Creating a Request
    ShutdownGateway (..),
    newShutdownGateway,

    -- * Request Lenses
    shutdownGateway_gatewayARN,

    -- * Destructuring the Response
    ShutdownGatewayResponse (..),
    newShutdownGatewayResponse,

    -- * Response Lenses
    shutdownGatewayResponse_gatewayARN,
    shutdownGatewayResponse_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

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

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

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

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

instance Prelude.NFData ShutdownGateway

instance Core.ToHeaders ShutdownGateway where
  toHeaders :: ShutdownGateway -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ShutdownGateway -> 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.ShutdownGateway" ::
                          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 ShutdownGateway where
  toJSON :: ShutdownGateway -> Value
toJSON ShutdownGateway' {Text
gatewayARN :: Text
$sel:gatewayARN:ShutdownGateway' :: ShutdownGateway -> 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 ShutdownGateway where
  toPath :: ShutdownGateway -> ByteString
toPath = ByteString -> ShutdownGateway -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'ShutdownGatewayResponse' 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', 'shutdownGatewayResponse_gatewayARN' - Undocumented member.
--
-- 'httpStatus', 'shutdownGatewayResponse_httpStatus' - The response's http status code.
newShutdownGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ShutdownGatewayResponse
newShutdownGatewayResponse :: Int -> ShutdownGatewayResponse
newShutdownGatewayResponse Int
pHttpStatus_ =
  ShutdownGatewayResponse' :: Maybe Text -> Int -> ShutdownGatewayResponse
ShutdownGatewayResponse'
    { $sel:gatewayARN:ShutdownGatewayResponse' :: Maybe Text
gatewayARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ShutdownGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData ShutdownGatewayResponse