{-# 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.SageMaker.UpdateDevices
-- 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)
--
-- Updates one or more devices in a fleet.
module Amazonka.SageMaker.UpdateDevices
  ( -- * Creating a Request
    UpdateDevices (..),
    newUpdateDevices,

    -- * Request Lenses
    updateDevices_deviceFleetName,
    updateDevices_devices,

    -- * Destructuring the Response
    UpdateDevicesResponse (..),
    newUpdateDevicesResponse,
  )
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.SageMaker.Types

-- | /See:/ 'newUpdateDevices' smart constructor.
data UpdateDevices = UpdateDevices'
  { -- | The name of the fleet the devices belong to.
    UpdateDevices -> Text
deviceFleetName :: Prelude.Text,
    -- | List of devices to register with Edge Manager agent.
    UpdateDevices -> [Device]
devices :: [Device]
  }
  deriving (UpdateDevices -> UpdateDevices -> Bool
(UpdateDevices -> UpdateDevices -> Bool)
-> (UpdateDevices -> UpdateDevices -> Bool) -> Eq UpdateDevices
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDevices -> UpdateDevices -> Bool
$c/= :: UpdateDevices -> UpdateDevices -> Bool
== :: UpdateDevices -> UpdateDevices -> Bool
$c== :: UpdateDevices -> UpdateDevices -> Bool
Prelude.Eq, ReadPrec [UpdateDevices]
ReadPrec UpdateDevices
Int -> ReadS UpdateDevices
ReadS [UpdateDevices]
(Int -> ReadS UpdateDevices)
-> ReadS [UpdateDevices]
-> ReadPrec UpdateDevices
-> ReadPrec [UpdateDevices]
-> Read UpdateDevices
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDevices]
$creadListPrec :: ReadPrec [UpdateDevices]
readPrec :: ReadPrec UpdateDevices
$creadPrec :: ReadPrec UpdateDevices
readList :: ReadS [UpdateDevices]
$creadList :: ReadS [UpdateDevices]
readsPrec :: Int -> ReadS UpdateDevices
$creadsPrec :: Int -> ReadS UpdateDevices
Prelude.Read, Int -> UpdateDevices -> ShowS
[UpdateDevices] -> ShowS
UpdateDevices -> String
(Int -> UpdateDevices -> ShowS)
-> (UpdateDevices -> String)
-> ([UpdateDevices] -> ShowS)
-> Show UpdateDevices
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDevices] -> ShowS
$cshowList :: [UpdateDevices] -> ShowS
show :: UpdateDevices -> String
$cshow :: UpdateDevices -> String
showsPrec :: Int -> UpdateDevices -> ShowS
$cshowsPrec :: Int -> UpdateDevices -> ShowS
Prelude.Show, (forall x. UpdateDevices -> Rep UpdateDevices x)
-> (forall x. Rep UpdateDevices x -> UpdateDevices)
-> Generic UpdateDevices
forall x. Rep UpdateDevices x -> UpdateDevices
forall x. UpdateDevices -> Rep UpdateDevices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDevices x -> UpdateDevices
$cfrom :: forall x. UpdateDevices -> Rep UpdateDevices x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDevices' 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:
--
-- 'deviceFleetName', 'updateDevices_deviceFleetName' - The name of the fleet the devices belong to.
--
-- 'devices', 'updateDevices_devices' - List of devices to register with Edge Manager agent.
newUpdateDevices ::
  -- | 'deviceFleetName'
  Prelude.Text ->
  UpdateDevices
newUpdateDevices :: Text -> UpdateDevices
newUpdateDevices Text
pDeviceFleetName_ =
  UpdateDevices' :: Text -> [Device] -> UpdateDevices
UpdateDevices'
    { $sel:deviceFleetName:UpdateDevices' :: Text
deviceFleetName = Text
pDeviceFleetName_,
      $sel:devices:UpdateDevices' :: [Device]
devices = [Device]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the fleet the devices belong to.
updateDevices_deviceFleetName :: Lens.Lens' UpdateDevices Prelude.Text
updateDevices_deviceFleetName :: (Text -> f Text) -> UpdateDevices -> f UpdateDevices
updateDevices_deviceFleetName = (UpdateDevices -> Text)
-> (UpdateDevices -> Text -> UpdateDevices)
-> Lens UpdateDevices UpdateDevices Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDevices' {Text
deviceFleetName :: Text
$sel:deviceFleetName:UpdateDevices' :: UpdateDevices -> Text
deviceFleetName} -> Text
deviceFleetName) (\s :: UpdateDevices
s@UpdateDevices' {} Text
a -> UpdateDevices
s {$sel:deviceFleetName:UpdateDevices' :: Text
deviceFleetName = Text
a} :: UpdateDevices)

-- | List of devices to register with Edge Manager agent.
updateDevices_devices :: Lens.Lens' UpdateDevices [Device]
updateDevices_devices :: ([Device] -> f [Device]) -> UpdateDevices -> f UpdateDevices
updateDevices_devices = (UpdateDevices -> [Device])
-> (UpdateDevices -> [Device] -> UpdateDevices)
-> Lens UpdateDevices UpdateDevices [Device] [Device]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDevices' {[Device]
devices :: [Device]
$sel:devices:UpdateDevices' :: UpdateDevices -> [Device]
devices} -> [Device]
devices) (\s :: UpdateDevices
s@UpdateDevices' {} [Device]
a -> UpdateDevices
s {$sel:devices:UpdateDevices' :: [Device]
devices = [Device]
a} :: UpdateDevices) (([Device] -> f [Device]) -> UpdateDevices -> f UpdateDevices)
-> (([Device] -> f [Device]) -> [Device] -> f [Device])
-> ([Device] -> f [Device])
-> UpdateDevices
-> f UpdateDevices
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Device] -> f [Device]) -> [Device] -> f [Device]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable UpdateDevices

instance Prelude.NFData UpdateDevices

instance Core.ToHeaders UpdateDevices where
  toHeaders :: UpdateDevices -> [Header]
toHeaders =
    [Header] -> UpdateDevices -> [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
"SageMaker.UpdateDevices" :: 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 UpdateDevices where
  toJSON :: UpdateDevices -> Value
toJSON UpdateDevices' {[Device]
Text
devices :: [Device]
deviceFleetName :: Text
$sel:devices:UpdateDevices' :: UpdateDevices -> [Device]
$sel:deviceFleetName:UpdateDevices' :: UpdateDevices -> 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
"DeviceFleetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceFleetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Devices" Text -> [Device] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Device]
devices)
          ]
      )

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

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

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

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

instance Prelude.NFData UpdateDevicesResponse