{-# 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.UpdateGatewaySoftwareNow
-- 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)
--
-- Updates the gateway virtual machine (VM) software. The request
-- immediately triggers the software update.
--
-- When you make this request, you get a @200 OK@ success response
-- immediately. However, it might take some time for the update to
-- complete. You can call DescribeGatewayInformation to verify the gateway
-- is in the @STATE_RUNNING@ state.
--
-- A software update forces a system restart of your gateway. You can
-- minimize the chance of any disruption to your applications by increasing
-- your iSCSI Initiators\' timeouts. For more information about increasing
-- iSCSI Initiator timeouts for Windows and Linux, see
-- <https://docs.aws.amazon.com/storagegateway/latest/userguide/ConfiguringiSCSIClientInitiatorWindowsClient.html#CustomizeWindowsiSCSISettings Customizing your Windows iSCSI settings>
-- and
-- <https://docs.aws.amazon.com/storagegateway/latest/userguide/ConfiguringiSCSIClientInitiatorRedHatClient.html#CustomizeLinuxiSCSISettings Customizing your Linux iSCSI settings>,
-- respectively.
module Amazonka.StorageGateway.UpdateGatewaySoftwareNow
  ( -- * Creating a Request
    UpdateGatewaySoftwareNow (..),
    newUpdateGatewaySoftwareNow,

    -- * Request Lenses
    updateGatewaySoftwareNow_gatewayARN,

    -- * Destructuring the Response
    UpdateGatewaySoftwareNowResponse (..),
    newUpdateGatewaySoftwareNowResponse,

    -- * Response Lenses
    updateGatewaySoftwareNowResponse_gatewayARN,
    updateGatewaySoftwareNowResponse_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 update.
--
-- /See:/ 'newUpdateGatewaySoftwareNow' smart constructor.
data UpdateGatewaySoftwareNow = UpdateGatewaySoftwareNow'
  { UpdateGatewaySoftwareNow -> Text
gatewayARN :: Prelude.Text
  }
  deriving (UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool
(UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool)
-> (UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool)
-> Eq UpdateGatewaySoftwareNow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool
$c/= :: UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool
== :: UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool
$c== :: UpdateGatewaySoftwareNow -> UpdateGatewaySoftwareNow -> Bool
Prelude.Eq, ReadPrec [UpdateGatewaySoftwareNow]
ReadPrec UpdateGatewaySoftwareNow
Int -> ReadS UpdateGatewaySoftwareNow
ReadS [UpdateGatewaySoftwareNow]
(Int -> ReadS UpdateGatewaySoftwareNow)
-> ReadS [UpdateGatewaySoftwareNow]
-> ReadPrec UpdateGatewaySoftwareNow
-> ReadPrec [UpdateGatewaySoftwareNow]
-> Read UpdateGatewaySoftwareNow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGatewaySoftwareNow]
$creadListPrec :: ReadPrec [UpdateGatewaySoftwareNow]
readPrec :: ReadPrec UpdateGatewaySoftwareNow
$creadPrec :: ReadPrec UpdateGatewaySoftwareNow
readList :: ReadS [UpdateGatewaySoftwareNow]
$creadList :: ReadS [UpdateGatewaySoftwareNow]
readsPrec :: Int -> ReadS UpdateGatewaySoftwareNow
$creadsPrec :: Int -> ReadS UpdateGatewaySoftwareNow
Prelude.Read, Int -> UpdateGatewaySoftwareNow -> ShowS
[UpdateGatewaySoftwareNow] -> ShowS
UpdateGatewaySoftwareNow -> String
(Int -> UpdateGatewaySoftwareNow -> ShowS)
-> (UpdateGatewaySoftwareNow -> String)
-> ([UpdateGatewaySoftwareNow] -> ShowS)
-> Show UpdateGatewaySoftwareNow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGatewaySoftwareNow] -> ShowS
$cshowList :: [UpdateGatewaySoftwareNow] -> ShowS
show :: UpdateGatewaySoftwareNow -> String
$cshow :: UpdateGatewaySoftwareNow -> String
showsPrec :: Int -> UpdateGatewaySoftwareNow -> ShowS
$cshowsPrec :: Int -> UpdateGatewaySoftwareNow -> ShowS
Prelude.Show, (forall x.
 UpdateGatewaySoftwareNow -> Rep UpdateGatewaySoftwareNow x)
-> (forall x.
    Rep UpdateGatewaySoftwareNow x -> UpdateGatewaySoftwareNow)
-> Generic UpdateGatewaySoftwareNow
forall x.
Rep UpdateGatewaySoftwareNow x -> UpdateGatewaySoftwareNow
forall x.
UpdateGatewaySoftwareNow -> Rep UpdateGatewaySoftwareNow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateGatewaySoftwareNow x -> UpdateGatewaySoftwareNow
$cfrom :: forall x.
UpdateGatewaySoftwareNow -> Rep UpdateGatewaySoftwareNow x
Prelude.Generic)

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

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

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

