{-# 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.UpdateFindings
-- 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)
--
-- @UpdateFindings@ is deprecated. Instead of @UpdateFindings@, use
-- @BatchUpdateFindings@.
--
-- Updates the @Note@ and @RecordState@ of the Security Hub-aggregated
-- findings that the filter attributes specify. Any member account that can
-- view the finding also sees the update to the finding.
module Amazonka.SecurityHub.UpdateFindings
  ( -- * Creating a Request
    UpdateFindings (..),
    newUpdateFindings,

    -- * Request Lenses
    updateFindings_recordState,
    updateFindings_note,
    updateFindings_filters,

    -- * Destructuring the Response
    UpdateFindingsResponse (..),
    newUpdateFindingsResponse,

    -- * Response Lenses
    updateFindingsResponse_httpStatus,
  )
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:/ 'newUpdateFindings' smart constructor.
data UpdateFindings = UpdateFindings'
  { -- | The updated record state for the finding.
    UpdateFindings -> Maybe RecordState
recordState :: Prelude.Maybe RecordState,
    -- | The updated note for the finding.
    UpdateFindings -> Maybe NoteUpdate
note :: Prelude.Maybe NoteUpdate,
    -- | A collection of attributes that specify which findings you want to
    -- update.
    UpdateFindings -> AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters
  }
  deriving (UpdateFindings -> UpdateFindings -> Bool
(UpdateFindings -> UpdateFindings -> Bool)
-> (UpdateFindings -> UpdateFindings -> Bool) -> Eq UpdateFindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFindings -> UpdateFindings -> Bool
$c/= :: UpdateFindings -> UpdateFindings -> Bool
== :: UpdateFindings -> UpdateFindings -> Bool
$c== :: UpdateFindings -> UpdateFindings -> Bool
Prelude.Eq, ReadPrec [UpdateFindings]
ReadPrec UpdateFindings
Int -> ReadS UpdateFindings
ReadS [UpdateFindings]
(Int -> ReadS UpdateFindings)
-> ReadS [UpdateFindings]
-> ReadPrec UpdateFindings
-> ReadPrec [UpdateFindings]
-> Read UpdateFindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateFindings]
$creadListPrec :: ReadPrec [UpdateFindings]
readPrec :: ReadPrec UpdateFindings
$creadPrec :: ReadPrec UpdateFindings
readList :: ReadS [UpdateFindings]
$creadList :: ReadS [UpdateFindings]
readsPrec :: Int -> ReadS UpdateFindings
$creadsPrec :: Int -> ReadS UpdateFindings
Prelude.Read, Int -> UpdateFindings -> ShowS
[UpdateFindings] -> ShowS
UpdateFindings -> String
(Int -> UpdateFindings -> ShowS)
-> (UpdateFindings -> String)
-> ([UpdateFindings] -> ShowS)
-> Show UpdateFindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFindings] -> ShowS
$cshowList :: [UpdateFindings] -> ShowS
show :: UpdateFindings -> String
$cshow :: UpdateFindings -> String
showsPrec :: Int -> UpdateFindings -> ShowS
$cshowsPrec :: Int -> UpdateFindings -> ShowS
Prelude.Show, (forall x. UpdateFindings -> Rep UpdateFindings x)
-> (forall x. Rep UpdateFindings x -> UpdateFindings)
-> Generic UpdateFindings
forall x. Rep UpdateFindings x -> UpdateFindings
forall x. UpdateFindings -> Rep UpdateFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFindings x -> UpdateFindings
$cfrom :: forall x. UpdateFindings -> Rep UpdateFindings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFindings' 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:
--
-- 'recordState', 'updateFindings_recordState' - The updated record state for the finding.
--
-- 'note', 'updateFindings_note' - The updated note for the finding.
--
-- 'filters', 'updateFindings_filters' - A collection of attributes that specify which findings you want to
-- update.
newUpdateFindings ::
  -- | 'filters'
  AwsSecurityFindingFilters ->
  UpdateFindings
newUpdateFindings :: AwsSecurityFindingFilters -> UpdateFindings
newUpdateFindings AwsSecurityFindingFilters
pFilters_ =
  UpdateFindings' :: Maybe RecordState
-> Maybe NoteUpdate -> AwsSecurityFindingFilters -> UpdateFindings
UpdateFindings'
    { $sel:recordState:UpdateFindings' :: Maybe RecordState
recordState = Maybe RecordState
forall a. Maybe a
Prelude.Nothing,
      $sel:note:UpdateFindings' :: Maybe NoteUpdate
note = Maybe NoteUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:UpdateFindings' :: AwsSecurityFindingFilters
filters = AwsSecurityFindingFilters
pFilters_
    }

-- | The updated record state for the finding.
updateFindings_recordState :: Lens.Lens' UpdateFindings (Prelude.Maybe RecordState)
updateFindings_recordState :: (Maybe RecordState -> f (Maybe RecordState))
-> UpdateFindings -> f UpdateFindings
updateFindings_recordState = (UpdateFindings -> Maybe RecordState)
-> (UpdateFindings -> Maybe RecordState -> UpdateFindings)
-> Lens
     UpdateFindings
     UpdateFindings
     (Maybe RecordState)
     (Maybe RecordState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {Maybe RecordState
recordState :: Maybe RecordState
$sel:recordState:UpdateFindings' :: UpdateFindings -> Maybe RecordState
recordState} -> Maybe RecordState
recordState) (\s :: UpdateFindings
s@UpdateFindings' {} Maybe RecordState
a -> UpdateFindings
s {$sel:recordState:UpdateFindings' :: Maybe RecordState
recordState = Maybe RecordState
a} :: UpdateFindings)

-- | The updated note for the finding.
updateFindings_note :: Lens.Lens' UpdateFindings (Prelude.Maybe NoteUpdate)
updateFindings_note :: (Maybe NoteUpdate -> f (Maybe NoteUpdate))
-> UpdateFindings -> f UpdateFindings
updateFindings_note = (UpdateFindings -> Maybe NoteUpdate)
-> (UpdateFindings -> Maybe NoteUpdate -> UpdateFindings)
-> Lens
     UpdateFindings UpdateFindings (Maybe NoteUpdate) (Maybe NoteUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {Maybe NoteUpdate
note :: Maybe NoteUpdate
$sel:note:UpdateFindings' :: UpdateFindings -> Maybe NoteUpdate
note} -> Maybe NoteUpdate
note) (\s :: UpdateFindings
s@UpdateFindings' {} Maybe NoteUpdate
a -> UpdateFindings
s {$sel:note:UpdateFindings' :: Maybe NoteUpdate
note = Maybe NoteUpdate
a} :: UpdateFindings)

-- | A collection of attributes that specify which findings you want to
-- update.
updateFindings_filters :: Lens.Lens' UpdateFindings AwsSecurityFindingFilters
updateFindings_filters :: (AwsSecurityFindingFilters -> f AwsSecurityFindingFilters)
-> UpdateFindings -> f UpdateFindings
updateFindings_filters = (UpdateFindings -> AwsSecurityFindingFilters)
-> (UpdateFindings -> AwsSecurityFindingFilters -> UpdateFindings)
-> Lens
     UpdateFindings
     UpdateFindings
     AwsSecurityFindingFilters
     AwsSecurityFindingFilters
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters
$sel:filters:UpdateFindings' :: UpdateFindings -> AwsSecurityFindingFilters
filters} -> AwsSecurityFindingFilters
filters) (\s :: UpdateFindings
s@UpdateFindings' {} AwsSecurityFindingFilters
a -> UpdateFindings
s {$sel:filters:UpdateFindings' :: AwsSecurityFindingFilters
filters = AwsSecurityFindingFilters
a} :: UpdateFindings)

instance Core.AWSRequest UpdateFindings where
  type
    AWSResponse UpdateFindings =
      UpdateFindingsResponse
  request :: UpdateFindings -> Request UpdateFindings
request = Service -> UpdateFindings -> Request UpdateFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFindings)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateFindings))
-> Logger
-> Service
-> Proxy UpdateFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFindings)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateFindingsResponse
UpdateFindingsResponse'
            (Int -> UpdateFindingsResponse)
-> Either String Int -> Either String UpdateFindingsResponse
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))
      )

instance Prelude.Hashable UpdateFindings

instance Prelude.NFData UpdateFindings

instance Core.ToHeaders UpdateFindings where
  toHeaders :: UpdateFindings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateFindings -> 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.ToJSON UpdateFindings where
  toJSON :: UpdateFindings -> Value
toJSON UpdateFindings' {Maybe NoteUpdate
Maybe RecordState
AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters
note :: Maybe NoteUpdate
recordState :: Maybe RecordState
$sel:filters:UpdateFindings' :: UpdateFindings -> AwsSecurityFindingFilters
$sel:note:UpdateFindings' :: UpdateFindings -> Maybe NoteUpdate
$sel:recordState:UpdateFindings' :: UpdateFindings -> Maybe RecordState
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RecordState" Text -> RecordState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RecordState -> Pair) -> Maybe RecordState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RecordState
recordState,
            (Text
"Note" Text -> NoteUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NoteUpdate -> Pair) -> Maybe NoteUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NoteUpdate
note,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Filters" Text -> AwsSecurityFindingFilters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AwsSecurityFindingFilters
filters)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateFindingsResponse' 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', 'updateFindingsResponse_httpStatus' - The response's http status code.
newUpdateFindingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateFindingsResponse
newUpdateFindingsResponse :: Int -> UpdateFindingsResponse
newUpdateFindingsResponse Int
pHttpStatus_ =
  UpdateFindingsResponse' :: Int -> UpdateFindingsResponse
UpdateFindingsResponse' {$sel:httpStatus:UpdateFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData UpdateFindingsResponse