{-# 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.UpdateSecurityHubConfiguration
-- 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 configuration options for Security Hub.
module Amazonka.SecurityHub.UpdateSecurityHubConfiguration
  ( -- * Creating a Request
    UpdateSecurityHubConfiguration (..),
    newUpdateSecurityHubConfiguration,

    -- * Request Lenses
    updateSecurityHubConfiguration_autoEnableControls,

    -- * Destructuring the Response
    UpdateSecurityHubConfigurationResponse (..),
    newUpdateSecurityHubConfigurationResponse,

    -- * Response Lenses
    updateSecurityHubConfigurationResponse_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:/ 'newUpdateSecurityHubConfiguration' smart constructor.
data UpdateSecurityHubConfiguration = UpdateSecurityHubConfiguration'
  { -- | Whether to automatically enable new controls when they are added to
    -- standards that are enabled.
    --
    -- By default, this is set to @true@, and new controls are enabled
    -- automatically. To not automatically enable new controls, set this to
    -- @false@.
    UpdateSecurityHubConfiguration -> Maybe Bool
autoEnableControls :: Prelude.Maybe Prelude.Bool
  }
  deriving (UpdateSecurityHubConfiguration
-> UpdateSecurityHubConfiguration -> Bool
(UpdateSecurityHubConfiguration
 -> UpdateSecurityHubConfiguration -> Bool)
-> (UpdateSecurityHubConfiguration
    -> UpdateSecurityHubConfiguration -> Bool)
-> Eq UpdateSecurityHubConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSecurityHubConfiguration
-> UpdateSecurityHubConfiguration -> Bool
$c/= :: UpdateSecurityHubConfiguration
-> UpdateSecurityHubConfiguration -> Bool
== :: UpdateSecurityHubConfiguration
-> UpdateSecurityHubConfiguration -> Bool
$c== :: UpdateSecurityHubConfiguration
-> UpdateSecurityHubConfiguration -> Bool
Prelude.Eq, ReadPrec [UpdateSecurityHubConfiguration]
ReadPrec UpdateSecurityHubConfiguration
Int -> ReadS UpdateSecurityHubConfiguration
ReadS [UpdateSecurityHubConfiguration]
(Int -> ReadS UpdateSecurityHubConfiguration)
-> ReadS [UpdateSecurityHubConfiguration]
-> ReadPrec UpdateSecurityHubConfiguration
-> ReadPrec [UpdateSecurityHubConfiguration]
-> Read UpdateSecurityHubConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSecurityHubConfiguration]
$creadListPrec :: ReadPrec [UpdateSecurityHubConfiguration]
readPrec :: ReadPrec UpdateSecurityHubConfiguration
$creadPrec :: ReadPrec UpdateSecurityHubConfiguration
readList :: ReadS [UpdateSecurityHubConfiguration]
$creadList :: ReadS [UpdateSecurityHubConfiguration]
readsPrec :: Int -> ReadS UpdateSecurityHubConfiguration
$creadsPrec :: Int -> ReadS UpdateSecurityHubConfiguration
Prelude.Read, Int -> UpdateSecurityHubConfiguration -> ShowS
[UpdateSecurityHubConfiguration] -> ShowS
UpdateSecurityHubConfiguration -> String
(Int -> UpdateSecurityHubConfiguration -> ShowS)
-> (UpdateSecurityHubConfiguration -> String)
-> ([UpdateSecurityHubConfiguration] -> ShowS)
-> Show UpdateSecurityHubConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSecurityHubConfiguration] -> ShowS
$cshowList :: [UpdateSecurityHubConfiguration] -> ShowS
show :: UpdateSecurityHubConfiguration -> String
$cshow :: UpdateSecurityHubConfiguration -> String
showsPrec :: Int -> UpdateSecurityHubConfiguration -> ShowS
$cshowsPrec :: Int -> UpdateSecurityHubConfiguration -> ShowS
Prelude.Show, (forall x.
 UpdateSecurityHubConfiguration
 -> Rep UpdateSecurityHubConfiguration x)
-> (forall x.
    Rep UpdateSecurityHubConfiguration x
    -> UpdateSecurityHubConfiguration)
-> Generic UpdateSecurityHubConfiguration
forall x.
Rep UpdateSecurityHubConfiguration x
-> UpdateSecurityHubConfiguration
forall x.
UpdateSecurityHubConfiguration
-> Rep UpdateSecurityHubConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateSecurityHubConfiguration x
-> UpdateSecurityHubConfiguration
$cfrom :: forall x.
UpdateSecurityHubConfiguration
-> Rep UpdateSecurityHubConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSecurityHubConfiguration' 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:
--
-- 'autoEnableControls', 'updateSecurityHubConfiguration_autoEnableControls' - Whether to automatically enable new controls when they are added to
-- standards that are enabled.
--
-- By default, this is set to @true@, and new controls are enabled
-- automatically. To not automatically enable new controls, set this to
-- @false@.
newUpdateSecurityHubConfiguration ::
  UpdateSecurityHubConfiguration
newUpdateSecurityHubConfiguration :: UpdateSecurityHubConfiguration
newUpdateSecurityHubConfiguration =
  UpdateSecurityHubConfiguration' :: Maybe Bool -> UpdateSecurityHubConfiguration
UpdateSecurityHubConfiguration'
    { $sel:autoEnableControls:UpdateSecurityHubConfiguration' :: Maybe Bool
autoEnableControls =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to automatically enable new controls when they are added to
-- standards that are enabled.
--
-- By default, this is set to @true@, and new controls are enabled
-- automatically. To not automatically enable new controls, set this to
-- @false@.
updateSecurityHubConfiguration_autoEnableControls :: Lens.Lens' UpdateSecurityHubConfiguration (Prelude.Maybe Prelude.Bool)
updateSecurityHubConfiguration_autoEnableControls :: (Maybe Bool -> f (Maybe Bool))
-> UpdateSecurityHubConfiguration
-> f UpdateSecurityHubConfiguration
updateSecurityHubConfiguration_autoEnableControls = (UpdateSecurityHubConfiguration -> Maybe Bool)
-> (UpdateSecurityHubConfiguration
    -> Maybe Bool -> UpdateSecurityHubConfiguration)
-> Lens
     UpdateSecurityHubConfiguration
     UpdateSecurityHubConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSecurityHubConfiguration' {Maybe Bool
autoEnableControls :: Maybe Bool
$sel:autoEnableControls:UpdateSecurityHubConfiguration' :: UpdateSecurityHubConfiguration -> Maybe Bool
autoEnableControls} -> Maybe Bool
autoEnableControls) (\s :: UpdateSecurityHubConfiguration
s@UpdateSecurityHubConfiguration' {} Maybe Bool
a -> UpdateSecurityHubConfiguration
s {$sel:autoEnableControls:UpdateSecurityHubConfiguration' :: Maybe Bool
autoEnableControls = Maybe Bool
a} :: UpdateSecurityHubConfiguration)

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

instance
  Prelude.NFData
    UpdateSecurityHubConfiguration

instance
  Core.ToHeaders
    UpdateSecurityHubConfiguration
  where
  toHeaders :: UpdateSecurityHubConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> UpdateSecurityHubConfiguration -> 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 UpdateSecurityHubConfiguration where
  toJSON :: UpdateSecurityHubConfiguration -> Value
toJSON UpdateSecurityHubConfiguration' {Maybe Bool
autoEnableControls :: Maybe Bool
$sel:autoEnableControls:UpdateSecurityHubConfiguration' :: UpdateSecurityHubConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutoEnableControls" 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
autoEnableControls
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateSecurityHubConfigurationResponse