{-# 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.UpdateMacieSession
-- 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)
--
-- Suspends or re-enables an Amazon Macie account, or updates the
-- configuration settings for a Macie account.
module Amazonka.MacieV2.UpdateMacieSession
  ( -- * Creating a Request
    UpdateMacieSession (..),
    newUpdateMacieSession,

    -- * Request Lenses
    updateMacieSession_status,
    updateMacieSession_findingPublishingFrequency,

    -- * Destructuring the Response
    UpdateMacieSessionResponse (..),
    newUpdateMacieSessionResponse,

    -- * Response Lenses
    updateMacieSessionResponse_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:/ 'newUpdateMacieSession' smart constructor.
data UpdateMacieSession = UpdateMacieSession'
  { -- | Specifies a new status for the account. Valid values are: ENABLED,
    -- resume all Amazon Macie activities for the account; and, PAUSED, suspend
    -- all Macie activities for the account.
    UpdateMacieSession -> Maybe MacieStatus
status :: Prelude.Maybe MacieStatus,
    -- | Specifies how often to publish updates to policy findings for the
    -- account. This includes publishing updates to Security Hub and Amazon
    -- EventBridge (formerly called Amazon CloudWatch Events).
    UpdateMacieSession -> Maybe FindingPublishingFrequency
findingPublishingFrequency :: Prelude.Maybe FindingPublishingFrequency
  }
  deriving (UpdateMacieSession -> UpdateMacieSession -> Bool
(UpdateMacieSession -> UpdateMacieSession -> Bool)
-> (UpdateMacieSession -> UpdateMacieSession -> Bool)
-> Eq UpdateMacieSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMacieSession -> UpdateMacieSession -> Bool
$c/= :: UpdateMacieSession -> UpdateMacieSession -> Bool
== :: UpdateMacieSession -> UpdateMacieSession -> Bool
$c== :: UpdateMacieSession -> UpdateMacieSession -> Bool
Prelude.Eq, ReadPrec [UpdateMacieSession]
ReadPrec UpdateMacieSession
Int -> ReadS UpdateMacieSession
ReadS [UpdateMacieSession]
(Int -> ReadS UpdateMacieSession)
-> ReadS [UpdateMacieSession]
-> ReadPrec UpdateMacieSession
-> ReadPrec [UpdateMacieSession]
-> Read UpdateMacieSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMacieSession]
$creadListPrec :: ReadPrec [UpdateMacieSession]
readPrec :: ReadPrec UpdateMacieSession
$creadPrec :: ReadPrec UpdateMacieSession
readList :: ReadS [UpdateMacieSession]
$creadList :: ReadS [UpdateMacieSession]
readsPrec :: Int -> ReadS UpdateMacieSession
$creadsPrec :: Int -> ReadS UpdateMacieSession
Prelude.Read, Int -> UpdateMacieSession -> ShowS
[UpdateMacieSession] -> ShowS
UpdateMacieSession -> String
(Int -> UpdateMacieSession -> ShowS)
-> (UpdateMacieSession -> String)
-> ([UpdateMacieSession] -> ShowS)
-> Show UpdateMacieSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMacieSession] -> ShowS
$cshowList :: [UpdateMacieSession] -> ShowS
show :: UpdateMacieSession -> String
$cshow :: UpdateMacieSession -> String
showsPrec :: Int -> UpdateMacieSession -> ShowS
$cshowsPrec :: Int -> UpdateMacieSession -> ShowS
Prelude.Show, (forall x. UpdateMacieSession -> Rep UpdateMacieSession x)
-> (forall x. Rep UpdateMacieSession x -> UpdateMacieSession)
-> Generic UpdateMacieSession
forall x. Rep UpdateMacieSession x -> UpdateMacieSession
forall x. UpdateMacieSession -> Rep UpdateMacieSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMacieSession x -> UpdateMacieSession
$cfrom :: forall x. UpdateMacieSession -> Rep UpdateMacieSession x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMacieSession' 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:
--
-- 'status', 'updateMacieSession_status' - Specifies a new status for the account. Valid values are: ENABLED,
-- resume all Amazon Macie activities for the account; and, PAUSED, suspend
-- all Macie activities for the account.
--
-- 'findingPublishingFrequency', 'updateMacieSession_findingPublishingFrequency' - Specifies how often to publish updates to policy findings for the
-- account. This includes publishing updates to Security Hub and Amazon
-- EventBridge (formerly called Amazon CloudWatch Events).
newUpdateMacieSession ::
  UpdateMacieSession
