{-# 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.DescribePlacement
-- 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)
--
-- Describes a placement in a project.
module Amazonka.IoT1ClickProjects.DescribePlacement
  ( -- * Creating a Request
    DescribePlacement (..),
    newDescribePlacement,

    -- * Request Lenses
    describePlacement_placementName,
    describePlacement_projectName,

    -- * Destructuring the Response
    DescribePlacementResponse (..),
    newDescribePlacementResponse,

    -- * Response Lenses
    describePlacementResponse_httpStatus,
    describePlacementResponse_placement,
  )
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:/ 'newDescribePlacement' smart constructor.
data DescribePlacement = DescribePlacement'
  { -- | The name of the placement within a project.
    DescribePlacement -> Text
placementName :: Prelude.Text,
    -- | The project containing the placement to be described.
    DescribePlacement -> Text
projectName :: Prelude.Text
  }
  deriving (DescribePlacement -> DescribePlacement -> Bool
(DescribePlacement -> DescribePlacement -> Bool)
-> (DescribePlacement -> DescribePlacement -> Bool)
-> Eq DescribePlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePlacement -> DescribePlacement -> Bool
$c/= :: DescribePlacement -> DescribePlacement -> Bool
== :: DescribePlacement -> DescribePlacement -> Bool
$c== :: DescribePlacement -> DescribePlacement -> Bool
Prelude.Eq, ReadPrec [DescribePlacement]
ReadPrec DescribePlacement
Int -> ReadS DescribePlacement
ReadS [DescribePlacement]
(Int -> ReadS DescribePlacement)
-> ReadS [DescribePlacement]
-> ReadPrec DescribePlacement
-> ReadPrec [DescribePlacement]
-> Read DescribePlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePlacement]
$creadListPrec :: ReadPrec [DescribePlacement]
readPrec :: ReadPrec DescribePlacement
$creadPrec :: ReadPrec DescribePlacement
readList :: ReadS [DescribePlacement]
$creadList :: ReadS [DescribePlacement]
readsPrec :: Int -> ReadS DescribePlacement
$creadsPrec :: Int -> ReadS DescribePlacement
Prelude.Read, Int -> DescribePlacement -> ShowS
[DescribePlacement] -> ShowS
DescribePlacement -> String
(Int -> DescribePlacement -> ShowS)
-> (DescribePlacement -> String)
-> ([DescribePlacement] -> ShowS)
-> Show DescribePlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePlacement] -> ShowS
$cshowList :: [DescribePlacement] -> ShowS
show :: DescribePlacement -> String
$cshow :: DescribePlacement -> String
showsPrec :: Int -> DescribePlacement -> ShowS
$cshowsPrec :: Int -> DescribePlacement -> ShowS
Prelude.Show, (forall x. DescribePlacement -> Rep DescribePlacement x)
-> (forall x. Rep DescribePlacement x -> DescribePlacement)
-> Generic DescribePlacement
forall x. Rep DescribePlacement x -> DescribePlacement
forall x. DescribePlacement -> Rep DescribePlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribePlacement x -> DescribePlacement
$cfrom :: forall x. DescribePlacement -> Rep DescribePlacement x
Prelude.Generic)

-- |
-- Create a value of 'DescribePlacement' 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:
--
-- 'placementName', 'describePlacement_placementName' - The name of the placement within a project.
--
-- 'projectName', 'describePlacement_projectName' - The project containing the placement to be described.
newDescribePlacement ::
  -- | 'placementName'
  Prelude.Text ->
  -- | 'projectName'
  Prelude.Text ->
  DescribePlacement
newDescribePlacement :: Text -> Text -> DescribePlacement
newDescribePlacement Text
pPlacementName_ Text
pProjectName_ =
  DescribePlacement' :: Text -> Text -> DescribePlacement
DescribePlacement'
    { $sel:placementName:DescribePlacement' :: Text
placementName = Text
pPlacementName_,
      $sel:projectName:DescribePlacement' :: Text
projectName = Text
pProjectName_
    }

-- | The name of the placement within a project.
describePlacement_placementName :: Lens.Lens' DescribePlacement Prelude.Text
describePlacement_placementName :: (Text -> f Text) -> DescribePlacement -> f DescribePlacement
describePlacement_placementName = (DescribePlacement -> Text)
-> (DescribePlacement -> Text -> DescribePlacement)
-> Lens DescribePlacement DescribePlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlacement' {Text
placementName :: Text
$sel:placementName:DescribePlacement' :: DescribePlacement -> Text
placementName} -> Text
placementName) (\s :: DescribePlacement
s@DescribePlacement' {} Text
a -> DescribePlacement
s {$sel:placementName:DescribePlacement' :: Text
placementName = Text
a} :: DescribePlacement)

