{-# 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.GetRun
-- 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 run.
module Amazonka.DeviceFarm.GetRun
  ( -- * Creating a Request
    GetRun (..),
    newGetRun,

    -- * Request Lenses
    getRun_arn,

    -- * Destructuring the Response
    GetRunResponse (..),
    newGetRunResponse,

    -- * Response Lenses
    getRunResponse_run,
    getRunResponse_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 run operation.
--
-- /See:/ 'newGetRun' smart constructor.
data GetRun = GetRun'
  { -- | The run\'s ARN.
    GetRun -> Text
arn :: Prelude.Text
  }
  deriving (GetRun -> GetRun -> Bool
(GetRun -> GetRun -> Bool)
-> (GetRun -> GetRun -> Bool) -> Eq GetRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRun -> GetRun -> Bool
$c/= :: GetRun -> GetRun -> Bool
== :: GetRun -> GetRun -> Bool
$c== :: GetRun -> GetRun -> Bool
Prelude.Eq, ReadPrec [GetRun]
ReadPrec GetRun
Int -> ReadS GetRun
ReadS [GetRun]
(Int -> ReadS GetRun)
-> ReadS [GetRun]
-> ReadPrec GetRun
-> ReadPrec [GetRun]
-> Read GetRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRun]
$creadListPrec :: ReadPrec [GetRun]
readPrec :: ReadPrec GetRun
$creadPrec :: ReadPrec GetRun
readList :: ReadS [GetRun]
$creadList :: ReadS [GetRun]
readsPrec :: Int -> ReadS GetRun
$creadsPrec :: Int -> ReadS GetRun
Prelude.Read, Int -> GetRun -> ShowS
[GetRun] -> ShowS
GetRun -> String
(Int -> GetRun -> ShowS)
-> (GetRun -> String) -> ([GetRun] -> ShowS) -> Show GetRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRun] -> ShowS
$cshowList :: [GetRun] -> ShowS
show :: GetRun -> String
$cshow :: GetRun -> String
showsPrec :: Int -> GetRun -> ShowS
$cshowsPrec :: Int -> GetRun -> ShowS
Prelude.Show, (forall x. GetRun -> Rep GetRun x)
-> (forall x. Rep GetRun x -> GetRun) -> Generic GetRun
forall x. Rep GetRun x -> GetRun
forall x. GetRun -> Rep GetRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRun x -> GetRun
$cfrom :: forall x. GetRun -> Rep GetRun x
Prelude.Generic)

-- |
-- Create a value of 'GetRun' 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', 'getRun_arn' - The run\'s ARN.
newGetRun ::
  -- | 'arn'
  Prelude.Text ->
  GetRun
newGetRun :: Text -> GetRun
newGetRun Text
pArn_ = GetRun' :: Text -> GetRun
GetRun' {$sel:arn:GetRun' :: Text
arn = Text
pArn_}

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

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

instance Prelude.NFData GetRun

instance Core.ToHeaders GetRun where
  toHeaders :: GetRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRun -> 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.GetRun" :: 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 GetRun where
  toJSON :: GetRun -> Value
toJSON GetRun' {Text
arn :: Text
$sel:arn:GetRun' :: GetRun -> 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 GetRun where
  toPath :: GetRun -> ByteString
toPath = ByteString -> GetRun -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the result of a get run request.
--
-- /See:/ 'newGetRunResponse' smart constructor.
data GetRunResponse = GetRunResponse'
  { -- | The run to get results from.
    GetRunResponse -> Maybe Run
run :: Prelude.Maybe Run,
    -- | The response's http status code.
    GetRunResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRunResponse -> GetRunResponse -> Bool
(GetRunResponse -> GetRunResponse -> Bool)
-> (GetRunResponse -> GetRunResponse -> Bool) -> Eq GetRunResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRunResponse -> GetRunResponse -> Bool
$c/= :: GetRunResponse -> GetRunResponse -> Bool
== :: GetRunResponse -> GetRunResponse -> Bool
$c== :: GetRunResponse -> GetRunResponse -> Bool
Prelude.Eq, ReadPrec [GetRunResponse]
ReadPrec GetRunResponse
Int -> ReadS GetRunResponse
ReadS [GetRunResponse]
(Int -> ReadS GetRunResponse)
-> ReadS [GetRunResponse]
-> ReadPrec GetRunResponse
-> ReadPrec [GetRunResponse]
-> Read GetRunResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRunResponse]
$creadListPrec :: ReadPrec [GetRunResponse]
readPrec :: ReadPrec GetRunResponse
$creadPrec :: ReadPrec GetRunResponse
readList :: ReadS [GetRunResponse]
$creadList :: ReadS [GetRunResponse]
readsPrec :: Int -> ReadS GetRunResponse
$creadsPrec :: Int -> ReadS GetRunResponse
Prelude.Read, Int -> GetRunResponse -> ShowS
[GetRunResponse] -> ShowS
GetRunResponse -> String
(Int -> GetRunResponse -> ShowS)
-> (GetRunResponse -> String)
-> ([GetRunResponse] -> ShowS)
-> Show GetRunResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRunResponse] -> ShowS
$cshowList :: [GetRunResponse] -> ShowS
show :: GetRunResponse -> String
$cshow :: GetRunResponse -> String
showsPrec :: Int -> GetRunResponse -> ShowS
$cshowsPrec :: Int -> GetRunResponse -> ShowS
Prelude.Show, (forall x. GetRunResponse -> Rep GetRunResponse x)
-> (forall x. Rep GetRunResponse x -> GetRunResponse)
-> Generic GetRunResponse
forall x. Rep GetRunResponse x -> GetRunResponse
forall x. GetRunResponse -> Rep GetRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRunResponse x -> GetRunResponse
$cfrom :: forall x. GetRunResponse -> Rep GetRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRunResponse' 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:
--
-- 'run', 'getRunResponse_run' - The run to get results from.
--
-- 'httpStatus', 'getRunResponse_httpStatus' - The response's http status code.
newGetRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRunResponse
newGetRunResponse :: Int -> GetRunResponse
newGetRunResponse Int
pHttpStatus_ =
  GetRunResponse' :: Maybe Run -> Int -> GetRunResponse
GetRunResponse'
    { $sel:run:GetRunResponse' :: Maybe Run
run = Maybe Run
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The run to get results from.
getRunResponse_run :: Lens.Lens' GetRunResponse (Prelude.Maybe Run)
getRunResponse_run :: (Maybe Run -> f (Maybe Run)) -> GetRunResponse -> f GetRunResponse
getRunResponse_run = (GetRunResponse -> Maybe Run)
-> (GetRunResponse -> Maybe Run -> GetRunResponse)
-> Lens GetRunResponse GetRunResponse (Maybe Run) (Maybe Run)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRunResponse' {Maybe Run
run :: Maybe Run
$sel:run:GetRunResponse' :: GetRunResponse -> Maybe Run
run} -> Maybe Run
run) (\s :: GetRunResponse
s@GetRunResponse' {} Maybe Run
a -> GetRunResponse
s {$sel:run:GetRunResponse' :: Maybe Run
run = Maybe Run
a} :: GetRunResponse)

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

instance Prelude.NFData GetRunResponse