{-# 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.IoT1ClickProjects.GetDevicesInPlacement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an object enumerating the devices in a placement.
module Amazonka.IoT1ClickProjects.GetDevicesInPlacement
  ( -- * Creating a Request
    GetDevicesInPlacement (..),
    newGetDevicesInPlacement,

    -- * Request Lenses
    getDevicesInPlacement_projectName,
    getDevicesInPlacement_placementName,

    -- * Destructuring the Response
    GetDevicesInPlacementResponse (..),
    newGetDevicesInPlacementResponse,

    -- * Response Lenses
    getDevicesInPlacementResponse_httpStatus,
    getDevicesInPlacementResponse_devices,
  )
where

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

-- | /See:/ 'newGetDevicesInPlacement' smart constructor.
data GetDevicesInPlacement = GetDevicesInPlacement'
  { -- | The name of the project containing the placement.
    GetDevicesInPlacement -> Text
projectName :: Prelude.Text,
    -- | The name of the placement to get the devices from.
    GetDevicesInPlacement -> Text
placementName :: Prelude.Text
  }
  deriving (GetDevicesInPlacement -> GetDevicesInPlacement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevicesInPlacement -> GetDevicesInPlacement -> Bool
$c/= :: GetDevicesInPlacement -> GetDevicesInPlacement -> Bool
== :: GetDevicesInPlacement -> GetDevicesInPlacement -> Bool
$c== :: GetDevicesInPlacement -> GetDevicesInPlacement -> Bool
Prelude.Eq, ReadPrec [GetDevicesInPlacement]
ReadPrec GetDevicesInPlacement
Int -> ReadS GetDevicesInPlacement
ReadS [GetDevicesInPlacement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevicesInPlacement]
$creadListPrec :: ReadPrec [GetDevicesInPlacement]
readPrec :: ReadPrec GetDevicesInPlacement
$creadPrec :: ReadPrec GetDevicesInPlacement
readList :: ReadS [GetDevicesInPlacement]
$creadList :: ReadS [GetDevicesInPlacement]
readsPrec :: Int -> ReadS GetDevicesInPlacement
$creadsPrec :: Int -> ReadS GetDevicesInPlacement
Prelude.Read, Int -> GetDevicesInPlacement -> ShowS
[GetDevicesInPlacement] -> ShowS
GetDevicesInPlacement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevicesInPlacement] -> ShowS
$cshowList :: [GetDevicesInPlacement] -> ShowS
show :: GetDevicesInPlacement -> String
$cshow :: GetDevicesInPlacement -> String
showsPrec :: Int -> GetDevicesInPlacement -> ShowS
$cshowsPrec :: Int -> GetDevicesInPlacement -> ShowS
Prelude.Show, forall x. Rep GetDevicesInPlacement x -> GetDevicesInPlacement
forall x. GetDevicesInPlacement -> Rep GetDevicesInPlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDevicesInPlacement x -> GetDevicesInPlacement
$cfrom :: forall x. GetDevicesInPlacement -> Rep GetDevicesInPlacement x
Prelude.Generic)

-- |
-- Create a value of 'GetDevicesInPlacement' 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:
--
-- 'projectName', 'getDevicesInPlacement_projectName' - The name of the project containing the placement.
--
-- 'placementName', 'getDevicesInPlacement_placementName' - The name of the placement to get the devices from.
newGetDevicesInPlacement ::
  -- | 'projectName'
  Prelude.Text ->
  -- | 'placementName'
  Prelude.Text ->
  GetDevicesInPlacement
newGetDevicesInPlacement :: Text -> Text -> GetDevicesInPlacement
newGetDevicesInPlacement
  Text
pProjectName_
  Text
pPlacementName_ =
    GetDevicesInPlacement'
      { $sel:projectName:GetDevicesInPlacement' :: Text
projectName = Text
pProjectName_,
        $sel:placementName:GetDevicesInPlacement' :: Text
placementName = Text
pPlacementName_
      }

-- | The name of the project containing the placement.
getDevicesInPlacement_projectName :: Lens.Lens' GetDevicesInPlacement Prelude.Text
getDevicesInPlacement_projectName :: Lens' GetDevicesInPlacement Text
getDevicesInPlacement_projectName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicesInPlacement' {Text
projectName :: Text
$sel:projectName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
projectName} -> Text
projectName) (\s :: GetDevicesInPlacement
s@GetDevicesInPlacement' {} Text
a -> GetDevicesInPlacement
s {$sel:projectName:GetDevicesInPlacement' :: Text
projectName = Text
a} :: GetDevicesInPlacement)

-- | The name of the placement to get the devices from.
getDevicesInPlacement_placementName :: Lens.Lens' GetDevicesInPlacement Prelude.Text
getDevicesInPlacement_placementName :: Lens' GetDevicesInPlacement Text
getDevicesInPlacement_placementName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicesInPlacement' {Text
placementName :: Text
$sel:placementName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
placementName} -> Text
placementName) (\s :: GetDevicesInPlacement
s@GetDevicesInPlacement' {} Text
a -> GetDevicesInPlacement
s {$sel:placementName:GetDevicesInPlacement' :: Text
placementName = Text
a} :: GetDevicesInPlacement)

instance Core.AWSRequest GetDevicesInPlacement where
  type
    AWSResponse GetDevicesInPlacement =
      GetDevicesInPlacementResponse
  request :: (Service -> Service)
-> GetDevicesInPlacement -> Request GetDevicesInPlacement
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDevicesInPlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDevicesInPlacement)))
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 ->
          Int -> HashMap Text Text -> GetDevicesInPlacementResponse
GetDevicesInPlacementResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"devices" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable GetDevicesInPlacement where
  hashWithSalt :: Int -> GetDevicesInPlacement -> Int
