{-# 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.DeviceFarm.GetDevicePool
-- 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)
--
-- Gets information about a device pool.
module Amazonka.DeviceFarm.GetDevicePool
  ( -- * Creating a Request
    GetDevicePool (..),
    newGetDevicePool,

    -- * Request Lenses
    getDevicePool_arn,

    -- * Destructuring the Response
    GetDevicePoolResponse (..),
    newGetDevicePoolResponse,

    -- * Response Lenses
    getDevicePoolResponse_devicePool,
    getDevicePoolResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.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

-- | Represents a request to the get device pool operation.
--
-- /See:/ 'newGetDevicePool' smart constructor.
data GetDevicePool = GetDevicePool'
  { -- | The device pool\'s ARN.
    GetDevicePool -> Text
arn :: Prelude.Text
  }
  deriving (GetDevicePool -> GetDevicePool -> Bool
(GetDevicePool -> GetDevicePool -> Bool)
-> (GetDevicePool -> GetDevicePool -> Bool) -> Eq GetDevicePool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevicePool -> GetDevicePool -> Bool
$c/= :: GetDevicePool -> GetDevicePool -> Bool
== :: GetDevicePool -> GetDevicePool -> Bool
$c== :: GetDevicePool -> GetDevicePool -> Bool
Prelude.Eq, ReadPrec [GetDevicePool]
ReadPrec GetDevicePool
Int -> ReadS GetDevicePool
ReadS [GetDevicePool]
(Int -> ReadS GetDevicePool)
-> ReadS [GetDevicePool]
-> ReadPrec GetDevicePool
-> ReadPrec [GetDevicePool]
-> Read GetDevicePool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevicePool]
$creadListPrec :: ReadPrec [GetDevicePool]
readPrec :: ReadPrec GetDevicePool
$creadPrec :: ReadPrec GetDevicePool
readList :: ReadS [GetDevicePool]
$creadList :: ReadS [GetDevicePool]
readsPrec :: Int -> ReadS GetDevicePool
$creadsPrec :: Int -> ReadS GetDevicePool
Prelude.Read, Int -> GetDevicePool -> ShowS
[GetDevicePool] -> ShowS
GetDevicePool -> String
(Int -> GetDevicePool -> ShowS)
-> (GetDevicePool -> String)
-> ([GetDevicePool] -> ShowS)
-> Show GetDevicePool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevicePool] -> ShowS
$cshowList :: [GetDevicePool] -> ShowS
show :: GetDevicePool -> String
$cshow :: GetDevicePool -> String
showsPrec :: Int -> GetDevicePool -> ShowS
$cshowsPrec :: Int -> GetDevicePool -> ShowS
Prelude.Show, (forall x. GetDevicePool -> Rep GetDevicePool x)
-> (forall x. Rep GetDevicePool x -> GetDevicePool)
-> Generic GetDevicePool
forall x. Rep GetDevicePool x -> GetDevicePool
forall x. GetDevicePool -> Rep GetDevicePool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDevicePool x -> GetDevicePool
$cfrom :: forall x. GetDevicePool -> Rep GetDevicePool x
Prelude.Generic)

-- |
-- Create a value of 'GetDevicePool' 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:
--
-- 'arn', 'getDevicePool_arn' - The device pool\'s ARN.
newGetDevicePool ::
  -- | 'arn'
  Prelude.Text ->
  GetDevicePool
newGetDevicePool :: Text -> GetDevicePool
newGetDevicePool Text
pArn_ = GetDevicePool' :: Text -> GetDevicePool
GetDevicePool' {$sel:arn:GetDevicePool' :: Text
arn = Text
pArn_}

-- | The device pool\'s ARN.
getDevicePool_arn :: Lens.Lens' GetDevicePool Prelude.Text
getDevicePool_arn :: (Text -> f Text) -> GetDevicePool -> f GetDevicePool
getDevicePool_arn = (GetDevicePool -> Text)
-> (GetDevicePool -> Text -> GetDevicePool)
-> Lens GetDevicePool GetDevicePool Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePool' {Text
arn :: Text
$sel:arn:GetDevicePool' :: GetDevicePool -> Text
arn} -> Text
arn) (\s :: GetDevicePool
s@GetDevicePool' {} Text
a -> GetDevicePool
s {$sel:arn:GetDevicePool' :: Text
arn = Text
a} :: GetDevicePool)

instance Core.AWSRequest GetDevicePool where
  type
    AWSResponse GetDevicePool =
      GetDevicePoolResponse
  request :: GetDevicePool -> Request GetDevicePool
request = Service -> GetDevicePool -> Request GetDevicePool
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDevicePool
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDevicePool)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDevicePool))
-> Logger
-> Service
-> Proxy GetDevicePool
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDevicePool)))
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 ->
          Maybe DevicePool -> Int -> GetDevicePoolResponse
GetDevicePoolResponse'
            (Maybe DevicePool -> Int -> GetDevicePoolResponse)
-> Either String (Maybe DevicePool)
-> Either String (Int -> GetDevicePoolResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DevicePool)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"devicePool")
            Either String (Int -> GetDevicePoolResponse)
-> Either String Int -> Either String GetDevicePoolResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetDevicePool

instance Prelude.NFData GetDevicePool

instance Core.ToHeaders GetDevicePool where
  toHeaders :: GetDevicePool -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDevicePool -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DeviceFarm_20150623.GetDevicePool" ::
                          Prelude.ByteString
                      ),
            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.ToJSON GetDevicePool where
  toJSON :: GetDevicePool -> Value
