{-# 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.GetTestGridProject
-- 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)
--
-- Retrieves information about a Selenium testing project.
module Amazonka.DeviceFarm.GetTestGridProject
  ( -- * Creating a Request
    GetTestGridProject (..),
    newGetTestGridProject,

    -- * Request Lenses
    getTestGridProject_projectArn,

    -- * Destructuring the Response
    GetTestGridProjectResponse (..),
    newGetTestGridProjectResponse,

    -- * Response Lenses
    getTestGridProjectResponse_testGridProject,
    getTestGridProjectResponse_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

-- | /See:/ 'newGetTestGridProject' smart constructor.
data GetTestGridProject = GetTestGridProject'
  { -- | The ARN of the Selenium testing project, from either
    -- CreateTestGridProject or ListTestGridProjects.
    GetTestGridProject -> Text
projectArn :: Prelude.Text
  }
  deriving (GetTestGridProject -> GetTestGridProject -> Bool
(GetTestGridProject -> GetTestGridProject -> Bool)
-> (GetTestGridProject -> GetTestGridProject -> Bool)
-> Eq GetTestGridProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTestGridProject -> GetTestGridProject -> Bool
$c/= :: GetTestGridProject -> GetTestGridProject -> Bool
== :: GetTestGridProject -> GetTestGridProject -> Bool
$c== :: GetTestGridProject -> GetTestGridProject -> Bool
Prelude.Eq, ReadPrec [GetTestGridProject]
ReadPrec GetTestGridProject
Int -> ReadS GetTestGridProject
ReadS [GetTestGridProject]
(Int -> ReadS GetTestGridProject)
-> ReadS [GetTestGridProject]
-> ReadPrec GetTestGridProject
-> ReadPrec [GetTestGridProject]
-> Read GetTestGridProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTestGridProject]
$creadListPrec :: ReadPrec [GetTestGridProject]
readPrec :: ReadPrec GetTestGridProject
$creadPrec :: ReadPrec GetTestGridProject
readList :: ReadS [GetTestGridProject]
$creadList :: ReadS [GetTestGridProject]
readsPrec :: Int -> ReadS GetTestGridProject
$creadsPrec :: Int -> ReadS GetTestGridProject
Prelude.Read, Int -> GetTestGridProject -> ShowS
[GetTestGridProject] -> ShowS
GetTestGridProject -> String
(Int -> GetTestGridProject -> ShowS)
-> (GetTestGridProject -> String)
-> ([GetTestGridProject] -> ShowS)
-> Show GetTestGridProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTestGridProject] -> ShowS
$cshowList :: [GetTestGridProject] -> ShowS
show :: GetTestGridProject -> String
$cshow :: GetTestGridProject -> String
showsPrec :: Int -> GetTestGridProject -> ShowS
$cshowsPrec :: Int -> GetTestGridProject -> ShowS
Prelude.Show, (forall x. GetTestGridProject -> Rep GetTestGridProject x)
-> (forall x. Rep GetTestGridProject x -> GetTestGridProject)
-> Generic GetTestGridProject
forall x. Rep GetTestGridProject x -> GetTestGridProject
forall x. GetTestGridProject -> Rep GetTestGridProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTestGridProject x -> GetTestGridProject
$cfrom :: forall x. GetTestGridProject -> Rep GetTestGridProject x
Prelude.Generic)

-- |
-- Create a value of 'GetTestGridProject' 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:
--
-- 'projectArn', 'getTestGridProject_projectArn' - The ARN of the Selenium testing project, from either
-- CreateTestGridProject or ListTestGridProjects.
newGetTestGridProject ::
  -- | 'projectArn'
  Prelude.Text ->
  GetTestGridProject
newGetTestGridProject :: Text -> GetTestGridProject
newGetTestGridProject Text
pProjectArn_ =
  GetTestGridProject' :: Text -> GetTestGridProject
GetTestGridProject' {$sel:projectArn:GetTestGridProject' :: Text
projectArn = Text
pProjectArn_}

-- | The ARN of the Selenium testing project, from either
-- CreateTestGridProject or ListTestGridProjects.
getTestGridProject_projectArn :: Lens.Lens' GetTestGridProject Prelude.Text
getTestGridProject_projectArn :: (Text -> f Text) -> GetTestGridProject -> f GetTestGridProject
getTestGridProject_projectArn = (GetTestGridProject -> Text)
-> (GetTestGridProject -> Text -> GetTestGridProject)
-> Lens GetTestGridProject GetTestGridProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridProject' {Text
projectArn :: Text
$sel:projectArn:GetTestGridProject' :: GetTestGridProject -> Text
projectArn} -> Text
projectArn) (\s :: GetTestGridProject
s@GetTestGridProject' {} Text
a -> GetTestGridProject
s {$sel:projectArn:GetTestGridProject' :: Text
projectArn = Text
a} :: GetTestGridProject)

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

instance Prelude.NFData GetTestGridProject

instance Core.ToHeaders GetTestGridProject where
  toHeaders :: GetTestGridProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetTestGridProject -> 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.GetTestGridProject" ::
                          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 GetTestGridProject where
  toJSON :: GetTestGridProject -> Value
toJSON GetTestGridProject' {Text
projectArn :: Text
$sel:projectArn:GetTestGridProject' :: GetTestGridProject -> 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
"projectArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
projectArn)]
      )

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

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

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

-- |
-- Create a value of 'GetTestGridProjectResponse' 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:
--
-- 'testGridProject', 'getTestGridProjectResponse_testGridProject' - A TestGridProject.
--
-- 'httpStatus', 'getTestGridProjectResponse_httpStatus' - The response's http status code.
newGetTestGridProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTestGridProjectResponse
newGetTestGridProjectResponse :: Int -> GetTestGridProjectResponse
newGetTestGridProjectResponse Int
pHttpStatus_ =
  GetTestGridProjectResponse' :: Maybe TestGridProject -> Int -> GetTestGridProjectResponse
GetTestGridProjectResponse'
    { $sel:testGridProject:GetTestGridProjectResponse' :: Maybe TestGridProject
testGridProject =
        Maybe TestGridProject
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTestGridProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A TestGridProject.
getTestGridProjectResponse_testGridProject :: Lens.Lens' GetTestGridProjectResponse (Prelude.Maybe TestGridProject)
getTestGridProjectResponse_testGridProject :: (Maybe TestGridProject -> f (Maybe TestGridProject))
-> GetTestGridProjectResponse -> f GetTestGridProjectResponse
getTestGridProjectResponse_testGridProject = (GetTestGridProjectResponse -> Maybe TestGridProject)
-> (GetTestGridProjectResponse
    -> Maybe TestGridProject -> GetTestGridProjectResponse)
-> Lens
     GetTestGridProjectResponse
     GetTestGridProjectResponse
     (Maybe TestGridProject)
     (Maybe TestGridProject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridProjectResponse' {Maybe TestGridProject
testGridProject :: Maybe TestGridProject
$sel:testGridProject:GetTestGridProjectResponse' :: GetTestGridProjectResponse -> Maybe TestGridProject
testGridProject} -> Maybe TestGridProject
testGridProject) (\s :: GetTestGridProjectResponse
s@GetTestGridProjectResponse' {} Maybe TestGridProject
a -> GetTestGridProjectResponse
s {$sel:testGridProject:GetTestGridProjectResponse' :: Maybe TestGridProject
testGridProject = Maybe TestGridProject
a} :: GetTestGridProjectResponse)

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

instance Prelude.NFData GetTestGridProjectResponse