{-# 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.Inspector.StopAssessmentRun
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops the assessment run that is specified by the ARN of the assessment
-- run.
module Amazonka.Inspector.StopAssessmentRun
  ( -- * Creating a Request
    StopAssessmentRun (..),
    newStopAssessmentRun,

    -- * Request Lenses
    stopAssessmentRun_stopAction,
    stopAssessmentRun_assessmentRunArn,

    -- * Destructuring the Response
    StopAssessmentRunResponse (..),
    newStopAssessmentRunResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStopAssessmentRun' smart constructor.
data StopAssessmentRun = StopAssessmentRun'
  { -- | An input option that can be set to either START_EVALUATION or
    -- SKIP_EVALUATION. START_EVALUATION (the default value), stops the AWS
    -- agent from collecting data and begins the results evaluation and the
    -- findings generation process. SKIP_EVALUATION cancels the assessment run
    -- immediately, after which no findings are generated.
    StopAssessmentRun -> Maybe StopAction
stopAction :: Prelude.Maybe StopAction,
    -- | The ARN of the assessment run that you want to stop.
    StopAssessmentRun -> Text
assessmentRunArn :: Prelude.Text
  }
  deriving (StopAssessmentRun -> StopAssessmentRun -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopAssessmentRun -> StopAssessmentRun -> Bool
$c/= :: StopAssessmentRun -> StopAssessmentRun -> Bool
== :: StopAssessmentRun -> StopAssessmentRun -> Bool
$c== :: StopAssessmentRun -> StopAssessmentRun -> Bool
Prelude.Eq, ReadPrec [StopAssessmentRun]
ReadPrec StopAssessmentRun
Int -> ReadS StopAssessmentRun
ReadS [StopAssessmentRun]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopAssessmentRun]
$creadListPrec :: ReadPrec [StopAssessmentRun]
readPrec :: ReadPrec StopAssessmentRun
$creadPrec :: ReadPrec StopAssessmentRun
readList :: ReadS [StopAssessmentRun]
$creadList :: ReadS [StopAssessmentRun]
readsPrec :: Int -> ReadS StopAssessmentRun
$creadsPrec :: Int -> ReadS StopAssessmentRun
Prelude.Read, Int -> StopAssessmentRun -> ShowS
[StopAssessmentRun] -> ShowS
StopAssessmentRun -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopAssessmentRun] -> ShowS
$cshowList :: [StopAssessmentRun] -> ShowS
show :: StopAssessmentRun -> String
$cshow :: StopAssessmentRun -> String
showsPrec :: Int -> StopAssessmentRun -> ShowS
$cshowsPrec :: Int -> StopAssessmentRun -> ShowS
Prelude.Show, forall x. Rep StopAssessmentRun x -> StopAssessmentRun
forall x. StopAssessmentRun -> Rep StopAssessmentRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopAssessmentRun x -> StopAssessmentRun
$cfrom :: forall x. StopAssessmentRun -> Rep StopAssessmentRun x
Prelude.Generic)

-- |
-- Create a value of 'StopAssessmentRun' 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:
--
-- 'stopAction', 'stopAssessmentRun_stopAction' - An input option that can be set to either START_EVALUATION or
-- SKIP_EVALUATION. START_EVALUATION (the default value), stops the AWS
-- agent from collecting data and begins the results evaluation and the
-- findings generation process. SKIP_EVALUATION cancels the assessment run
-- immediately, after which no findings are generated.
--
-- 'assessmentRunArn', 'stopAssessmentRun_assessmentRunArn' - The ARN of the assessment run that you want to stop.
newStopAssessmentRun ::
  -- | 'assessmentRunArn'
  Prelude.Text ->
  StopAssessmentRun
newStopAssessmentRun :: Text -> StopAssessmentRun
newStopAssessmentRun Text
pAssessmentRunArn_ =
  StopAssessmentRun'
    { $sel:stopAction:StopAssessmentRun' :: Maybe StopAction
stopAction = forall a. Maybe a
Prelude.Nothing,
      $sel:assessmentRunArn:StopAssessmentRun' :: Text
assessmentRunArn = Text
pAssessmentRunArn_
    }

-- | An input option that can be set to either START_EVALUATION or
-- SKIP_EVALUATION. START_EVALUATION (the default value), stops the AWS
-- agent from collecting data and begins the results evaluation and the
-- findings generation process. SKIP_EVALUATION cancels the assessment run
-- immediately, after which no findings are generated.
stopAssessmentRun_stopAction :: Lens.Lens' StopAssessmentRun (Prelude.Maybe StopAction)
stopAssessmentRun_stopAction :: Lens' StopAssessmentRun (Maybe StopAction)
stopAssessmentRun_stopAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopAssessmentRun' {Maybe StopAction
stopAction :: Maybe StopAction
$sel:stopAction:StopAssessmentRun' :: StopAssessmentRun -> Maybe StopAction
stopAction} -> Maybe StopAction
stopAction) (\s :: StopAssessmentRun
s@StopAssessmentRun' {} Maybe StopAction
a -> StopAssessmentRun
s {$sel:stopAction:StopAssessmentRun' :: Maybe StopAction
stopAction = Maybe StopAction
a} :: StopAssessmentRun)

