{-# 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.SageMakerEdge.SendHeartbeat
-- 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)
--
-- Use to get the current status of devices registered on SageMaker Edge
-- Manager.
module Amazonka.SageMakerEdge.SendHeartbeat
  ( -- * Creating a Request
    SendHeartbeat (..),
    newSendHeartbeat,

    -- * Request Lenses
    sendHeartbeat_agentMetrics,
    sendHeartbeat_models,
    sendHeartbeat_agentVersion,
    sendHeartbeat_deviceName,
    sendHeartbeat_deviceFleetName,

    -- * Destructuring the Response
    SendHeartbeatResponse (..),
    newSendHeartbeatResponse,
  )
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.SageMakerEdge.Types

-- | /See:/ 'newSendHeartbeat' smart constructor.
data SendHeartbeat = SendHeartbeat'
  { -- | For internal use. Returns a list of SageMaker Edge Manager agent
    -- operating metrics.
    SendHeartbeat -> Maybe [EdgeMetric]
agentMetrics :: Prelude.Maybe [EdgeMetric],
    -- | Returns a list of models deployed on the the device.
    SendHeartbeat -> Maybe [Model]
models :: Prelude.Maybe [Model],
    -- | Returns the version of the agent.
    SendHeartbeat -> Text
agentVersion :: Prelude.Text,
    -- | The unique name of the device.
    SendHeartbeat -> Text
deviceName :: Prelude.Text,
    -- | The name of the fleet that the device belongs to.
    SendHeartbeat -> Text
deviceFleetName :: Prelude.Text
  }
  deriving (SendHeartbeat -> SendHeartbeat -> Bool
(SendHeartbeat -> SendHeartbeat -> Bool)
-> (SendHeartbeat -> SendHeartbeat -> Bool) -> Eq SendHeartbeat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendHeartbeat -> SendHeartbeat -> Bool
$c/= :: SendHeartbeat -> SendHeartbeat -> Bool
== :: SendHeartbeat -> SendHeartbeat -> Bool
$c== :: SendHeartbeat -> SendHeartbeat -> Bool
Prelude.Eq, ReadPrec [SendHeartbeat]
ReadPrec SendHeartbeat
Int -> ReadS SendHeartbeat
ReadS [SendHeartbeat]
(Int -> ReadS SendHeartbeat)
-> ReadS [SendHeartbeat]
-> ReadPrec SendHeartbeat
-> ReadPrec [SendHeartbeat]
-> Read SendHeartbeat
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendHeartbeat]
$creadListPrec :: ReadPrec [SendHeartbeat]
readPrec :: ReadPrec SendHeartbeat
$creadPrec :: ReadPrec SendHeartbeat
readList :: ReadS [SendHeartbeat]
$creadList :: ReadS [SendHeartbeat]
readsPrec :: Int -> ReadS SendHeartbeat
$creadsPrec :: Int -> ReadS SendHeartbeat
Prelude.Read, Int -> SendHeartbeat -> ShowS
[SendHeartbeat] -> ShowS
SendHeartbeat -> String
(Int -> SendHeartbeat -> ShowS)
-> (SendHeartbeat -> String)
-> ([SendHeartbeat] -> ShowS)
-> Show SendHeartbeat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendHeartbeat] -> ShowS
$cshowList :: [SendHeartbeat] -> ShowS
show :: SendHeartbeat -> String
$cshow :: SendHeartbeat -> String
showsPrec :: Int -> SendHeartbeat -> ShowS
$cshowsPrec :: Int -> SendHeartbeat -> ShowS
Prelude.Show, (forall x. SendHeartbeat -> Rep SendHeartbeat x)
-> (forall x. Rep SendHeartbeat x -> SendHeartbeat)
-> Generic SendHeartbeat
forall x. Rep SendHeartbeat x -> SendHeartbeat
forall x. SendHeartbeat -> Rep SendHeartbeat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendHeartbeat x -> SendHeartbeat
$cfrom :: forall x. SendHeartbeat -> Rep SendHeartbeat x
Prelude.Generic)

-- |
-- Create a value of 'SendHeartbeat' 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:
--
-- 'agentMetrics', 'sendHeartbeat_agentMetrics' - For internal use. Returns a list of SageMaker Edge Manager agent
-- operating metrics.
--
-- 'models', 'sendHeartbeat_models' - Returns a list of models deployed on the the device.
--
-- 'agentVersion', 'sendHeartbeat_agentVersion' - Returns the version of the agent.
--
-- 'deviceName', 'sendHeartbeat_deviceName' - The unique name of the device.
--
-- 'deviceFleetName', 'sendHeartbeat_deviceFleetName' - The name of the fleet that the device belongs to.
newSendHeartbeat ::
  -- | 'agentVersion'
  Prelude.Text ->
  -- | 'deviceName'
  Prelude.Text ->
  -- | 'deviceFleetName'
  Prelude.Text ->
  SendHeartbeat