newUpdateMacieSession :: UpdateMacieSession
newUpdateMacieSession =
  UpdateMacieSession' :: Maybe MacieStatus
-> Maybe FindingPublishingFrequency -> UpdateMacieSession
UpdateMacieSession'
    { $sel:status:UpdateMacieSession' :: Maybe MacieStatus
status = Maybe MacieStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:findingPublishingFrequency:UpdateMacieSession' :: Maybe FindingPublishingFrequency
findingPublishingFrequency = Maybe FindingPublishingFrequency
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies a new status for the account. Valid values are: ENABLED,
-- resume all Amazon Macie activities for the account; and, PAUSED, suspend
-- all Macie activities for the account.
updateMacieSession_status :: Lens.Lens' UpdateMacieSession (Prelude.Maybe MacieStatus)
updateMacieSession_status :: (Maybe MacieStatus -> f (Maybe MacieStatus))
-> UpdateMacieSession -> f UpdateMacieSession
updateMacieSession_status = (UpdateMacieSession -> Maybe MacieStatus)
-> (UpdateMacieSession -> Maybe MacieStatus -> UpdateMacieSession)
-> Lens
     UpdateMacieSession
     UpdateMacieSession
     (Maybe MacieStatus)
     (Maybe MacieStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMacieSession' {Maybe MacieStatus
status :: Maybe MacieStatus
$sel:status:UpdateMacieSession' :: UpdateMacieSession -> Maybe MacieStatus
status} -> Maybe MacieStatus
status) (\s :: UpdateMacieSession
s@UpdateMacieSession' {} Maybe MacieStatus
a -> UpdateMacieSession
s {$sel:status:UpdateMacieSession' :: Maybe MacieStatus
status = Maybe MacieStatus
a} :: UpdateMacieSession)

-- | Specifies how often to publish updates to policy findings for the
-- account. This includes publishing updates to Security Hub and Amazon
-- EventBridge (formerly called Amazon CloudWatch Events).
updateMacieSession_findingPublishingFrequency :: Lens.Lens' UpdateMacieSession (Prelude.Maybe FindingPublishingFrequency)
updateMacieSession_findingPublishingFrequency :: (Maybe FindingPublishingFrequency
 -> f (Maybe FindingPublishingFrequency))
-> UpdateMacieSession -> f UpdateMacieSession
updateMacieSession_findingPublishingFrequency = (UpdateMacieSession -> Maybe FindingPublishingFrequency)
-> (UpdateMacieSession
    -> Maybe FindingPublishingFrequency -> UpdateMacieSession)
-> Lens
     UpdateMacieSession
     UpdateMacieSession
     (Maybe FindingPublishingFrequency)
     (Maybe FindingPublishingFrequency)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMacieSession' {Maybe FindingPublishingFrequency
findingPublishingFrequency :: Maybe FindingPublishingFrequency
$sel:findingPublishingFrequency:UpdateMacieSession' :: UpdateMacieSession -> Maybe FindingPublishingFrequency
findingPublishingFrequency} -> Maybe FindingPublishingFrequency
findingPublishingFrequency) (\s :: UpdateMacieSession
s@UpdateMacieSession' {} Maybe FindingPublishingFrequency
a -> UpdateMacieSession
s {$sel:findingPublishingFrequency:UpdateMacieSession' :: Maybe FindingPublishingFrequency
findingPublishingFrequency = Maybe FindingPublishingFrequency
a} :: UpdateMacieSession)

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

instance Prelude.NFData UpdateMacieSession

instance Core.ToHeaders UpdateMacieSession where
  toHeaders :: UpdateMacieSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateMacieSession -> 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 UpdateMacieSession where
  toJSON :: UpdateMacieSession -> Value
toJSON UpdateMacieSession' {Maybe FindingPublishingFrequency
Maybe MacieStatus
findingPublishingFrequency :: Maybe FindingPublishingFrequency
status :: Maybe MacieStatus
$sel:findingPublishingFrequency:UpdateMacieSession' :: UpdateMacieSession -> Maybe FindingPublishingFrequency
$sel:status:UpdateMacieSession' :: UpdateMacieSession -> Maybe MacieStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"status" Text -> MacieStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MacieStatus -> Pair) -> Maybe MacieStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MacieStatus
status,
            (Text
"findingPublishingFrequency" Text -> FindingPublishingFrequency -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FindingPublishingFrequency -> Pair)
-> Maybe FindingPublishingFrequency -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FindingPublishingFrequency
findingPublishingFrequency
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateMacieSessionResponse