{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DeviceFarm.Types
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
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]
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
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. 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' {$sel:arn:GetDevicePool' :: Text
arn = Text
pArn_}

-- | The device pool\'s ARN.
getDevicePool_arn :: Lens.Lens' GetDevicePool Prelude.Text
getDevicePool_arn :: Lens' GetDevicePool Text
getDevicePool_arn = 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 :: (Service -> Service) -> GetDevicePool -> Request GetDevicePool
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 GetDevicePool
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDevicePool)))
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 DevicePool -> Int -> GetDevicePoolResponse
GetDevicePoolResponse'
            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
"devicePool")
            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 GetDevicePool where
  hashWithSalt :: Int -> GetDevicePool -> Int
hashWithSalt Int
_salt GetDevicePool' {Text
arn :: Text
$sel:arn:GetDevicePool' :: GetDevicePool -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData GetDevicePool where
  rnf :: GetDevicePool -> ()
rnf GetDevicePool' {Text
arn :: Text
$sel:arn:GetDevicePool' :: GetDevicePool -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
arn

instance Data.ToHeaders GetDevicePool where
  toHeaders :: GetDevicePool -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"DeviceFarm_20150623.GetDevicePool" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetDevicePool where
  toJSON :: GetDevicePool -> Value
toJSON GetDevicePool' {Text
arn :: Text
$sel:arn:GetDevicePool' :: GetDevicePool -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)]
      )

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

instance Data.ToQuery GetDevicePool where
  toQuery :: GetDevicePool -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:devicePool:GetDevicePoolResponse' :: Maybe DevicePool
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 :: Lens' GetDevicePoolResponse (Maybe DevicePool)
getDevicePoolResponse_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 :: Lens' GetDevicePoolResponse Int
getDevicePoolResponse_httpStatus = 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 where
  rnf :: GetDevicePoolResponse -> ()
rnf GetDevicePoolResponse' {Int
Maybe DevicePool
httpStatus :: Int
devicePool :: Maybe DevicePool
$sel:httpStatus:GetDevicePoolResponse' :: GetDevicePoolResponse -> Int
$sel:devicePool:GetDevicePoolResponse' :: GetDevicePoolResponse -> Maybe DevicePool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DevicePool
devicePool
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus