{-# 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.CreateExclusionsPreview
-- 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)
--
-- Starts the generation of an exclusions preview for the specified
-- assessment template. The exclusions preview lists the potential
-- exclusions (ExclusionPreview) that Inspector can detect before it runs
-- the assessment.
module Amazonka.Inspector.CreateExclusionsPreview
  ( -- * Creating a Request
    CreateExclusionsPreview (..),
    newCreateExclusionsPreview,

    -- * Request Lenses
    createExclusionsPreview_assessmentTemplateArn,

    -- * Destructuring the Response
    CreateExclusionsPreviewResponse (..),
    newCreateExclusionsPreviewResponse,

    -- * Response Lenses
    createExclusionsPreviewResponse_httpStatus,
    createExclusionsPreviewResponse_previewToken,
  )
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:/ 'newCreateExclusionsPreview' smart constructor.
data CreateExclusionsPreview = CreateExclusionsPreview'
  { -- | The ARN that specifies the assessment template for which you want to
    -- create an exclusions preview.
    CreateExclusionsPreview -> Text
assessmentTemplateArn :: Prelude.Text
  }
  deriving (CreateExclusionsPreview -> CreateExclusionsPreview -> Bool
(CreateExclusionsPreview -> CreateExclusionsPreview -> Bool)
-> (CreateExclusionsPreview -> CreateExclusionsPreview -> Bool)
-> Eq CreateExclusionsPreview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateExclusionsPreview -> CreateExclusionsPreview -> Bool
$c/= :: CreateExclusionsPreview -> CreateExclusionsPreview -> Bool
== :: CreateExclusionsPreview -> CreateExclusionsPreview -> Bool
$c== :: CreateExclusionsPreview -> CreateExclusionsPreview -> Bool
Prelude.Eq, ReadPrec [CreateExclusionsPreview]
ReadPrec CreateExclusionsPreview
Int -> ReadS CreateExclusionsPreview
ReadS [CreateExclusionsPreview]
(Int -> ReadS CreateExclusionsPreview)
-> ReadS [CreateExclusionsPreview]
-> ReadPrec CreateExclusionsPreview
-> ReadPrec [CreateExclusionsPreview]
-> Read CreateExclusionsPreview
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateExclusionsPreview]
$creadListPrec :: ReadPrec [CreateExclusionsPreview]
readPrec :: ReadPrec CreateExclusionsPreview
$creadPrec :: ReadPrec CreateExclusionsPreview
readList :: ReadS [CreateExclusionsPreview]
$creadList :: ReadS [CreateExclusionsPreview]
readsPrec :: Int -> ReadS CreateExclusionsPreview
$creadsPrec :: Int -> ReadS CreateExclusionsPreview
Prelude.Read, Int -> CreateExclusionsPreview -> ShowS
[CreateExclusionsPreview] -> ShowS
CreateExclusionsPreview -> String
(Int -> CreateExclusionsPreview -> ShowS)
-> (CreateExclusionsPreview -> String)
-> ([CreateExclusionsPreview] -> ShowS)
-> Show CreateExclusionsPreview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateExclusionsPreview] -> ShowS
$cshowList :: [CreateExclusionsPreview] -> ShowS
show :: CreateExclusionsPreview -> String
$cshow :: CreateExclusionsPreview -> String
showsPrec :: Int -> CreateExclusionsPreview -> ShowS
$cshowsPrec :: Int -> CreateExclusionsPreview -> ShowS
Prelude.Show, (forall x.
 CreateExclusionsPreview -> Rep CreateExclusionsPreview x)
-> (forall x.
    Rep CreateExclusionsPreview x -> CreateExclusionsPreview)
-> Generic CreateExclusionsPreview
forall x. Rep CreateExclusionsPreview x -> CreateExclusionsPreview
forall x. CreateExclusionsPreview -> Rep CreateExclusionsPreview x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateExclusionsPreview x -> CreateExclusionsPreview
$cfrom :: forall x. CreateExclusionsPreview -> Rep CreateExclusionsPreview x
Prelude.Generic)

-- |
-- Create a value of 'CreateExclusionsPreview' 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:
--
-- 'assessmentTemplateArn', 'createExclusionsPreview_assessmentTemplateArn' - The ARN that specifies the assessment template for which you want to
-- create an exclusions preview.
newCreateExclusionsPreview ::
  -- | 'assessmentTemplateArn'
  Prelude.Text ->
  CreateExclusionsPreview
newCreateExclusionsPreview :: Text -> CreateExclusionsPreview
newCreateExclusionsPreview Text
pAssessmentTemplateArn_ =
  CreateExclusionsPreview' :: Text -> CreateExclusionsPreview