instance Prelude.NFData UpdateGatewaySoftwareNow

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

instance Core.ToQuery UpdateGatewaySoftwareNow where
  toQuery :: UpdateGatewaySoftwareNow -> QueryString
toQuery = QueryString -> UpdateGatewaySoftwareNow -> 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 updated.
--
-- /See:/ 'newUpdateGatewaySoftwareNowResponse' smart constructor.
data UpdateGatewaySoftwareNowResponse = UpdateGatewaySoftwareNowResponse'
  { UpdateGatewaySoftwareNowResponse -> Maybe Text
gatewayARN :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateGatewaySoftwareNowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateGatewaySoftwareNowResponse
-> UpdateGatewaySoftwareNowResponse -> Bool
(UpdateGatewaySoftwareNowResponse
 -> UpdateGatewaySoftwareNowResponse -> Bool)
-> (UpdateGatewaySoftwareNowResponse
    -> UpdateGatewaySoftwareNowResponse -> Bool)
-> Eq UpdateGatewaySoftwareNowResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGatewaySoftwareNowResponse
-> UpdateGatewaySoftwareNowResponse -> Bool
$c/= :: UpdateGatewaySoftwareNowResponse
-> UpdateGatewaySoftwareNowResponse -> Bool
== :: UpdateGatewaySoftwareNowResponse
-> UpdateGatewaySoftwareNowResponse -> Bool
$c== :: UpdateGatewaySoftwareNowResponse
-> UpdateGatewaySoftwareNowResponse -> Bool
Prelude.Eq, ReadPrec [UpdateGatewaySoftwareNowResponse]
ReadPrec UpdateGatewaySoftwareNowResponse
Int -> ReadS UpdateGatewaySoftwareNowResponse
ReadS [UpdateGatewaySoftwareNowResponse]
(Int -> ReadS UpdateGatewaySoftwareNowResponse)
-> ReadS [UpdateGatewaySoftwareNowResponse]
-> ReadPrec UpdateGatewaySoftwareNowResponse
-> ReadPrec [UpdateGatewaySoftwareNowResponse]
-> Read UpdateGatewaySoftwareNowResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGatewaySoftwareNowResponse]
$creadListPrec :: ReadPrec [UpdateGatewaySoftwareNowResponse]
readPrec :: ReadPrec UpdateGatewaySoftwareNowResponse
$creadPrec :: ReadPrec UpdateGatewaySoftwareNowResponse
readList :: ReadS [UpdateGatewaySoftwareNowResponse]
$creadList :: ReadS [UpdateGatewaySoftwareNowResponse]
readsPrec :: Int -> ReadS UpdateGatewaySoftwareNowResponse
$creadsPrec :: Int -> ReadS UpdateGatewaySoftwareNowResponse
Prelude.Read, Int -> UpdateGatewaySoftwareNowResponse -> ShowS
[UpdateGatewaySoftwareNowResponse] -> ShowS
UpdateGatewaySoftwareNowResponse -> String
(Int -> UpdateGatewaySoftwareNowResponse -> ShowS)
-> (UpdateGatewaySoftwareNowResponse -> String)
-> ([UpdateGatewaySoftwareNowResponse] -> ShowS)
-> Show UpdateGatewaySoftwareNowResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGatewaySoftwareNowResponse] -> ShowS
$cshowList :: [UpdateGatewaySoftwareNowResponse] -> ShowS
show :: UpdateGatewaySoftwareNowResponse -> String
$cshow :: UpdateGatewaySoftwareNowResponse -> String
showsPrec :: Int -> UpdateGatewaySoftwareNowResponse -> ShowS
$cshowsPrec :: Int -> UpdateGatewaySoftwareNowResponse -> ShowS
Prelude.Show, (forall x.
 UpdateGatewaySoftwareNowResponse
 -> Rep UpdateGatewaySoftwareNowResponse x)
-> (forall x.
    Rep UpdateGatewaySoftwareNowResponse x
    -> UpdateGatewaySoftwareNowResponse)
-> Generic UpdateGatewaySoftwareNowResponse
forall x.
Rep UpdateGatewaySoftwareNowResponse x
-> UpdateGatewaySoftwareNowResponse
forall x.
UpdateGatewaySoftwareNowResponse
-> Rep UpdateGatewaySoftwareNowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateGatewaySoftwareNowResponse x
-> UpdateGatewaySoftwareNowResponse
$cfrom :: forall x.
UpdateGatewaySoftwareNowResponse
-> Rep UpdateGatewaySoftwareNowResponse x
Prelude.Generic)

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

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

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

instance
  Prelude.NFData
    UpdateGatewaySoftwareNowResponse