{-# 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.MacieV2.PutFindingsPublicationConfiguration
-- 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 configuration settings for publishing findings to Security
-- Hub.
module Amazonka.MacieV2.PutFindingsPublicationConfiguration
  ( -- * Creating a Request
    PutFindingsPublicationConfiguration (..),
    newPutFindingsPublicationConfiguration,

    -- * Request Lenses
    putFindingsPublicationConfiguration_clientToken,
    putFindingsPublicationConfiguration_securityHubConfiguration,

    -- * Destructuring the Response
    PutFindingsPublicationConfigurationResponse (..),
    newPutFindingsPublicationConfigurationResponse,

    -- * Response Lenses
    putFindingsPublicationConfigurationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutFindingsPublicationConfiguration' smart constructor.
data PutFindingsPublicationConfiguration = PutFindingsPublicationConfiguration'
  { -- | A unique, case-sensitive token that you provide to ensure the
    -- idempotency of the request.
    PutFindingsPublicationConfiguration -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The configuration settings that determine which findings to publish to
    -- Security Hub.
    PutFindingsPublicationConfiguration
-> Maybe SecurityHubConfiguration
securityHubConfiguration :: Prelude.Maybe SecurityHubConfiguration
  }
  deriving (PutFindingsPublicationConfiguration
-> PutFindingsPublicationConfiguration -> Bool
(PutFindingsPublicationConfiguration
 -> PutFindingsPublicationConfiguration -> Bool)
-> (PutFindingsPublicationConfiguration
    -> PutFindingsPublicationConfiguration -> Bool)
-> Eq PutFindingsPublicationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutFindingsPublicationConfiguration
-> PutFindingsPublicationConfiguration -> Bool
$c/= :: PutFindingsPublicationConfiguration
-> PutFindingsPublicationConfiguration -> Bool
== :: PutFindingsPublicationConfiguration
-> PutFindingsPublicationConfiguration -> Bool
$c== :: PutFindingsPublicationConfiguration
-> PutFindingsPublicationConfiguration -> Bool
Prelude.Eq, ReadPrec [PutFindingsPublicationConfiguration]
ReadPrec PutFindingsPublicationConfiguration
Int -> ReadS PutFindingsPublicationConfiguration
ReadS [PutFindingsPublicationConfiguration]
(Int -> ReadS PutFindingsPublicationConfiguration)
-> ReadS [PutFindingsPublicationConfiguration]
-> ReadPrec PutFindingsPublicationConfiguration
-> ReadPrec [PutFindingsPublicationConfiguration]
-> Read PutFindingsPublicationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutFindingsPublicationConfiguration]
$creadListPrec :: ReadPrec [PutFindingsPublicationConfiguration]
readPrec :: ReadPrec PutFindingsPublicationConfiguration
$creadPrec :: ReadPrec PutFindingsPublicationConfiguration
readList :: ReadS [PutFindingsPublicationConfiguration]
$creadList :: ReadS [PutFindingsPublicationConfiguration]
readsPrec :: Int -> ReadS PutFindingsPublicationConfiguration
$creadsPrec :: Int -> ReadS PutFindingsPublicationConfiguration
Prelude.Read, Int -> PutFindingsPublicationConfiguration -> ShowS
[PutFindingsPublicationConfiguration] -> ShowS
PutFindingsPublicationConfiguration -> String
(Int -> PutFindingsPublicationConfiguration -> ShowS)
-> (PutFindingsPublicationConfiguration -> String)
-> ([PutFindingsPublicationConfiguration] -> ShowS)
-> Show PutFindingsPublicationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutFindingsPublicationConfiguration] -> ShowS
$cshowList :: [PutFindingsPublicationConfiguration] -> ShowS
show :: PutFindingsPublicationConfiguration -> String
$cshow :: PutFindingsPublicationConfiguration -> String
showsPrec :: Int -> PutFindingsPublicationConfiguration -> ShowS
$cshowsPrec :: Int -> PutFindingsPublicationConfiguration -> ShowS
Prelude.Show, (forall x.
 PutFindingsPublicationConfiguration
 -> Rep PutFindingsPublicationConfiguration x)
-> (forall x.
    Rep PutFindingsPublicationConfiguration x
    -> PutFindingsPublicationConfiguration)
-> Generic PutFindingsPublicationConfiguration
forall x.
Rep PutFindingsPublicationConfiguration x
-> PutFindingsPublicationConfiguration
forall x.
PutFindingsPublicationConfiguration
-> Rep PutFindingsPublicationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutFindingsPublicationConfiguration x
-> PutFindingsPublicationConfiguration
$cfrom :: forall x.
PutFindingsPublicationConfiguration
-> Rep PutFindingsPublicationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PutFindingsPublicationConfiguration' 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', 'putFindingsPublicationConfiguration_clientToken' - A unique, case-sensitive token that you provide to ensure the
-- idempotency of the request.
--
-- 'securityHubConfiguration', 'putFindingsPublicationConfiguration_securityHubConfiguration' - The configuration settings that determine which findings to publish to
-- Security Hub.
newPutFindingsPublicationConfiguration ::
  PutFindingsPublicationConfiguration
newPutFindingsPublicationConfiguration :: PutFindingsPublicationConfiguration
newPutFindingsPublicationConfiguration =
  PutFindingsPublicationConfiguration' :: Maybe Text
-> Maybe SecurityHubConfiguration
-> PutFindingsPublicationConfiguration
PutFindingsPublicationConfiguration'
    { $sel:clientToken:PutFindingsPublicationConfiguration' :: Maybe Text
clientToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:securityHubConfiguration:PutFindingsPublicationConfiguration' :: Maybe SecurityHubConfiguration
securityHubConfiguration =
        Maybe SecurityHubConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | A unique, case-sensitive token that you provide to ensure the
-- idempotency of the request.
putFindingsPublicationConfiguration_clientToken :: Lens.Lens' PutFindingsPublicationConfiguration (Prelude.Maybe Prelude.Text)
putFindingsPublicationConfiguration_clientToken :: (Maybe Text -> f (Maybe Text))
-> PutFindingsPublicationConfiguration
-> f PutFindingsPublicationConfiguration
putFindingsPublicationConfiguration_clientToken = (PutFindingsPublicationConfiguration -> Maybe Text)
-> (PutFindingsPublicationConfiguration
    -> Maybe Text -> PutFindingsPublicationConfiguration)
-> Lens
     PutFindingsPublicationConfiguration
     PutFindingsPublicationConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFindingsPublicationConfiguration' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:PutFindingsPublicationConfiguration' :: PutFindingsPublicationConfiguration -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: PutFindingsPublicationConfiguration
s@PutFindingsPublicationConfiguration' {} Maybe Text
a -> PutFindingsPublicationConfiguration
s {$sel:clientToken:PutFindingsPublicationConfiguration' :: Maybe Text
clientToken = Maybe Text
a} :: PutFindingsPublicationConfiguration)

-- | The configuration settings that determine which findings to publish to
-- Security Hub.
putFindingsPublicationConfiguration_securityHubConfiguration :: Lens.Lens' PutFindingsPublicationConfiguration (Prelude.Maybe SecurityHubConfiguration)
putFindingsPublicationConfiguration_securityHubConfiguration :: (Maybe SecurityHubConfiguration
 -> f (Maybe SecurityHubConfiguration))
-> PutFindingsPublicationConfiguration
-> f PutFindingsPublicationConfiguration
putFindingsPublicationConfiguration_securityHubConfiguration = (PutFindingsPublicationConfiguration
 -> Maybe SecurityHubConfiguration)
-> (PutFindingsPublicationConfiguration
    -> Maybe SecurityHubConfiguration
    -> PutFindingsPublicationConfiguration)
-> Lens
     PutFindingsPublicationConfiguration
     PutFindingsPublicationConfiguration
     (Maybe SecurityHubConfiguration)
     (Maybe SecurityHubConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFindingsPublicationConfiguration' {Maybe SecurityHubConfiguration
securityHubConfiguration :: Maybe SecurityHubConfiguration
$sel:securityHubConfiguration:PutFindingsPublicationConfiguration' :: PutFindingsPublicationConfiguration
-> Maybe SecurityHubConfiguration
securityHubConfiguration} -> Maybe SecurityHubConfiguration
securityHubConfiguration) (\s :: PutFindingsPublicationConfiguration
s@PutFindingsPublicationConfiguration' {} Maybe SecurityHubConfiguration
a -> PutFindingsPublicationConfiguration
s {$sel:securityHubConfiguration:PutFindingsPublicationConfiguration' :: Maybe SecurityHubConfiguration
securityHubConfiguration = Maybe SecurityHubConfiguration
a} :: PutFindingsPublicationConfiguration)

