{-# 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.SecurityHub.EnableSecurityHub
-- 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 Security Hub for your account in the current Region or the
-- Region you specify in the request.
--
-- When you enable Security Hub, you grant to Security Hub the permissions
-- necessary to gather findings from other services that are integrated
-- with Security Hub.
--
-- When you use the @EnableSecurityHub@ operation to enable Security Hub,
-- you also automatically enable the following standards.
--
-- -   CIS Amazon Web Services Foundations
--
-- -   Amazon Web Services Foundational Security Best Practices
--
-- You do not enable the Payment Card Industry Data Security Standard (PCI
-- DSS) standard.
--
-- To not enable the automatically enabled standards, set
-- @EnableDefaultStandards@ to @false@.
--
-- After you enable Security Hub, to enable a standard, use the
-- @BatchEnableStandards@ operation. To disable a standard, use the
-- @BatchDisableStandards@ operation.
--
-- To learn more, see the
-- <https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-settingup.html setup information>
-- in the /Security Hub User Guide/.
module Amazonka.SecurityHub.EnableSecurityHub
  ( -- * Creating a Request
    EnableSecurityHub (..),
    newEnableSecurityHub,

    -- * Request Lenses
    enableSecurityHub_enableDefaultStandards,
    enableSecurityHub_tags,

    -- * Destructuring the Response
    EnableSecurityHubResponse (..),
    newEnableSecurityHubResponse,

    -- * Response Lenses
    enableSecurityHubResponse_httpStatus,
  )
where

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

-- | /See:/ 'newEnableSecurityHub' smart constructor.
data EnableSecurityHub = EnableSecurityHub'
  { -- | Whether to enable the security standards that Security Hub has
    -- designated as automatically enabled. If you do not provide a value for
    -- @EnableDefaultStandards@, it is set to @true@. To not enable the
    -- automatically enabled standards, set @EnableDefaultStandards@ to
    -- @false@.
    EnableSecurityHub -> Maybe Bool
enableDefaultStandards :: Prelude.Maybe Prelude.Bool,
    -- | The tags to add to the hub resource when you enable Security Hub.
    EnableSecurityHub -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (EnableSecurityHub -> EnableSecurityHub -> Bool
(EnableSecurityHub -> EnableSecurityHub -> Bool)
-> (EnableSecurityHub -> EnableSecurityHub -> Bool)
-> Eq EnableSecurityHub
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableSecurityHub -> EnableSecurityHub -> Bool
$c/= :: EnableSecurityHub -> EnableSecurityHub -> Bool
== :: EnableSecurityHub -> EnableSecurityHub -> Bool
$c== :: EnableSecurityHub -> EnableSecurityHub -> Bool
Prelude.Eq, ReadPrec [EnableSecurityHub]
ReadPrec EnableSecurityHub
Int -> ReadS EnableSecurityHub
ReadS [EnableSecurityHub]
(Int -> ReadS EnableSecurityHub)
-> ReadS [EnableSecurityHub]
-> ReadPrec EnableSecurityHub
-> ReadPrec [EnableSecurityHub]
-> Read EnableSecurityHub
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableSecurityHub]
$creadListPrec :: ReadPrec [EnableSecurityHub]
readPrec :: ReadPrec EnableSecurityHub
$creadPrec :: ReadPrec EnableSecurityHub
readList :: ReadS [EnableSecurityHub]
$creadList :: ReadS [EnableSecurityHub]
readsPrec :: Int -> ReadS EnableSecurityHub
$creadsPrec :: Int -> ReadS EnableSecurityHub
Prelude.Read, Int -> EnableSecurityHub -> ShowS
[EnableSecurityHub] -> ShowS
EnableSecurityHub -> String
(Int -> EnableSecurityHub -> ShowS)
-> (EnableSecurityHub -> String)
-> ([EnableSecurityHub] -> ShowS)
-> Show EnableSecurityHub
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableSecurityHub] -> ShowS
$cshowList :: [EnableSecurityHub] -> ShowS
show :: EnableSecurityHub -> String
$cshow :: EnableSecurityHub -> String
showsPrec :: Int -> EnableSecurityHub -> ShowS
$cshowsPrec :: Int -> EnableSecurityHub -> ShowS
Prelude.Show, (forall x. EnableSecurityHub -> Rep EnableSecurityHub x)
-> (forall x. Rep EnableSecurityHub x -> EnableSecurityHub)
-> Generic EnableSecurityHub
forall x. Rep EnableSecurityHub x -> EnableSecurityHub
forall x. EnableSecurityHub -> Rep EnableSecurityHub x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableSecurityHub x -> EnableSecurityHub
$cfrom :: forall x. EnableSecurityHub -> Rep EnableSecurityHub x
Prelude.Generic)

