{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}
{-# LANGUAGE TypeFamilies       #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds   #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Network.AWS.Inspector.RunAssessment
-- Copyright   : (c) 2013-2015 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts the analysis of the application’s behavior against selected rule
-- packages for the assessment specified by the assessment ARN.
--
-- /See:/ <http://docs.aws.amazon.com/inspector/latest/APIReference/API_RunAssessment.html AWS API Reference> for RunAssessment.
module Network.AWS.Inspector.RunAssessment
    (
    -- * Creating a Request
      runAssessment
    , RunAssessment
    -- * Request Lenses
    , raAssessmentARN
    , raRunName

    -- * Destructuring the Response
    , runAssessmentResponse
    , RunAssessmentResponse
    -- * Response Lenses
    , rarsRunARN
    , rarsResponseStatus
    ) where

import           Network.AWS.Inspector.Types
import           Network.AWS.Inspector.Types.Product
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response

-- | /See:/ 'runAssessment' smart constructor.
data RunAssessment = RunAssessment'
    { _raAssessmentARN :: !(Maybe Text)
    , _raRunName       :: !(Maybe Text)
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'RunAssessment' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'raAssessmentARN'
--
-- * 'raRunName'
runAssessment
    :: RunAssessment
runAssessment =
    RunAssessment'
    { _raAssessmentARN = Nothing
    , _raRunName = Nothing
    }

-- | The ARN of the assessment that you want to run.
raAssessmentARN :: Lens' RunAssessment (Maybe Text)
raAssessmentARN = lens _raAssessmentARN (\ s a -> s{_raAssessmentARN = a});

-- | A name specifying the run of the assessment.
raRunName :: Lens' RunAssessment (Maybe Text)
raRunName = lens _raRunName (\ s a -> s{_raRunName = a});

instance AWSRequest RunAssessment where
        type Rs RunAssessment = RunAssessmentResponse
        request = postJSON inspector
        response
          = receiveJSON
              (\ s h x ->
                 RunAssessmentResponse' <$>
                   (x .?> "runArn") <*> (pure (fromEnum s)))

instance ToHeaders RunAssessment where
        toHeaders
          = const
              (mconcat
                 ["X-Amz-Target" =#
                    ("InspectorService.RunAssessment" :: ByteString),
                  "Content-Type" =#
                    ("application/x-amz-json-1.1" :: ByteString)])

instance ToJSON RunAssessment where
        toJSON RunAssessment'{..}
          = object
              (catMaybes
                 [("assessmentArn" .=) <$> _raAssessmentARN,
                  ("runName" .=) <$> _raRunName])

instance ToPath RunAssessment where
        toPath = const "/"

instance ToQuery RunAssessment where
        toQuery = const mempty

-- | /See:/ 'runAssessmentResponse' smart constructor.
data RunAssessmentResponse = RunAssessmentResponse'
    { _rarsRunARN         :: !(Maybe Text)
    , _rarsResponseStatus :: !Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'RunAssessmentResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'rarsRunARN'
--
-- * 'rarsResponseStatus'
runAssessmentResponse
    :: Int -- ^ 'rarsResponseStatus'
    -> RunAssessmentResponse
runAssessmentResponse pResponseStatus_ =
    RunAssessmentResponse'
    { _rarsRunARN = Nothing
    , _rarsResponseStatus = pResponseStatus_
    }

-- | The ARN specifying the run of the assessment.
rarsRunARN :: Lens' RunAssessmentResponse (Maybe Text)
rarsRunARN = lens _rarsRunARN (\ s a -> s{_rarsRunARN = a});

-- | The response status code.
rarsResponseStatus :: Lens' RunAssessmentResponse Int
rarsResponseStatus = lens _rarsResponseStatus (\ s a -> s{_rarsResponseStatus = a});