newSendHeartbeat :: Text -> Text -> Text -> SendHeartbeat
newSendHeartbeat
  Text
pAgentVersion_
  Text
pDeviceName_
  Text
pDeviceFleetName_ =
    SendHeartbeat' :: Maybe [EdgeMetric]
-> Maybe [Model] -> Text -> Text -> Text -> SendHeartbeat
SendHeartbeat'
      { $sel:agentMetrics:SendHeartbeat' :: Maybe [EdgeMetric]
agentMetrics = Maybe [EdgeMetric]
forall a. Maybe a
Prelude.Nothing,
        $sel:models:SendHeartbeat' :: Maybe [Model]
models = Maybe [Model]
forall a. Maybe a
Prelude.Nothing,
        $sel:agentVersion:SendHeartbeat' :: Text
agentVersion = Text
pAgentVersion_,
        $sel:deviceName:SendHeartbeat' :: Text
deviceName = Text
pDeviceName_,
        $sel:deviceFleetName:SendHeartbeat' :: Text
deviceFleetName = Text
pDeviceFleetName_
      }

-- | For internal use. Returns a list of SageMaker Edge Manager agent
-- operating metrics.
sendHeartbeat_agentMetrics :: Lens.Lens' SendHeartbeat (Prelude.Maybe [EdgeMetric])
sendHeartbeat_agentMetrics :: (Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
-> SendHeartbeat -> f SendHeartbeat
sendHeartbeat_agentMetrics = (SendHeartbeat -> Maybe [EdgeMetric])
-> (SendHeartbeat -> Maybe [EdgeMetric] -> SendHeartbeat)
-> Lens
     SendHeartbeat
     SendHeartbeat
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendHeartbeat' {Maybe [EdgeMetric]
agentMetrics :: Maybe [EdgeMetric]
$sel:agentMetrics:SendHeartbeat' :: SendHeartbeat -> Maybe [EdgeMetric]
agentMetrics} -> Maybe [EdgeMetric]
agentMetrics) (\s :: SendHeartbeat
s@SendHeartbeat' {} Maybe [EdgeMetric]
a -> SendHeartbeat
s {$sel:agentMetrics:SendHeartbeat' :: Maybe [EdgeMetric]
agentMetrics = Maybe [EdgeMetric]
a} :: SendHeartbeat) ((Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
 -> SendHeartbeat -> f SendHeartbeat)
-> ((Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
    -> Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
-> (Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
-> SendHeartbeat
-> f SendHeartbeat
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EdgeMetric] [EdgeMetric] [EdgeMetric] [EdgeMetric]
-> Iso
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [EdgeMetric] [EdgeMetric] [EdgeMetric] [EdgeMetric]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Returns a list of models deployed on the the device.
sendHeartbeat_models :: Lens.Lens' SendHeartbeat (Prelude.Maybe [Model])
sendHeartbeat_models :: (Maybe [Model] -> f (Maybe [Model]))
-> SendHeartbeat -> f SendHeartbeat
sendHeartbeat_models = (SendHeartbeat -> Maybe [Model])
-> (SendHeartbeat -> Maybe [Model] -> SendHeartbeat)
-> Lens SendHeartbeat SendHeartbeat (Maybe [Model]) (Maybe [Model])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendHeartbeat' {Maybe [Model]
models :: Maybe [Model]
$sel:models:SendHeartbeat' :: SendHeartbeat -> Maybe [Model]
models} -> Maybe [Model]
models) (\s :: SendHeartbeat
s@SendHeartbeat' {} Maybe [Model]
a -> SendHeartbeat
s {$sel:models:SendHeartbeat' :: Maybe [Model]
models = Maybe [Model]
a} :: SendHeartbeat) ((Maybe [Model] -> f (Maybe [Model]))
 -> SendHeartbeat -> f SendHeartbeat)
-> ((Maybe [Model] -> f (Maybe [Model]))
    -> Maybe [Model] -> f (Maybe [Model]))
-> (Maybe [Model] -> f (Maybe [Model]))
-> SendHeartbeat
-> f SendHeartbeat
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Model] [Model] [Model] [Model]
-> Iso
     (Maybe [Model]) (Maybe [Model]) (Maybe [Model]) (Maybe [Model])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Model] [Model] [Model] [Model]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Returns the version of the agent.
