{-# 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.SecurityHub.DeleteInsight
-- 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)
--
-- Deletes the insight specified by the @InsightArn@.
module Amazonka.SecurityHub.DeleteInsight
  ( -- * Creating a Request
    DeleteInsight (..),
    newDeleteInsight,

    -- * Request Lenses
    deleteInsight_insightArn,

    -- * Destructuring the Response
    DeleteInsightResponse (..),
    newDeleteInsightResponse,

    -- * Response Lenses
    deleteInsightResponse_httpStatus,
    deleteInsightResponse_insightArn,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SecurityHub.Types

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

-- |
-- Create a value of 'DeleteInsight' 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:
--
-- 'insightArn', 'deleteInsight_insightArn' - The ARN of the insight to delete.
newDeleteInsight ::
  -- | 'insightArn'
  Prelude.Text ->
  DeleteInsight
newDeleteInsight :: Text -> DeleteInsight
newDeleteInsight Text
pInsightArn_ =
  DeleteInsight' :: Text -> DeleteInsight
DeleteInsight' {$sel:insightArn:DeleteInsight' :: Text
insightArn = Text
pInsightArn_}

-- | The ARN of the insight to delete.
deleteInsight_insightArn :: Lens.Lens' DeleteInsight Prelude.Text
deleteInsight_insightArn :: (Text -> f Text) -> DeleteInsight -> f DeleteInsight
deleteInsight_insightArn = (DeleteInsight -> Text)
-> (DeleteInsight -> Text -> DeleteInsight)
-> Lens DeleteInsight DeleteInsight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInsight' {Text
insightArn :: Text
$sel:insightArn:DeleteInsight' :: DeleteInsight -> Text
insightArn} -> Text
insightArn) (\s :: DeleteInsight
s@DeleteInsight' {} Text
a -> DeleteInsight
s {$sel:insightArn:DeleteInsight' :: Text
insightArn = Text
a} :: DeleteInsight)

instance Core.AWSRequest DeleteInsight where
  type
    AWSResponse DeleteInsight =
      DeleteInsightResponse
  request :: DeleteInsight -> Request DeleteInsight
request = Service -> DeleteInsight -> Request DeleteInsight
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteInsight
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteInsight)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteInsight))
-> Logger
-> Service
-> Proxy DeleteInsight
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteInsight)))
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 -> DeleteInsightResponse
DeleteInsightResponse'
            (Int -> Text -> DeleteInsightResponse)
-> Either String Int
-> Either String (Text -> DeleteInsightResponse)
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 -> DeleteInsightResponse)
-> Either String Text -> Either String DeleteInsightResponse
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
"InsightArn")
      )

instance Prelude.Hashable DeleteInsight

instance Prelude.NFData DeleteInsight

instance Core.ToHeaders DeleteInsight where
  toHeaders :: DeleteInsight -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteInsight -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DeleteInsight where
  toPath :: DeleteInsight -> ByteString
toPath DeleteInsight' {Text
insightArn :: Text
$sel:insightArn:DeleteInsight' :: DeleteInsight -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/insights/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
insightArn]

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

