{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ '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
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]
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
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. 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'
    { $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 :: Lens' CreateExclusionsPreview Text
createExclusionsPreview_assessmentTemplateArn = 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 :: (Service -> Service)
-> CreateExclusionsPreview -> Request CreateExclusionsPreview
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 CreateExclusionsPreview
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateExclusionsPreview)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> CreateExclusionsPreviewResponse
CreateExclusionsPreviewResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"previewToken")
      )

instance Prelude.Hashable CreateExclusionsPreview where
  hashWithSalt :: Int -> CreateExclusionsPreview -> Int
hashWithSalt Int
_salt CreateExclusionsPreview' {Text
assessmentTemplateArn :: Text
$sel:assessmentTemplateArn:CreateExclusionsPreview' :: CreateExclusionsPreview -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
assessmentTemplateArn

instance Prelude.NFData CreateExclusionsPreview where
  rnf :: CreateExclusionsPreview -> ()
rnf CreateExclusionsPreview' {Text
assessmentTemplateArn :: Text
$sel:assessmentTemplateArn:CreateExclusionsPreview' :: CreateExclusionsPreview -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
assessmentTemplateArn

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

instance Data.ToJSON CreateExclusionsPreview where
  toJSON :: CreateExclusionsPreview -> Value
toJSON CreateExclusionsPreview' {Text
assessmentTemplateArn :: Text
$sel:assessmentTemplateArn:CreateExclusionsPreview' :: CreateExclusionsPreview -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"assessmentTemplateArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
assessmentTemplateArn
              )
          ]
      )

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

instance Data.ToQuery CreateExclusionsPreview where
  toQuery :: CreateExclusionsPreview -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
      { $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 :: Lens' CreateExclusionsPreviewResponse Int
createExclusionsPreviewResponse_httpStatus = 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 :: Lens' CreateExclusionsPreviewResponse Text
createExclusionsPreviewResponse_previewToken = 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
  where
  rnf :: CreateExclusionsPreviewResponse -> ()
rnf CreateExclusionsPreviewResponse' {Int
Text
previewToken :: Text
httpStatus :: Int
$sel:previewToken:CreateExclusionsPreviewResponse' :: CreateExclusionsPreviewResponse -> Text
$sel:httpStatus:CreateExclusionsPreviewResponse' :: CreateExclusionsPreviewResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
previewToken