{-# 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.ArchiveFindings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Archives GuardDuty findings that are specified by the list of finding
-- IDs.
--
-- Only the administrator account can archive findings. Member accounts
-- don\'t have permission to archive findings from their accounts.
module Amazonka.GuardDuty.ArchiveFindings
  ( -- * Creating a Request
    ArchiveFindings (..),
    newArchiveFindings,

    -- * Request Lenses
    archiveFindings_detectorId,
    archiveFindings_findingIds,

    -- * Destructuring the Response
    ArchiveFindingsResponse (..),
    newArchiveFindingsResponse,

    -- * Response Lenses
    archiveFindingsResponse_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:/ 'newArchiveFindings' smart constructor.
data ArchiveFindings = ArchiveFindings'
  { -- | The ID of the detector that specifies the GuardDuty service whose
    -- findings you want to archive.
    ArchiveFindings -> Text
detectorId :: Prelude.Text,
    -- | The IDs of the findings that you want to archive.
    ArchiveFindings -> [Text]
findingIds :: [Prelude.Text]
  }
  deriving (ArchiveFindings -> ArchiveFindings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArchiveFindings -> ArchiveFindings -> Bool
$c/= :: ArchiveFindings -> ArchiveFindings -> Bool
== :: ArchiveFindings -> ArchiveFindings -> Bool
$c== :: ArchiveFindings -> ArchiveFindings -> Bool
Prelude.Eq, ReadPrec [ArchiveFindings]
ReadPrec ArchiveFindings
Int -> ReadS ArchiveFindings
ReadS [ArchiveFindings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArchiveFindings]
$creadListPrec :: ReadPrec [ArchiveFindings]
readPrec :: ReadPrec ArchiveFindings
$creadPrec :: ReadPrec ArchiveFindings
readList :: ReadS [ArchiveFindings]
$creadList :: ReadS [ArchiveFindings]
readsPrec :: Int -> ReadS ArchiveFindings
$creadsPrec :: Int -> ReadS ArchiveFindings
Prelude.Read, Int -> ArchiveFindings -> ShowS
[ArchiveFindings] -> ShowS
ArchiveFindings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArchiveFindings] -> ShowS
$cshowList :: [ArchiveFindings] -> ShowS
show :: ArchiveFindings -> String
$cshow :: ArchiveFindings -> String
showsPrec :: Int -> ArchiveFindings -> ShowS
$cshowsPrec :: Int -> ArchiveFindings -> ShowS
Prelude.Show, forall x. Rep ArchiveFindings x -> ArchiveFindings
forall x. ArchiveFindings -> Rep ArchiveFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArchiveFindings x -> ArchiveFindings
$cfrom :: forall x. ArchiveFindings -> Rep ArchiveFindings x
Prelude.Generic)

-- |
-- Create a value of 'ArchiveFindings' 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', 'archiveFindings_detectorId' - The ID of the detector that specifies the GuardDuty service whose
-- findings you want to archive.
--
-- 'findingIds', 'archiveFindings_findingIds' - The IDs of the findings that you want to archive.
newArchiveFindings ::
  -- | 'detectorId'
  Prelude.Text ->
  ArchiveFindings
newArchiveFindings :: Text -> ArchiveFindings
newArchiveFindings Text
pDetectorId_ =
  ArchiveFindings'
    { $sel:detectorId:ArchiveFindings' :: Text
detectorId = Text
pDetectorId_,
      $sel:findingIds:ArchiveFindings' :: [Text]
findingIds = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the detector that specifies the GuardDuty service whose
-- findings you want to archive.
archiveFindings_detectorId :: Lens.Lens' ArchiveFindings Prelude.Text
archiveFindings_detectorId :: Lens' ArchiveFindings Text
archiveFindings_detectorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveFindings' {Text
detectorId :: Text
$sel:detectorId:ArchiveFindings' :: ArchiveFindings -> Text
detectorId} -> Text
detectorId) (\s :: ArchiveFindings
s@ArchiveFindings' {} Text
a -> ArchiveFindings
s {$sel:detectorId:ArchiveFindings' :: Text
detectorId = Text
a} :: ArchiveFindings)

-- | The IDs of the findings that you want to archive.
archiveFindings_findingIds :: Lens.Lens' ArchiveFindings [Prelude.Text]
archiveFindings_findingIds :: Lens' ArchiveFindings [Text]
archiveFindings_findingIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveFindings' {[Text]
findingIds :: [Text]
$sel:findingIds:ArchiveFindings' :: ArchiveFindings -> [Text]
findingIds} -> [Text]
findingIds) (\s :: ArchiveFindings
s@ArchiveFindings' {} [Text]
a -> ArchiveFindings
s {$sel:findingIds:ArchiveFindings' :: [Text]
findingIds = [Text]
a} :: ArchiveFindings) 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 ArchiveFindings where
  type
    AWSResponse ArchiveFindings =
      ArchiveFindingsResponse
  request :: (Service -> Service) -> ArchiveFindings -> Request ArchiveFindings
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 ArchiveFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ArchiveFindings)))
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 -> ArchiveFindingsResponse
ArchiveFindingsResponse'
            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 ArchiveFindings where
  hashWithSalt :: Int -> ArchiveFindings -> Int
hashWithSalt Int
_salt ArchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:ArchiveFindings' :: ArchiveFindings -> [Text]
$sel:detectorId:ArchiveFindings' :: ArchiveFindings -> 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 ArchiveFindings where
  rnf :: ArchiveFindings -> ()
rnf ArchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:ArchiveFindings' :: ArchiveFindings -> [Text]
$sel:detectorId:ArchiveFindings' :: ArchiveFindings -> 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 ArchiveFindings where
  toHeaders :: ArchiveFindings -> 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 ArchiveFindings where
  toJSON :: ArchiveFindings -> Value
toJSON ArchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:ArchiveFindings' :: ArchiveFindings -> [Text]
$sel:detectorId:ArchiveFindings' :: ArchiveFindings -> 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 ArchiveFindings where
  toPath :: ArchiveFindings -> ByteString
toPath ArchiveFindings' {[Text]
Text
findingIds :: [Text]
detectorId :: Text
$sel:findingIds:ArchiveFindings' :: ArchiveFindings -> [Text]
$sel:detectorId:ArchiveFindings' :: ArchiveFindings -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/detector/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
detectorId,
        ByteString
"/findings/archive"
      ]

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

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

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

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

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