-- | /See:/ 'newDeleteInsightResponse' smart constructor.
data DeleteInsightResponse = DeleteInsightResponse'
  { -- | The response's http status code.
    DeleteInsightResponse -> Int
httpStatus :: Prelude.Int,
    -- | The ARN of the insight that was deleted.
    DeleteInsightResponse -> Text
insightArn :: Prelude.Text
  }
  deriving (DeleteInsightResponse -> DeleteInsightResponse -> Bool
(DeleteInsightResponse -> DeleteInsightResponse -> Bool)
-> (DeleteInsightResponse -> DeleteInsightResponse -> Bool)
-> Eq DeleteInsightResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInsightResponse -> DeleteInsightResponse -> Bool
$c/= :: DeleteInsightResponse -> DeleteInsightResponse -> Bool
== :: DeleteInsightResponse -> DeleteInsightResponse -> Bool
$c== :: DeleteInsightResponse -> DeleteInsightResponse -> Bool
Prelude.Eq, ReadPrec [DeleteInsightResponse]
ReadPrec DeleteInsightResponse
Int -> ReadS DeleteInsightResponse
ReadS [DeleteInsightResponse]
(Int -> ReadS DeleteInsightResponse)
-> ReadS [DeleteInsightResponse]
-> ReadPrec DeleteInsightResponse
-> ReadPrec [DeleteInsightResponse]
-> Read DeleteInsightResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInsightResponse]
$creadListPrec :: ReadPrec [DeleteInsightResponse]
readPrec :: ReadPrec DeleteInsightResponse
$creadPrec :: ReadPrec DeleteInsightResponse
readList :: ReadS [DeleteInsightResponse]
$creadList :: ReadS [DeleteInsightResponse]
readsPrec :: Int -> ReadS DeleteInsightResponse
$creadsPrec :: Int -> ReadS DeleteInsightResponse
Prelude.Read, Int -> DeleteInsightResponse -> ShowS
[DeleteInsightResponse] -> ShowS
DeleteInsightResponse -> String
(Int -> DeleteInsightResponse -> ShowS)
-> (DeleteInsightResponse -> String)
-> ([DeleteInsightResponse] -> ShowS)
-> Show DeleteInsightResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInsightResponse] -> ShowS
$cshowList :: [DeleteInsightResponse] -> ShowS
show :: DeleteInsightResponse -> String
$cshow :: DeleteInsightResponse -> String
showsPrec :: Int -> DeleteInsightResponse -> ShowS
$cshowsPrec :: Int -> DeleteInsightResponse -> ShowS
Prelude.Show, (forall x. DeleteInsightResponse -> Rep DeleteInsightResponse x)
-> (forall x. Rep DeleteInsightResponse x -> DeleteInsightResponse)
-> Generic DeleteInsightResponse
forall x. Rep DeleteInsightResponse x -> DeleteInsightResponse
forall x. DeleteInsightResponse -> Rep DeleteInsightResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteInsightResponse x -> DeleteInsightResponse
$cfrom :: forall x. DeleteInsightResponse -> Rep DeleteInsightResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInsightResponse' 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', 'deleteInsightResponse_httpStatus' - The response's http status code.
--
-- 'insightArn', 'deleteInsightResponse_insightArn' - The ARN of the insight that was deleted.
newDeleteInsightResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'insightArn'
  Prelude.Text ->
  DeleteInsightResponse
newDeleteInsightResponse :: Int -> Text -> DeleteInsightResponse
newDeleteInsightResponse Int
pHttpStatus_ Text
pInsightArn_ =
  DeleteInsightResponse' :: Int -> Text -> DeleteInsightResponse
DeleteInsightResponse'
    { $sel:httpStatus:DeleteInsightResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:insightArn:DeleteInsightResponse' :: Text
insightArn = Text
pInsightArn_
    }

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

-- | The ARN of the insight that was deleted.
deleteInsightResponse_insightArn :: Lens.Lens' DeleteInsightResponse Prelude.Text
deleteInsightResponse_insightArn :: (Text -> f Text)
-> DeleteInsightResponse -> f DeleteInsightResponse
deleteInsightResponse_insightArn = (DeleteInsightResponse -> Text)
-> (DeleteInsightResponse -> Text -> DeleteInsightResponse)
-> Lens DeleteInsightResponse DeleteInsightResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInsightResponse' {Text
insightArn :: Text
$sel:insightArn:DeleteInsightResponse' :: DeleteInsightResponse -> Text
insightArn} -> Text
insightArn) (\s :: DeleteInsightResponse
s@DeleteInsightResponse' {} Text
a -> DeleteInsightResponse
s {$sel:insightArn:DeleteInsightResponse' :: Text
insightArn = Text
a} :: DeleteInsightResponse)

instance Prelude.NFData DeleteInsightResponse