toJSON GetDevicePool' {Text
arn :: Text
$sel:arn:GetDevicePool' :: GetDevicePool -> 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
"arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

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

-- | Represents the result of a get device pool request.
--
-- /See:/ 'newGetDevicePoolResponse' smart constructor.
data GetDevicePoolResponse = GetDevicePoolResponse'
  { -- | An object that contains information about the requested device pool.
    GetDevicePoolResponse -> Maybe DevicePool
devicePool :: Prelude.Maybe DevicePool,
    -- | The response's http status code.
    GetDevicePoolResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDevicePoolResponse -> GetDevicePoolResponse -> Bool
(GetDevicePoolResponse -> GetDevicePoolResponse -> Bool)
-> (GetDevicePoolResponse -> GetDevicePoolResponse -> Bool)
-> Eq GetDevicePoolResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevicePoolResponse -> GetDevicePoolResponse -> Bool
$c/= :: GetDevicePoolResponse -> GetDevicePoolResponse -> Bool
== :: GetDevicePoolResponse -> GetDevicePoolResponse -> Bool
$c== :: GetDevicePoolResponse -> GetDevicePoolResponse -> Bool
Prelude.Eq, ReadPrec [GetDevicePoolResponse]
ReadPrec GetDevicePoolResponse
Int -> ReadS GetDevicePoolResponse
ReadS [GetDevicePoolResponse]
(Int -> ReadS GetDevicePoolResponse)
-> ReadS [GetDevicePoolResponse]
-> ReadPrec GetDevicePoolResponse
-> ReadPrec [GetDevicePoolResponse]
-> Read GetDevicePoolResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevicePoolResponse]
$creadListPrec :: ReadPrec [GetDevicePoolResponse]
readPrec :: ReadPrec GetDevicePoolResponse
$creadPrec :: ReadPrec GetDevicePoolResponse
readList :: ReadS [GetDevicePoolResponse]
$creadList :: ReadS [GetDevicePoolResponse]
readsPrec :: Int -> ReadS GetDevicePoolResponse
$creadsPrec :: Int -> ReadS GetDevicePoolResponse
Prelude.Read, Int -> GetDevicePoolResponse -> ShowS
[GetDevicePoolResponse] -> ShowS
GetDevicePoolResponse -> String
(Int -> GetDevicePoolResponse -> ShowS)
-> (GetDevicePoolResponse -> String)
-> ([GetDevicePoolResponse] -> ShowS)
-> Show GetDevicePoolResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevicePoolResponse] -> ShowS
$cshowList :: [GetDevicePoolResponse] -> ShowS
show :: GetDevicePoolResponse -> String
$cshow :: GetDevicePoolResponse -> String
showsPrec :: Int -> GetDevicePoolResponse -> ShowS
$cshowsPrec :: Int -> GetDevicePoolResponse -> ShowS
Prelude.Show, (forall x. GetDevicePoolResponse -> Rep GetDevicePoolResponse x)
-> (forall x. Rep GetDevicePoolResponse x -> GetDevicePoolResponse)
-> Generic GetDevicePoolResponse
forall x. Rep GetDevicePoolResponse x -> GetDevicePoolResponse
forall x. GetDevicePoolResponse -> Rep GetDevicePoolResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDevicePoolResponse x -> GetDevicePoolResponse
$cfrom :: forall x. GetDevicePoolResponse -> Rep GetDevicePoolResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDevicePoolResponse' 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:
--
-- 'devicePool', 'getDevicePoolResponse_devicePool' - An object that contains information about the requested device pool.
--
-- 'httpStatus', 'getDevicePoolResponse_httpStatus' - The response's http status code.
newGetDevicePoolResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDevicePoolResponse
newGetDevicePoolResponse :: Int -> GetDevicePoolResponse
newGetDevicePoolResponse Int
pHttpStatus_ =
  GetDevicePoolResponse' :: Maybe DevicePool -> Int -> GetDevicePoolResponse
GetDevicePoolResponse'
    { $sel:devicePool:GetDevicePoolResponse' :: Maybe DevicePool
devicePool =
        Maybe DevicePool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDevicePoolResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains information about the requested device pool.
getDevicePoolResponse_devicePool :: Lens.Lens' GetDevicePoolResponse (Prelude.Maybe DevicePool)
getDevicePoolResponse_devicePool :: (Maybe DevicePool -> f (Maybe DevicePool))
-> GetDevicePoolResponse -> f GetDevicePoolResponse
getDevicePoolResponse_devicePool = (GetDevicePoolResponse -> Maybe DevicePool)
-> (GetDevicePoolResponse
    -> Maybe DevicePool -> GetDevicePoolResponse)
-> Lens
     GetDevicePoolResponse
     GetDevicePoolResponse
     (Maybe DevicePool)
     (Maybe DevicePool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePoolResponse' {Maybe DevicePool
devicePool :: Maybe DevicePool
$sel:devicePool:GetDevicePoolResponse' :: GetDevicePoolResponse -> Maybe DevicePool
devicePool} -> Maybe DevicePool
devicePool) (\s :: GetDevicePoolResponse
s@GetDevicePoolResponse' {} Maybe DevicePool
a -> GetDevicePoolResponse
s {$sel:devicePool:GetDevicePoolResponse' :: Maybe DevicePool
devicePool = Maybe DevicePool
a} :: GetDevicePoolResponse)

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

instance Prelude.NFData GetDevicePoolResponse