{-# 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.GetDeployments
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Use to get the active deployments from a device.
module Amazonka.SageMakerEdge.GetDeployments
  ( -- * Creating a Request
    GetDeployments (..),
    newGetDeployments,

    -- * Request Lenses
    getDeployments_deviceName,
    getDeployments_deviceFleetName,

    -- * Destructuring the Response
    GetDeploymentsResponse (..),
    newGetDeploymentsResponse,

    -- * Response Lenses
    getDeploymentsResponse_deployments,
    getDeploymentsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetDeployments' smart constructor.
data GetDeployments = GetDeployments'
  { -- | The unique name of the device you want to get the configuration of
    -- active deployments from.
    GetDeployments -> Text
deviceName :: Prelude.Text,
    -- | The name of the fleet that the device belongs to.
    GetDeployments -> Text
deviceFleetName :: Prelude.Text
  }
  deriving (GetDeployments -> GetDeployments -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeployments -> GetDeployments -> Bool
$c/= :: GetDeployments -> GetDeployments -> Bool
== :: GetDeployments -> GetDeployments -> Bool
$c== :: GetDeployments -> GetDeployments -> Bool
Prelude.Eq, ReadPrec [GetDeployments]
ReadPrec GetDeployments
Int -> ReadS GetDeployments
ReadS [GetDeployments]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeployments]
$creadListPrec :: ReadPrec [GetDeployments]
readPrec :: ReadPrec GetDeployments
$creadPrec :: ReadPrec GetDeployments
readList :: ReadS [GetDeployments]
$creadList :: ReadS [GetDeployments]
readsPrec :: Int -> ReadS GetDeployments
$creadsPrec :: Int -> ReadS GetDeployments
Prelude.Read, Int -> GetDeployments -> ShowS
[GetDeployments] -> ShowS
GetDeployments -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeployments] -> ShowS
$cshowList :: [GetDeployments] -> ShowS
show :: GetDeployments -> String
$cshow :: GetDeployments -> String
showsPrec :: Int -> GetDeployments -> ShowS
$cshowsPrec :: Int -> GetDeployments -> ShowS
Prelude.Show, forall x. Rep GetDeployments x -> GetDeployments
forall x. GetDeployments -> Rep GetDeployments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeployments x -> GetDeployments
$cfrom :: forall x. GetDeployments -> Rep GetDeployments x
Prelude.Generic)

-- |
-- Create a value of 'GetDeployments' 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:
--
-- 'deviceName', 'getDeployments_deviceName' - The unique name of the device you want to get the configuration of
-- active deployments from.
--
-- 'deviceFleetName', 'getDeployments_deviceFleetName' - The name of the fleet that the device belongs to.
newGetDeployments ::
  -- | 'deviceName'
  Prelude.Text ->
  -- | 'deviceFleetName'
  Prelude.Text ->
  GetDeployments
newGetDeployments :: Text -> Text -> GetDeployments
newGetDeployments Text
pDeviceName_ Text
pDeviceFleetName_ =
  GetDeployments'
    { $sel:deviceName:GetDeployments' :: Text
deviceName = Text
pDeviceName_,
      $sel:deviceFleetName:GetDeployments' :: Text
deviceFleetName = Text
pDeviceFleetName_
    }

-- | The unique name of the device you want to get the configuration of
-- active deployments from.
getDeployments_deviceName :: Lens.Lens' GetDeployments Prelude.Text
getDeployments_deviceName :: Lens' GetDeployments Text
getDeployments_deviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeployments' {Text
deviceName :: Text
$sel:deviceName:GetDeployments' :: GetDeployments -> Text
deviceName} -> Text
deviceName) (\s :: GetDeployments
s@GetDeployments' {} Text
a -> GetDeployments
s {$sel:deviceName:GetDeployments' :: Text
deviceName = Text
a} :: GetDeployments)

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

instance Core.AWSRequest GetDeployments where
  type
    AWSResponse GetDeployments =
      GetDeploymentsResponse
  request :: (Service -> Service) -> GetDeployments -> Request GetDeployments
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 GetDeployments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDeployments)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [EdgeDeployment] -> Int -> GetDeploymentsResponse
GetDeploymentsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Deployments" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => 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 GetDeployments where
  hashWithSalt :: Int -> GetDeployments -> Int
hashWithSalt Int
_salt GetDeployments' {Text
deviceFleetName :: Text
deviceName :: Text
$sel:deviceFleetName:GetDeployments' :: GetDeployments -> Text
$sel:deviceName:GetDeployments' :: GetDeployments -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceFleetName

instance Prelude.NFData GetDeployments where
  rnf :: GetDeployments -> ()
rnf GetDeployments' {Text
deviceFleetName :: Text
deviceName :: Text
$sel:deviceFleetName:GetDeployments' :: GetDeployments -> Text
$sel:deviceName:GetDeployments' :: GetDeployments -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
deviceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deviceFleetName