sendHeartbeat_agentVersion :: Lens.Lens' SendHeartbeat Prelude.Text
sendHeartbeat_agentVersion :: (Text -> f Text) -> SendHeartbeat -> f SendHeartbeat
sendHeartbeat_agentVersion = (SendHeartbeat -> Text)
-> (SendHeartbeat -> Text -> SendHeartbeat)
-> Lens SendHeartbeat SendHeartbeat Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendHeartbeat' {Text
agentVersion :: Text
$sel:agentVersion:SendHeartbeat' :: SendHeartbeat -> Text
agentVersion} -> Text
agentVersion) (\s :: SendHeartbeat
s@SendHeartbeat' {} Text
a -> SendHeartbeat
s {$sel:agentVersion:SendHeartbeat' :: Text
agentVersion = Text
a} :: SendHeartbeat)

-- | The unique name of the device.
sendHeartbeat_deviceName :: Lens.Lens' SendHeartbeat Prelude.Text
sendHeartbeat_deviceName :: (Text -> f Text) -> SendHeartbeat -> f SendHeartbeat
sendHeartbeat_deviceName = (SendHeartbeat -> Text)
-> (SendHeartbeat -> Text -> SendHeartbeat)
-> Lens SendHeartbeat SendHeartbeat Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendHeartbeat' {Text
deviceName :: Text
$sel:deviceName:SendHeartbeat' :: SendHeartbeat -> Text
deviceName} -> Text
deviceName) (\s :: SendHeartbeat
s@SendHeartbeat' {} Text
a -> SendHeartbeat
s {$sel:deviceName:SendHeartbeat' :: Text
deviceName = Text
a} :: SendHeartbeat)

-- | The name of the fleet that the device belongs to.
sendHeartbeat_deviceFleetName :: Lens.Lens' SendHeartbeat Prelude.Text
sendHeartbeat_deviceFleetName :: (Text -> f Text) -> SendHeartbeat -> f SendHeartbeat
sendHeartbeat_deviceFleetName = (SendHeartbeat -> Text)
-> (SendHeartbeat -> Text -> SendHeartbeat)
-> Lens SendHeartbeat SendHeartbeat Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendHeartbeat' {Text
deviceFleetName :: Text
$sel:deviceFleetName:SendHeartbeat' :: SendHeartbeat -> Text
deviceFleetName} -> Text
deviceFleetName) (\s :: SendHeartbeat
s@SendHeartbeat' {} Text
a -> SendHeartbeat
s {$sel:deviceFleetName:SendHeartbeat' :: Text
deviceFleetName = Text
a} :: SendHeartbeat)

instance Core.AWSRequest SendHeartbeat where
  type
    AWSResponse SendHeartbeat =
      SendHeartbeatResponse
  request :: SendHeartbeat -> Request SendHeartbeat
request = Service -> SendHeartbeat -> Request SendHeartbeat
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SendHeartbeat
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendHeartbeat)))
response =
    AWSResponse SendHeartbeat
-> Logger
-> Service
-> Proxy SendHeartbeat
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendHeartbeat)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SendHeartbeat
SendHeartbeatResponse
SendHeartbeatResponse'

instance Prelude.Hashable SendHeartbeat

instance Prelude.NFData SendHeartbeat

instance Core.ToHeaders SendHeartbeat where
  toHeaders :: SendHeartbeat -> [Header]
toHeaders =
    [Header] -> SendHeartbeat -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 SendHeartbeat where
  toJSON :: SendHeartbeat -> Value
toJSON SendHeartbeat' {Maybe [EdgeMetric]
Maybe [Model]
Text
deviceFleetName :: Text
deviceName :: Text
agentVersion :: Text
models :: Maybe [Model]
agentMetrics :: Maybe [EdgeMetric]
$sel:deviceFleetName:SendHeartbeat' :: SendHeartbeat -> Text
$sel:deviceName:SendHeartbeat' :: SendHeartbeat -> Text
$sel:agentVersion:SendHeartbeat' :: SendHeartbeat -> Text
$sel:models:SendHeartbeat' :: SendHeartbeat -> Maybe [Model]
$sel:agentMetrics:SendHeartbeat' :: SendHeartbeat -> Maybe [EdgeMetric]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AgentMetrics" Text -> [EdgeMetric] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([EdgeMetric] -> Pair) -> Maybe [EdgeMetric] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EdgeMetric]
agentMetrics,
            (Text
"Models" Text -> [Model] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Model] -> Pair) -> Maybe [Model] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Model]
models,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AgentVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
agentVersion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DeviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DeviceFleetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceFleetName)
          ]
      )

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

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

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

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

instance Prelude.NFData SendHeartbeatResponse