{-# 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.FIS.GetExperiment
-- 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 the specified experiment.
module Amazonka.FIS.GetExperiment
  ( -- * Creating a Request
    GetExperiment (..),
    newGetExperiment,

    -- * Request Lenses
    getExperiment_id,

    -- * Destructuring the Response
    GetExperimentResponse (..),
    newGetExperimentResponse,

    -- * Response Lenses
    getExperimentResponse_experiment,
    getExperimentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FIS.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:/ 'newGetExperiment' smart constructor.
data GetExperiment = GetExperiment'
  { -- | The ID of the experiment.
    GetExperiment -> Text
id :: Prelude.Text
  }
  deriving (GetExperiment -> GetExperiment -> Bool
(GetExperiment -> GetExperiment -> Bool)
-> (GetExperiment -> GetExperiment -> Bool) -> Eq GetExperiment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetExperiment -> GetExperiment -> Bool
$c/= :: GetExperiment -> GetExperiment -> Bool
== :: GetExperiment -> GetExperiment -> Bool
$c== :: GetExperiment -> GetExperiment -> Bool
Prelude.Eq, ReadPrec [GetExperiment]
ReadPrec GetExperiment
Int -> ReadS GetExperiment
ReadS [GetExperiment]
(Int -> ReadS GetExperiment)
-> ReadS [GetExperiment]
-> ReadPrec GetExperiment
-> ReadPrec [GetExperiment]
-> Read GetExperiment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetExperiment]
$creadListPrec :: ReadPrec [GetExperiment]
readPrec :: ReadPrec GetExperiment
$creadPrec :: ReadPrec GetExperiment
readList :: ReadS [GetExperiment]
$creadList :: ReadS [GetExperiment]
readsPrec :: Int -> ReadS GetExperiment
$creadsPrec :: Int -> ReadS GetExperiment
Prelude.Read, Int -> GetExperiment -> ShowS
[GetExperiment] -> ShowS
GetExperiment -> String
(Int -> GetExperiment -> ShowS)
-> (GetExperiment -> String)
-> ([GetExperiment] -> ShowS)
-> Show GetExperiment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetExperiment] -> ShowS
$cshowList :: [GetExperiment] -> ShowS
show :: GetExperiment -> String
$cshow :: GetExperiment -> String
showsPrec :: Int -> GetExperiment -> ShowS
$cshowsPrec :: Int -> GetExperiment -> ShowS
Prelude.Show, (forall x. GetExperiment -> Rep GetExperiment x)
-> (forall x. Rep GetExperiment x -> GetExperiment)
-> Generic GetExperiment
forall x. Rep GetExperiment x -> GetExperiment
forall x. GetExperiment -> Rep GetExperiment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetExperiment x -> GetExperiment
$cfrom :: forall x. GetExperiment -> Rep GetExperiment x
Prelude.Generic)

-- |
-- Create a value of 'GetExperiment' 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:
--
-- 'id', 'getExperiment_id' - The ID of the experiment.
newGetExperiment ::
  -- | 'id'
  Prelude.Text ->
  GetExperiment
newGetExperiment :: Text -> GetExperiment
newGetExperiment Text
pId_ = GetExperiment' :: Text -> GetExperiment
GetExperiment' {$sel:id:GetExperiment' :: Text
id = Text
pId_}

-- | The ID of the experiment.
getExperiment_id :: Lens.Lens' GetExperiment Prelude.Text
getExperiment_id :: (Text -> f Text) -> GetExperiment -> f GetExperiment
getExperiment_id = (GetExperiment -> Text)
-> (GetExperiment -> Text -> GetExperiment)
-> Lens GetExperiment GetExperiment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExperiment' {Text
id :: Text
$sel:id:GetExperiment' :: GetExperiment -> Text
id} -> Text
id) (\s :: GetExperiment
s@GetExperiment' {} Text
a -> GetExperiment
s {$sel:id:GetExperiment' :: Text
id = Text
a} :: GetExperiment)

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

instance Prelude.NFData GetExperiment

instance Core.ToHeaders GetExperiment where
  toHeaders :: GetExperiment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetExperiment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetExperiment where
  toPath :: GetExperiment -> ByteString
toPath GetExperiment' {Text
id :: Text
$sel:id:GetExperiment' :: GetExperiment -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/experiments/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

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

-- |
-- Create a value of 'GetExperimentResponse' 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:
--
-- 'experiment', 'getExperimentResponse_experiment' - Information about the experiment.
--
-- 'httpStatus', 'getExperimentResponse_httpStatus' - The response's http status code.
newGetExperimentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetExperimentResponse
newGetExperimentResponse :: Int -> GetExperimentResponse
newGetExperimentResponse Int
pHttpStatus_ =
  GetExperimentResponse' :: Maybe Experiment -> Int -> GetExperimentResponse
GetExperimentResponse'
    { $sel:experiment:GetExperimentResponse' :: Maybe Experiment
experiment =
        Maybe Experiment
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetExperimentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the experiment.
getExperimentResponse_experiment :: Lens.Lens' GetExperimentResponse (Prelude.Maybe Experiment)
getExperimentResponse_experiment :: (Maybe Experiment -> f (Maybe Experiment))
-> GetExperimentResponse -> f GetExperimentResponse
getExperimentResponse_experiment = (GetExperimentResponse -> Maybe Experiment)
-> (GetExperimentResponse
    -> Maybe Experiment -> GetExperimentResponse)
-> Lens
     GetExperimentResponse
     GetExperimentResponse
     (Maybe Experiment)
     (Maybe Experiment)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExperimentResponse' {Maybe Experiment
experiment :: Maybe Experiment
$sel:experiment:GetExperimentResponse' :: GetExperimentResponse -> Maybe Experiment
experiment} -> Maybe Experiment
experiment) (\s :: GetExperimentResponse
s@GetExperimentResponse' {} Maybe Experiment
a -> GetExperimentResponse
s {$sel:experiment:GetExperimentResponse' :: Maybe Experiment
experiment = Maybe Experiment
a} :: GetExperimentResponse)

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

instance Prelude.NFData GetExperimentResponse