instance Data.ToHeaders GetDeployments where
  toHeaders :: GetDeployments -> 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 GetDeployments where
  toJSON :: GetDeployments -> Value
toJSON GetDeployments' {Text
deviceFleetName :: Text
deviceName :: Text
$sel:deviceFleetName:GetDeployments' :: GetDeployments -> Text
$sel:deviceName:GetDeployments' :: GetDeployments -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"DeviceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deviceName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"DeviceFleetName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deviceFleetName)
          ]
      )

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

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

-- | /See:/ 'newGetDeploymentsResponse' smart constructor.
data GetDeploymentsResponse = GetDeploymentsResponse'
  { -- | Returns a list of the configurations of the active deployments on the
    -- device.
    GetDeploymentsResponse -> Maybe [EdgeDeployment]
deployments :: Prelude.Maybe [EdgeDeployment],
    -- | The response's http status code.
    GetDeploymentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDeploymentsResponse -> GetDeploymentsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeploymentsResponse -> GetDeploymentsResponse -> Bool
$c/= :: GetDeploymentsResponse -> GetDeploymentsResponse -> Bool
== :: GetDeploymentsResponse -> GetDeploymentsResponse -> Bool
$c== :: GetDeploymentsResponse -> GetDeploymentsResponse -> Bool
Prelude.Eq, ReadPrec [GetDeploymentsResponse]
ReadPrec GetDeploymentsResponse
Int -> ReadS GetDeploymentsResponse
ReadS [GetDeploymentsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeploymentsResponse]
$creadListPrec :: ReadPrec [GetDeploymentsResponse]
readPrec :: ReadPrec GetDeploymentsResponse
$creadPrec :: ReadPrec GetDeploymentsResponse
readList :: ReadS [GetDeploymentsResponse]
$creadList :: ReadS [GetDeploymentsResponse]
readsPrec :: Int -> ReadS GetDeploymentsResponse
$creadsPrec :: Int -> ReadS GetDeploymentsResponse
Prelude.Read, Int -> GetDeploymentsResponse -> ShowS
[GetDeploymentsResponse] -> ShowS
GetDeploymentsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeploymentsResponse] -> ShowS
$cshowList :: [GetDeploymentsResponse] -> ShowS
show :: GetDeploymentsResponse -> String
$cshow :: GetDeploymentsResponse -> String
showsPrec :: Int -> GetDeploymentsResponse -> ShowS
$cshowsPrec :: Int -> GetDeploymentsResponse -> ShowS
Prelude.Show, forall x. Rep GetDeploymentsResponse x -> GetDeploymentsResponse
forall x. GetDeploymentsResponse -> Rep GetDeploymentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeploymentsResponse x -> GetDeploymentsResponse
$cfrom :: forall x. GetDeploymentsResponse -> Rep GetDeploymentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDeploymentsResponse' 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:
--
-- 'deployments', 'getDeploymentsResponse_deployments' - Returns a list of the configurations of the active deployments on the
-- device.
--
-- 'httpStatus', 'getDeploymentsResponse_httpStatus' - The response's http status code.
newGetDeploymentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDeploymentsResponse
newGetDeploymentsResponse :: Int -> GetDeploymentsResponse
newGetDeploymentsResponse Int
pHttpStatus_ =
  GetDeploymentsResponse'
    { $sel:deployments:GetDeploymentsResponse' :: Maybe [EdgeDeployment]
deployments =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDeploymentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a list of the configurations of the active deployments on the
-- device.
getDeploymentsResponse_deployments :: Lens.Lens' GetDeploymentsResponse (Prelude.Maybe [EdgeDeployment])
getDeploymentsResponse_deployments :: Lens' GetDeploymentsResponse (Maybe [EdgeDeployment])
getDeploymentsResponse_deployments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentsResponse' {Maybe [EdgeDeployment]
deployments :: Maybe [EdgeDeployment]
$sel:deployments:GetDeploymentsResponse' :: GetDeploymentsResponse -> Maybe [EdgeDeployment]
deployments} -> Maybe [EdgeDeployment]
deployments) (\s :: GetDeploymentsResponse
s@GetDeploymentsResponse' {} Maybe [EdgeDeployment]
a -> GetDeploymentsResponse
s {$sel:deployments:GetDeploymentsResponse' :: Maybe [EdgeDeployment]
deployments = Maybe [EdgeDeployment]
a} :: GetDeploymentsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetDeploymentsResponse where
  rnf :: GetDeploymentsResponse -> ()
rnf GetDeploymentsResponse' {Int
Maybe [EdgeDeployment]
httpStatus :: Int
deployments :: Maybe [EdgeDeployment]
$sel:httpStatus:GetDeploymentsResponse' :: GetDeploymentsResponse -> Int
$sel:deployments:GetDeploymentsResponse' :: GetDeploymentsResponse -> Maybe [EdgeDeployment]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [EdgeDeployment]
deployments
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus