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

    -- * Request Lenses
    stopExperiment_id,

    -- * Destructuring the Response
    StopExperimentResponse (..),
    newStopExperimentResponse,

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

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

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

instance Core.AWSRequest StopExperiment where
  type
    AWSResponse StopExperiment =
      StopExperimentResponse
  request :: StopExperiment -> Request StopExperiment
request = Service -> StopExperiment -> Request StopExperiment
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy StopExperiment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopExperiment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopExperiment))
-> Logger
-> Service
-> Proxy StopExperiment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopExperiment)))
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 -> StopExperimentResponse
StopExperimentResponse'
            (Maybe Experiment -> Int -> StopExperimentResponse)
-> Either String (Maybe Experiment)
-> Either String (Int -> StopExperimentResponse)
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 -> StopExperimentResponse)
-> Either String Int -> Either String StopExperimentResponse
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 StopExperiment

instance Prelude.NFData StopExperiment

instance Core.ToHeaders StopExperiment where
  toHeaders :: StopExperiment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopExperiment -> 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 StopExperiment where
  toPath :: StopExperiment -> ByteString
toPath StopExperiment' {Text
id :: Text
$sel:id:StopExperiment' :: StopExperiment -> 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 StopExperiment where
  toQuery :: StopExperiment -> QueryString
toQuery = QueryString -> StopExperiment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

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

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

instance Prelude.NFData StopExperimentResponse