-- | The ARN of the assessment run that you want to stop.
stopAssessmentRun_assessmentRunArn :: Lens.Lens' StopAssessmentRun Prelude.Text
stopAssessmentRun_assessmentRunArn :: Lens' StopAssessmentRun Text
stopAssessmentRun_assessmentRunArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopAssessmentRun' {Text
assessmentRunArn :: Text
$sel:assessmentRunArn:StopAssessmentRun' :: StopAssessmentRun -> Text
assessmentRunArn} -> Text
assessmentRunArn) (\s :: StopAssessmentRun
s@StopAssessmentRun' {} Text
a -> StopAssessmentRun
s {$sel:assessmentRunArn:StopAssessmentRun' :: Text
assessmentRunArn = Text
a} :: StopAssessmentRun)

instance Core.AWSRequest StopAssessmentRun where
  type
    AWSResponse StopAssessmentRun =
      StopAssessmentRunResponse
  request :: (Service -> Service)
-> StopAssessmentRun -> Request StopAssessmentRun
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 StopAssessmentRun
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopAssessmentRun)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull StopAssessmentRunResponse
StopAssessmentRunResponse'

instance Prelude.Hashable StopAssessmentRun where
  hashWithSalt :: Int -> StopAssessmentRun -> Int
hashWithSalt Int
_salt StopAssessmentRun' {Maybe StopAction
Text
assessmentRunArn :: Text
stopAction :: Maybe StopAction
$sel:assessmentRunArn:StopAssessmentRun' :: StopAssessmentRun -> Text
$sel:stopAction:StopAssessmentRun' :: StopAssessmentRun -> Maybe StopAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StopAction
stopAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
assessmentRunArn

instance Prelude.NFData StopAssessmentRun where
  rnf :: StopAssessmentRun -> ()
rnf StopAssessmentRun' {Maybe StopAction
Text
assessmentRunArn :: Text
stopAction :: Maybe StopAction
$sel:assessmentRunArn:StopAssessmentRun' :: StopAssessmentRun -> Text
$sel:stopAction:StopAssessmentRun' :: StopAssessmentRun -> Maybe StopAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StopAction
stopAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
assessmentRunArn

instance Data.ToHeaders StopAssessmentRun where
  toHeaders :: StopAssessmentRun -> [Header]
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 -> [Header]
Data.=# ( ByteString
"InspectorService.StopAssessmentRun" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StopAssessmentRun where
  toJSON :: StopAssessmentRun -> Value
toJSON StopAssessmentRun' {Maybe StopAction
Text
assessmentRunArn :: Text
stopAction :: Maybe StopAction
$sel:assessmentRunArn:StopAssessmentRun' :: StopAssessmentRun -> Text
$sel:stopAction:StopAssessmentRun' :: StopAssessmentRun -> Maybe StopAction
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"stopAction" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StopAction
stopAction,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"assessmentRunArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
assessmentRunArn)
          ]
      )

instance Data.ToPath StopAssessmentRun where
  toPath :: StopAssessmentRun -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newStopAssessmentRunResponse' smart constructor.
data StopAssessmentRunResponse = StopAssessmentRunResponse'
  {
  }
  deriving (StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool
$c/= :: StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool
== :: StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool
$c== :: StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool
Prelude.Eq, ReadPrec [StopAssessmentRunResponse]
ReadPrec StopAssessmentRunResponse
Int -> ReadS StopAssessmentRunResponse
ReadS [StopAssessmentRunResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopAssessmentRunResponse]
$creadListPrec :: ReadPrec [StopAssessmentRunResponse]
readPrec :: ReadPrec StopAssessmentRunResponse
$creadPrec :: ReadPrec StopAssessmentRunResponse
readList :: ReadS [StopAssessmentRunResponse]
$creadList :: ReadS [StopAssessmentRunResponse]
readsPrec :: Int -> ReadS StopAssessmentRunResponse
$creadsPrec :: Int -> ReadS StopAssessmentRunResponse
Prelude.Read, Int -> StopAssessmentRunResponse -> ShowS
[StopAssessmentRunResponse] -> ShowS
StopAssessmentRunResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopAssessmentRunResponse] -> ShowS
$cshowList :: [StopAssessmentRunResponse] -> ShowS
show :: StopAssessmentRunResponse -> String
$cshow :: StopAssessmentRunResponse -> String
showsPrec :: Int -> StopAssessmentRunResponse -> ShowS
$cshowsPrec :: Int -> StopAssessmentRunResponse -> ShowS
Prelude.Show, forall x.
Rep StopAssessmentRunResponse x -> StopAssessmentRunResponse
forall x.
StopAssessmentRunResponse -> Rep StopAssessmentRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopAssessmentRunResponse x -> StopAssessmentRunResponse
$cfrom :: forall x.
StopAssessmentRunResponse -> Rep StopAssessmentRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopAssessmentRunResponse' 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.
newStopAssessmentRunResponse ::
  StopAssessmentRunResponse
newStopAssessmentRunResponse :: StopAssessmentRunResponse
newStopAssessmentRunResponse =
  StopAssessmentRunResponse
StopAssessmentRunResponse'

instance Prelude.NFData StopAssessmentRunResponse where
  rnf :: StopAssessmentRunResponse -> ()
rnf StopAssessmentRunResponse
_ = ()