-- |
-- Create a value of 'EnableSecurityHub' 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:
--
-- 'enableDefaultStandards', 'enableSecurityHub_enableDefaultStandards' - Whether to enable the security standards that Security Hub has
-- designated as automatically enabled. If you do not provide a value for
-- @EnableDefaultStandards@, it is set to @true@. To not enable the
-- automatically enabled standards, set @EnableDefaultStandards@ to
-- @false@.
--
-- 'tags', 'enableSecurityHub_tags' - The tags to add to the hub resource when you enable Security Hub.
newEnableSecurityHub ::
  EnableSecurityHub
newEnableSecurityHub :: EnableSecurityHub
newEnableSecurityHub =
  EnableSecurityHub' :: Maybe Bool -> Maybe (HashMap Text Text) -> EnableSecurityHub
EnableSecurityHub'
    { $sel:enableDefaultStandards:EnableSecurityHub' :: Maybe Bool
enableDefaultStandards =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:EnableSecurityHub' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to enable the security standards that Security Hub has
-- designated as automatically enabled. If you do not provide a value for
-- @EnableDefaultStandards@, it is set to @true@. To not enable the
-- automatically enabled standards, set @EnableDefaultStandards@ to
-- @false@.
enableSecurityHub_enableDefaultStandards :: Lens.Lens' EnableSecurityHub (Prelude.Maybe Prelude.Bool)
enableSecurityHub_enableDefaultStandards :: (Maybe Bool -> f (Maybe Bool))
-> EnableSecurityHub -> f EnableSecurityHub
enableSecurityHub_enableDefaultStandards = (EnableSecurityHub -> Maybe Bool)
-> (EnableSecurityHub -> Maybe Bool -> EnableSecurityHub)
-> Lens
     EnableSecurityHub EnableSecurityHub (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableSecurityHub' {Maybe Bool
enableDefaultStandards :: Maybe Bool
$sel:enableDefaultStandards:EnableSecurityHub' :: EnableSecurityHub -> Maybe Bool
enableDefaultStandards} -> Maybe Bool
enableDefaultStandards) (\s :: EnableSecurityHub
s@EnableSecurityHub' {} Maybe Bool
a -> EnableSecurityHub
s {$sel:enableDefaultStandards:EnableSecurityHub' :: Maybe Bool
enableDefaultStandards = Maybe Bool
a} :: EnableSecurityHub)

-- | The tags to add to the hub resource when you enable Security Hub.
enableSecurityHub_tags :: Lens.Lens' EnableSecurityHub (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
enableSecurityHub_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EnableSecurityHub -> f EnableSecurityHub
enableSecurityHub_tags = (EnableSecurityHub -> Maybe (HashMap Text Text))
-> (EnableSecurityHub
    -> Maybe (HashMap Text Text) -> EnableSecurityHub)
-> Lens
     EnableSecurityHub
     EnableSecurityHub
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableSecurityHub' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:EnableSecurityHub' :: EnableSecurityHub -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: EnableSecurityHub
s@EnableSecurityHub' {} Maybe (HashMap Text Text)
a -> EnableSecurityHub
s {$sel:tags:EnableSecurityHub' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: EnableSecurityHub) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> EnableSecurityHub -> f EnableSecurityHub)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EnableSecurityHub
-> f EnableSecurityHub
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData EnableSecurityHub

instance Core.ToHeaders EnableSecurityHub where
  toHeaders :: EnableSecurityHub -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableSecurityHub -> 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 EnableSecurityHub where
  toJSON :: EnableSecurityHub -> Value
toJSON EnableSecurityHub' {Maybe Bool
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
enableDefaultStandards :: Maybe Bool
$sel:tags:EnableSecurityHub' :: EnableSecurityHub -> Maybe (HashMap Text Text)
$sel:enableDefaultStandards:EnableSecurityHub' :: EnableSecurityHub -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EnableDefaultStandards" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enableDefaultStandards,
            (Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags
          ]
      )

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

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

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

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

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

instance Prelude.NFData EnableSecurityHubResponse