-- | The project containing the placement to be described.
describePlacement_projectName :: Lens.Lens' DescribePlacement Prelude.Text
describePlacement_projectName :: (Text -> f Text) -> DescribePlacement -> f DescribePlacement
describePlacement_projectName = (DescribePlacement -> Text)
-> (DescribePlacement -> Text -> DescribePlacement)
-> Lens DescribePlacement DescribePlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlacement' {Text
projectName :: Text
$sel:projectName:DescribePlacement' :: DescribePlacement -> Text
projectName} -> Text
projectName) (\s :: DescribePlacement
s@DescribePlacement' {} Text
a -> DescribePlacement
s {$sel:projectName:DescribePlacement' :: Text
projectName = Text
a} :: DescribePlacement)

instance Core.AWSRequest DescribePlacement where
  type
    AWSResponse DescribePlacement =
      DescribePlacementResponse
  request :: DescribePlacement -> Request DescribePlacement
request = Service -> DescribePlacement -> Request DescribePlacement
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribePlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribePlacement)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribePlacement))
-> Logger
-> Service
-> Proxy DescribePlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribePlacement)))
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 -> PlacementDescription -> DescribePlacementResponse
DescribePlacementResponse'
            (Int -> PlacementDescription -> DescribePlacementResponse)
-> Either String Int
-> Either
     String (PlacementDescription -> DescribePlacementResponse)
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 (PlacementDescription -> DescribePlacementResponse)
-> Either String PlacementDescription
-> Either String DescribePlacementResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String PlacementDescription
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"placement")
      )

instance Prelude.Hashable DescribePlacement

instance Prelude.NFData DescribePlacement

instance Core.ToHeaders DescribePlacement where
  toHeaders :: DescribePlacement -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribePlacement -> 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 DescribePlacement where
  toPath :: DescribePlacement -> ByteString
toPath DescribePlacement' {Text
projectName :: Text
placementName :: Text
$sel:projectName:DescribePlacement' :: DescribePlacement -> Text
$sel:placementName:DescribePlacement' :: DescribePlacement -> 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
      ]

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

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

-- |
-- Create a value of 'DescribePlacementResponse' 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', 'describePlacementResponse_httpStatus' - The response's http status code.
--
-- 'placement', 'describePlacementResponse_placement' - An object describing the placement.
newDescribePlacementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'placement'
  PlacementDescription ->
  DescribePlacementResponse
newDescribePlacementResponse :: Int -> PlacementDescription -> DescribePlacementResponse
newDescribePlacementResponse Int
pHttpStatus_ PlacementDescription
pPlacement_ =
  DescribePlacementResponse' :: Int -> PlacementDescription -> DescribePlacementResponse
DescribePlacementResponse'
    { $sel:httpStatus:DescribePlacementResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:placement:DescribePlacementResponse' :: PlacementDescription
placement = PlacementDescription
pPlacement_
    }

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

-- | An object describing the placement.
describePlacementResponse_placement :: Lens.Lens' DescribePlacementResponse PlacementDescription
describePlacementResponse_placement :: (PlacementDescription -> f PlacementDescription)
-> DescribePlacementResponse -> f DescribePlacementResponse
describePlacementResponse_placement = (DescribePlacementResponse -> PlacementDescription)
-> (DescribePlacementResponse
    -> PlacementDescription -> DescribePlacementResponse)
-> Lens
     DescribePlacementResponse
     DescribePlacementResponse
     PlacementDescription
     PlacementDescription
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlacementResponse' {PlacementDescription
placement :: PlacementDescription
$sel:placement:DescribePlacementResponse' :: DescribePlacementResponse -> PlacementDescription
placement} -> PlacementDescription
placement) (\s :: DescribePlacementResponse
s@DescribePlacementResponse' {} PlacementDescription
a -> DescribePlacementResponse
s {$sel:placement:DescribePlacementResponse' :: PlacementDescription
placement = PlacementDescription
a} :: DescribePlacementResponse)

instance Prelude.NFData DescribePlacementResponse