{-# 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.RemoveAttributesFromFindings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes entire attributes (key and value pairs) from the findings that
-- are specified by the ARNs of the findings where an attribute with the
-- specified key exists.
module Amazonka.Inspector.RemoveAttributesFromFindings
  ( -- * Creating a Request
    RemoveAttributesFromFindings (..),
    newRemoveAttributesFromFindings,

    -- * Request Lenses
    removeAttributesFromFindings_findingArns,
    removeAttributesFromFindings_attributeKeys,

    -- * Destructuring the Response
    RemoveAttributesFromFindingsResponse (..),
    newRemoveAttributesFromFindingsResponse,

    -- * Response Lenses
    removeAttributesFromFindingsResponse_httpStatus,
    removeAttributesFromFindingsResponse_failedItems,
  )
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:/ 'newRemoveAttributesFromFindings' smart constructor.
data RemoveAttributesFromFindings = RemoveAttributesFromFindings'
  { -- | The ARNs that specify the findings that you want to remove attributes
    -- from.
    RemoveAttributesFromFindings -> NonEmpty Text
findingArns :: Prelude.NonEmpty Prelude.Text,
    -- | The array of attribute keys that you want to remove from specified
    -- findings.
    RemoveAttributesFromFindings -> [Text]
attributeKeys :: [Prelude.Text]
  }
  deriving (RemoveAttributesFromFindings
-> RemoveAttributesFromFindings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveAttributesFromFindings
-> RemoveAttributesFromFindings -> Bool
$c/= :: RemoveAttributesFromFindings
-> RemoveAttributesFromFindings -> Bool
== :: RemoveAttributesFromFindings
-> RemoveAttributesFromFindings -> Bool
$c== :: RemoveAttributesFromFindings
-> RemoveAttributesFromFindings -> Bool
Prelude.Eq, ReadPrec [RemoveAttributesFromFindings]
ReadPrec RemoveAttributesFromFindings
Int -> ReadS RemoveAttributesFromFindings
ReadS [RemoveAttributesFromFindings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveAttributesFromFindings]
$creadListPrec :: ReadPrec [RemoveAttributesFromFindings]
readPrec :: ReadPrec RemoveAttributesFromFindings
$creadPrec :: ReadPrec RemoveAttributesFromFindings
readList :: ReadS [RemoveAttributesFromFindings]
$creadList :: ReadS [RemoveAttributesFromFindings]
readsPrec :: Int -> ReadS RemoveAttributesFromFindings
$creadsPrec :: Int -> ReadS RemoveAttributesFromFindings
Prelude.Read, Int -> RemoveAttributesFromFindings -> ShowS
[RemoveAttributesFromFindings] -> ShowS
RemoveAttributesFromFindings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveAttributesFromFindings] -> ShowS
$cshowList :: [RemoveAttributesFromFindings] -> ShowS
show :: RemoveAttributesFromFindings -> String
$cshow :: RemoveAttributesFromFindings -> String
showsPrec :: Int -> RemoveAttributesFromFindings -> ShowS
$cshowsPrec :: Int -> RemoveAttributesFromFindings -> ShowS
Prelude.Show, forall x.
Rep RemoveAttributesFromFindings x -> RemoveAttributesFromFindings
forall x.
RemoveAttributesFromFindings -> Rep RemoveAttributesFromFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveAttributesFromFindings x -> RemoveAttributesFromFindings
$cfrom :: forall x.
RemoveAttributesFromFindings -> Rep RemoveAttributesFromFindings x
Prelude.Generic)

-- |
-- Create a value of 'RemoveAttributesFromFindings' 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:
--
-- 'findingArns', 'removeAttributesFromFindings_findingArns' - The ARNs that specify the findings that you want to remove attributes
-- from.
--
-- 'attributeKeys', 'removeAttributesFromFindings_attributeKeys' - The array of attribute keys that you want to remove from specified
-- findings.
newRemoveAttributesFromFindings ::
  -- | 'findingArns'
  Prelude.NonEmpty Prelude.Text ->
  RemoveAttributesFromFindings
newRemoveAttributesFromFindings :: NonEmpty Text -> RemoveAttributesFromFindings
newRemoveAttributesFromFindings NonEmpty Text
pFindingArns_ =
  RemoveAttributesFromFindings'
    { $sel:findingArns:RemoveAttributesFromFindings' :: NonEmpty Text
findingArns =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pFindingArns_,
      $sel:attributeKeys:RemoveAttributesFromFindings' :: [Text]
attributeKeys = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ARNs that specify the findings that you want to remove attributes
-- from.
removeAttributesFromFindings_findingArns :: Lens.Lens' RemoveAttributesFromFindings (Prelude.NonEmpty Prelude.Text)
removeAttributesFromFindings_findingArns :: Lens' RemoveAttributesFromFindings (NonEmpty Text)
removeAttributesFromFindings_findingArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAttributesFromFindings' {NonEmpty Text
findingArns :: NonEmpty Text
$sel:findingArns:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> NonEmpty Text
findingArns} -> NonEmpty Text
findingArns) (\s :: RemoveAttributesFromFindings
s@RemoveAttributesFromFindings' {} NonEmpty Text
a -> RemoveAttributesFromFindings
s {$sel:findingArns:RemoveAttributesFromFindings' :: NonEmpty Text
findingArns = NonEmpty Text
a} :: RemoveAttributesFromFindings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The array of attribute keys that you want to remove from specified
-- findings.
removeAttributesFromFindings_attributeKeys :: Lens.Lens' RemoveAttributesFromFindings [Prelude.Text]
removeAttributesFromFindings_attributeKeys :: Lens' RemoveAttributesFromFindings [Text]
removeAttributesFromFindings_attributeKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAttributesFromFindings' {[Text]
attributeKeys :: [Text]
$sel:attributeKeys:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> [Text]
attributeKeys} -> [Text]
attributeKeys) (\s :: RemoveAttributesFromFindings
s@RemoveAttributesFromFindings' {} [Text]
a -> RemoveAttributesFromFindings
s {$sel:attributeKeys:RemoveAttributesFromFindings' :: [Text]
attributeKeys = [Text]
a} :: RemoveAttributesFromFindings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest RemoveAttributesFromFindings where
  type
    AWSResponse RemoveAttributesFromFindings =
      RemoveAttributesFromFindingsResponse
  request :: (Service -> Service)
-> RemoveAttributesFromFindings
-> Request RemoveAttributesFromFindings
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 RemoveAttributesFromFindings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveAttributesFromFindings)))
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
-> HashMap Text FailedItemDetails
-> RemoveAttributesFromFindingsResponse
RemoveAttributesFromFindingsResponse'
            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 (Maybe a)
Data..?> Key
"failedItems" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    RemoveAttributesFromFindings
  where
  hashWithSalt :: Int -> RemoveAttributesFromFindings -> Int
hashWithSalt Int
_salt RemoveAttributesFromFindings' {[Text]
NonEmpty Text
attributeKeys :: [Text]
findingArns :: NonEmpty Text
$sel:attributeKeys:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> [Text]
$sel:findingArns:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> NonEmpty Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
findingArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
attributeKeys

instance Prelude.NFData RemoveAttributesFromFindings where
  rnf :: RemoveAttributesFromFindings -> ()
rnf RemoveAttributesFromFindings' {[Text]
NonEmpty Text
attributeKeys :: [Text]
findingArns :: NonEmpty Text
$sel:attributeKeys:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> [Text]
$sel:findingArns:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> NonEmpty Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
findingArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
attributeKeys

instance Data.ToHeaders RemoveAttributesFromFindings where
  toHeaders :: RemoveAttributesFromFindings -> 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.RemoveAttributesFromFindings" ::
                          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 RemoveAttributesFromFindings where
  toJSON :: RemoveAttributesFromFindings -> Value
toJSON RemoveAttributesFromFindings' {[Text]
NonEmpty Text
attributeKeys :: [Text]
findingArns :: NonEmpty Text
$sel:attributeKeys:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> [Text]
$sel:findingArns:RemoveAttributesFromFindings' :: RemoveAttributesFromFindings -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"findingArns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
findingArns),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"attributeKeys" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
attributeKeys)
          ]
      )

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

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

