{-# 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.AccessAnalyzer.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)
--
-- Updates the status for the specified findings.
module Amazonka.AccessAnalyzer.UpdateFindings
  ( -- * Creating a Request
    UpdateFindings (..),
    newUpdateFindings,

    -- * Request Lenses
    updateFindings_clientToken,
    updateFindings_ids,
    updateFindings_resourceArn,
    updateFindings_analyzerArn,
    updateFindings_status,

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

import Amazonka.AccessAnalyzer.Types
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

-- | Updates findings with the new values provided in the request.
--
-- /See:/ 'newUpdateFindings' smart constructor.
data UpdateFindings = UpdateFindings'
  { -- | A client token.
    UpdateFindings -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The IDs of the findings to update.
    UpdateFindings -> Maybe [Text]
ids :: Prelude.Maybe [Prelude.Text],
    -- | The ARN of the resource identified in the finding.
    UpdateFindings -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
    -- that generated the findings to update.
    UpdateFindings -> Text
analyzerArn :: Prelude.Text,
    -- | The state represents the action to take to update the finding Status.
    -- Use @ARCHIVE@ to change an Active finding to an Archived finding. Use
    -- @ACTIVE@ to change an Archived finding to an Active finding.
    UpdateFindings -> FindingStatusUpdate
status :: FindingStatusUpdate
  }
  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:
--
-- 'clientToken', 'updateFindings_clientToken' - A client token.
--
-- 'ids', 'updateFindings_ids' - The IDs of the findings to update.
--
-- 'resourceArn', 'updateFindings_resourceArn' - The ARN of the resource identified in the finding.
--
-- 'analyzerArn', 'updateFindings_analyzerArn' - The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- that generated the findings to update.
--
-- 'status', 'updateFindings_status' - The state represents the action to take to update the finding Status.
-- Use @ARCHIVE@ to change an Active finding to an Archived finding. Use
-- @ACTIVE@ to change an Archived finding to an Active finding.
newUpdateFindings ::
  -- | 'analyzerArn'
  Prelude.Text ->
  -- | 'status'
  FindingStatusUpdate ->
  UpdateFindings
newUpdateFindings :: Text -> FindingStatusUpdate -> UpdateFindings
newUpdateFindings Text
pAnalyzerArn_ FindingStatusUpdate
pStatus_ =
  UpdateFindings' :: Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Text
-> FindingStatusUpdate
-> UpdateFindings
UpdateFindings'
    { $sel:clientToken:UpdateFindings' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ids:UpdateFindings' :: Maybe [Text]
ids = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:UpdateFindings' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:analyzerArn:UpdateFindings' :: Text
analyzerArn = Text
pAnalyzerArn_,
      $sel:status:UpdateFindings' :: FindingStatusUpdate
status = FindingStatusUpdate
pStatus_
    }

-- | A client token.
updateFindings_clientToken :: Lens.Lens' UpdateFindings (Prelude.Maybe Prelude.Text)
updateFindings_clientToken :: (Maybe Text -> f (Maybe Text))
-> UpdateFindings -> f UpdateFindings
updateFindings_clientToken = (UpdateFindings -> Maybe Text)
-> (UpdateFindings -> Maybe Text -> UpdateFindings)
-> Lens UpdateFindings UpdateFindings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateFindings' :: UpdateFindings -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateFindings
s@UpdateFindings' {} Maybe Text
a -> UpdateFindings
s {$sel:clientToken:UpdateFindings' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateFindings)

-- | The IDs of the findings to update.
updateFindings_ids :: Lens.Lens' UpdateFindings (Prelude.Maybe [Prelude.Text])
updateFindings_ids :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateFindings -> f UpdateFindings
updateFindings_ids = (UpdateFindings -> Maybe [Text])
-> (UpdateFindings -> Maybe [Text] -> UpdateFindings)
-> Lens UpdateFindings UpdateFindings (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {Maybe [Text]
ids :: Maybe [Text]
$sel:ids:UpdateFindings' :: UpdateFindings -> Maybe [Text]
ids} -> Maybe [Text]
ids) (\s :: UpdateFindings
s@UpdateFindings' {} Maybe [Text]
a -> UpdateFindings
s {$sel:ids:UpdateFindings' :: Maybe [Text]
ids = Maybe [Text]
a} :: UpdateFindings) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateFindings -> f UpdateFindings)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateFindings
-> f UpdateFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the resource identified in the finding.
updateFindings_resourceArn :: Lens.Lens' UpdateFindings (Prelude.Maybe Prelude.Text)
updateFindings_resourceArn :: (Maybe Text -> f (Maybe Text))
-> UpdateFindings -> f UpdateFindings
updateFindings_resourceArn = (UpdateFindings -> Maybe Text)
-> (UpdateFindings -> Maybe Text -> UpdateFindings)
-> Lens UpdateFindings UpdateFindings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:UpdateFindings' :: UpdateFindings -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: UpdateFindings
s@UpdateFindings' {} Maybe Text
a -> UpdateFindings
s {$sel:resourceArn:UpdateFindings' :: Maybe Text
resourceArn = Maybe Text
a} :: UpdateFindings)

-- | The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- that generated the findings to update.
updateFindings_analyzerArn :: Lens.Lens' UpdateFindings Prelude.Text
updateFindings_analyzerArn :: (Text -> f Text) -> UpdateFindings -> f UpdateFindings
updateFindings_analyzerArn = (UpdateFindings -> Text)
-> (UpdateFindings -> Text -> UpdateFindings)
-> Lens UpdateFindings UpdateFindings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {Text
analyzerArn :: Text
$sel:analyzerArn:UpdateFindings' :: UpdateFindings -> Text
analyzerArn} -> Text
analyzerArn) (\s :: UpdateFindings
s@UpdateFindings' {} Text
a -> UpdateFindings
s {$sel:analyzerArn:UpdateFindings' :: Text
analyzerArn = Text
a} :: UpdateFindings)

-- | The state represents the action to take to update the finding Status.
-- Use @ARCHIVE@ to change an Active finding to an Archived finding. Use
-- @ACTIVE@ to change an Archived finding to an Active finding.
updateFindings_status :: Lens.Lens' UpdateFindings FindingStatusUpdate
updateFindings_status :: (FindingStatusUpdate -> f FindingStatusUpdate)
-> UpdateFindings -> f UpdateFindings
updateFindings_status = (UpdateFindings -> FindingStatusUpdate)
-> (UpdateFindings -> FindingStatusUpdate -> UpdateFindings)
-> Lens
     UpdateFindings
     UpdateFindings
     FindingStatusUpdate
     FindingStatusUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFindings' {FindingStatusUpdate
status :: FindingStatusUpdate
$sel:status:UpdateFindings' :: UpdateFindings -> FindingStatusUpdate
status} -> FindingStatusUpdate
status) (\s :: UpdateFindings
s@UpdateFindings' {} FindingStatusUpdate
a -> UpdateFindings
s {$sel:status:UpdateFindings' :: FindingStatusUpdate
status = FindingStatusUpdate
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.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFindings)))
response =
    AWSResponse UpdateFindings
-> Logger
-> Service
-> Proxy UpdateFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFindings)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateFindings
UpdateFindingsResponse
UpdateFindingsResponse'

instance Prelude.Hashable UpdateFindings

instance Prelude.NFData UpdateFindings

instance Core.ToHeaders UpdateFindings where
  toHeaders :: UpdateFindings -> [Header]
toHeaders =
    [Header] -> UpdateFindings -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateFindings where
  toJSON :: UpdateFindings -> Value
toJSON UpdateFindings' {Maybe [Text]
Maybe Text
Text
FindingStatusUpdate
status :: FindingStatusUpdate
analyzerArn :: Text
resourceArn :: Maybe Text
ids :: Maybe [Text]
clientToken :: Maybe Text
$sel:status:UpdateFindings' :: UpdateFindings -> FindingStatusUpdate
$sel:analyzerArn:UpdateFindings' :: UpdateFindings -> Text
$sel:resourceArn:UpdateFindings' :: UpdateFindings -> Maybe Text
$sel:ids:UpdateFindings' :: UpdateFindings -> Maybe [Text]
$sel:clientToken:UpdateFindings' :: UpdateFindings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Text
"ids" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ids,
            (Text
"resourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"analyzerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
analyzerArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> FindingStatusUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FindingStatusUpdate
status)
          ]
      )

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

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'
  {
  }
  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.
newUpdateFindingsResponse ::
  UpdateFindingsResponse
newUpdateFindingsResponse :: UpdateFindingsResponse
newUpdateFindingsResponse = UpdateFindingsResponse
UpdateFindingsResponse'

instance Prelude.NFData UpdateFindingsResponse