CreateExclusionsPreview'
    { $sel:assessmentTemplateArn:CreateExclusionsPreview' :: Text
assessmentTemplateArn =
        Text
pAssessmentTemplateArn_
    }

-- | The ARN that specifies the assessment template for which you want to
-- create an exclusions preview.
createExclusionsPreview_assessmentTemplateArn :: Lens.Lens' CreateExclusionsPreview Prelude.Text
createExclusionsPreview_assessmentTemplateArn :: (Text -> f Text)
-> CreateExclusionsPreview -> f CreateExclusionsPreview
createExclusionsPreview_assessmentTemplateArn = (CreateExclusionsPreview -> Text)
-> (CreateExclusionsPreview -> Text -> CreateExclusionsPreview)
-> Lens CreateExclusionsPreview CreateExclusionsPreview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExclusionsPreview' {Text
assessmentTemplateArn :: Text
$sel:assessmentTemplateArn:CreateExclusionsPreview' :: CreateExclusionsPreview -> Text
assessmentTemplateArn} -> Text
assessmentTemplateArn) (\s :: CreateExclusionsPreview
s@CreateExclusionsPreview' {} Text
a -> CreateExclusionsPreview
s {$sel:assessmentTemplateArn:CreateExclusionsPreview' :: Text
assessmentTemplateArn = Text
a} :: CreateExclusionsPreview)

instance Core.AWSRequest CreateExclusionsPreview where
  type
    AWSResponse CreateExclusionsPreview =
      CreateExclusionsPreviewResponse
  request :: CreateExclusionsPreview -> Request CreateExclusionsPreview
request = Service
-> CreateExclusionsPreview -> Request CreateExclusionsPreview
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateExclusionsPreview
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateExclusionsPreview)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateExclusionsPreview))
-> Logger
-> Service
-> Proxy CreateExclusionsPreview
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateExclusionsPreview)))
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 ->
          Int -> Text -> CreateExclusionsPreviewResponse
CreateExclusionsPreviewResponse'
            (Int -> Text -> CreateExclusionsPreviewResponse)
-> Either String Int
-> Either String (Text -> CreateExclusionsPreviewResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Text -> CreateExclusionsPreviewResponse)
-> Either String Text
-> Either String CreateExclusionsPreviewResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"previewToken")
      )

instance Prelude.Hashable CreateExclusionsPreview

instance Prelude.NFData CreateExclusionsPreview

instance Core.ToHeaders CreateExclusionsPreview where
  toHeaders :: CreateExclusionsPreview -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateExclusionsPreview -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"InspectorService.CreateExclusionsPreview" ::
                          Prelude.ByteString
                      ),
            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.ToJSON CreateExclusionsPreview where
  toJSON :: CreateExclusionsPreview -> Value
toJSON CreateExclusionsPreview' {Text
assessmentTemplateArn :: Text
$sel:assessmentTemplateArn:CreateExclusionsPreview' :: CreateExclusionsPreview -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"assessmentTemplateArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assessmentTemplateArn
              )
          ]
      )

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

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

-- | /See:/ 'newCreateExclusionsPreviewResponse' smart constructor.
data CreateExclusionsPreviewResponse = CreateExclusionsPreviewResponse'
  { -- | The response's http status code.
    CreateExclusionsPreviewResponse -> Int
httpStatus :: Prelude.Int,
    -- | Specifies the unique identifier of the requested exclusions preview. You
    -- can use the unique identifier to retrieve the exclusions preview when
    -- running the GetExclusionsPreview API.
    CreateExclusionsPreviewResponse -> Text
previewToken :: Prelude.Text
  }
  deriving (CreateExclusionsPreviewResponse
-> CreateExclusionsPreviewResponse -> Bool
(CreateExclusionsPreviewResponse
 -> CreateExclusionsPreviewResponse -> Bool)
-> (CreateExclusionsPreviewResponse
    -> CreateExclusionsPreviewResponse -> Bool)
-> Eq CreateExclusionsPreviewResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateExclusionsPreviewResponse
-> CreateExclusionsPreviewResponse -> Bool
$c/= :: CreateExclusionsPreviewResponse
-> CreateExclusionsPreviewResponse -> Bool
== :: CreateExclusionsPreviewResponse
-> CreateExclusionsPreviewResponse -> Bool
$c== :: CreateExclusionsPreviewResponse
-> CreateExclusionsPreviewResponse -> Bool
Prelude.Eq, ReadPrec [CreateExclusionsPreviewResponse]
ReadPrec CreateExclusionsPreviewResponse
Int -> ReadS CreateExclusionsPreviewResponse
ReadS [CreateExclusionsPreviewResponse]
(Int -> ReadS CreateExclusionsPreviewResponse)
-> ReadS [CreateExclusionsPreviewResponse]
-> ReadPrec CreateExclusionsPreviewResponse
-> ReadPrec [CreateExclusionsPreviewResponse]
-> Read CreateExclusionsPreviewResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateExclusionsPreviewResponse]
$creadListPrec :: ReadPrec [CreateExclusionsPreviewResponse]
readPrec :: ReadPrec CreateExclusionsPreviewResponse
$creadPrec :: ReadPrec CreateExclusionsPreviewResponse
readList :: ReadS [CreateExclusionsPreviewResponse]
$creadList :: ReadS [CreateExclusionsPreviewResponse]
readsPrec :: Int -> ReadS CreateExclusionsPreviewResponse
$creadsPrec :: Int -> ReadS CreateExclusionsPreviewResponse
Prelude.Read, Int -> CreateExclusionsPreviewResponse -> ShowS
[CreateExclusionsPreviewResponse] -> ShowS
CreateExclusionsPreviewResponse -> String
(Int -> CreateExclusionsPreviewResponse -> ShowS)
-> (CreateExclusionsPreviewResponse -> String)
-> ([CreateExclusionsPreviewResponse] -> ShowS)
-> Show CreateExclusionsPreviewResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateExclusionsPreviewResponse] -> ShowS
$cshowList :: [CreateExclusionsPreviewResponse] -> ShowS
show :: CreateExclusionsPreviewResponse -> String
$cshow :: CreateExclusionsPreviewResponse -> String
showsPrec :: Int -> CreateExclusionsPreviewResponse -> ShowS
$cshowsPrec :: Int -> CreateExclusionsPreviewResponse -> ShowS
Prelude.Show, (forall x.
 CreateExclusionsPreviewResponse
 -> Rep CreateExclusionsPreviewResponse x)
