{-# 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-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)
--
-- 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 Amazonka.IoT1ClickProjects.Types
import qualified Amazonka.Lens as Lens
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
(GetDevicesInPlacement -> GetDevicesInPlacement -> Bool)
-> (GetDevicesInPlacement -> GetDevicesInPlacement -> Bool)
-> Eq GetDevicesInPlacement
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]
(Int -> ReadS GetDevicesInPlacement)
-> ReadS [GetDevicesInPlacement]
-> ReadPrec GetDevicesInPlacement
-> ReadPrec [GetDevicesInPlacement]
-> Read 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
(Int -> GetDevicesInPlacement -> ShowS)
-> (GetDevicesInPlacement -> String)
-> ([GetDevicesInPlacement] -> ShowS)
-> Show GetDevicesInPlacement
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. GetDevicesInPlacement -> Rep GetDevicesInPlacement x)
-> (forall x. Rep GetDevicesInPlacement x -> GetDevicesInPlacement)
-> Generic GetDevicesInPlacement
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' :: Text -> Text -> GetDevicesInPlacement
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 :: (Text -> f Text)
-> GetDevicesInPlacement -> f GetDevicesInPlacement
getDevicesInPlacement_projectName = (GetDevicesInPlacement -> Text)
-> (GetDevicesInPlacement -> Text -> GetDevicesInPlacement)
-> Lens GetDevicesInPlacement GetDevicesInPlacement Text Text
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 :: (Text -> f Text)
-> GetDevicesInPlacement -> f GetDevicesInPlacement
getDevicesInPlacement_placementName = (GetDevicesInPlacement -> Text)
-> (GetDevicesInPlacement -> Text -> GetDevicesInPlacement)
-> Lens GetDevicesInPlacement GetDevicesInPlacement Text Text
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 :: GetDevicesInPlacement -> Request GetDevicesInPlacement
request = Service -> GetDevicesInPlacement -> Request GetDevicesInPlacement
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDevicesInPlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDevicesInPlacement)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDevicesInPlacement))
-> Logger
-> Service
-> Proxy GetDevicesInPlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDevicesInPlacement)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Int -> HashMap Text Text -> GetDevicesInPlacementResponse)
-> Either String Int
-> Either
     String (HashMap Text Text -> GetDevicesInPlacementResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (HashMap Text Text -> GetDevicesInPlacementResponse)
-> Either String (HashMap Text Text)
-> Either String GetDevicesInPlacementResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (HashMap Text Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"devices" Either String (Maybe (HashMap Text Text))
-> HashMap Text Text -> Either String (HashMap Text Text)
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ HashMap Text Text
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable GetDevicesInPlacement

instance Prelude.NFData GetDevicesInPlacement

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

instance Core.ToPath GetDevicesInPlacement where
  toPath :: GetDevicesInPlacement -> ByteString
toPath GetDevicesInPlacement' {Text
placementName :: Text
projectName :: Text
$sel:placementName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
$sel:projectName:GetDevicesInPlacement' :: GetDevicesInPlacement -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/projects/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectName,
        ByteString
"/placements/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
placementName,
        ByteString
"/devices"
      ]

instance Core.ToQuery GetDevicesInPlacement where
  toQuery :: GetDevicesInPlacement -> QueryString
toQuery = QueryString -> GetDevicesInPlacement -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetDevicesInPlacementResponse
 -> GetDevicesInPlacementResponse -> Bool)
-> (GetDevicesInPlacementResponse
    -> GetDevicesInPlacementResponse -> Bool)
-> Eq GetDevicesInPlacementResponse
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]
(Int -> ReadS GetDevicesInPlacementResponse)
-> ReadS [GetDevicesInPlacementResponse]
-> ReadPrec GetDevicesInPlacementResponse
-> ReadPrec [GetDevicesInPlacementResponse]
-> Read 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
(Int -> GetDevicesInPlacementResponse -> ShowS)
-> (GetDevicesInPlacementResponse -> String)
-> ([GetDevicesInPlacementResponse] -> ShowS)
-> Show GetDevicesInPlacementResponse
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.
 GetDevicesInPlacementResponse
 -> Rep GetDevicesInPlacementResponse x)
-> (forall x.
    Rep GetDevicesInPlacementResponse x
    -> GetDevicesInPlacementResponse)
-> Generic GetDevicesInPlacementResponse
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' :: Int -> HashMap Text Text -> GetDevicesInPlacementResponse
GetDevicesInPlacementResponse'
    { $sel:httpStatus:GetDevicesInPlacementResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:devices:GetDevicesInPlacementResponse' :: HashMap Text Text
devices = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | The response's http status code.
getDevicesInPlacementResponse_httpStatus :: Lens.Lens' GetDevicesInPlacementResponse Prelude.Int
getDevicesInPlacementResponse_httpStatus :: (Int -> f Int)
-> GetDevicesInPlacementResponse -> f GetDevicesInPlacementResponse
getDevicesInPlacementResponse_httpStatus = (GetDevicesInPlacementResponse -> Int)
-> (GetDevicesInPlacementResponse
    -> Int -> GetDevicesInPlacementResponse)
-> Lens
     GetDevicesInPlacementResponse GetDevicesInPlacementResponse Int Int
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 :: (HashMap Text Text -> f (HashMap Text Text))
-> GetDevicesInPlacementResponse -> f GetDevicesInPlacementResponse
getDevicesInPlacementResponse_devices = (GetDevicesInPlacementResponse -> HashMap Text Text)
-> (GetDevicesInPlacementResponse
    -> HashMap Text Text -> GetDevicesInPlacementResponse)
-> Lens
     GetDevicesInPlacementResponse
     GetDevicesInPlacementResponse
     (HashMap Text Text)
     (HashMap Text Text)
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) ((HashMap Text Text -> f (HashMap Text Text))
 -> GetDevicesInPlacementResponse
 -> f GetDevicesInPlacementResponse)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> GetDevicesInPlacementResponse
-> f GetDevicesInPlacementResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetDevicesInPlacementResponse