{-# 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.MediaLive.RebootInputDevice
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Send a reboot command to the specified input device. The device will
-- begin rebooting within a few seconds of sending the command. When the
-- reboot is complete, the device’s connection status will change to
-- connected.
module Amazonka.MediaLive.RebootInputDevice
  ( -- * Creating a Request
    RebootInputDevice' (..),
    newRebootInputDevice',

    -- * Request Lenses
    rebootInputDevice'_force,
    rebootInputDevice'_inputDeviceId,

    -- * Destructuring the Response
    RebootInputDeviceResponse (..),
    newRebootInputDeviceResponse,

    -- * Response Lenses
    rebootInputDeviceResponse_httpStatus,
  )
where

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

-- | A request to reboot an AWS Elemental device.
--
-- /See:/ 'newRebootInputDevice'' smart constructor.
data RebootInputDevice' = RebootInputDevice''
  { -- | Force a reboot of an input device. If the device is streaming, it will
    -- stop streaming and begin rebooting within a few seconds of sending the
    -- command. If the device was streaming prior to the reboot, the device
    -- will resume streaming when the reboot completes.
    RebootInputDevice' -> Maybe RebootInputDeviceForce
force :: Prelude.Maybe RebootInputDeviceForce,
    -- | The unique ID of the input device to reboot. For example,
    -- hd-123456789abcdef.
    RebootInputDevice' -> Text
inputDeviceId :: Prelude.Text
  }
  deriving (RebootInputDevice' -> RebootInputDevice' -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebootInputDevice' -> RebootInputDevice' -> Bool
$c/= :: RebootInputDevice' -> RebootInputDevice' -> Bool
== :: RebootInputDevice' -> RebootInputDevice' -> Bool
$c== :: RebootInputDevice' -> RebootInputDevice' -> Bool
Prelude.Eq, ReadPrec [RebootInputDevice']
ReadPrec RebootInputDevice'
Int -> ReadS RebootInputDevice'
ReadS [RebootInputDevice']
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebootInputDevice']
$creadListPrec :: ReadPrec [RebootInputDevice']
readPrec :: ReadPrec RebootInputDevice'
$creadPrec :: ReadPrec RebootInputDevice'
readList :: ReadS [RebootInputDevice']
$creadList :: ReadS [RebootInputDevice']
readsPrec :: Int -> ReadS RebootInputDevice'
$creadsPrec :: Int -> ReadS RebootInputDevice'
Prelude.Read, Int -> RebootInputDevice' -> ShowS
[RebootInputDevice'] -> ShowS
RebootInputDevice' -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebootInputDevice'] -> ShowS
$cshowList :: [RebootInputDevice'] -> ShowS
show :: RebootInputDevice' -> String
$cshow :: RebootInputDevice' -> String
showsPrec :: Int -> RebootInputDevice' -> ShowS
$cshowsPrec :: Int -> RebootInputDevice' -> ShowS
Prelude.Show, forall x. Rep RebootInputDevice' x -> RebootInputDevice'
forall x. RebootInputDevice' -> Rep RebootInputDevice' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RebootInputDevice' x -> RebootInputDevice'
$cfrom :: forall x. RebootInputDevice' -> Rep RebootInputDevice' x
Prelude.Generic)

-- |
-- Create a value of 'RebootInputDevice'' 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:
--
-- 'force', 'rebootInputDevice'_force' - Force a reboot of an input device. If the device is streaming, it will
-- stop streaming and begin rebooting within a few seconds of sending the
-- command. If the device was streaming prior to the reboot, the device
-- will resume streaming when the reboot completes.
--
-- 'inputDeviceId', 'rebootInputDevice'_inputDeviceId' - The unique ID of the input device to reboot. For example,
-- hd-123456789abcdef.
newRebootInputDevice' ::
  -- | 'inputDeviceId'
  Prelude.Text ->
  RebootInputDevice'
newRebootInputDevice' :: Text -> RebootInputDevice'
newRebootInputDevice' Text
pInputDeviceId_ =
  RebootInputDevice''
    { $sel:force:RebootInputDevice'' :: Maybe RebootInputDeviceForce
force = forall a. Maybe a
Prelude.Nothing,
      $sel:inputDeviceId:RebootInputDevice'' :: Text
inputDeviceId = Text
pInputDeviceId_
    }

-- | Force a reboot of an input device. If the device is streaming, it will
-- stop streaming and begin rebooting within a few seconds of sending the
-- command. If the device was streaming prior to the reboot, the device
-- will resume streaming when the reboot completes.
rebootInputDevice'_force :: Lens.Lens' RebootInputDevice' (Prelude.Maybe RebootInputDeviceForce)
rebootInputDevice'_force :: Lens' RebootInputDevice' (Maybe RebootInputDeviceForce)
rebootInputDevice'_force = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootInputDevice'' {Maybe RebootInputDeviceForce
force :: Maybe RebootInputDeviceForce
$sel:force:RebootInputDevice'' :: RebootInputDevice' -> Maybe RebootInputDeviceForce
force} -> Maybe RebootInputDeviceForce
force) (\s :: RebootInputDevice'
s@RebootInputDevice'' {} Maybe RebootInputDeviceForce
a -> RebootInputDevice'
s {$sel:force:RebootInputDevice'' :: Maybe RebootInputDeviceForce
force = Maybe RebootInputDeviceForce
a} :: RebootInputDevice')

-- | The unique ID of the input device to reboot. For example,
-- hd-123456789abcdef.
rebootInputDevice'_inputDeviceId :: Lens.Lens' RebootInputDevice' Prelude.Text
rebootInputDevice'_inputDeviceId :: Lens' RebootInputDevice' Text
rebootInputDevice'_inputDeviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootInputDevice'' {Text
inputDeviceId :: Text
$sel:inputDeviceId:RebootInputDevice'' :: RebootInputDevice' -> Text
inputDeviceId} -> Text
inputDeviceId) (\s :: RebootInputDevice'
s@RebootInputDevice'' {} Text
a -> RebootInputDevice'
s {$sel:inputDeviceId:RebootInputDevice'' :: Text
inputDeviceId = Text
a} :: RebootInputDevice')

instance Core.AWSRequest RebootInputDevice' where
  type
    AWSResponse RebootInputDevice' =
      RebootInputDeviceResponse
  request :: (Service -> Service)
-> RebootInputDevice' -> Request RebootInputDevice'
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 RebootInputDevice'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RebootInputDevice')))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RebootInputDeviceResponse
RebootInputDeviceResponse'
            forall (f :: * -> *) a b. Functor 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 RebootInputDevice' where
  hashWithSalt :: Int -> RebootInputDevice' -> Int
hashWithSalt Int
_salt RebootInputDevice'' {Maybe RebootInputDeviceForce
Text
inputDeviceId :: Text
force :: Maybe RebootInputDeviceForce
$sel:inputDeviceId:RebootInputDevice'' :: RebootInputDevice' -> Text
$sel:force:RebootInputDevice'' :: RebootInputDevice' -> Maybe RebootInputDeviceForce
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RebootInputDeviceForce
force
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
inputDeviceId

instance Prelude.NFData RebootInputDevice' where
  rnf :: RebootInputDevice' -> ()
rnf RebootInputDevice'' {Maybe RebootInputDeviceForce
Text
inputDeviceId :: Text
force :: Maybe RebootInputDeviceForce
$sel:inputDeviceId:RebootInputDevice'' :: RebootInputDevice' -> Text
$sel:force:RebootInputDevice'' :: RebootInputDevice' -> Maybe RebootInputDeviceForce
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RebootInputDeviceForce
force
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
inputDeviceId

instance Data.ToHeaders RebootInputDevice' where
  toHeaders :: RebootInputDevice' -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON RebootInputDevice' where
  toJSON :: RebootInputDevice' -> Value
toJSON RebootInputDevice'' {Maybe RebootInputDeviceForce
Text
inputDeviceId :: Text
force :: Maybe RebootInputDeviceForce
$sel:inputDeviceId:RebootInputDevice'' :: RebootInputDevice' -> Text
$sel:force:RebootInputDevice'' :: RebootInputDevice' -> Maybe RebootInputDeviceForce
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"force" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RebootInputDeviceForce
force]
      )

instance Data.ToPath RebootInputDevice' where
  toPath :: RebootInputDevice' -> ByteString
toPath RebootInputDevice'' {Maybe RebootInputDeviceForce
Text
inputDeviceId :: Text
force :: Maybe RebootInputDeviceForce
$sel:inputDeviceId:RebootInputDevice'' :: RebootInputDevice' -> Text
$sel:force:RebootInputDevice'' :: RebootInputDevice' -> Maybe RebootInputDeviceForce
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/prod/inputDevices/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
inputDeviceId,
        ByteString
"/reboot"
      ]

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

-- | Placeholder documentation for RebootInputDeviceResponse
--
-- /See:/ 'newRebootInputDeviceResponse' smart constructor.
data RebootInputDeviceResponse = RebootInputDeviceResponse'
  { -- | The response's http status code.
    RebootInputDeviceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RebootInputDeviceResponse -> RebootInputDeviceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebootInputDeviceResponse -> RebootInputDeviceResponse -> Bool
$c/= :: RebootInputDeviceResponse -> RebootInputDeviceResponse -> Bool
== :: RebootInputDeviceResponse -> RebootInputDeviceResponse -> Bool
$c== :: RebootInputDeviceResponse -> RebootInputDeviceResponse -> Bool
Prelude.Eq, ReadPrec [RebootInputDeviceResponse]
ReadPrec RebootInputDeviceResponse
Int -> ReadS RebootInputDeviceResponse
ReadS [RebootInputDeviceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebootInputDeviceResponse]
$creadListPrec :: ReadPrec [RebootInputDeviceResponse]
readPrec :: ReadPrec RebootInputDeviceResponse
$creadPrec :: ReadPrec RebootInputDeviceResponse
readList :: ReadS [RebootInputDeviceResponse]
$creadList :: ReadS [RebootInputDeviceResponse]
readsPrec :: Int -> ReadS RebootInputDeviceResponse
$creadsPrec :: Int -> ReadS RebootInputDeviceResponse
Prelude.Read, Int -> RebootInputDeviceResponse -> ShowS
[RebootInputDeviceResponse] -> ShowS
RebootInputDeviceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebootInputDeviceResponse] -> ShowS
$cshowList :: [RebootInputDeviceResponse] -> ShowS
show :: RebootInputDeviceResponse -> String
$cshow :: RebootInputDeviceResponse -> String
showsPrec :: Int -> RebootInputDeviceResponse -> ShowS
$cshowsPrec :: Int -> RebootInputDeviceResponse -> ShowS
Prelude.Show, forall x.
Rep RebootInputDeviceResponse x -> RebootInputDeviceResponse
forall x.
RebootInputDeviceResponse -> Rep RebootInputDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RebootInputDeviceResponse x -> RebootInputDeviceResponse
$cfrom :: forall x.
RebootInputDeviceResponse -> Rep RebootInputDeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'RebootInputDeviceResponse' 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:
--
-- 'httpStatus', 'rebootInputDeviceResponse_httpStatus' - The response's http status code.
newRebootInputDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RebootInputDeviceResponse
newRebootInputDeviceResponse :: Int -> RebootInputDeviceResponse
newRebootInputDeviceResponse Int
pHttpStatus_ =
  RebootInputDeviceResponse'
    { $sel:httpStatus:RebootInputDeviceResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData RebootInputDeviceResponse where
  rnf :: RebootInputDeviceResponse -> ()
rnf RebootInputDeviceResponse' {Int
httpStatus :: Int
$sel:httpStatus:RebootInputDeviceResponse' :: RebootInputDeviceResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus