{-# 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-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 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 Amazonka.Inspector.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:/ '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
(StopAssessmentRun -> StopAssessmentRun -> Bool)
-> (StopAssessmentRun -> StopAssessmentRun -> Bool)
-> Eq StopAssessmentRun
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]
(Int -> ReadS StopAssessmentRun)
-> ReadS [StopAssessmentRun]
-> ReadPrec StopAssessmentRun
-> ReadPrec [StopAssessmentRun]
-> Read 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
(Int -> StopAssessmentRun -> ShowS)
-> (StopAssessmentRun -> String)
-> ([StopAssessmentRun] -> ShowS)
-> Show StopAssessmentRun
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. StopAssessmentRun -> Rep StopAssessmentRun x)
-> (forall x. Rep StopAssessmentRun x -> StopAssessmentRun)
-> Generic StopAssessmentRun
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' :: Maybe StopAction -> Text -> StopAssessmentRun
StopAssessmentRun'
    { $sel:stopAction:StopAssessmentRun' :: Maybe StopAction
stopAction = Maybe 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 :: (Maybe StopAction -> f (Maybe StopAction))
-> StopAssessmentRun -> f StopAssessmentRun
stopAssessmentRun_stopAction = (StopAssessmentRun -> Maybe StopAction)
-> (StopAssessmentRun -> Maybe StopAction -> StopAssessmentRun)
-> Lens
     StopAssessmentRun
     StopAssessmentRun
     (Maybe StopAction)
     (Maybe 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 :: (Text -> f Text) -> StopAssessmentRun -> f StopAssessmentRun
stopAssessmentRun_assessmentRunArn = (StopAssessmentRun -> Text)
-> (StopAssessmentRun -> Text -> StopAssessmentRun)
-> Lens StopAssessmentRun StopAssessmentRun Text Text
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 :: StopAssessmentRun -> Request StopAssessmentRun
request = Service -> StopAssessmentRun -> Request StopAssessmentRun
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopAssessmentRun
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopAssessmentRun)))
response =
    AWSResponse StopAssessmentRun
-> Logger
-> Service
-> Proxy StopAssessmentRun
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopAssessmentRun)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StopAssessmentRun
StopAssessmentRunResponse
StopAssessmentRunResponse'

instance Prelude.Hashable StopAssessmentRun

instance Prelude.NFData StopAssessmentRun

instance Core.ToHeaders StopAssessmentRun where
  toHeaders :: StopAssessmentRun -> [Header]
toHeaders =
    [Header] -> StopAssessmentRun -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"InspectorService.StopAssessmentRun" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"stopAction" Text -> StopAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StopAction -> Pair) -> Maybe StopAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StopAction
stopAction,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"assessmentRunArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assessmentRunArn)
          ]
      )

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

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

-- | /See:/ 'newStopAssessmentRunResponse' smart constructor.
data StopAssessmentRunResponse = StopAssessmentRunResponse'
  {
  }
  deriving (StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool
(StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool)
-> (StopAssessmentRunResponse -> StopAssessmentRunResponse -> Bool)
-> Eq StopAssessmentRunResponse
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]
(Int -> ReadS StopAssessmentRunResponse)
-> ReadS [StopAssessmentRunResponse]
-> ReadPrec StopAssessmentRunResponse
-> ReadPrec [StopAssessmentRunResponse]
-> Read 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
(Int -> StopAssessmentRunResponse -> ShowS)
-> (StopAssessmentRunResponse -> String)
-> ([StopAssessmentRunResponse] -> ShowS)
-> Show StopAssessmentRunResponse
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.
 StopAssessmentRunResponse -> Rep StopAssessmentRunResponse x)
-> (forall x.
    Rep StopAssessmentRunResponse x -> StopAssessmentRunResponse)
-> Generic StopAssessmentRunResponse
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