{-# 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.OpsWorks.RebootInstance
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Reboots a specified instance. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-starting.html Starting, Stopping, and Rebooting Instances>.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.RebootInstance
  ( -- * Creating a Request
    RebootInstance (..),
    newRebootInstance,

    -- * Request Lenses
    rebootInstance_instanceId,

    -- * Destructuring the Response
    RebootInstanceResponse (..),
    newRebootInstanceResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'RebootInstance' 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:
--
-- 'instanceId', 'rebootInstance_instanceId' - The instance ID.
newRebootInstance ::
  -- | 'instanceId'
  Prelude.Text ->
  RebootInstance
newRebootInstance :: Text -> RebootInstance
newRebootInstance Text
pInstanceId_ =
  RebootInstance' {$sel:instanceId:RebootInstance' :: Text
instanceId = Text
pInstanceId_}

-- | The instance ID.
rebootInstance_instanceId :: Lens.Lens' RebootInstance Prelude.Text
rebootInstance_instanceId :: Lens' RebootInstance Text
rebootInstance_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootInstance' {Text
instanceId :: Text
$sel:instanceId:RebootInstance' :: RebootInstance -> Text
instanceId} -> Text
instanceId) (\s :: RebootInstance
s@RebootInstance' {} Text
a -> RebootInstance
s {$sel:instanceId:RebootInstance' :: Text
instanceId = Text
a} :: RebootInstance)

instance Core.AWSRequest RebootInstance where
  type
    AWSResponse RebootInstance =
      RebootInstanceResponse
  request :: (Service -> Service) -> RebootInstance -> Request RebootInstance
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 RebootInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootInstance)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull RebootInstanceResponse
RebootInstanceResponse'

instance Prelude.Hashable RebootInstance where
  hashWithSalt :: Int -> RebootInstance -> Int
hashWithSalt Int
_salt RebootInstance' {Text
instanceId :: Text
$sel:instanceId:RebootInstance' :: RebootInstance -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId

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

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

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

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

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

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

-- |
-- Create a value of 'RebootInstanceResponse' 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.
newRebootInstanceResponse ::
  RebootInstanceResponse
newRebootInstanceResponse :: RebootInstanceResponse
newRebootInstanceResponse = RebootInstanceResponse
RebootInstanceResponse'

instance Prelude.NFData RebootInstanceResponse where
  rnf :: RebootInstanceResponse -> ()
rnf RebootInstanceResponse
_ = ()