{-# 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.Evidently.GetExperiment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the details about one experiment. You must already know the
-- experiment name. To retrieve a list of experiments in your account, use
-- <https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_ListExperiments.html ListExperiments>.
module Amazonka.Evidently.GetExperiment
  ( -- * Creating a Request
    GetExperiment (..),
    newGetExperiment,

    -- * Request Lenses
    getExperiment_experiment,
    getExperiment_project,

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

    -- * Response Lenses
    getExperimentResponse_experiment,
    getExperimentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Evidently.Types
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 name of the experiment that you want to see the details of.
    GetExperiment -> Text
experiment :: Prelude.Text,
    -- | The name or ARN of the project that contains the experiment.
    GetExperiment -> Text
project :: Prelude.Text
  }
  deriving (GetExperiment -> GetExperiment -> Bool
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]
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
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. 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:
--
-- 'experiment', 'getExperiment_experiment' - The name of the experiment that you want to see the details of.
--
-- 'project', 'getExperiment_project' - The name or ARN of the project that contains the experiment.
newGetExperiment ::
  -- | 'experiment'
  Prelude.Text ->
  -- | 'project'
  Prelude.Text ->
  GetExperiment
newGetExperiment :: Text -> Text -> GetExperiment
newGetExperiment Text
pExperiment_ Text
pProject_ =
  GetExperiment'
    { $sel:experiment:GetExperiment' :: Text
experiment = Text
pExperiment_,
      $sel:project:GetExperiment' :: Text
project = Text
pProject_
    }

-- | The name of the experiment that you want to see the details of.
getExperiment_experiment :: Lens.Lens' GetExperiment Prelude.Text
getExperiment_experiment :: Lens' GetExperiment Text
getExperiment_experiment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExperiment' {Text
experiment :: Text
$sel:experiment:GetExperiment' :: GetExperiment -> Text
experiment} -> Text
experiment) (\s :: GetExperiment
s@GetExperiment' {} Text
a -> GetExperiment
s {$sel:experiment:GetExperiment' :: Text
experiment = Text
a} :: GetExperiment)

-- | The name or ARN of the project that contains the experiment.
getExperiment_project :: Lens.Lens' GetExperiment Prelude.Text
getExperiment_project :: Lens' GetExperiment Text
getExperiment_project = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExperiment' {Text
project :: Text
$sel:project:GetExperiment' :: GetExperiment -> Text
project} -> Text
project) (\s :: GetExperiment
s@GetExperiment' {} Text
a -> GetExperiment
s {$sel:project:GetExperiment' :: Text
project = Text
a} :: GetExperiment)

instance Core.AWSRequest GetExperiment where
  type
    AWSResponse GetExperiment =
      GetExperimentResponse
  request :: (Service -> Service) -> GetExperiment -> Request GetExperiment
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetExperiment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetExperiment)))
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 Experiment -> Int -> GetExperimentResponse
GetExperimentResponse'
            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
"experiment")
            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 GetExperiment where
  hashWithSalt :: Int -> GetExperiment -> Int
hashWithSalt Int
_salt GetExperiment' {Text
project :: Text
experiment :: Text
$sel:project:GetExperiment' :: GetExperiment -> Text
$sel:experiment:GetExperiment' :: GetExperiment -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
experiment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
project

instance Prelude.NFData GetExperiment where
  rnf :: GetExperiment -> ()
rnf GetExperiment' {Text
project :: Text
experiment :: Text
$sel:project:GetExperiment' :: GetExperiment -> Text
$sel:experiment:GetExperiment' :: GetExperiment -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
experiment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
project

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

instance Data.ToPath GetExperiment where
  toPath :: GetExperiment -> ByteString
toPath GetExperiment' {Text
project :: Text
experiment :: Text
$sel:project:GetExperiment' :: GetExperiment -> Text
$sel:experiment:GetExperiment' :: GetExperiment -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/projects/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
project,
        ByteString
"/experiments/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
experiment
      ]

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

-- | /See:/ 'newGetExperimentResponse' smart constructor.
data GetExperimentResponse = GetExperimentResponse'
  { -- | A structure containing the configuration details of the experiment.
    GetExperimentResponse -> Maybe Experiment
experiment :: Prelude.Maybe Experiment,
    -- | The response's http status code.
    GetExperimentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetExperimentResponse -> GetExperimentResponse -> Bool
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]
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
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. 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' - A structure containing the configuration details of the experiment.
--
-- 'httpStatus', 'getExperimentResponse_httpStatus' - The response's http status code.
newGetExperimentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetExperimentResponse
newGetExperimentResponse :: Int -> GetExperimentResponse
newGetExperimentResponse Int
pHttpStatus_ =
  GetExperimentResponse'
    { $sel:experiment:GetExperimentResponse' :: Maybe Experiment
experiment =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetExperimentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A structure containing the configuration details of the experiment.
getExperimentResponse_experiment :: Lens.Lens' GetExperimentResponse (Prelude.Maybe Experiment)
getExperimentResponse_experiment :: Lens' GetExperimentResponse (Maybe Experiment)
getExperimentResponse_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 :: Lens' GetExperimentResponse Int
getExperimentResponse_httpStatus = 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 where
  rnf :: GetExperimentResponse -> ()
rnf GetExperimentResponse' {Int
Maybe Experiment
httpStatus :: Int
experiment :: Maybe Experiment
$sel:httpStatus:GetExperimentResponse' :: GetExperimentResponse -> Int
$sel:experiment:GetExperimentResponse' :: GetExperimentResponse -> Maybe Experiment
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Experiment
experiment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus