{-# 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-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)
--
-- 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.Lens as Lens
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
(RebootInstance -> RebootInstance -> Bool)
-> (RebootInstance -> RebootInstance -> Bool) -> Eq RebootInstance
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]
(Int -> ReadS RebootInstance)
-> ReadS [RebootInstance]
-> ReadPrec RebootInstance
-> ReadPrec [RebootInstance]
-> Read 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
(Int -> RebootInstance -> ShowS)
-> (RebootInstance -> String)
-> ([RebootInstance] -> ShowS)
-> Show RebootInstance
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. RebootInstance -> Rep RebootInstance x)
-> (forall x. Rep RebootInstance x -> RebootInstance)
-> Generic RebootInstance
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' :: Text -> RebootInstance
RebootInstance' {$sel:instanceId:RebootInstance' :: Text
instanceId = Text
pInstanceId_}

-- | The instance ID.
rebootInstance_instanceId :: Lens.Lens' RebootInstance Prelude.Text
rebootInstance_instanceId :: (Text -> f Text) -> RebootInstance -> f RebootInstance
rebootInstance_instanceId = (RebootInstance -> Text)
-> (RebootInstance -> Text -> RebootInstance)
-> Lens RebootInstance RebootInstance Text Text
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 :: RebootInstance -> Request RebootInstance
request = Service -> RebootInstance -> Request RebootInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RebootInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootInstance)))
response =
    AWSResponse RebootInstance
-> Logger
-> Service
-> Proxy RebootInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootInstance)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse RebootInstance
RebootInstanceResponse
RebootInstanceResponse'

instance Prelude.Hashable RebootInstance

instance Prelude.NFData RebootInstance

instance Core.ToHeaders RebootInstance where
  toHeaders :: RebootInstance -> [Header]
toHeaders =
    [Header] -> RebootInstance -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.RebootInstance" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RebootInstance where
  toJSON :: RebootInstance -> Value
toJSON RebootInstance' {Text
instanceId :: Text
$sel:instanceId:RebootInstance' :: RebootInstance -> 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
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId)]
      )

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

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

-- | /See:/ 'newRebootInstanceResponse' smart constructor.
data RebootInstanceResponse = RebootInstanceResponse'
  {
  }
  deriving (RebootInstanceResponse -> RebootInstanceResponse -> Bool
(RebootInstanceResponse -> RebootInstanceResponse -> Bool)
-> (RebootInstanceResponse -> RebootInstanceResponse -> Bool)
-> Eq RebootInstanceResponse
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]
(Int -> ReadS RebootInstanceResponse)
-> ReadS [RebootInstanceResponse]
-> ReadPrec RebootInstanceResponse
-> ReadPrec [RebootInstanceResponse]
-> Read 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
(Int -> RebootInstanceResponse -> ShowS)
-> (RebootInstanceResponse -> String)
-> ([RebootInstanceResponse] -> ShowS)
-> Show RebootInstanceResponse
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. RebootInstanceResponse -> Rep RebootInstanceResponse x)
-> (forall x.
    Rep RebootInstanceResponse x -> RebootInstanceResponse)
-> Generic RebootInstanceResponse
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