{-# 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-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)
--
-- 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 Amazonka.GuardDuty.Types
import qualified Amazonka.Lens as Lens
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
(ArchiveFindings -> ArchiveFindings -> Bool)
-> (ArchiveFindings -> ArchiveFindings -> Bool)
-> Eq ArchiveFindings
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]
(Int -> ReadS ArchiveFindings)
-> ReadS [ArchiveFindings]
-> ReadPrec ArchiveFindings
-> ReadPrec [ArchiveFindings]
-> Read 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
(Int -> ArchiveFindings -> ShowS)
-> (ArchiveFindings -> String)
-> ([ArchiveFindings] -> ShowS)
-> Show ArchiveFindings
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. ArchiveFindings -> Rep ArchiveFindings x)
-> (forall x. Rep ArchiveFindings x -> ArchiveFindings)
-> Generic ArchiveFindings
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' :: Text -> [Text] -> ArchiveFindings
ArchiveFindings'
    { $sel:detectorId:ArchiveFindings' :: Text
detectorId = Text
pDetectorId_,
      $sel:findingIds:ArchiveFindings' :: [Text]
findingIds = [Text]
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 :: (Text -> f Text) -> ArchiveFindings -> f ArchiveFindings
archiveFindings_detectorId = (ArchiveFindings -> Text)
-> (ArchiveFindings -> Text -> ArchiveFindings)
-> Lens ArchiveFindings ArchiveFindings Text Text
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 :: ([Text] -> f [Text]) -> ArchiveFindings -> f ArchiveFindings
archiveFindings_findingIds = (ArchiveFindings -> [Text])
-> (ArchiveFindings -> [Text] -> ArchiveFindings)
-> Lens ArchiveFindings ArchiveFindings [Text] [Text]
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) (([Text] -> f [Text]) -> ArchiveFindings -> f ArchiveFindings)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ArchiveFindings
-> f ArchiveFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
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 :: ArchiveFindings -> Request ArchiveFindings
request = Service -> ArchiveFindings -> Request ArchiveFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ArchiveFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ArchiveFindings)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ArchiveFindings))
-> Logger
-> Service
-> Proxy ArchiveFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ArchiveFindings)))
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 -> ArchiveFindingsResponse
ArchiveFindingsResponse'
            (Int -> ArchiveFindingsResponse)
-> Either String Int -> Either String ArchiveFindingsResponse
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 ArchiveFindings

instance Prelude.NFData ArchiveFindings

instance Core.ToHeaders ArchiveFindings where
  toHeaders :: ArchiveFindings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ArchiveFindings -> 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"findingIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
findingIds)]
      )

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

instance Core.ToQuery ArchiveFindings where
  toQuery :: ArchiveFindings -> QueryString
toQuery = QueryString -> ArchiveFindings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ArchiveFindingsResponse -> ArchiveFindingsResponse -> Bool)
-> (ArchiveFindingsResponse -> ArchiveFindingsResponse -> Bool)
-> Eq ArchiveFindingsResponse
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]
(Int -> ReadS ArchiveFindingsResponse)
-> ReadS [ArchiveFindingsResponse]
-> ReadPrec ArchiveFindingsResponse
-> ReadPrec [ArchiveFindingsResponse]
-> Read 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
(Int -> ArchiveFindingsResponse -> ShowS)
-> (ArchiveFindingsResponse -> String)
-> ([ArchiveFindingsResponse] -> ShowS)
-> Show ArchiveFindingsResponse
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.
 ArchiveFindingsResponse -> Rep ArchiveFindingsResponse x)
-> (forall x.
    Rep ArchiveFindingsResponse x -> ArchiveFindingsResponse)
-> Generic ArchiveFindingsResponse
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' :: Int -> ArchiveFindingsResponse
ArchiveFindingsResponse' {$sel:httpStatus:ArchiveFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
archiveFindingsResponse_httpStatus :: Lens.Lens' ArchiveFindingsResponse Prelude.Int
archiveFindingsResponse_httpStatus :: (Int -> f Int)
-> ArchiveFindingsResponse -> f ArchiveFindingsResponse
archiveFindingsResponse_httpStatus = (ArchiveFindingsResponse -> Int)
-> (ArchiveFindingsResponse -> Int -> ArchiveFindingsResponse)
-> Lens ArchiveFindingsResponse ArchiveFindingsResponse Int Int
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