{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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
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
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]
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
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.
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'
    { $sel:gatewayARN:UpdateGatewaySoftwareNow' :: Text
gatewayARN =
        Text
pGatewayARN_
    }

-- | Undocumented member.
updateGatewaySoftwareNow_gatewayARN :: Lens.Lens' UpdateGatewaySoftwareNow Prelude.Text
updateGatewaySoftwareNow_gatewayARN :: Lens' UpdateGatewaySoftwareNow Text
updateGatewaySoftwareNow_gatewayARN = 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 :: (Service -> Service)
-> UpdateGatewaySoftwareNow -> Request UpdateGatewaySoftwareNow
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 UpdateGatewaySoftwareNow
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGatewaySoftwareNow)))
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 -> UpdateGatewaySoftwareNowResponse
UpdateGatewaySoftwareNowResponse'
            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 UpdateGatewaySoftwareNow where
  hashWithSalt :: Int -> UpdateGatewaySoftwareNow -> Int
hashWithSalt Int
_salt UpdateGatewaySoftwareNow' {Text
gatewayARN :: Text
$sel:gatewayARN:UpdateGatewaySoftwareNow' :: UpdateGatewaySoftwareNow -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gatewayARN

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

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

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

instance Data.ToQuery UpdateGatewaySoftwareNow where
  toQuery :: UpdateGatewaySoftwareNow -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:gatewayARN:UpdateGatewaySoftwareNowResponse' :: Maybe Text
gatewayARN =
        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 :: Lens' UpdateGatewaySoftwareNowResponse (Maybe Text)
updateGatewaySoftwareNowResponse_gatewayARN = 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 :: Lens' UpdateGatewaySoftwareNowResponse Int
updateGatewaySoftwareNowResponse_httpStatus = 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
  where
  rnf :: UpdateGatewaySoftwareNowResponse -> ()
rnf UpdateGatewaySoftwareNowResponse' {Int
Maybe Text
httpStatus :: Int
gatewayARN :: Maybe Text
$sel:httpStatus:UpdateGatewaySoftwareNowResponse' :: UpdateGatewaySoftwareNowResponse -> Int
$sel:gatewayARN:UpdateGatewaySoftwareNowResponse' :: UpdateGatewaySoftwareNowResponse -> 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