-> (forall x.
    Rep CreateExclusionsPreviewResponse x
    -> CreateExclusionsPreviewResponse)
-> Generic CreateExclusionsPreviewResponse
forall x.
Rep CreateExclusionsPreviewResponse x
-> CreateExclusionsPreviewResponse
forall x.
CreateExclusionsPreviewResponse
-> Rep CreateExclusionsPreviewResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateExclusionsPreviewResponse x
-> CreateExclusionsPreviewResponse
$cfrom :: forall x.
CreateExclusionsPreviewResponse
-> Rep CreateExclusionsPreviewResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateExclusionsPreviewResponse' 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:
--
-- 'httpStatus', 'createExclusionsPreviewResponse_httpStatus' - The response's http status code.
--
-- 'previewToken', 'createExclusionsPreviewResponse_previewToken' - Specifies the unique identifier of the requested exclusions preview. You
-- can use the unique identifier to retrieve the exclusions preview when
-- running the GetExclusionsPreview API.
newCreateExclusionsPreviewResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'previewToken'
  Prelude.Text ->
  CreateExclusionsPreviewResponse
newCreateExclusionsPreviewResponse :: Int -> Text -> CreateExclusionsPreviewResponse
newCreateExclusionsPreviewResponse
  Int
pHttpStatus_
  Text
pPreviewToken_ =
    CreateExclusionsPreviewResponse' :: Int -> Text -> CreateExclusionsPreviewResponse
CreateExclusionsPreviewResponse'
      { $sel:httpStatus:CreateExclusionsPreviewResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:previewToken:CreateExclusionsPreviewResponse' :: Text
previewToken = Text
pPreviewToken_
      }

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

-- | Specifies the unique identifier of the requested exclusions preview. You
-- can use the unique identifier to retrieve the exclusions preview when
-- running the GetExclusionsPreview API.
createExclusionsPreviewResponse_previewToken :: Lens.Lens' CreateExclusionsPreviewResponse Prelude.Text
createExclusionsPreviewResponse_previewToken :: (Text -> f Text)
-> CreateExclusionsPreviewResponse
-> f CreateExclusionsPreviewResponse
createExclusionsPreviewResponse_previewToken = (CreateExclusionsPreviewResponse -> Text)
-> (CreateExclusionsPreviewResponse
    -> Text -> CreateExclusionsPreviewResponse)
-> Lens
     CreateExclusionsPreviewResponse
     CreateExclusionsPreviewResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExclusionsPreviewResponse' {Text
previewToken :: Text
$sel:previewToken:CreateExclusionsPreviewResponse' :: CreateExclusionsPreviewResponse -> Text
previewToken} -> Text
previewToken) (\s :: CreateExclusionsPreviewResponse
s@CreateExclusionsPreviewResponse' {} Text
a -> CreateExclusionsPreviewResponse
s {$sel:previewToken:CreateExclusionsPreviewResponse' :: Text
previewToken = Text
a} :: CreateExclusionsPreviewResponse)

instance
  Prelude.NFData
    CreateExclusionsPreviewResponse