-- | /See:/ 'newRemoveAttributesFromFindingsResponse' smart constructor.
data RemoveAttributesFromFindingsResponse = RemoveAttributesFromFindingsResponse'
  { -- | The response's http status code.
    RemoveAttributesFromFindingsResponse -> Int
httpStatus :: Prelude.Int,
    -- | Attributes details that cannot be described. An error code is provided
    -- for each failed item.
    RemoveAttributesFromFindingsResponse
-> HashMap Text FailedItemDetails
failedItems :: Prelude.HashMap Prelude.Text FailedItemDetails
  }
  deriving (RemoveAttributesFromFindingsResponse
-> RemoveAttributesFromFindingsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveAttributesFromFindingsResponse
-> RemoveAttributesFromFindingsResponse -> Bool
$c/= :: RemoveAttributesFromFindingsResponse
-> RemoveAttributesFromFindingsResponse -> Bool
== :: RemoveAttributesFromFindingsResponse
-> RemoveAttributesFromFindingsResponse -> Bool
$c== :: RemoveAttributesFromFindingsResponse
-> RemoveAttributesFromFindingsResponse -> Bool
Prelude.Eq, ReadPrec [RemoveAttributesFromFindingsResponse]
ReadPrec RemoveAttributesFromFindingsResponse
Int -> ReadS RemoveAttributesFromFindingsResponse
ReadS [RemoveAttributesFromFindingsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveAttributesFromFindingsResponse]
$creadListPrec :: ReadPrec [RemoveAttributesFromFindingsResponse]
readPrec :: ReadPrec RemoveAttributesFromFindingsResponse
$creadPrec :: ReadPrec RemoveAttributesFromFindingsResponse
readList :: ReadS [RemoveAttributesFromFindingsResponse]
$creadList :: ReadS [RemoveAttributesFromFindingsResponse]
readsPrec :: Int -> ReadS RemoveAttributesFromFindingsResponse
$creadsPrec :: Int -> ReadS RemoveAttributesFromFindingsResponse
Prelude.Read, Int -> RemoveAttributesFromFindingsResponse -> ShowS
[RemoveAttributesFromFindingsResponse] -> ShowS
RemoveAttributesFromFindingsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveAttributesFromFindingsResponse] -> ShowS
$cshowList :: [RemoveAttributesFromFindingsResponse] -> ShowS
show :: RemoveAttributesFromFindingsResponse -> String
$cshow :: RemoveAttributesFromFindingsResponse -> String
showsPrec :: Int -> RemoveAttributesFromFindingsResponse -> ShowS
$cshowsPrec :: Int -> RemoveAttributesFromFindingsResponse -> ShowS
Prelude.Show, forall x.
Rep RemoveAttributesFromFindingsResponse x
-> RemoveAttributesFromFindingsResponse
forall x.
RemoveAttributesFromFindingsResponse
-> Rep RemoveAttributesFromFindingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveAttributesFromFindingsResponse x
-> RemoveAttributesFromFindingsResponse
$cfrom :: forall x.
RemoveAttributesFromFindingsResponse
-> Rep RemoveAttributesFromFindingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'RemoveAttributesFromFindingsResponse' 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', 'removeAttributesFromFindingsResponse_httpStatus' - The response's http status code.
--
-- 'failedItems', 'removeAttributesFromFindingsResponse_failedItems' - Attributes details that cannot be described. An error code is provided
-- for each failed item.
newRemoveAttributesFromFindingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RemoveAttributesFromFindingsResponse
newRemoveAttributesFromFindingsResponse :: Int -> RemoveAttributesFromFindingsResponse
newRemoveAttributesFromFindingsResponse Int
pHttpStatus_ =
  RemoveAttributesFromFindingsResponse'
    { $sel:httpStatus:RemoveAttributesFromFindingsResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:failedItems:RemoveAttributesFromFindingsResponse' :: HashMap Text FailedItemDetails
failedItems = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | Attributes details that cannot be described. An error code is provided
-- for each failed item.
removeAttributesFromFindingsResponse_failedItems :: Lens.Lens' RemoveAttributesFromFindingsResponse (Prelude.HashMap Prelude.Text FailedItemDetails)
removeAttributesFromFindingsResponse_failedItems :: Lens'
  RemoveAttributesFromFindingsResponse
  (HashMap Text FailedItemDetails)
removeAttributesFromFindingsResponse_failedItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAttributesFromFindingsResponse' {HashMap Text FailedItemDetails
failedItems :: HashMap Text FailedItemDetails
$sel:failedItems:RemoveAttributesFromFindingsResponse' :: RemoveAttributesFromFindingsResponse
-> HashMap Text FailedItemDetails
failedItems} -> HashMap Text FailedItemDetails
failedItems) (\s :: RemoveAttributesFromFindingsResponse
s@RemoveAttributesFromFindingsResponse' {} HashMap Text FailedItemDetails
a -> RemoveAttributesFromFindingsResponse
s {$sel:failedItems:RemoveAttributesFromFindingsResponse' :: HashMap Text FailedItemDetails
failedItems = HashMap Text FailedItemDetails
a} :: RemoveAttributesFromFindingsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    RemoveAttributesFromFindingsResponse
  where
  rnf :: RemoveAttributesFromFindingsResponse -> ()
rnf RemoveAttributesFromFindingsResponse' {Int
HashMap Text FailedItemDetails
failedItems :: HashMap Text FailedItemDetails
httpStatus :: Int
$sel:failedItems:RemoveAttributesFromFindingsResponse' :: RemoveAttributesFromFindingsResponse
-> HashMap Text FailedItemDetails
$sel:httpStatus:RemoveAttributesFromFindingsResponse' :: RemoveAttributesFromFindingsResponse -> 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 HashMap Text FailedItemDetails
failedItems