hashWithSalt Int
_salt GetDevicesInPlacement' {Text
placementName :: Text
projectName :: Text
$sel:placementName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
$sel:projectName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
projectName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
placementName

instance Prelude.NFData GetDevicesInPlacement where
  rnf :: GetDevicesInPlacement -> ()
rnf GetDevicesInPlacement' {Text
placementName :: Text
projectName :: Text
$sel:placementName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
$sel:projectName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
projectName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
placementName

instance Data.ToHeaders GetDevicesInPlacement where
  toHeaders :: GetDevicesInPlacement -> 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.ToPath GetDevicesInPlacement where
  toPath :: GetDevicesInPlacement -> ByteString
toPath GetDevicesInPlacement' {Text
placementName :: Text
projectName :: Text
$sel:placementName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
$sel:projectName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/projects/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
projectName,
        ByteString
"/placements/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
placementName,
        ByteString
"/devices"
      ]

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

-- | /See:/ 'newGetDevicesInPlacementResponse' smart constructor.
data GetDevicesInPlacementResponse = GetDevicesInPlacementResponse'
  { -- | The response's http status code.
    GetDevicesInPlacementResponse -> Int
httpStatus :: Prelude.Int,
    -- | An object containing the devices (zero or more) within the placement.
    GetDevicesInPlacementResponse -> HashMap Text Text
devices :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (GetDevicesInPlacementResponse
-> GetDevicesInPlacementResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevicesInPlacementResponse
-> GetDevicesInPlacementResponse -> Bool
$c/= :: GetDevicesInPlacementResponse
-> GetDevicesInPlacementResponse -> Bool
== :: GetDevicesInPlacementResponse
-> GetDevicesInPlacementResponse -> Bool
$c== :: GetDevicesInPlacementResponse
-> GetDevicesInPlacementResponse -> Bool
Prelude.Eq, ReadPrec [GetDevicesInPlacementResponse]
ReadPrec GetDevicesInPlacementResponse
Int -> ReadS GetDevicesInPlacementResponse
ReadS [GetDevicesInPlacementResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevicesInPlacementResponse]
$creadListPrec :: ReadPrec [GetDevicesInPlacementResponse]
readPrec :: ReadPrec GetDevicesInPlacementResponse
$creadPrec :: ReadPrec GetDevicesInPlacementResponse
readList :: ReadS [GetDevicesInPlacementResponse]
$creadList :: ReadS [GetDevicesInPlacementResponse]
readsPrec :: Int -> ReadS GetDevicesInPlacementResponse
$creadsPrec :: Int -> ReadS GetDevicesInPlacementResponse
Prelude.Read, Int -> GetDevicesInPlacementResponse -> ShowS
[GetDevicesInPlacementResponse] -> ShowS
GetDevicesInPlacementResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevicesInPlacementResponse] -> ShowS
$cshowList :: [GetDevicesInPlacementResponse] -> ShowS
show :: GetDevicesInPlacementResponse -> String
$cshow :: GetDevicesInPlacementResponse -> String
showsPrec :: Int -> GetDevicesInPlacementResponse -> ShowS
$cshowsPrec :: Int -> GetDevicesInPlacementResponse -> ShowS
Prelude.Show, forall x.
Rep GetDevicesInPlacementResponse x
-> GetDevicesInPlacementResponse
forall x.
GetDevicesInPlacementResponse
-> Rep GetDevicesInPlacementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDevicesInPlacementResponse x
-> GetDevicesInPlacementResponse
$cfrom :: forall x.
GetDevicesInPlacementResponse
-> Rep GetDevicesInPlacementResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDevicesInPlacementResponse' 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', 'getDevicesInPlacementResponse_httpStatus' - The response's http status code.
--
-- 'devices', 'getDevicesInPlacementResponse_devices' - An object containing the devices (zero or more) within the placement.
newGetDevicesInPlacementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDevicesInPlacementResponse
newGetDevicesInPlacementResponse :: Int -> GetDevicesInPlacementResponse
newGetDevicesInPlacementResponse Int
pHttpStatus_ =
  GetDevicesInPlacementResponse'
    { $sel:httpStatus:GetDevicesInPlacementResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:devices:GetDevicesInPlacementResponse' :: HashMap Text Text
devices = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | An object containing the devices (zero or more) within the placement.
getDevicesInPlacementResponse_devices :: Lens.Lens' GetDevicesInPlacementResponse (Prelude.HashMap Prelude.Text Prelude.Text)
getDevicesInPlacementResponse_devices :: Lens' GetDevicesInPlacementResponse (HashMap Text Text)
getDevicesInPlacementResponse_devices = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicesInPlacementResponse' {HashMap Text Text
devices :: HashMap Text Text
$sel:devices:GetDevicesInPlacementResponse' :: GetDevicesInPlacementResponse -> HashMap Text Text
devices} -> HashMap Text Text
devices) (\s :: GetDevicesInPlacementResponse
s@GetDevicesInPlacementResponse' {} HashMap Text Text
a -> GetDevicesInPlacementResponse
s {$sel:devices:GetDevicesInPlacementResponse' :: HashMap Text Text
devices = HashMap Text Text
a} :: GetDevicesInPlacementResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetDevicesInPlacementResponse where
  rnf :: GetDevicesInPlacementResponse -> ()
rnf GetDevicesInPlacementResponse' {Int
HashMap Text Text
devices :: HashMap Text Text
httpStatus :: Int
$sel:devices:GetDevicesInPlacementResponse' :: GetDevicesInPlacementResponse -> HashMap Text Text
$sel:httpStatus:GetDevicesInPlacementResponse' :: GetDevicesInPlacementResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
devices