instance
  Core.AWSRequest
    PutFindingsPublicationConfiguration
  where
  type
    AWSResponse PutFindingsPublicationConfiguration =
      PutFindingsPublicationConfigurationResponse
  request :: PutFindingsPublicationConfiguration
-> Request PutFindingsPublicationConfiguration
request = Service
-> PutFindingsPublicationConfiguration
-> Request PutFindingsPublicationConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutFindingsPublicationConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutFindingsPublicationConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutFindingsPublicationConfiguration))
-> Logger
-> Service
-> Proxy PutFindingsPublicationConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutFindingsPublicationConfiguration)))
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 -> PutFindingsPublicationConfigurationResponse
PutFindingsPublicationConfigurationResponse'
            (Int -> PutFindingsPublicationConfigurationResponse)
-> Either String Int
-> Either String PutFindingsPublicationConfigurationResponse
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
    PutFindingsPublicationConfiguration

instance
  Prelude.NFData
    PutFindingsPublicationConfiguration

instance
  Core.ToHeaders
    PutFindingsPublicationConfiguration
  where
  toHeaders :: PutFindingsPublicationConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> PutFindingsPublicationConfiguration -> 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
    PutFindingsPublicationConfiguration
  where
  toJSON :: PutFindingsPublicationConfiguration -> Value
toJSON PutFindingsPublicationConfiguration' {Maybe Text
Maybe SecurityHubConfiguration
securityHubConfiguration :: Maybe SecurityHubConfiguration
clientToken :: Maybe Text
$sel:securityHubConfiguration:PutFindingsPublicationConfiguration' :: PutFindingsPublicationConfiguration
-> Maybe SecurityHubConfiguration
$sel:clientToken:PutFindingsPublicationConfiguration' :: PutFindingsPublicationConfiguration -> 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
"securityHubConfiguration" Text -> SecurityHubConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SecurityHubConfiguration -> Pair)
-> Maybe SecurityHubConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SecurityHubConfiguration
securityHubConfiguration
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    PutFindingsPublicationConfigurationResponse