{-# 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-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 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 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 run operation.
--
-- /See:/ 'newGetRun' smart constructor.
data GetRun = GetRun'
  { -- | The run\'s ARN.
    GetRun -> Text
arn :: Prelude.Text
  }
  deriving (GetRun -> GetRun -> Bool
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]
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
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. 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' {$sel:arn:GetRun' :: Text
arn = Text
pArn_}

-- | The run\'s ARN.
getRun_arn :: Lens.Lens' GetRun Prelude.Text
getRun_arn :: Lens' GetRun Text
getRun_arn = 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 :: (Service -> Service) -> GetRun -> Request GetRun
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 GetRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRun)))
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 Run -> Int -> GetRunResponse
GetRunResponse'
            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
"run")
            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 GetRun where
  hashWithSalt :: Int -> GetRun -> Int
hashWithSalt Int
_salt GetRun' {Text
arn :: Text
$sel:arn:GetRun' :: GetRun -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

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

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

instance Data.ToQuery GetRun where
  toQuery :: GetRun -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:run:GetRunResponse' :: Maybe Run
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 :: Lens' GetRunResponse (Maybe Run)
getRunResponse_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 :: Lens' GetRunResponse Int
getRunResponse_httpStatus = 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 where
  rnf :: GetRunResponse -> ()
rnf GetRunResponse' {Int
Maybe Run
httpStatus :: Int
run :: Maybe Run
$sel:httpStatus:GetRunResponse' :: GetRunResponse -> Int
$sel:run:GetRunResponse' :: GetRunResponse -> Maybe Run
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Run
run
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus