{-# 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.GuardDuty.UnarchiveFindings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Unarchives GuardDuty findings specified by the @findingIds@.
module Amazonka.GuardDuty.UnarchiveFindings
  ( -- * Creating a Request
    UnarchiveFindings (..),
    newUnarchiveFindings,

    -- * Request Lenses
    unarchiveFindings_detectorId,
    unarchiveFindings_findingIds,

    -- * Destructuring the Response
    UnarchiveFindingsResponse (..),
    newUnarchiveFindingsResponse,

    -- * Response Lenses
    unarchiveFindingsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUnarchiveFindings' smart constructor.
data UnarchiveFindings = UnarchiveFindings'
  { -- | The ID of the detector associated with the findings to unarchive.
    UnarchiveFindings -> Text
detectorId :: Prelude.Text,
    -- | The IDs of the findings to unarchive.
    UnarchiveFindings -> [Text]
findingIds :: [Prelude.Text]
  }
  deriving (UnarchiveFindings -> UnarchiveFindings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnarchiveFindings -> UnarchiveFindings -> Bool
$c/= :: UnarchiveFindings -> UnarchiveFindings -> Bool
== :: UnarchiveFindings -> UnarchiveFindings -> Bool
$c== :: UnarchiveFindings -> UnarchiveFindings -> Bool
Prelude.Eq, ReadPrec [UnarchiveFindings]
ReadPrec UnarchiveFindings
Int -> ReadS UnarchiveFindings
ReadS [UnarchiveFindings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnarchiveFindings]
$creadListPrec :: ReadPrec [UnarchiveFindings]
readPrec :: ReadPrec UnarchiveFindings
$creadPrec :: ReadPrec UnarchiveFindings
readList :: ReadS [UnarchiveFindings]
$creadList :: ReadS [UnarchiveFindings]
readsPrec :: Int -> ReadS UnarchiveFindings
$creadsPrec :: Int -> ReadS UnarchiveFindings
Prelude.Read, Int -> UnarchiveFindings -> ShowS
[UnarchiveFindings] -> ShowS
UnarchiveFindings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnarchiveFindings] -> ShowS
$cshowList :: [UnarchiveFindings] -> ShowS
show :: UnarchiveFindings -> String
$cshow :: UnarchiveFindings -> String
showsPrec :: Int -> UnarchiveFindings -> ShowS
$cshowsPrec :: Int -> UnarchiveFindings -> ShowS
Prelude.Show, forall x. Rep UnarchiveFindings x -> UnarchiveFindings
forall x. UnarchiveFindings -> Rep UnarchiveFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnarchiveFindings x -> UnarchiveFindings
$cfrom :: forall x. UnarchiveFindings -> Rep UnarchiveFindings x
Prelude.Generic)

-- |
-- Create a value of 'UnarchiveFindings' 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:
--
-- 'detectorId', 'unarchiveFindings_detectorId' - The ID of the detector associated with the findings to unarchive.
--
-- 'findingIds', 'unarchiveFindings_findingIds' - The IDs of the findings to unarchive.
newUnarchiveFindings ::
  -- | 'detectorId'
  Prelude.Text ->
  UnarchiveFindings
newUnarchiveFindings :: Text -> UnarchiveFindings
newUnarchiveFindings Text
pDetectorId_ =
  UnarchiveFindings'
    { $sel:detectorId:UnarchiveFindings' :: Text
detectorId = Text
pDetectorId_,
      $sel:findingIds:UnarchiveFindings' :: [Text]
findingIds = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the detector associated with the findings to unarchive.
unarchiveFindings_detectorId :: Lens.Lens' UnarchiveFindings Prelude.Text
unarchiveFindings_detectorId :: Lens' UnarchiveFindings Text
unarchiveFindings_detectorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnarchiveFindings' {Text
detectorId :: Text
$sel:detectorId:UnarchiveFindings' :: UnarchiveFindings -> Text
detectorId} -> Text
detectorId) (\s :: UnarchiveFindings
s@UnarchiveFindings' {} Text
a -> UnarchiveFindings
s {$sel:detectorId:UnarchiveFindings' :: Text
detectorId = Text
a} :: UnarchiveFindings)

-- | The IDs of the findings to unarchive.
unarchiveFindings_findingIds :: Lens.Lens' UnarchiveFindings [Prelude.Text]
unarchiveFindings_findingIds :: Lens' UnarchiveFindings [Text]
unarchiveFindings_findingIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnarchiveFindings' {[Text]
findingIds :: [Text]
$sel:findingIds:UnarchiveFindings' :: UnarchiveFindings -> [Text]
findingIds} -> [Text]
findingIds) (\s :: UnarchiveFindings
s@UnarchiveFindings' {} [Text]
a -> UnarchiveFindings
s {$sel:findingIds:UnarchiveFindings' :: [Text]
findingIds = [Text]
a} :: UnarchiveFindings) 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 UnarchiveFindings where
  type
    AWSResponse UnarchiveFindings =
      UnarchiveFindingsResponse
  request :: (Service -> Service)
-> UnarchiveFindings -> Request UnarchiveFindings
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 UnarchiveFindings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnarchiveFindings)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UnarchiveFindingsResponse
UnarchiveFindingsResponse'
            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))
      )

instance Prelude.Hashable UnarchiveFindings where
  hashWithSalt :: Int -> UnarchiveFindings -> Int
hashWithSalt Int
_salt UnarchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:UnarchiveFindings' :: UnarchiveFindings -> [Text]
$sel:detectorId:UnarchiveFindings' :: UnarchiveFindings -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
detectorId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
findingIds

instance Prelude.NFData UnarchiveFindings where
  rnf :: UnarchiveFindings -> ()
rnf UnarchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:UnarchiveFindings' :: UnarchiveFindings -> [Text]
$sel:detectorId:UnarchiveFindings' :: UnarchiveFindings -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
detectorId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
findingIds

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

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

instance Data.ToPath UnarchiveFindings where
  toPath :: UnarchiveFindings -> ByteString
toPath UnarchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:UnarchiveFindings' :: UnarchiveFindings -> [Text]
$sel:detectorId:UnarchiveFindings' :: UnarchiveFindings -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/detector/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
detectorId,
        ByteString
"/findings/unarchive"
      ]

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

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

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

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

instance Prelude.NFData UnarchiveFindingsResponse where
  rnf :: UnarchiveFindingsResponse -> ()
rnf UnarchiveFindingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UnarchiveFindingsResponse' :: UnarchiveFindingsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus