{-# 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.EnableMacie
-- 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)
--
-- Enables Amazon Macie and specifies the configuration settings for a
-- Macie account.
module Amazonka.MacieV2.EnableMacie
  ( -- * Creating a Request
    EnableMacie (..),
    newEnableMacie,

    -- * Request Lenses
    enableMacie_status,
    enableMacie_clientToken,
    enableMacie_findingPublishingFrequency,

    -- * Destructuring the Response
    EnableMacieResponse (..),
    newEnableMacieResponse,

    -- * Response Lenses
    enableMacieResponse_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:/ 'newEnableMacie' smart constructor.
data EnableMacie = EnableMacie'
  { -- | Specifies the new status for the account. To enable Amazon Macie and
    -- start all Macie activities for the account, set this value to ENABLED.
    EnableMacie -> Maybe MacieStatus
status :: Prelude.Maybe MacieStatus,
    -- | A unique, case-sensitive token that you provide to ensure the
    -- idempotency of the request.
    EnableMacie -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | 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).
    EnableMacie -> Maybe FindingPublishingFrequency
findingPublishingFrequency :: Prelude.Maybe FindingPublishingFrequency
  }
  deriving (EnableMacie -> EnableMacie -> Bool
(EnableMacie -> EnableMacie -> Bool)
-> (EnableMacie -> EnableMacie -> Bool) -> Eq EnableMacie
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableMacie -> EnableMacie -> Bool
$c/= :: EnableMacie -> EnableMacie -> Bool
== :: EnableMacie -> EnableMacie -> Bool
$c== :: EnableMacie -> EnableMacie -> Bool
Prelude.Eq, ReadPrec [EnableMacie]
ReadPrec EnableMacie
Int -> ReadS EnableMacie
ReadS [EnableMacie]
(Int -> ReadS EnableMacie)
-> ReadS [EnableMacie]
-> ReadPrec EnableMacie
-> ReadPrec [EnableMacie]
-> Read EnableMacie
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableMacie]
$creadListPrec :: ReadPrec [EnableMacie]
readPrec :: ReadPrec EnableMacie
$creadPrec :: ReadPrec EnableMacie
readList :: ReadS [EnableMacie]
$creadList :: ReadS [EnableMacie]
readsPrec :: Int -> ReadS EnableMacie
$creadsPrec :: Int -> ReadS EnableMacie
Prelude.Read, Int -> EnableMacie -> ShowS
[EnableMacie] -> ShowS
EnableMacie -> String
(Int -> EnableMacie -> ShowS)
-> (EnableMacie -> String)
-> ([EnableMacie] -> ShowS)
-> Show EnableMacie
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableMacie] -> ShowS
$cshowList :: [EnableMacie] -> ShowS
show :: EnableMacie -> String
$cshow :: EnableMacie -> String
showsPrec :: Int -> EnableMacie -> ShowS
$cshowsPrec :: Int -> EnableMacie -> ShowS
Prelude.Show, (forall x. EnableMacie -> Rep EnableMacie x)
-> (forall x. Rep EnableMacie x -> EnableMacie)
-> Generic EnableMacie
forall x. Rep EnableMacie x -> EnableMacie
forall x. EnableMacie -> Rep EnableMacie x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableMacie x -> EnableMacie
$cfrom :: forall x. EnableMacie -> Rep EnableMacie x
Prelude.Generic)

-- |
-- Create a value of 'EnableMacie' 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', 'enableMacie_status' - Specifies the new status for the account. To enable Amazon Macie and
-- start all Macie activities for the account, set this value to ENABLED.
--
-- 'clientToken', 'enableMacie_clientToken' - A unique, case-sensitive token that you provide to ensure the
-- idempotency of the request.
--
-- 'findingPublishingFrequency', 'enableMacie_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).
newEnableMacie ::
  EnableMacie
newEnableMacie :: EnableMacie
newEnableMacie =
  EnableMacie' :: Maybe MacieStatus
-> Maybe Text -> Maybe FindingPublishingFrequency -> EnableMacie
EnableMacie'
    { $sel:status:EnableMacie' :: Maybe MacieStatus
status = Maybe MacieStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:clientToken:EnableMacie' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:findingPublishingFrequency:EnableMacie' :: Maybe FindingPublishingFrequency
findingPublishingFrequency = Maybe FindingPublishingFrequency
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the new status for the account. To enable Amazon Macie and
-- start all Macie activities for the account, set this value to ENABLED.
enableMacie_status :: Lens.Lens' EnableMacie (Prelude.Maybe MacieStatus)
enableMacie_status :: (Maybe MacieStatus -> f (Maybe MacieStatus))
-> EnableMacie -> f EnableMacie
enableMacie_status = (EnableMacie -> Maybe MacieStatus)
-> (EnableMacie -> Maybe MacieStatus -> EnableMacie)
-> Lens
     EnableMacie EnableMacie (Maybe MacieStatus) (Maybe MacieStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableMacie' {Maybe MacieStatus
status :: Maybe MacieStatus
$sel:status:EnableMacie' :: EnableMacie -> Maybe MacieStatus
status} -> Maybe MacieStatus
status) (\s :: EnableMacie
s@EnableMacie' {} Maybe MacieStatus
a -> EnableMacie
s {$sel:status:EnableMacie' :: Maybe MacieStatus
status = Maybe MacieStatus
a} :: EnableMacie)

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

-- | 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).
enableMacie_findingPublishingFrequency :: Lens.Lens' EnableMacie (Prelude.Maybe FindingPublishingFrequency)
enableMacie_findingPublishingFrequency :: (Maybe FindingPublishingFrequency
 -> f (Maybe FindingPublishingFrequency))
-> EnableMacie -> f EnableMacie
enableMacie_findingPublishingFrequency = (EnableMacie -> Maybe FindingPublishingFrequency)
-> (EnableMacie -> Maybe FindingPublishingFrequency -> EnableMacie)
-> Lens
     EnableMacie
     EnableMacie
     (Maybe FindingPublishingFrequency)
     (Maybe FindingPublishingFrequency)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableMacie' {Maybe FindingPublishingFrequency
findingPublishingFrequency :: Maybe FindingPublishingFrequency
$sel:findingPublishingFrequency:EnableMacie' :: EnableMacie -> Maybe FindingPublishingFrequency
findingPublishingFrequency} -> Maybe FindingPublishingFrequency
findingPublishingFrequency) (\s :: EnableMacie
s@EnableMacie' {} Maybe FindingPublishingFrequency
a -> EnableMacie
s {$sel:findingPublishingFrequency:EnableMacie' :: Maybe FindingPublishingFrequency
findingPublishingFrequency = Maybe FindingPublishingFrequency
a} :: EnableMacie)

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

instance Prelude.NFData EnableMacie

instance Core.ToHeaders EnableMacie where
  toHeaders :: EnableMacie -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableMacie -> 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 EnableMacie where
  toJSON :: EnableMacie -> Value
toJSON EnableMacie' {Maybe Text
Maybe FindingPublishingFrequency
Maybe MacieStatus
findingPublishingFrequency :: Maybe FindingPublishingFrequency
clientToken :: Maybe Text
status :: Maybe MacieStatus
$sel:findingPublishingFrequency:EnableMacie' :: EnableMacie -> Maybe FindingPublishingFrequency
$sel:clientToken:EnableMacie' :: EnableMacie -> Maybe Text
$sel:status:EnableMacie' :: EnableMacie -> 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
"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
"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 EnableMacie where
  toPath :: EnableMacie -> ByteString
toPath = ByteString -> EnableMacie -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/macie"

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

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

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

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

instance Prelude.NFData EnableMacieResponse